本文整理匯總了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);
}