当前位置: 首页>>代码示例>>Java>>正文


Java SimpleName.getStartPosition方法代码示例

本文整理汇总了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;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:16,代码来源:LinkedNodeFinder.java

示例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;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:11,代码来源:ImportRemover.java

示例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;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:46,代码来源:NewVariableCorrectionProposal.java


注:本文中的org.eclipse.jdt.core.dom.SimpleName.getStartPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。