本文整理汇总了Java中org.eclipse.jdt.core.dom.SimpleName.getStartPosition方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleName.getStartPosition方法的具体用法?Java SimpleName.getStartPosition怎么用?Java SimpleName.getStartPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.SimpleName
的用法示例。
在下文中一共展示了SimpleName.getStartPosition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNameNodeProblemKind
import org.eclipse.jdt.core.dom.SimpleName; //导入方法依赖的package包/类
private static int getNameNodeProblemKind(IProblem[] problems, SimpleName nameNode) {
int nameOffset= nameNode.getStartPosition();
int nameInclEnd= nameOffset + nameNode.getLength() - 1;
for (int i= 0; i < problems.length; i++) {
IProblem curr= problems[i];
if (curr.getSourceStart() == nameOffset && curr.getSourceEnd() == nameInclEnd) {
int kind= getProblemKind(curr);
if (kind != 0) {
return kind;
}
}
}
return 0;
}
示例2: isInRemoved
import org.eclipse.jdt.core.dom.SimpleName; //导入方法依赖的package包/类
private boolean isInRemoved(SimpleName ref, List<int[]> removedStartsEnds) {
int start= ref.getStartPosition();
int end= start + ref.getLength();
for (int[] removedStartsEnd : removedStartsEnds) {
if (start >= removedStartsEnd[0] && end <= removedStartsEnd[1]) {
return true;
}
}
return false;
}
示例3: doAddField
import org.eclipse.jdt.core.dom.SimpleName; //导入方法依赖的package包/类
private ASTRewrite doAddField(CompilationUnit astRoot) {
SimpleName node= fOriginalNode;
boolean isInDifferentCU= false;
ASTNode newTypeDecl= astRoot.findDeclaringNode(fSenderBinding);
if (newTypeDecl == null) {
astRoot= ASTResolving.createQuickFixAST(getCompilationUnit(), null);
newTypeDecl= astRoot.findDeclaringNode(fSenderBinding.getKey());
isInDifferentCU= true;
}
ImportRewrite imports= createImportRewrite(astRoot);
ImportRewriteContext importRewriteContext= new ContextSensitiveImportRewriteContext(ASTResolving.findParentBodyDeclaration(node), imports);
if (newTypeDecl != null) {
AST ast= newTypeDecl.getAST();
ASTRewrite rewrite= ASTRewrite.create(ast);
VariableDeclarationFragment fragment= ast.newVariableDeclarationFragment();
fragment.setName(ast.newSimpleName(node.getIdentifier()));
Type type= evaluateVariableType(ast, imports, importRewriteContext, fSenderBinding, TypeLocation.FIELD);
FieldDeclaration newDecl= ast.newFieldDeclaration(fragment);
newDecl.setType(type);
newDecl.modifiers().addAll(ASTNodeFactory.newModifiers(ast, evaluateFieldModifiers(newTypeDecl)));
if (fSenderBinding.isInterface() || fVariableKind == CONST_FIELD) {
fragment.setInitializer(ASTNodeFactory.newDefaultExpression(ast, type, 0));
}
ChildListPropertyDescriptor property= ASTNodes.getBodyDeclarationsProperty(newTypeDecl);
List<BodyDeclaration> decls= ASTNodes.<BodyDeclaration>getChildListProperty(newTypeDecl, property);
int maxOffset= isInDifferentCU ? -1 : node.getStartPosition();
int insertIndex= findFieldInsertIndex(decls, newDecl, maxOffset);
ListRewrite listRewriter= rewrite.getListRewrite(newTypeDecl, property);
listRewriter.insertAt(newDecl, insertIndex, null);
return rewrite;
}
return null;
}