Lines 644-649
Link Here
|
644 |
return findNameSpan(var.getName().toString(), var); |
644 |
return findNameSpan(var.getName().toString(), var); |
645 |
} |
645 |
} |
646 |
|
646 |
|
|
|
647 |
/**Find span of the {@link MethodTree#getParameters()} parameter list in the source. |
648 |
* Returns the position of the opening and closing parentheses of the parameter list |
649 |
* in the source code that was parsed (ie. {@link CompilationInfo.getText()}, which |
650 |
* may differ from the positions in the source document if it has been already altered. |
651 |
* |
652 |
* @param method method which parameter list should be searched for |
653 |
* @return the span of the parameter list, or null if cannot be found |
654 |
* @since 0.81 |
655 |
*/ |
656 |
public int[] findMethodParameterSpan(MethodTree method) { |
657 |
JCTree jcTree = (JCTree) method; |
658 |
int pos = jcTree.pos; |
659 |
|
660 |
if (pos < 0) |
661 |
return null; |
662 |
|
663 |
TokenSequence<JavaTokenId> tokenSequence = info.getTokenHierarchy().tokenSequence(JavaTokenId.language()); |
664 |
tokenSequence.move(pos); |
665 |
|
666 |
int startPos = -1; |
667 |
int endPos = -1; |
668 |
while(tokenSequence.moveNext()) { |
669 |
if(tokenSequence.token().id() == JavaTokenId.LPAREN) { |
670 |
startPos = tokenSequence.offset(); |
671 |
} |
672 |
if(tokenSequence.token().id() == JavaTokenId.RPAREN) { |
673 |
endPos = tokenSequence.offset(); |
674 |
break; |
675 |
} |
676 |
if(tokenSequence.token().id() == JavaTokenId.LBRACE) { |
677 |
return null; |
678 |
} |
679 |
} |
680 |
|
681 |
if(startPos == -1 || endPos == -1) { |
682 |
return null; |
683 |
} |
684 |
|
685 |
return new int[] { |
686 |
startPos, |
687 |
endPos |
688 |
}; |
689 |
} |
690 |
|
647 |
/**Find span of the {@link MemberSelectTree#getIdentifier()} identifier in the source. |
691 |
/**Find span of the {@link MemberSelectTree#getIdentifier()} identifier in the source. |
648 |
* Returns starting and ending offset of the name in the source code that was parsed |
692 |
* Returns starting and ending offset of the name in the source code that was parsed |
649 |
* (ie. {@link CompilationInfo.getText()}, which may differ from the positions in the source |
693 |
* (ie. {@link CompilationInfo.getText()}, which may differ from the positions in the source |