當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。