Java 类org.eclipse.jdt.core.search.FieldDeclarationMatch 实例源码

项目:che    文件:RenameAnalyzeUtil.java   
private static void addReferenceShadowedError(
    ICompilationUnit cu, SearchMatch newMatch, String newElementName, RefactoringStatus result) {
  // Found a new match with no corresponding old match.
  // -> The new match is a reference which was pointing to another element,
  // but that other element has been shadowed

  // 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);
}
项目:che    文件:RenameAnalyzeUtil.java   
private static void addShadowsError(
    ICompilationUnit cu, SearchMatch oldMatch, RefactoringStatus result) {
  // Old match not found in new matches -> reference has been shadowed

  // 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);
}
项目:che    文件:NewSearchResultCollector.java   
@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));
  }
}
项目:Eclipse-Postfix-Code-Completion    文件:RenameAnalyzeUtil.java   
private static void addReferenceShadowedError(ICompilationUnit cu, SearchMatch newMatch, String newElementName, RefactoringStatus result) {
    //Found a new match with no corresponding old match.
    //-> The new match is a reference which was pointing to another element,
    //but that other element has been shadowed

    //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);
}
项目:Eclipse-Postfix-Code-Completion    文件:RenameAnalyzeUtil.java   
private static void addShadowsError(ICompilationUnit cu, SearchMatch oldMatch, RefactoringStatus result) {
    // Old match not found in new matches -> reference has been shadowed

    //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);
}
项目:Eclipse-Postfix-Code-Completion    文件:NewSearchResultCollector.java   
@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));
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:RenameAnalyzeUtil.java   
private static void addReferenceShadowedError(ICompilationUnit cu, SearchMatch newMatch, String newElementName, RefactoringStatus result) {
    //Found a new match with no corresponding old match.
    //-> The new match is a reference which was pointing to another element,
    //but that other element has been shadowed

    //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);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:RenameAnalyzeUtil.java   
private static void addShadowsError(ICompilationUnit cu, SearchMatch oldMatch, RefactoringStatus result) {
    // Old match not found in new matches -> reference has been shadowed

    //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);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:NewSearchResultCollector.java   
@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));
    }
}
项目:Constants-to-Enum-Eclipse-Plugin    文件:ConvertConstantsToEnumRefactoring.java   
private void rewriteDeclarationsAndNamespaces(CompilationUnit node,
        SearchMatch match, RefactoringStatus status, ASTRewrite astRewrite,
        ImportRewrite importRewrite) throws CoreException {
    // final ASTNode result = NodeFinder.perform(node, match
    // .getOffset(), match.getLength());
    final ASTNode result = Util.getExactASTNode(node, match);

    // Must be simple name node.
    if (result.getNodeType() != ASTNode.SIMPLE_NAME) {
        final String errorMessage = Messages.ConvertConstantsToEnumRefactoring_WrongType;
        status.merge(RefactoringStatus.createFatalErrorStatus(MessageFormat
                .format(errorMessage,
                        new Object[] { node, node.getClass() })));
        final IStatus stateStatus = new InternalStateStatus(IStatus.ERROR,
                errorMessage);
        throw new CoreException(stateStatus);
    }

    // Get the fully qualified type name.
    final String fqn = this.getFullyQualifiedName(((Name) result)
            .resolveBinding().getJavaElement());

    if (match instanceof FieldDeclarationMatch
            && this.fieldsToRefactor.contains(match.getElement()))
        status.merge(this.removeConstField(astRewrite, importRewrite,
                Util.getFieldDeclaration(result),
                (IField) match.getElement()));

    else if (match instanceof FieldDeclarationMatch)
        status.merge(this.rewriteFieldDeclaration(astRewrite,
                importRewrite, Util.getFieldDeclaration(result), fqn));

    // Workaround for Bug 207257.
    else if (match instanceof LocalVariableDeclarationMatch
            || match instanceof LocalVariableReferenceMatch)
        if (((IVariableBinding) ((Name) result).resolveBinding())
                .isParameter())
            status.merge(this.rewriteFormalParameterDeclaration(astRewrite,
                    importRewrite,
                    Util.getSingleVariableDeclaration(result), fqn));

        else
            status.merge(this.rewriteLocalVariableDeclaration(astRewrite,
                    importRewrite,
                    Util.getVariableDeclarationStatement(result), fqn));

    else if (match instanceof MethodDeclarationMatch)
        status.merge(this.rewriteMethodDeclaration(astRewrite,
                importRewrite, Util.getMethodDeclaration(result), fqn));

    else if (match instanceof FieldReferenceMatch)
        // Rewrite the reference.
        status.merge(this.rewriteReference(astRewrite, importRewrite,
                (SimpleName) result, fqn));

}