|
67 | 67 | @CustomLog |
68 | 68 | public class HaxeResolver implements ResolveCache.AbstractResolver<HaxeReference, List<? extends PsiElement>> { |
69 | 69 | public static final int MAX_DEBUG_MESSAGE_LENGTH = 200; |
70 | | - public static final Key<String> typeHintKey = new Key<>("typeHint"); |
71 | | - private static final Key<Boolean> skipCacheKey = new Key<>("skipCache"); |
72 | 70 |
|
73 | 71 | //static { // Remove when finished debugging. |
74 | 72 | // LOG.setLevel(LogLevel.DEBUG); |
@@ -103,8 +101,7 @@ public List<? extends PsiElement> resolve(@NotNull HaxeReference reference, bool |
103 | 101 | // fail until the indices are complete), we don't want to cache the (likely incorrect) |
104 | 102 | // results. |
105 | 103 | boolean isDumb = DumbService.isDumb(reference.getProject()); |
106 | | - boolean hasTypeHint = checkForTypeHint(reference); |
107 | | - boolean skipCaching = skipCachingForDebug || isDumb || hasTypeHint; |
| 104 | + boolean skipCaching = skipCachingForDebug || isDumb; |
108 | 105 |
|
109 | 106 | List<? extends PsiElement> elements = skipCaching ? doResolve(reference, incompleteCode) |
110 | 107 | : ResolveCache.getInstance(reference.getProject()) |
@@ -132,20 +129,6 @@ public List<? extends PsiElement> resolve(@NotNull HaxeReference reference, bool |
132 | 129 | return elements == null ? EMPTY_LIST : elements; |
133 | 130 | } |
134 | 131 |
|
135 | | - //TODO until we have type hints everywhere we need to skip caching for those refrences that rely on typeHints |
136 | | - private boolean checkForTypeHint(HaxeReference reference) { |
137 | | - if (reference.getUserData(typeHintKey) != null ) return true; |
138 | | - if (reference.getParent() instanceof HaxeCallExpression expression) { |
139 | | - if (expression.getUserData(typeHintKey) != null ) return true; |
140 | | - } |
141 | | - return false; |
142 | | - } |
143 | | - |
144 | | - private boolean isResolving(@NotNull HaxeReference reference) { |
145 | | - Stack<PsiElement> stack = referencesProcessing.get(); |
146 | | - return stack.contains(reference); |
147 | | - } |
148 | | - |
149 | 132 |
|
150 | 133 | @Nullable |
151 | 134 | private List<? extends PsiElement> doResolve(@NotNull HaxeReference reference, boolean incompleteCode) { |
@@ -182,6 +165,17 @@ private List<? extends PsiElement> doResolveInner(@NotNull HaxeReference referen |
182 | 165 | resolves.incrementAndGet(); |
183 | 166 | } |
184 | 167 |
|
| 168 | + try { |
| 169 | + if (reference.getParent().getParent().getParent().textMatches(":Array<ClassField>")) { // OR |
| 170 | + int i = 0; |
| 171 | + } |
| 172 | + if (reference.getParent().getParent().getParent().textMatches("::Map<String,Bool>")) { |
| 173 | + int i = 0; |
| 174 | + } |
| 175 | + }catch (Exception e) { |
| 176 | + |
| 177 | + } |
| 178 | + |
185 | 179 | if (reference instanceof HaxeLiteralExpression || reference instanceof HaxeConstantExpression) { |
186 | 180 | if (!(reference instanceof HaxeRegularExpression || reference instanceof HaxeStringLiteralExpression)) { |
187 | 181 | return EMPTY_LIST; |
@@ -232,23 +226,6 @@ private List<? extends PsiElement> doResolveInner(@NotNull HaxeReference referen |
232 | 226 | if(matchesInImport.size()> 1 && reference.getParent() instanceof HaxeCallExpression callExpression) { |
233 | 227 | int expectedSize = Optional.ofNullable(callExpression.getExpressionList()).map(e -> e.getExpressionList().size()).orElse(0); |
234 | 228 |
|
235 | | - // check type hinting for enumValues |
236 | | - for (PsiElement importElement : matchesInImport) { |
237 | | - if (importElement.getParent() instanceof HaxeEnumValueDeclaration enumValueDeclaration) { |
238 | | - PsiElement typeHintPsi = reference; |
239 | | - |
240 | | - if (reference.getParent() instanceof HaxeCallExpression expression) { |
241 | | - typeHintPsi = expression; |
242 | | - } |
243 | | - String currentQname = enumValueDeclaration.getContainingClass().getQualifiedName(); |
244 | | - String data = typeHintPsi.getUserData(typeHintKey); |
245 | | - if (currentQname != null && currentQname.equals(data)) { |
246 | | - LogResolution(reference, "via import & typeHintKey"); |
247 | | - return List.of(importElement); |
248 | | - } |
249 | | - } |
250 | | - } |
251 | | - |
252 | 229 | // test call expression if possible |
253 | 230 | for (PsiElement importElement : matchesInImport) { |
254 | 231 | if (importElement.getParent() instanceof HaxeEnumValueDeclarationConstructor enumValueDeclaration) { |
@@ -299,6 +276,28 @@ private List<? extends PsiElement> doResolveInner(@NotNull HaxeReference referen |
299 | 276 | String message = "caching result for :" + referenceText; |
300 | 277 | traceAs(log, HaxeDebugUtil.getCallerStackFrame(), message); |
301 | 278 | } |
| 279 | + |
| 280 | + try { |
| 281 | + if (reference.getParent().getParent().getParent().textMatches(":Array<ClassField>")) { |
| 282 | + if(result != null && !result.isEmpty()) { |
| 283 | + PsiElement first = result.getFirst(); |
| 284 | + if(!first.textMatches("Array")) { |
| 285 | + int i = 0; |
| 286 | + } |
| 287 | + } |
| 288 | + } |
| 289 | + if (reference.getParent().getParent().getParent().textMatches(":Map<String,Bool>")) { |
| 290 | + if(result != null && !result.isEmpty()) { |
| 291 | + PsiElement first = result.getFirst(); |
| 292 | + if(!first.textMatches("Map")) { |
| 293 | + int i = 0; |
| 294 | + } |
| 295 | + } |
| 296 | + } |
| 297 | + }catch (Exception e) { |
| 298 | + |
| 299 | + } |
| 300 | + |
302 | 301 | return result; |
303 | 302 |
|
304 | 303 | } |
|
0 commit comments