本文整理汇总了Java中org.eclipse.jdt.core.dom.MethodDeclaration.getStartPosition方法的典型用法代码示例。如果您正苦于以下问题:Java MethodDeclaration.getStartPosition方法的具体用法?Java MethodDeclaration.getStartPosition怎么用?Java MethodDeclaration.getStartPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.MethodDeclaration
的用法示例。
在下文中一共展示了MethodDeclaration.getStartPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMethod
import org.eclipse.jdt.core.dom.MethodDeclaration; //导入方法依赖的package包/类
public RastNode createMethod(String methodSignature, HasChildrenNodes parent, String sourceFilePath, boolean constructor, MethodDeclaration ast) {
String methodName = ast.isConstructor() ? "" : ast.getName().getIdentifier();
RastNode rastNode = new RastNode(++nodeCounter);
rastNode.setType(ast.getClass().getSimpleName());
Block body = ast.getBody();
int bodyStart;
int bodyLength;
if (body == null) {
rastNode.addStereotypes(Stereotype.ABSTRACT);
bodyStart = ast.getStartPosition() + ast.getLength();
bodyLength = 0;
} else {
bodyStart = body.getStartPosition();
bodyLength = body.getLength();
}
rastNode.setLocation(new Location(sourceFilePath, ast.getStartPosition(), ast.getStartPosition() + ast.getLength(), bodyStart, bodyStart + bodyLength));
rastNode.setLocalName(methodSignature);
rastNode.setSimpleName(methodName);
parent.addNode(rastNode);
keyMap.put(JavaParser.getKey(rastNode), rastNode);
return rastNode;
}
示例2: createOverrideAnnotation
import org.eclipse.jdt.core.dom.MethodDeclaration; //导入方法依赖的package包/类
public static void createOverrideAnnotation(ASTRewrite rewrite, ImportRewrite imports, MethodDeclaration decl, TextEditGroup group) {
if (findAnnotation("java.lang.Override", decl.modifiers()) != null) { //$NON-NLS-1$
return; // No need to add duplicate annotation
}
AST ast= rewrite.getAST();
ASTNode root= decl.getRoot();
ImportRewriteContext context= null;
if (root instanceof CompilationUnit) {
context= new ContextSensitiveImportRewriteContext((CompilationUnit) root, decl.getStartPosition(), imports);
}
Annotation marker= ast.newMarkerAnnotation();
marker.setTypeName(ast.newName(imports.addImport("java.lang.Override", context))); //$NON-NLS-1$
rewrite.getListRewrite(decl, MethodDeclaration.MODIFIERS2_PROPERTY).insertFirst(marker, group);
}