Skip to content

Commit

Permalink
Clarify code around reference proxying
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkyenus committed Oct 4, 2015
1 parent e519d33 commit 04b2117
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/glslplugin/lang/elements/GLSLIdentifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,18 @@ public PsiElement setName(@NotNull String name) throws IncorrectOperationExcepti
return newName;
}

@Nullable
private GLSLReferenceElement getRealReference() {
PsiElement parent = getParent();
if (parent instanceof GLSLReferenceElement) {
return (GLSLReferenceElement) parent;
} else {
return null;
}
}

/**
* GLSLIdentifier can be a reference to pretty much anything (functions, variables...),
* but it poses only as a "source", the real logic is in the parent.
* @return getReferenceProxy() of parent if parent is GLSLReferenceElement
* @see GLSLReferenceElement
*/
@Override
@Nullable
public PsiReference getReference() {
GLSLReferenceElement theRealReference = getRealReference();
if (theRealReference != null) {
return theRealReference.getReferenceProxy();
PsiElement parent = getParent();
if (parent instanceof GLSLReferenceElement) {
return ((GLSLReferenceElement) parent).getReferenceProxy();
} else {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public GLSLRedefinedToken(@NotNull ASTNode astNode) {
super(astNode);
}

/**
* @return reference to the #define which caused the redefinition of this token
*/
@Override
public GLSLMacroReference getReference() {
return new GLSLMacroReference(this);
Expand Down

0 comments on commit 04b2117

Please sign in to comment.