Skip to content

Commit 5019a75

Browse files
committed
Reworking of ASTTree, References and resolving
1 parent 556b8f4 commit 5019a75

69 files changed

Lines changed: 1485 additions & 776 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.idea/runConfigurations/Mathematica_Plugin.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Mathematica-IntelliJ-Plugin.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<exclude-output />
66
<content url="file://$MODULE_DIR$">
77
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
8-
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
98
<sourceFolder url="file://$MODULE_DIR$/testData" type="java-test-resource" />
109
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
10+
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
1111
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
1212
<excludeFolder url="file://$MODULE_DIR$/build" />
1313
<excludeFolder url="file://$MODULE_DIR$/classes" />

resources/META-INF/plugin.xml

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
<errorHandler implementation="de.halirutan.mathematica.errorreporting.GitHubErrorReporter"/>
3434
<fileTypeFactory implementation="de.halirutan.mathematica.file.MathematicaFileTypeFactory"/>
35+
<lang.ast.factory language="Mathematica" implementationClass="de.halirutan.mathematica.lang.tree.MathematicaASTFactory"/>
3536
<lang.parserDefinition language="Mathematica"
3637
implementationClass="de.halirutan.mathematica.lang.parsing.prattparser.MathematicaParserDefinition"/>
3738

@@ -47,63 +48,63 @@
4748

4849
<lang.syntaxHighlighterFactory language="Mathematica"
4950
implementationClass="de.halirutan.mathematica.codeinsight.highlighting.MathematicaSyntaxHighlighterFactory"/>
50-
<lang.psiStructureViewFactory language="Mathematica"
51-
implementationClass="de.halirutan.mathematica.codeinsight.structureview.MathematicaStructureViewFactory"/>
52-
<lang.documentationProvider language="Mathematica"
53-
implementationClass="de.halirutan.mathematica.documentation.MathematicaDocumentationProvider"/>
51+
<!--<lang.psiStructureViewFactory language="Mathematica"-->
52+
<!--implementationClass="de.halirutan.mathematica.codeinsight.structureview.MathematicaStructureViewFactory"/>-->
53+
<!--<lang.documentationProvider language="Mathematica"-->
54+
<!--implementationClass="de.halirutan.mathematica.documentation.MathematicaDocumentationProvider"/>-->
5455

5556
<annotator language="Mathematica"
5657
implementationClass="de.halirutan.mathematica.codeinsight.highlighting.MathematicaHighlightingAnnotator"/>
5758
<lang.braceMatcher language="Mathematica"
5859
implementationClass="de.halirutan.mathematica.codeinsight.highlighting.MathematicaBraceMatcher"/>
5960

6061
<!-- Smart editing features -->
61-
<quoteHandler fileType="Mathematica"
62-
className="de.halirutan.mathematica.codeinsight.completion.MathematicaQuoteHandler"/>
63-
<completion.contributor language="Mathematica"
64-
implementationClass="de.halirutan.mathematica.codeinsight.completion.MathematicaCompletionContributor"/>
65-
66-
<lang.smartEnterProcessor language="Mathematica"
67-
implementationClass="de.halirutan.mathematica.codeinsight.editoractions.smartenter.MathematicaSmartEnter"/>
68-
<lookup.charFilter implementation="de.halirutan.mathematica.codeinsight.completion.MathematicaCharFilter"/>
69-
70-
<lang.commenter language="Mathematica"
71-
implementationClass="de.halirutan.mathematica.codeinsight.editoractions.MathematicaCommenter"/>
72-
73-
<lang.surroundDescriptor language="Mathematica"
74-
implementationClass="de.halirutan.mathematica.codeinsight.surround.MathematicaSurroundDescriptor"/>
75-
<codeInsight.surroundWithRangeAdjuster
76-
implementation="de.halirutan.mathematica.codeinsight.surround.MathematicaSurroundWithRangeAdjuster"/>
77-
<liveTemplateContext
78-
implementation="de.halirutan.mathematica.codeinsight.livetemplates.MathematicaTemplateContextType"/>
79-
<defaultLiveTemplatesProvider
80-
implementation="de.halirutan.mathematica.codeinsight.livetemplates.MathematicaDefaultLiveTemplateProvider"/>
81-
82-
<extendWordSelectionHandler
83-
implementation="de.halirutan.mathematica.codeinsight.editoractions.wordselection.MathematicaFunctionSelectioner"/>
84-
<extendWordSelectionHandler
85-
implementation="de.halirutan.mathematica.codeinsight.editoractions.wordselection.MathematicaListSelectioner"/>
86-
87-
<!--<basicWordSelectionFilter-->
88-
<!--implementation="de.halirutan.mathematica.codeinsight.editoractions.wordselection.BasicExpressionSelectionFilter"/>-->
89-
90-
<lang.refactoringSupport language="Mathematica"
91-
implementationClass="de.halirutan.mathematica.refactoring.MathematicaRefactoringSupport"/>
92-
<lang.namesValidator language="Mathematica" implementationClass="de.halirutan.mathematica.refactoring.MathematicaNamesValidator"/>
93-
<lang.foldingBuilder language="Mathematica"
94-
implementationClass="de.halirutan.mathematica.codeinsight.folding.MathematicaExpressionFoldingBuilder"/>
95-
96-
<applicationService
97-
serviceInterface="de.halirutan.mathematica.codeinsight.folding.MathematicaCodeFoldingSettingsImpl"
98-
serviceImplementation="de.halirutan.mathematica.codeinsight.folding.MathematicaCodeFoldingSettingsImpl"/>
99-
<codeFoldingOptionsProvider
100-
instance="de.halirutan.mathematica.codeinsight.folding.MathematicaFoldingOptionProvider"/>
101-
102-
<enterHandlerDelegate
103-
implementation="de.halirutan.mathematica.codeinsight.editoractions.enter.MathematicaEnterInsideFunctionHandler"/>
104-
105-
<enterHandlerDelegate
106-
implementation="de.halirutan.mathematica.codeinsight.editoractions.enter.MathematicaEnterAfterOperatorHandler"/>
62+
<!--<quoteHandler fileType="Mathematica"-->
63+
<!--className="de.halirutan.mathematica.codeinsight.completion.MathematicaQuoteHandler"/>-->
64+
<!--<completion.contributor language="Mathematica"-->
65+
<!--implementationClass="de.halirutan.mathematica.codeinsight.completion.MathematicaCompletionContributor"/>-->
66+
67+
<!--<lang.smartEnterProcessor language="Mathematica"-->
68+
<!--implementationClass="de.halirutan.mathematica.codeinsight.editoractions.smartenter.MathematicaSmartEnter"/>-->
69+
<!--<lookup.charFilter implementation="de.halirutan.mathematica.codeinsight.completion.MathematicaCharFilter"/>-->
70+
71+
<!--<lang.commenter language="Mathematica"-->
72+
<!--implementationClass="de.halirutan.mathematica.codeinsight.editoractions.MathematicaCommenter"/>-->
73+
74+
<!--<lang.surroundDescriptor language="Mathematica"-->
75+
<!--implementationClass="de.halirutan.mathematica.codeinsight.surround.MathematicaSurroundDescriptor"/>-->
76+
<!--<codeInsight.surroundWithRangeAdjuster-->
77+
<!--implementation="de.halirutan.mathematica.codeinsight.surround.MathematicaSurroundWithRangeAdjuster"/>-->
78+
<!--<liveTemplateContext-->
79+
<!--implementation="de.halirutan.mathematica.codeinsight.livetemplates.MathematicaTemplateContextType"/>-->
80+
<!--<defaultLiveTemplatesProvider-->
81+
<!--implementation="de.halirutan.mathematica.codeinsight.livetemplates.MathematicaDefaultLiveTemplateProvider"/>-->
82+
83+
<!--<extendWordSelectionHandler-->
84+
<!--implementation="de.halirutan.mathematica.codeinsight.editoractions.wordselection.MathematicaFunctionSelectioner"/>-->
85+
<!--<extendWordSelectionHandler-->
86+
<!--implementation="de.halirutan.mathematica.codeinsight.editoractions.wordselection.MathematicaListSelectioner"/>-->
87+
88+
<!--&lt;!&ndash;<basicWordSelectionFilter&ndash;&gt;-->
89+
<!--&lt;!&ndash;implementation="de.halirutan.mathematica.codeinsight.editoractions.wordselection.BasicExpressionSelectionFilter"/>&ndash;&gt;-->
90+
91+
<!--<lang.refactoringSupport language="Mathematica"-->
92+
<!--implementationClass="de.halirutan.mathematica.refactoring.MathematicaRefactoringSupport"/>-->
93+
<!--<lang.namesValidator language="Mathematica" implementationClass="de.halirutan.mathematica.refactoring.MathematicaNamesValidator"/>-->
94+
<!--<lang.foldingBuilder language="Mathematica"-->
95+
<!--implementationClass="de.halirutan.mathematica.codeinsight.folding.MathematicaExpressionFoldingBuilder"/>-->
96+
97+
<!--<applicationService-->
98+
<!--serviceInterface="de.halirutan.mathematica.codeinsight.folding.MathematicaCodeFoldingSettingsImpl"-->
99+
<!--serviceImplementation="de.halirutan.mathematica.codeinsight.folding.MathematicaCodeFoldingSettingsImpl"/>-->
100+
<!--<codeFoldingOptionsProvider-->
101+
<!--instance="de.halirutan.mathematica.codeinsight.folding.MathematicaFoldingOptionProvider"/>-->
102+
103+
<!--<enterHandlerDelegate-->
104+
<!--implementation="de.halirutan.mathematica.codeinsight.editoractions.enter.MathematicaEnterInsideFunctionHandler"/>-->
105+
106+
<!--<enterHandlerDelegate-->
107+
<!--implementation="de.halirutan.mathematica.codeinsight.editoractions.enter.MathematicaEnterAfterOperatorHandler"/>-->
107108

108109
<!-- Code-style and colors-->
109110
<colorSettingsPage
@@ -120,27 +121,26 @@
120121
<additionalTextAttributes scheme="Default" file="colors/MathematicaDefault.xml"/>
121122
<lang.refactoringSupport language="Mathematica"
122123
implementationClass="de.halirutan.mathematica.refactoring.MathematicaRefactoringSupport"/>
124+
<!--<annotator language="Mathematica"-->
125+
<!--implementationClass="de.halirutan.mathematica.codeinsight.highlighting.CommentAnnotator"/>-->
123126

124-
<annotator language="Mathematica"
125-
implementationClass="de.halirutan.mathematica.codeinsight.highlighting.CommentAnnotator"/>
126-
127-
<inspectionToolProvider
128-
implementation="de.halirutan.mathematica.codeinsight.inspections.MathematicaInspectionProvider"/>
127+
<!--<inspectionToolProvider-->
128+
<!--implementation="de.halirutan.mathematica.codeinsight.inspections.MathematicaInspectionProvider"/>-->
129129

130-
<psi.referenceContributor language="Mathematica" implementation="de.halirutan.mathematica.lang.psi.MathematicaReferenceContributor"/>
131-
<renamePsiElementProcessor implementation="de.halirutan.mathematica.refactoring.MathematicaPsiRenameProcessor"/>
130+
<!--<psi.referenceContributor language="Mathematica" implementatide.halirutan.mathematica.lang.resolve.MathematicaReferenceContributorutor"/>-->
131+
<!--<renamePsiElementProcessor implementation="de.halirutan.mathematica.refactoring.MathematicaPsiRenameProcessor"/>-->
132132

133133
<applicationService serviceInterface="de.halirutan.mathematica.settings.MathematicaSettings" serviceImplementation="de.halirutan.mathematica.settings.MathematicaSettings"/>
134134
<applicationConfigurable groupId="language" displayName="Mathematica" id="preferences.Mathematica"
135135
instance="de.halirutan.mathematica.settings.MathematicaSettingsConfigurable"/>
136-
<gotoRelatedProvider
137-
implementation="de.halirutan.mathematica.codeinsight.navigation.MathematicaGotoRelatedProvider"/>
138-
139-
<spellchecker.support language="Mathematica"
140-
implementationClass="de.halirutan.mathematica.codeinsight.spellcheck.MathematicaSpellCheck"/>
141-
<intentionAction>
142-
<className>de.halirutan.mathematica.intentions.localization.MoveVariableToLocalisation</className>
143-
</intentionAction>
136+
<!--<gotoRelatedProvider-->
137+
<!--implementation="de.halirutan.mathematica.codeinsight.navigation.MathematicaGotoRelatedProvider"/>-->
138+
139+
<!--<spellchecker.support language="Mathematica"-->
140+
<!--implementationClass="de.halirutan.mathematica.codeinsight.spellcheck.MathematicaSpellCheck"/>-->
141+
<!--<intentionAction>-->
142+
<!--<className>de.halirutan.mathematica.intentions.localization.MoveVariableToLocalisation</className>-->
143+
<!--</intentionAction>-->
144144
</extensions>
145145

146146
<actions>

src/de/halirutan/mathematica/codeinsight/completion/LocalDefinitionCompletionProvider.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import de.halirutan.mathematica.lang.psi.api.assignment.TagSet;
3333
import de.halirutan.mathematica.lang.psi.api.assignment.TagSetDelayed;
3434
import de.halirutan.mathematica.lang.psi.api.rules.RuleDelayed;
35-
import de.halirutan.mathematica.lang.psi.impl.SymbolPsiReference;
3635
import de.halirutan.mathematica.lang.psi.util.LocalizationConstruct;
3736
import de.halirutan.mathematica.lang.psi.util.LocalizationConstruct.ConstructType;
3837
import de.halirutan.mathematica.lang.psi.util.MathematicaPatternVisitor;
@@ -150,7 +149,6 @@ private class SymbolComparator implements Comparator<Symbol> {
150149
public int compare(Symbol o1, Symbol o2) {
151150
return (o1.getFullSymbolName().compareTo(o2.getFullSymbolName()));
152151
}
153-
154152
}
155153

156154
}

src/de/halirutan/mathematica/codeinsight/completion/VariableNameCompletion.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@
3434
import com.intellij.util.ProcessingContext;
3535
import com.intellij.util.containers.hash.HashSet;
3636
import de.halirutan.mathematica.lang.psi.api.Symbol;
37-
import de.halirutan.mathematica.lang.psi.impl.SymbolPsiReference;
3837
import org.jetbrains.annotations.NotNull;
3938

4039
import java.util.List;
4140
import java.util.Set;
4241

42+
import static de.halirutan.mathematica.lang.psi.util.MathematicaPsiUtilities.isBuiltInSymbol;
43+
4344

4445
/**
4546
* @author patrick (4/2/13)
@@ -82,7 +83,7 @@ protected void addCompletions(@NotNull CompletionParameters parameters, Processi
8283

8384

8485
for (Symbol currentSymbol : variants) {
85-
if (!SymbolPsiReference.isBuiltInSymbol(currentSymbol)) {
86+
if (!isBuiltInSymbol(currentSymbol)) {
8687
result.addElement(PrioritizedLookupElement.withPriority(LookupElementBuilder.create(currentSymbol), LOCAL_VARIABLE_PRIORITY));
8788
}
8889
}

src/de/halirutan/mathematica/codeinsight/highlighting/MathematicaHighlightingAnnotator.java

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929
import com.intellij.openapi.editor.colors.TextAttributesKey;
3030
import com.intellij.openapi.editor.markup.TextAttributes;
3131
import com.intellij.psi.PsiElement;
32-
import com.intellij.psi.ResolveState;
3332
import com.intellij.psi.tree.IElementType;
34-
import com.intellij.psi.util.PsiTreeUtil;
3533
import de.halirutan.mathematica.codeinsight.completion.SymbolInformationProvider;
3634
import de.halirutan.mathematica.lang.parsing.MathematicaElementTypes;
3735
import de.halirutan.mathematica.lang.psi.MathematicaRecursiveVisitor;
@@ -42,8 +40,8 @@
4240
import de.halirutan.mathematica.lang.psi.api.function.Function;
4341
import de.halirutan.mathematica.lang.psi.api.slots.Slot;
4442
import de.halirutan.mathematica.lang.psi.api.slots.SlotExpression;
45-
import de.halirutan.mathematica.lang.psi.util.LocalDefinitionResolveProcessor;
4643
import de.halirutan.mathematica.lang.psi.util.LocalizationConstruct.ConstructType;
44+
import de.halirutan.mathematica.lang.resolve.SymbolResolveResult;
4745
import org.jetbrains.annotations.NotNull;
4846

4947
import java.util.Set;
@@ -86,32 +84,28 @@ public void annotate(@NotNull PsiElement element, @NotNull final AnnotationHolde
8684

8785
@Override
8886
public void visitSymbol(final Symbol symbol) {
89-
String possibleGlobalSymbol = symbol.getMathematicaContext().equals("") ?
90-
"System`"+symbol.getSymbolName() : symbol.getFullSymbolName();
91-
if (NAMES.contains(possibleGlobalSymbol)) {
92-
setHighlighting(symbol, myHolder, MathematicaSyntaxHighlighterColors.BUILTIN_FUNCTION);
93-
return;
94-
}
95-
96-
LocalDefinitionResolveProcessor processor = new LocalDefinitionResolveProcessor(symbol);
97-
PsiTreeUtil.treeWalkUp(processor, symbol, symbol.getContainingFile(), ResolveState.initial());
98-
99-
final ConstructType scope = processor.getMyLocalization();
100-
switch (scope) {
101-
case NULL:
102-
break;
103-
case MODULE:
104-
setHighlighting(symbol, myHolder, MathematicaSyntaxHighlighterColors.MODULE_LOCALIZED);
105-
break;
106-
case BLOCK:
107-
setHighlighting(symbol, myHolder, MathematicaSyntaxHighlighterColors.BLOCK_LOCALIZED);
108-
break;
109-
case SETDELAYEDPATTERN:
110-
setHighlighting(symbol, myHolder, MathematicaSyntaxHighlighterColors.PATTERN);
111-
break;
112-
default:
113-
setHighlighting(symbol, myHolder, MathematicaSyntaxHighlighterColors.MODULE_LOCALIZED);
114-
break;
87+
final SymbolResolveResult symbolResolveResult = symbol.advancedResolve();
88+
if (symbolResolveResult != null) {
89+
final ConstructType scope = symbolResolveResult.getLocalization();
90+
switch (scope) {
91+
case NULL:
92+
break;
93+
case BUILT_IN:
94+
setHighlighting(symbol, myHolder, MathematicaSyntaxHighlighterColors.BUILTIN_FUNCTION);
95+
break;
96+
case MODULE:
97+
setHighlighting(symbol, myHolder, MathematicaSyntaxHighlighterColors.MODULE_LOCALIZED);
98+
break;
99+
case BLOCK:
100+
setHighlighting(symbol, myHolder, MathematicaSyntaxHighlighterColors.BLOCK_LOCALIZED);
101+
break;
102+
case SETDELAYEDPATTERN:
103+
setHighlighting(symbol, myHolder, MathematicaSyntaxHighlighterColors.PATTERN);
104+
break;
105+
default:
106+
setHighlighting(symbol, myHolder, MathematicaSyntaxHighlighterColors.MODULE_LOCALIZED);
107+
break;
108+
}
115109
}
116110
}
117111

@@ -160,5 +154,4 @@ public void visitMessageName(final MessageName messageName) {
160154
setHighlightingStrict(children[i].getPsi(), myHolder, color);
161155
}
162156
}
163-
164157
}

src/de/halirutan/mathematica/codeinsight/highlighting/MathematicaReferenceAnnotator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
import de.halirutan.mathematica.lang.psi.api.MessageName;
3939
import de.halirutan.mathematica.lang.psi.api.Symbol;
4040
import de.halirutan.mathematica.lang.psi.api.function.Function;
41-
import de.halirutan.mathematica.lang.psi.util.LocalDefinitionResolveProcessor;
41+
import de.halirutan.mathematica.lang.resolve.LocalDefinitionResolveProcessor;
4242
import de.halirutan.mathematica.lang.psi.util.LocalizationConstruct.ConstructType;
4343
import org.jetbrains.annotations.NotNull;
4444

src/de/halirutan/mathematica/codeinsight/structureview/elements/AssignmentLeafViewTreeElement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import de.halirutan.mathematica.codeinsight.structureview.representations.*;
3131
import de.halirutan.mathematica.codeinsight.structureview.sorters.CodePlaceProvider;
3232
import de.halirutan.mathematica.lang.psi.SymbolAssignmentType;
33-
import de.halirutan.mathematica.lang.psi.util.GlobalDefinitionCollector.AssignmentProperty;
33+
import de.halirutan.mathematica.lang.resolve.GlobalDefinitionCollector.AssignmentProperty;
3434
import org.jetbrains.annotations.NotNull;
3535
import org.jetbrains.annotations.Nullable;
3636

src/de/halirutan/mathematica/codeinsight/structureview/elements/AssignmentSymbolNodeViewTreeElement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import com.intellij.navigation.ItemPresentation;
2929
import com.intellij.psi.PsiElement;
3030
import de.halirutan.mathematica.lang.psi.api.Expression;
31-
import de.halirutan.mathematica.lang.psi.util.GlobalDefinitionCollector.AssignmentProperty;
31+
import de.halirutan.mathematica.lang.resolve.GlobalDefinitionCollector.AssignmentProperty;
3232
import org.jetbrains.annotations.NotNull;
3333
import org.jetbrains.annotations.Nullable;
3434

src/de/halirutan/mathematica/codeinsight/structureview/elements/MathematicaFileTreeElement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
import com.intellij.ide.structureView.impl.common.PsiTreeElementBase;
2626
import com.intellij.navigation.ItemPresentation;
2727
import de.halirutan.mathematica.lang.psi.api.MathematicaPsiFile;
28-
import de.halirutan.mathematica.lang.psi.util.GlobalDefinitionCollector;
29-
import de.halirutan.mathematica.lang.psi.util.GlobalDefinitionCollector.AssignmentProperty;
28+
import de.halirutan.mathematica.lang.resolve.GlobalDefinitionCollector;
29+
import de.halirutan.mathematica.lang.resolve.GlobalDefinitionCollector.AssignmentProperty;
3030
import org.jetbrains.annotations.NotNull;
3131
import org.jetbrains.annotations.Nullable;
3232

0 commit comments

Comments
 (0)