本文整理汇总了Java中org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels.getJavaElementName方法的典型用法代码示例。如果您正苦于以下问题:Java BasicElementLabels.getJavaElementName方法的具体用法?Java BasicElementLabels.getJavaElementName怎么用?Java BasicElementLabels.getJavaElementName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels
的用法示例。
在下文中一共展示了BasicElementLabels.getJavaElementName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateVariables
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入方法依赖的package包/类
@Override
protected void validateVariables(TemplateVariable[] variables) throws TemplateException {
ArrayList<String> required = new ArrayList<String>(5);
String contextName = getId();
if (NEWTYPE_CONTEXTTYPE.equals(contextName)) {
required.add(PACKAGE_DECLARATION);
required.add(TYPE_DECLARATION);
}
for (int i = 0; i < variables.length; i++) {
String type = variables[i].getType();
if (getResolver(type) == null) {
String unknown = BasicElementLabels.getJavaElementName(type);
throw new TemplateException(
Messages.format(
JavaTemplateMessages.CodeTemplateContextType_validate_unknownvariable, unknown));
}
required.remove(type);
}
if (!required.isEmpty()) {
String missing = BasicElementLabels.getJavaElementName(required.get(0));
throw new TemplateException(
Messages.format(
JavaTemplateMessages.CodeTemplateContextType_validate_missingvariable, missing));
}
super.validateVariables(variables);
}
示例2: getDisplayString
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入方法依赖的package包/类
private static String getDisplayString(
SimpleName simpleName, IBinding binding, boolean removeAllAssignements) {
String name = BasicElementLabels.getJavaElementName(simpleName.getIdentifier());
switch (binding.getKind()) {
case IBinding.TYPE:
return Messages.format(FixMessages.UnusedCodeFix_RemoveType_description, name);
case IBinding.METHOD:
if (((IMethodBinding) binding).isConstructor()) {
return Messages.format(FixMessages.UnusedCodeFix_RemoveConstructor_description, name);
} else {
return Messages.format(FixMessages.UnusedCodeFix_RemoveMethod_description, name);
}
case IBinding.VARIABLE:
if (removeAllAssignements) {
return Messages.format(
FixMessages.UnusedCodeFix_RemoveFieldOrLocalWithInitializer_description, name);
} else {
return Messages.format(FixMessages.UnusedCodeFix_RemoveFieldOrLocal_description, name);
}
default:
return ""; // $NON-NLS-1$
}
}
示例3: checkParameterNamesInRippleMethods
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入方法依赖的package包/类
private RefactoringStatus checkParameterNamesInRippleMethods() throws JavaModelException {
RefactoringStatus result = new RefactoringStatus();
Set<String> newParameterNames = getNewParameterNamesList();
for (int i = 0; i < fRippleMethods.length; i++) {
String[] paramNames = fRippleMethods[i].getParameterNames();
for (int j = 0; j < paramNames.length; j++) {
if (newParameterNames.contains(paramNames[j])) {
String[] args =
new String[] {
JavaElementUtil.createMethodSignature(fRippleMethods[i]),
BasicElementLabels.getJavaElementName(paramNames[j])
};
String msg =
Messages.format(RefactoringCoreMessages.ChangeSignatureRefactoring_already_has, args);
RefactoringStatusContext context =
JavaStatusContext.create(
fRippleMethods[i].getCompilationUnit(), fRippleMethods[i].getNameRange());
result.addError(msg, context);
}
}
}
return result;
}
示例4: checkIfDeletedParametersUsed
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入方法依赖的package包/类
protected void checkIfDeletedParametersUsed() {
for (Iterator<ParameterInfo> iter = getDeletedInfos().iterator(); iter.hasNext(); ) {
ParameterInfo info = iter.next();
VariableDeclaration paramDecl = getParameter(info.getOldIndex());
TempOccurrenceAnalyzer analyzer = new TempOccurrenceAnalyzer(paramDecl, false);
analyzer.perform();
SimpleName[] paramRefs = analyzer.getReferenceNodes();
if (paramRefs.length > 0) {
RefactoringStatusContext context =
JavaStatusContext.create(fCuRewrite.getCu(), paramRefs[0]);
String typeName = getFullTypeName();
Object[] keys =
new String[] {
BasicElementLabels.getJavaElementName(paramDecl.getName().getIdentifier()),
BasicElementLabels.getJavaElementName(getMethod().getElementName()),
BasicElementLabels.getJavaElementName(typeName)
};
String msg =
Messages.format(
RefactoringCoreMessages.ChangeSignatureRefactoring_parameter_used, keys);
fResult.addError(msg, context);
}
}
}
示例5: createAddImportChange
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入方法依赖的package包/类
static CompilationUnitChange createAddImportChange(
ICompilationUnit cu, Name name, String fullyQualifiedName) throws CoreException {
String[] args = {
BasicElementLabels.getJavaElementName(Signature.getSimpleName(fullyQualifiedName)),
BasicElementLabels.getJavaElementName(Signature.getQualifier(fullyQualifiedName))
};
String label =
Messages.format(
CorrectionMessages.UnresolvedElementsSubProcessor_importtype_description, args);
CompilationUnitChange cuChange = new CompilationUnitChange(label, cu);
ImportRewrite importRewrite =
StubUtility.createImportRewrite((CompilationUnit) name.getRoot(), true);
importRewrite.addImport(fullyQualifiedName);
cuChange.setEdit(importRewrite.rewriteImports(null));
return cuChange;
}
示例6: checkPackageName
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入方法依赖的package包/类
private RefactoringStatus checkPackageName(String newName) throws CoreException {
RefactoringStatus status = new RefactoringStatus();
IPackageFragmentRoot[] roots = fPackage.getJavaProject().getPackageFragmentRoots();
Set<String> topLevelTypeNames = getTopLevelTypeNames();
for (int i = 0; i < roots.length; i++) {
IPackageFragmentRoot root = roots[i];
if (!isPackageNameOkInRoot(newName, root)) {
String rootLabel = JavaElementLabels.getElementLabel(root, JavaElementLabels.ALL_DEFAULT);
String newPackageName = BasicElementLabels.getJavaElementName(getNewElementName());
String message =
Messages.format(
RefactoringCoreMessages.RenamePackageRefactoring_aleady_exists,
new Object[] {newPackageName, rootLabel});
status.merge(RefactoringStatus.createWarningStatus(message));
status.merge(checkTypeNameConflicts(root, newName, topLevelTypeNames));
}
}
return status;
}
示例7: getDescription
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入方法依赖的package包/类
public String getDescription() {
String nameLabel = BasicElementLabels.getJavaElementName(fName.getIdentifier());
String qualifierLabel;
if (fQualifier == null) {
qualifierLabel = "this"; // $NON-NLS-1$
} else {
qualifierLabel = BasicElementLabels.getJavaElementName(fQualifier + ".this"); // $NON-NLS-1$
}
return Messages.format(
FixMessages.CodeStyleFix_QualifyWithThis_description,
new Object[] {nameLabel, qualifierLabel});
}
示例8: getName
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入方法依赖的package包/类
@Override
public String getName() {
IBinding binding = fName.resolveBinding();
String name = BasicElementLabels.getJavaElementName(fName.getIdentifier());
switch (binding.getKind()) {
case IBinding.TYPE:
return Messages.format(
CorrectionMessages.RemoveDeclarationCorrectionProposal_removeunusedtype_description,
name);
case IBinding.METHOD:
if (((IMethodBinding) binding).isConstructor()) {
return Messages.format(
CorrectionMessages
.RemoveDeclarationCorrectionProposal_removeunusedconstructor_description,
name);
} else {
return Messages.format(
CorrectionMessages.RemoveDeclarationCorrectionProposal_removeunusedmethod_description,
name);
}
case IBinding.VARIABLE:
if (((IVariableBinding) binding).isField()) {
return Messages.format(
CorrectionMessages.RemoveDeclarationCorrectionProposal_removeunusedfield_description,
name);
} else {
return Messages.format(
CorrectionMessages.RemoveDeclarationCorrectionProposal_removeunusedvar_description,
name);
}
default:
return super.getDisplayString();
}
}
示例9: checkClashesInConstructors
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入方法依赖的package包/类
private RefactoringStatus checkClashesInConstructors() {
Assert.isTrue(fInitializeIn == INITIALIZE_IN_CONSTRUCTOR);
Assert.isTrue(!isDeclaredInAnonymousClass());
final AbstractTypeDeclaration declaration =
(AbstractTypeDeclaration) getMethodDeclaration().getParent();
if (declaration instanceof TypeDeclaration) {
MethodDeclaration[] methods = ((TypeDeclaration) declaration).getMethods();
for (int i = 0; i < methods.length; i++) {
MethodDeclaration method = methods[i];
if (!method.isConstructor()) continue;
NameCollector nameCollector =
new NameCollector(method) {
@Override
protected boolean visitNode(ASTNode node) {
return true;
}
};
method.accept(nameCollector);
List<String> names = nameCollector.getNames();
if (names.contains(fFieldName)) {
String[] keys = {
BasicElementLabels.getJavaElementName(fFieldName),
BindingLabelProvider.getBindingLabel(
method.resolveBinding(), JavaElementLabels.ALL_FULLY_QUALIFIED)
};
String msg =
Messages.format(
RefactoringCoreMessages.PromoteTempToFieldRefactoring_Name_conflict, keys);
return RefactoringStatus.createFatalErrorStatus(msg);
}
}
}
return null;
}
示例10: getArgumentName
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入方法依赖的package包/类
private static String getArgumentName(List<Expression> arguments, int index) {
String def = String.valueOf(index + 1);
ASTNode expr = arguments.get(index);
if (expr.getLength() > 18) {
return def;
}
ASTMatcher matcher = new ASTMatcher();
for (int i = 0; i < arguments.size(); i++) {
if (i != index && matcher.safeSubtreeMatch(expr, arguments.get(i))) {
return def;
}
}
return '\'' + BasicElementLabels.getJavaElementName(ASTNodes.asString(expr)) + '\'';
}
示例11: createSignature
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入方法依赖的package包/类
public static String createSignature(IMember member) {
switch (member.getElementType()) {
case IJavaElement.FIELD:
return createFieldSignature((IField) member);
case IJavaElement.TYPE:
return BasicElementLabels.getJavaElementName(((IType) member).getFullyQualifiedName('.'));
case IJavaElement.INITIALIZER:
return RefactoringCoreMessages.JavaElementUtil_initializer;
case IJavaElement.METHOD:
return createMethodSignature((IMethod) member);
default:
Assert.isTrue(false);
return null;
}
}
示例12: getName
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入方法依赖的package包/类
@Override
public String getName() {
String[] keys =
new String[] {
BasicElementLabels.getJavaElementName(getOldName()),
BasicElementLabels.getJavaElementName(getNewName())
};
return Messages.format(RefactoringCoreMessages.RenameJavaProjectChange_rename, keys);
}
示例13: getName
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入方法依赖的package包/类
@Override
public String getName() {
String[] keys = {
BasicElementLabels.getJavaElementName(getOldName()),
BasicElementLabels.getJavaElementName(getNewName())
};
return Messages.format(RefactoringCoreMessages.RenameSourceFolderChange_rename, keys);
}
示例14: getName
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入方法依赖的package包/类
@Override
public String getName() {
String[] keys =
new String[] {
BasicElementLabels.getJavaElementName(getOldName()),
BasicElementLabels.getJavaElementName(getNewName())
};
return Messages.format(RefactoringCoreMessages.RenameCompilationUnitChange_name, keys);
}
示例15: createAddAnnotationToOverriddenOperation
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入方法依赖的package包/类
private static SignatureAnnotationRewriteOperation createAddAnnotationToOverriddenOperation(
CompilationUnit compilationUnit,
IProblemLocation problem,
String annotationToAdd,
String annotationToRemove,
boolean allowRemove) {
ICompilationUnit cu = (ICompilationUnit) compilationUnit.getJavaElement();
if (!JavaModelUtil.is50OrHigher(cu.getJavaProject())) return null;
ASTNode selectedNode = problem.getCoveringNode(compilationUnit);
if (selectedNode == null) return null;
ASTNode declaringNode = getDeclaringNode(selectedNode);
switch (problem.getProblemId()) {
case IProblem.IllegalDefinitionToNonNullParameter:
case IProblem.IllegalRedefinitionToNonNullParameter:
break;
case IProblem.IllegalReturnNullityRedefinition:
if (declaringNode == null) declaringNode = selectedNode;
break;
default:
return null;
}
String annotationNameLabel = annotationToAdd;
int lastDot = annotationToAdd.lastIndexOf('.');
if (lastDot != -1) annotationNameLabel = annotationToAdd.substring(lastDot + 1);
annotationNameLabel = BasicElementLabels.getJavaElementName(annotationNameLabel);
if (declaringNode instanceof MethodDeclaration) {
// complaint is in signature of this method
MethodDeclaration declaration = (MethodDeclaration) declaringNode;
switch (problem.getProblemId()) {
case IProblem.IllegalDefinitionToNonNullParameter:
case IProblem.IllegalRedefinitionToNonNullParameter:
return createChangeOverriddenParameterOperation(
compilationUnit,
cu,
declaration,
selectedNode,
allowRemove,
annotationToAdd,
annotationToRemove,
annotationNameLabel);
case IProblem.IllegalReturnNullityRedefinition:
if (hasNullAnnotation(
declaration)) { // don't adjust super if local has no explicit annotation (?)
return createChangeOverriddenReturnOperation(
compilationUnit,
cu,
declaration,
allowRemove,
annotationToAdd,
annotationToRemove,
annotationNameLabel);
}
}
}
return null;
}