-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e2ccfb
commit bca53cf
Showing
45 changed files
with
1,165 additions
and
201 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/aldor/build/module/AldorBuildLocationForm.form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="aldor.build.module.AldorBuildLocationForm"> | ||
<grid id="27dc6" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> | ||
<margin top="0" left="0" bottom="0" right="0"/> | ||
<constraints> | ||
<xy x="20" y="20" width="500" height="400"/> | ||
</constraints> | ||
<properties/> | ||
<border type="none"/> | ||
<children> | ||
<component id="6433d" class="javax.swing.JLabel"> | ||
<constraints> | ||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | ||
</constraints> | ||
<properties> | ||
<text value="Build Directory"/> | ||
</properties> | ||
</component> | ||
<vspacer id="1f79b"> | ||
<constraints> | ||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> | ||
</constraints> | ||
</vspacer> | ||
<component id="c8720" class="javax.swing.JTextField" binding="buildDirectory"> | ||
<constraints> | ||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> | ||
<preferred-size width="150" height="-1"/> | ||
</grid> | ||
</constraints> | ||
<properties> | ||
<toolTipText value="Location of Build Directory"/> | ||
</properties> | ||
</component> | ||
</children> | ||
</grid> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package aldor.build.module; | ||
|
||
import javax.swing.JComponent; | ||
import javax.swing.JTextField; | ||
|
||
public class AldorBuildLocationForm extends JComponent { | ||
private JTextField buildDirectory; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/aldor/hierarchy/AbstractChangeHierarchyViewAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package aldor.hierarchy; | ||
|
||
import com.intellij.ide.hierarchy.TypeHierarchyBrowserBase; | ||
import com.intellij.openapi.actionSystem.AnActionEvent; | ||
import com.intellij.openapi.actionSystem.DataContext; | ||
import com.intellij.openapi.actionSystem.Presentation; | ||
import com.intellij.openapi.actionSystem.ToggleAction; | ||
import com.intellij.openapi.application.ApplicationManager; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import javax.swing.Icon; | ||
|
||
public abstract class AbstractChangeHierarchyViewAction extends ToggleAction { | ||
|
||
AbstractChangeHierarchyViewAction(final String shortDescription, final String longDescription, final Icon icon) { | ||
super(shortDescription, longDescription, icon); | ||
} | ||
|
||
@Override | ||
public final boolean isSelected(final AnActionEvent event) { | ||
final AldorTypeHierarchyBrowser browser = (AldorTypeHierarchyBrowser) getTypeHierarchyBrowser(event.getDataContext()); | ||
return (browser != null) && getTypeName().equals(browser.typeName()); | ||
} | ||
|
||
protected abstract String getTypeName(); | ||
|
||
@Override | ||
public final void setSelected(final AnActionEvent event, final boolean flag) { | ||
if (flag) { | ||
final TypeHierarchyBrowserBase browser = getTypeHierarchyBrowser(event.getDataContext()); | ||
// setWaitCursor(); | ||
ApplicationManager.getApplication().invokeLater(() -> { | ||
if (browser != null) { | ||
browser.changeView(getTypeName()); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
@Override | ||
public void update(@NotNull final AnActionEvent event) { | ||
// its important to assign the myTypeHierarchyBrowser first | ||
super.update(event); | ||
final Presentation presentation = event.getPresentation(); | ||
presentation.setEnabled(true); | ||
} | ||
|
||
static TypeHierarchyBrowserBase getTypeHierarchyBrowser(final DataContext context) { | ||
return TypeHierarchyBrowserBase.DATA_KEY.getData(context); | ||
} | ||
|
||
|
||
} |
119 changes: 119 additions & 0 deletions
119
src/main/java/aldor/hierarchy/AldorFlatHierarchyTreeStructure.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package aldor.hierarchy; | ||
|
||
import aldor.spad.SpadLibrary; | ||
import aldor.spad.SpadLibraryManager; | ||
import aldor.syntax.Syntax; | ||
import aldor.syntax.SyntaxPrinter; | ||
import aldor.syntax.SyntaxUtils; | ||
import com.intellij.ide.hierarchy.HierarchyNodeDescriptor; | ||
import com.intellij.ide.hierarchy.HierarchyTreeStructure; | ||
import com.intellij.ide.util.treeView.NodeDescriptor; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.psi.PsiElement; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.ArrayDeque; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Deque; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
import static aldor.syntax.SyntaxUtils.psiElementFromSyntax; | ||
|
||
public class AldorFlatHierarchyTreeStructure extends HierarchyTreeStructure { | ||
private static final Object[] EMPTY_ARRAY = new Object[0]; | ||
//private final SmartPsiElementPointer<PsiElement> smartPointer; | ||
|
||
public AldorFlatHierarchyTreeStructure(Project project, @NotNull Syntax syntax) { | ||
super(project, createBaseNodeDescriptor(project, syntax)); | ||
//this.smartPointer = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(psiElementFromSyntax(syntax)); | ||
} | ||
|
||
private static HierarchyNodeDescriptor createBaseNodeDescriptor(Project project, @NotNull Syntax syntax) { | ||
return new AldorHierarchyNodeDescriptor(project, null, psiElementFromSyntax(syntax), syntax, true); | ||
} | ||
|
||
@Override | ||
public boolean isAlwaysLeaf(Object element) { | ||
if (!(element instanceof HierarchyNodeDescriptor)) { | ||
return true; | ||
} | ||
HierarchyNodeDescriptor descriptor = (HierarchyNodeDescriptor) element; | ||
if (descriptor instanceof ErrorNodeDescriptor) { | ||
return true; | ||
} | ||
if (descriptor.getParentDescriptor() != null) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
protected Object[] buildChildren(@NotNull HierarchyNodeDescriptor descriptor) { | ||
if (descriptor instanceof ErrorNodeDescriptor) { | ||
return EMPTY_ARRAY; | ||
} | ||
if (descriptor.getParentDescriptor() != null) { | ||
return EMPTY_ARRAY; | ||
} | ||
|
||
AldorHierarchyNodeDescriptor nodeDescriptor = (AldorHierarchyNodeDescriptor) descriptor; | ||
SpadLibrary library = SpadLibraryManager.instance().spadLibraryForElement(descriptor.getPsiElement()); | ||
if (library == null) { | ||
return new Object[] { "Missing library"}; | ||
} | ||
Syntax syntax = nodeDescriptor.syntax(); | ||
List<Syntax> parents = this.parents(library, syntax); | ||
//noinspection ObjectEquality | ||
assert parents.get(0) == syntax; | ||
List<SpadLibrary.Operation> operations = this.operations(library, parents); | ||
|
||
Stream<Object> parentNodes = parents.subList(1, parents.size()-1).stream().map(psyntax -> createNodeDescriptorMaybe(nodeDescriptor, psyntax)); | ||
Stream<Object> operationNodes = operations.stream().map(op -> createOperationNodeDescriptorMaybe(nodeDescriptor, op)); | ||
|
||
return Stream.concat(parentNodes, operationNodes).toArray(); | ||
} | ||
|
||
|
||
private Object createNodeDescriptorMaybe(AldorHierarchyNodeDescriptor parent, Syntax syntax) { | ||
if (psiElementFromSyntax(syntax) == null) { | ||
return new ErrorNodeDescriptor(parent, "Unknown element - " + SyntaxPrinter.instance().toString(syntax)); | ||
} | ||
else { | ||
return createNodeDescriptor(parent, syntax); | ||
} | ||
} | ||
|
||
private HierarchyNodeDescriptor createNodeDescriptor(NodeDescriptor<PsiElement> parentDescriptor, Syntax syntax) { | ||
return new AldorHierarchyNodeDescriptor(this.myProject, parentDescriptor, psiElementFromSyntax(syntax), syntax, false); | ||
} | ||
|
||
private Object createOperationNodeDescriptorMaybe(@NotNull AldorHierarchyNodeDescriptor parent, SpadLibrary.Operation operation) { | ||
return new AldorHierarchyOperationDescriptor(this.myProject, parent, operation); | ||
} | ||
|
||
|
||
|
||
private List<Syntax> parents(SpadLibrary library, Syntax syntax) { | ||
Deque<Syntax> candidates = new ArrayDeque<>(); | ||
candidates.add(syntax); | ||
List<Syntax> allParents = new ArrayList<>(); | ||
while (!candidates.isEmpty()) { | ||
Syntax candidate = candidates.pop(); | ||
if (allParents.stream().noneMatch(pp -> SyntaxUtils.match(pp, candidate))) { | ||
allParents.add(candidate); | ||
List<Syntax> parents = library.parentCategories(candidate); | ||
candidates.addAll(parents); | ||
} | ||
} | ||
return allParents; | ||
} | ||
|
||
private List<SpadLibrary.Operation> operations(SpadLibrary library, Collection<Syntax> allParents) { | ||
return allParents.stream().flatMap(syntax -> library.operations(syntax).stream()).collect(Collectors.toList()); | ||
} | ||
|
||
} |
Oops, something went wrong.