本文整理匯總了Java中org.eclipse.jdt.core.dom.AST.newQualifiedName方法的典型用法代碼示例。如果您正苦於以下問題:Java AST.newQualifiedName方法的具體用法?Java AST.newQualifiedName怎麽用?Java AST.newQualifiedName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.AST
的用法示例。
在下文中一共展示了AST.newQualifiedName方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addStaticImportFavoriteProposals
import org.eclipse.jdt.core.dom.AST; //導入方法依賴的package包/類
private static void addStaticImportFavoriteProposals(IInvocationContext context, SimpleName node, boolean isMethod,
Collection<CUCorrectionProposal> proposals) throws JavaModelException {
IJavaProject project= context.getCompilationUnit().getJavaProject();
if (JavaModelUtil.is50OrHigher(project)) {
String pref = PreferenceManager.getPrefs(context.getCompilationUnit().getResource())
.getFavoriteStaticMembers();
String[] favourites= pref.split(";"); //$NON-NLS-1$
if (favourites.length == 0) {
return;
}
CompilationUnit root= context.getASTRoot();
AST ast= root.getAST();
String name= node.getIdentifier();
String[] staticImports= SimilarElementsRequestor.getStaticImportFavorites(context.getCompilationUnit(), name, isMethod, favourites);
for (int i= 0; i < staticImports.length; i++) {
String curr= staticImports[i];
ImportRewrite importRewrite= StubUtility.createImportRewrite(root, true);
ASTRewrite astRewrite= ASTRewrite.create(ast);
String label;
String qualifiedTypeName= Signature.getQualifier(curr);
String elementLabel= BasicElementLabels.getJavaElementName(JavaModelUtil.concatenateName(Signature.getSimpleName(qualifiedTypeName), name));
String res= importRewrite.addStaticImport(qualifiedTypeName, name, isMethod, new ContextSensitiveImportRewriteContext(root, node.getStartPosition(), importRewrite));
int dot= res.lastIndexOf('.');
if (dot != -1) {
String usedTypeName= importRewrite.addImport(qualifiedTypeName);
Name newName= ast.newQualifiedName(ast.newName(usedTypeName), ast.newSimpleName(name));
astRewrite.replace(node, newName, null);
label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_change_to_static_import_description, elementLabel);
} else {
label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_add_static_import_description, elementLabel);
}
ASTRewriteCorrectionProposal proposal = new ASTRewriteCorrectionProposal(label,
context.getCompilationUnit(), astRewrite, IProposalRelevance.ADD_STATIC_IMPORT);
proposal.setImportRewrite(importRewrite);
proposals.add(proposal);
}
}
}