@@ -261,21 +261,23 @@ public static SymbolResolveResult resolveLocalFunctionVariables(Symbol myStartEl
261261 return null ;
262262 }
263263
264+ final MScope scope = functionCall .getScopingConstruct ();
265+
264266 final PsiElement lastParent = state .get (SymbolResolveHint .LAST_PARENT );
265267 final PsiElement firstArgument = arguments .get (0 );
266268 PsiElement definitions = arguments .size () > 1 ? firstArgument : null ;
267269 if (definitions != null ) {
268- boolean inDefition = definitions .equals (lastParent );
270+ boolean inDefinition = definitions .equals (lastParent );
269271 if (firstArgument instanceof Symbol && !((Symbol ) firstArgument ).getSymbolName ().equals ("Null" ) && ((Symbol ) firstArgument ).getFullSymbolName ().equals (myStartElement .getFullSymbolName ())) {
270- return new SymbolResolveResult (firstArgument , MScope . FUNCTION , true );
272+ return new SymbolResolveResult (firstArgument , scope , functionCall , true );
271273 } else if (firstArgument instanceof MList ) {
272- final List <Symbol > defs = getDefinitionSymbolsFromList (firstArgument );
273- for (Symbol def : defs ) {
274+ final List <Symbol > defSymbols = getDefinitionSymbolsFromList (firstArgument );
275+ for (Symbol def : defSymbols ) {
274276 if (def .getFullSymbolName ().equals (myStartElement .getFullSymbolName ())) {
275- if (!inDefition || def .equals (myStartElement )) {
276- return new SymbolResolveResult (def , MScope . FUNCTION , true );
277+ if (!inDefinition || def .equals (myStartElement )) {
278+ return new SymbolResolveResult (def , scope , functionCall , true );
277279 } else {
278- return new SymbolResolveResult (myStartElement , MScope . NULL_SCOPE , true );
280+ return new SymbolResolveResult (myStartElement , scope , functionCall , true );
279281 }
280282 }
281283 }
@@ -351,11 +353,11 @@ public static SymbolResolveResult resolveLocalModuleLikeVariables(@NotNull Symbo
351353 if (e instanceof Symbol ) {
352354 if (((Symbol ) e ).getSymbolName ().equals (symbol .getSymbolName ())) {
353355 if (!isInDefList || e .equals (symbol )) {
354- return new SymbolResolveResult (e , scopingConstruct , true );
356+ return new SymbolResolveResult (e , scopingConstruct , functionCall , true );
355357 } else {
356358 final List <Symbol > definitionInList = getDefinitionSymbolsFromList (moduleDefList );
357359 if (definitionInList .contains (symbol )) {
358- return new SymbolResolveResult (symbol , scopingConstruct , false );
360+ return new SymbolResolveResult (symbol , scopingConstruct , functionCall , false );
359361 } else {
360362 return null ;
361363 }
@@ -425,7 +427,7 @@ public static SymbolResolveResult resolveLocalTableLikeVariables(Symbol myStartE
425427 final PsiElement firstListElement = getFirstListElement (currentIterator );
426428 if (firstListElement instanceof Symbol ) {
427429 if (((Symbol ) firstListElement ).getFullSymbolName ().equals (myStartElement .getFullSymbolName ())) {
428- return new SymbolResolveResult (firstListElement , scopingConstruct , true );
430+ return new SymbolResolveResult (firstListElement , scopingConstruct , functionCall , true );
429431 }
430432 }
431433 }
@@ -434,7 +436,7 @@ public static SymbolResolveResult resolveLocalTableLikeVariables(Symbol myStartE
434436 // self-reference if we are the iterator
435437 if (args [pos ] instanceof MList ) {
436438 if (Objects .equals (getFirstListElement (args [pos ]), myStartElement )) {
437- return new SymbolResolveResult (myStartElement , scopingConstruct , true );
439+ return new SymbolResolveResult (myStartElement , scopingConstruct , functionCall , true );
438440 }
439441 }
440442
@@ -444,7 +446,7 @@ public static SymbolResolveResult resolveLocalTableLikeVariables(Symbol myStartE
444446 final PsiElement firstListElement = getFirstListElement (args [i ]);
445447 if (firstListElement instanceof Symbol ) {
446448 if (((Symbol ) firstListElement ).getFullSymbolName ().equals (myStartElement .getFullSymbolName ())) {
447- return new SymbolResolveResult (firstListElement , scopingConstruct , true );
449+ return new SymbolResolveResult (firstListElement , scopingConstruct , functionCall , true );
448450 }
449451 }
450452 }
@@ -529,47 +531,6 @@ public static List<Symbol> getLocalCompileLikeVariables(FunctionCall element) {
529531 }
530532
531533
532- @ Nullable
533- public static SymbolResolveResult resolveLocalCompileLikeVariables (Symbol myStartElement , FunctionCall functionCall , ResolveState state ) {
534-
535- final PsiElement lastParent = state .get (SymbolResolveHint .LAST_PARENT );
536- final List <PsiElement > arguments = getArguments (functionCall );
537- if (arguments .size () < 1 ) {
538- return null ;
539- }
540-
541- final PsiElement firstArgument = arguments .get (0 );
542- boolean inDef = firstArgument .equals (lastParent );
543-
544-
545- final MScope scopingConstruct = functionCall .getScopingConstruct ();
546- if (firstArgument instanceof Symbol ) {
547- if (((Symbol ) firstArgument ).getFullSymbolName ().equals (myStartElement .getFullSymbolName ())) {
548- return new SymbolResolveResult (firstArgument , scopingConstruct , true );
549- }
550- } else if (firstArgument instanceof MList ) {
551- final PsiElement [] children = firstArgument .getChildren ();
552- for (PsiElement child : children ) {
553- if (child instanceof MList ) {
554- child = child .getFirstChild ();
555- }
556- if (child instanceof Symbol ) {
557- if (inDef ) {
558- if (child .equals (myStartElement )) {
559- return new SymbolResolveResult (child , scopingConstruct , true );
560- }
561- } else {
562- if (((Symbol ) child ).getFullSymbolName ().equals (myStartElement .getFullSymbolName ())) {
563- return new SymbolResolveResult (child , scopingConstruct , true );
564- }
565- }
566- }
567- }
568- }
569- return null ;
570- }
571-
572-
573534 /**
574535 * This extracts the local defined argument for a <code>Limit[Sin[x]/x, x-> 0]</code> call. Note that the returned
575536 * list has always only one element since <code>Limit</code> always uses only one variable.
0 commit comments