|
33 | 33 | import de.halirutan.mathematica.lang.psi.util.LocalizationConstruct.MScope; |
34 | 34 | import de.halirutan.mathematica.lang.resolve.processors.SymbolResolveHint; |
35 | 35 | import org.jetbrains.annotations.NotNull; |
36 | | -import org.jetbrains.annotations.Nullable; |
37 | 36 |
|
38 | 37 | import java.util.List; |
39 | 38 |
|
40 | 39 | public class FunctionCallImpl extends ExpressionImpl implements FunctionCall { |
41 | 40 |
|
42 | | -// private final Key<Object> myScopeKey = Key.create("SCOPING_CONSTRUCT"); |
43 | | -// private boolean myIsUpToDate; |
44 | | - private String myHead; |
45 | | - private MScope myLocalizationConstruct = MScope.NULL; |
| 41 | + private final String myHead; |
| 42 | + private MScope myLocalizationConstruct = MScope.NULL_SCOPE; |
| 43 | + private final boolean myIsScopingFunction; |
46 | 44 |
|
47 | 45 |
|
48 | 46 | public FunctionCallImpl(@NotNull ASTNode node) { |
49 | 47 | super(node); |
50 | 48 | // myIsUpToDate = false; |
51 | 49 | myHead = node.getFirstChildNode().getText(); |
52 | | - myLocalizationConstruct = LocalizationConstruct.getType(myHead); |
| 50 | + myIsScopingFunction = LocalizationConstruct.isScopingFunction(myHead); |
| 51 | + myLocalizationConstruct = myIsScopingFunction ? LocalizationConstruct.getScope(myHead) : MScope.NULL_SCOPE; |
53 | 52 | } |
54 | 53 |
|
55 | 54 | @Override |
@@ -125,36 +124,15 @@ public List<PsiElement> getParameters() { |
125 | 124 | return allArguments; |
126 | 125 | } |
127 | 126 |
|
128 | | - |
129 | | - /** |
130 | | - * Extracts the head of the function call and looks whether it is in the list {@link #SCOPING_CONSTRUCTS}. This can |
131 | | - * lead to various false negatives. E.g. <code >(Block)[{..},..]</code> returns false, although after <em |
132 | | - * >evaluating</em> the code in Mathematica, it's of course found to be a correct scoping construct. Btw, the |
133 | | - * Mathematica front end has the same issues. |
134 | | - * |
135 | | - * @return True iff the head is a symbol defining the function as scoping construct like <code >Block[{..},..]</code>. |
136 | | - */ |
137 | | - |
138 | 127 | @Override |
139 | 128 | public boolean isScopingConstruct() { |
140 | | - return myLocalizationConstruct != MScope.NULL; |
| 129 | + return myIsScopingFunction; |
141 | 130 | } |
142 | 131 |
|
143 | 132 | @Override |
144 | 133 | public MScope getScopingConstruct() { |
145 | 134 | return myLocalizationConstruct; |
146 | 135 | } |
147 | | -// |
148 | | -// private void cacheScopingConstruct() { |
149 | | -// if (myIsUpToDate) return; |
150 | | -// PsiElement head = getFirstChild(); |
151 | | -// if (head instanceof Symbol) { |
152 | | -// cacheScopingConstruct(((Symbol) head).getSymbolName()); |
153 | | -// } else { |
154 | | -// putUserData(myScopeKey, MScope.NULL); |
155 | | -// } |
156 | | -// myIsUpToDate = true; |
157 | | -// } |
158 | 136 |
|
159 | 137 | @Override |
160 | 138 | public void accept(@NotNull PsiElementVisitor visitor) { |
|
0 commit comments