Search in sources :

Example 1 with FieldDeclarationMatch

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

the class RenameAnalyzeUtil method addReferenceShadowedError.

private static void addReferenceShadowedError(ICompilationUnit cu, SearchMatch newMatch, String newElementName, RefactoringStatus result) {
    //TODO: should not have to filter declarations:
    if (newMatch instanceof MethodDeclarationMatch || newMatch instanceof FieldDeclarationMatch)
        return;
    ISourceRange range = getOldSourceRange(newMatch);
    RefactoringStatusContext context = JavaStatusContext.create(cu, range);
    String message = Messages.format(RefactoringCoreMessages.RenameAnalyzeUtil_reference_shadowed, new String[] { BasicElementLabels.getFileName(cu), BasicElementLabels.getJavaElementName(newElementName) });
    result.addError(message, context);
}
Also used : RefactoringStatusContext(org.eclipse.ltk.core.refactoring.RefactoringStatusContext) MethodDeclarationMatch(org.eclipse.jdt.core.search.MethodDeclarationMatch) FieldDeclarationMatch(org.eclipse.jdt.core.search.FieldDeclarationMatch) ISourceRange(org.eclipse.jdt.core.ISourceRange)

Example 2 with FieldDeclarationMatch

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

the class RenameAnalyzeUtil method addShadowsError.

private static void addShadowsError(ICompilationUnit cu, SearchMatch oldMatch, RefactoringStatus result) {
    //TODO: should not have to filter declarations:
    if (oldMatch instanceof MethodDeclarationMatch || oldMatch instanceof FieldDeclarationMatch)
        return;
    ISourceRange range = new SourceRange(oldMatch.getOffset(), oldMatch.getLength());
    RefactoringStatusContext context = JavaStatusContext.create(cu, range);
    String message = Messages.format(RefactoringCoreMessages.RenameAnalyzeUtil_shadows, BasicElementLabels.getFileName(cu));
    result.addError(message, context);
}
Also used : RefactoringStatusContext(org.eclipse.ltk.core.refactoring.RefactoringStatusContext) ISourceRange(org.eclipse.jdt.core.ISourceRange) SourceRange(org.eclipse.jdt.core.SourceRange) MethodDeclarationMatch(org.eclipse.jdt.core.search.MethodDeclarationMatch) FieldDeclarationMatch(org.eclipse.jdt.core.search.FieldDeclarationMatch) ISourceRange(org.eclipse.jdt.core.ISourceRange)

Example 3 with FieldDeclarationMatch

use of org.eclipse.jdt.core.search.FieldDeclarationMatch 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

FieldDeclarationMatch (org.eclipse.jdt.core.search.FieldDeclarationMatch)3 ISourceRange (org.eclipse.jdt.core.ISourceRange)2 MethodDeclarationMatch (org.eclipse.jdt.core.search.MethodDeclarationMatch)2 RefactoringStatusContext (org.eclipse.ltk.core.refactoring.RefactoringStatusContext)2 IJavaElement (org.eclipse.jdt.core.IJavaElement)1 SourceRange (org.eclipse.jdt.core.SourceRange)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