org.eclipse.jdt.core.dom.MethodDeclaration#delete ( )源码实例Demo

下面列出了org.eclipse.jdt.core.dom.MethodDeclaration#delete ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: eclipse-cs   文件: UncommentedMainQuickfix.java
/**
 * {@inheritDoc}
 */
@Override
protected ASTVisitor handleGetCorrectingASTVisitor(final IRegion lineInfo,
        final int markerStartOffset) {
  return new ASTVisitor() {

    @Override
    public boolean visit(MethodDeclaration node) {
      // recalculate start position because optional javadoc is mixed
      // into the original start position
      int pos = node.getStartPosition() + (node.getJavadoc() != null
              ? node.getJavadoc().getLength() + JAVADOC_COMMENT_LENGTH
              : 0);
      if (containsPosition(lineInfo, pos)
              && node.getName().getFullyQualifiedName().equals("main")) {
        node.delete();
      }
      return true;
    }
  };
}
 
@Override
public ASTVisitor getCorrectingASTVisitor(IRegion lineInfo, int markerStartOffset) {
    return new ASTVisitor() {

        @Override
        public boolean visit(MethodDeclaration node) {
            // recalculate start position because optional javadoc is mixed
            // into the original start position
            final int pos = node.getStartPosition() +
                    (node.getJavadoc() != null ? node.getJavadoc().getLength() + JAVADOC_COMMENT_LENGTH : 0);
            if (containsPosition(lineInfo, pos) && node.getName().getFullyQualifiedName().equals("main")) {
                node.delete();
            }
            return true;
        }
    };
}