mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-13 04:34:21 -10:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a667b2cd2 | ||
|
|
7e11d0729b | ||
|
|
2e78c42fac |
No files matched your search
Binary file not shown.
@@ -8,6 +8,11 @@ import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.jdt.core.*;
|
||||
import org.eclipse.jdt.core.search.IJavaSearchScope;
|
||||
import org.eclipse.jdt.core.search.SearchEngine;
|
||||
import org.eclipse.jdt.internal.core.CreateTypeHierarchyOperation;
|
||||
import org.eclipse.jdt.internal.core.DefaultWorkingCopyOwner;
|
||||
import org.eclipse.jdt.internal.core.JavaModelManager;
|
||||
import org.eclipse.jdt.internal.corext.util.MethodOverrideTester;
|
||||
import org.eclipse.jdt.ls.core.internal.IDelegateCommandHandler;
|
||||
import org.eclipse.jdt.ls.core.internal.JDTUtils;
|
||||
@@ -56,7 +61,7 @@ public final class ImplementationsCommand implements IDelegateCommandHandler {
|
||||
return false;
|
||||
}
|
||||
if (type == null || type.getJavaProject() == null) return false;
|
||||
IRegion sources = JavaCore.newRegion();
|
||||
List<IJavaElement> sources = new ArrayList<>();
|
||||
for (IJavaProject project : JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects()) {
|
||||
for (IPackageFragmentRoot fragmentRoot : project.getPackageFragmentRoots()) {
|
||||
if (fragmentRoot.getKind() == IPackageFragmentRoot.K_SOURCE || isKotlinOutput(fragmentRoot)) {
|
||||
@@ -64,7 +69,13 @@ public final class ImplementationsCommand implements IDelegateCommandHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
ITypeHierarchy hierarchy = type.getJavaProject().newTypeHierarchy(type, sources, monitor);
|
||||
// IType.newTypeHierarchy's operation over the sources: the index narrows the subtypes to the
|
||||
// files that name a supertype, where a region hierarchy resolves every type in the region.
|
||||
ICompilationUnit[] workingCopies = JavaModelManager.getJavaModelManager().getWorkingCopies(DefaultWorkingCopyOwner.PRIMARY, true);
|
||||
IJavaSearchScope scope = SearchEngine.createJavaSearchScope(sources.toArray(IJavaElement[]::new));
|
||||
CreateTypeHierarchyOperation operation = new CreateTypeHierarchyOperation(type, workingCopies, scope, true);
|
||||
operation.runOperation(monitor);
|
||||
ITypeHierarchy hierarchy = operation.getResult();
|
||||
for (IType subtype : hierarchy.getAllSubtypes(type)) {
|
||||
if (monitor.isCanceled()) throw new OperationCanceledException();
|
||||
IMember found;
|
||||
|
||||
@@ -72,6 +72,21 @@ public class Task implements Runnable {
|
||||
public void run() {
|
||||
}
|
||||
}
|
||||
''',
|
||||
'Anon.java': '''package zoo;
|
||||
|
||||
public class Anon {
|
||||
Repo<Double> make() {
|
||||
class Local implements Repo<Double> {
|
||||
public void save(Double item) {
|
||||
}
|
||||
}
|
||||
return new Repo<Double>() {
|
||||
public void save(Double item) {
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
''',
|
||||
'Use.java': '''package zoo;
|
||||
|
||||
@@ -174,11 +189,11 @@ try:
|
||||
request('java/buildWorkspace', True)
|
||||
# (implementations in the sources, whether they are all there are)
|
||||
cases = {
|
||||
# Classes, abstract ones too, and those of the bridged Kotlin output; not the sub-interface.
|
||||
('Repo.java', 'Repo<T>'): (['Base.java:2', 'Longs.java:0', 'Numbers.java:2', 'Words.java:2'], True),
|
||||
# Classes, abstract, local and anonymous ones too, and those of the bridged Kotlin output; not the sub-interface.
|
||||
('Repo.java', 'Repo<T>'): (['Anon.java:4', 'Anon.java:8', 'Base.java:2', 'Longs.java:0', 'Numbers.java:2', 'Words.java:2'], True),
|
||||
# Through the type arguments; not the abstract re-declaration.
|
||||
('Repo.java', 'save(T'): (['Longs.java:0', 'Numbers.java:3', 'Words.java:3'], True),
|
||||
('Use.java', 'save("x")'): (['Longs.java:0', 'Numbers.java:3', 'Words.java:3'], True),
|
||||
('Repo.java', 'save(T'): (['Anon.java:5', 'Anon.java:9', 'Longs.java:0', 'Numbers.java:3', 'Words.java:3'], True),
|
||||
('Use.java', 'save("x")'): (['Anon.java:5', 'Anon.java:9', 'Longs.java:0', 'Numbers.java:3', 'Words.java:3'], True),
|
||||
('Repo.java', 'name()'): (['Words.java:6'], True),
|
||||
# A library type's implementations in the sources; the library has more.
|
||||
('Use.java', 'Runnable task'): (['Task.java:2'], False),
|
||||
|
||||
@@ -444,6 +444,54 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
/* Go to a merge commit's file: parent 1 | merge result | parent 2, each pane scrolling itself. */
|
||||
.mergeDiff {
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.mergeDiffLabels {
|
||||
flex: none;
|
||||
height: var(--h-row);
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
border-bottom: 1px solid var(--border);
|
||||
color: var(--fg-secondary);
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
.mergeDiffLabels > span {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
padding: 0 12px;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.mergeDiffLabels > span + span {
|
||||
border-left: 1px solid var(--border);
|
||||
}
|
||||
.mergeDiffPanes {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
}
|
||||
.mergeDiffPane {
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
}
|
||||
.mergeDiffPane + .mergeDiffPane {
|
||||
border-left: 1px solid var(--border);
|
||||
}
|
||||
.mergeDiffPane > :global(.cm-editor) {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.subjectLine {
|
||||
color: var(--fg-strong);
|
||||
font-weight: 600;
|
||||
|
||||
@@ -51,10 +51,7 @@ export function GitMergeDiff({ input }: { input: EditorInput }) {
|
||||
}
|
||||
for (const [i, text] of texts.entries()) {
|
||||
const pane = document.createElement("div");
|
||||
pane.style.cssText = "flex:1;min-width:0;display:flex;flex-direction:column";
|
||||
const label = document.createElement("div");
|
||||
label.textContent = `${sides[i]!.rev.slice(0, 8)} · ${sides[i]!.path}`;
|
||||
pane.append(label);
|
||||
pane.className = styles.mergeDiffPane!;
|
||||
host.current.append(pane);
|
||||
const view = new EditorView({
|
||||
parent: pane,
|
||||
@@ -86,10 +83,16 @@ export function GitMergeDiff({ input }: { input: EditorInput }) {
|
||||
element?.replaceChildren();
|
||||
};
|
||||
}, [data]);
|
||||
const labels = [data.parents[0]!, { rev: data.revision, path: data.path }, data.parents[1]!];
|
||||
return (
|
||||
<>
|
||||
<div role={error ? "alert" : undefined}>{error}</div>
|
||||
<div className={styles.revisionSource} style={{ display: "flex" }} ref={host} />
|
||||
</>
|
||||
<div className={styles.mergeDiff}>
|
||||
{error && <div role="alert">{error}</div>}
|
||||
<div className={styles.mergeDiffLabels}>
|
||||
{labels.map((side, i) => (
|
||||
<span key={i}>{`${side.rev.slice(0, 8)} · ${side.path}`}</span>
|
||||
))}
|
||||
</div>
|
||||
<div className={styles.mergeDiffPanes} ref={host} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user