Search in sources :

Example 1 with LocalVariableReferenceMatch

use of org.eclipse.jdt.core.search.LocalVariableReferenceMatch in project che by eclipse.

the class NewSearchResultCollector method acceptSearchMatch.

@Override
public void acceptSearchMatch(SearchMatch match) throws CoreException {
    IJavaElement enclosingElement = (IJavaElement) match.getElement();
    if (enclosingElement != null) {
        if (fIgnorePotentials && (match.getAccuracy() == SearchMatch.A_INACCURATE))
            return;
        boolean isWriteAccess = false;
        boolean isReadAccess = false;
        if (match instanceof FieldReferenceMatch) {
            FieldReferenceMatch fieldRef = ((FieldReferenceMatch) match);
            isWriteAccess = fieldRef.isWriteAccess();
            isReadAccess = fieldRef.isReadAccess();
        } else if (match instanceof FieldDeclarationMatch) {
            isWriteAccess = true;
        } else if (match instanceof LocalVariableReferenceMatch) {
            LocalVariableReferenceMatch localVarRef = ((LocalVariableReferenceMatch) match);
            isWriteAccess = localVarRef.isWriteAccess();
            isReadAccess = localVarRef.isReadAccess();
        } else if (match instanceof LocalVariableDeclarationMatch) {
            isWriteAccess = true;
        }
        boolean isSuperInvocation = false;
        if (match instanceof MethodReferenceMatch) {
            MethodReferenceMatch methodRef = (MethodReferenceMatch) match;
            isSuperInvocation = methodRef.isSuperInvocation();
        }
        fSearch.addMatch(new JavaElementMatch(enclosingElement, match.getRule(), match.getOffset(), match.getLength(), match.getAccuracy(), isReadAccess, isWriteAccess, match.isInsideDocComment(), isSuperInvocation));
    }
}
Also used : IJavaElement(org.eclipse.jdt.core.IJavaElement) MethodReferenceMatch(org.eclipse.jdt.core.search.MethodReferenceMatch) FieldReferenceMatch(org.eclipse.jdt.core.search.FieldReferenceMatch) LocalVariableDeclarationMatch(org.eclipse.jdt.core.search.LocalVariableDeclarationMatch) LocalVariableReferenceMatch(org.eclipse.jdt.core.search.LocalVariableReferenceMatch) FieldDeclarationMatch(org.eclipse.jdt.core.search.FieldDeclarationMatch)

Aggregations

IJavaElement (org.eclipse.jdt.core.IJavaElement)1 FieldDeclarationMatch (org.eclipse.jdt.core.search.FieldDeclarationMatch)1 FieldReferenceMatch (org.eclipse.jdt.core.search.FieldReferenceMatch)1 LocalVariableDeclarationMatch (org.eclipse.jdt.core.search.LocalVariableDeclarationMatch)1 LocalVariableReferenceMatch (org.eclipse.jdt.core.search.LocalVariableReferenceMatch)1 MethodReferenceMatch (org.eclipse.jdt.core.search.MethodReferenceMatch)1