Java Code Examples for org.eclipse.jdt.core.dom.MethodDeclaration#delete()

The following examples show how to use org.eclipse.jdt.core.dom.MethodDeclaration#delete() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UncommentedMainQuickfix.java    From eclipse-cs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * {@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;
    }
  };
}
 
Example 2
Source File: UncommentedMainQuickFix.java    From vscode-checkstyle with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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;
        }
    };
}