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);
}
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);
}
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));
}
}
Aggregations