本文整理汇总了Java中org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels类的典型用法代码示例。如果您正苦于以下问题:Java BasicElementLabels类的具体用法?Java BasicElementLabels怎么用?Java BasicElementLabels使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BasicElementLabels类属于org.eclipse.jdt.internal.ui.viewsupport包,在下文中一共展示了BasicElementLabels类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:CodeTemplateContextType.java
示例2: addModified
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入依赖的package包/类
private static IStatus addModified(IStatus status, IFile file) {
IStatus entry =
JavaUIStatus.createError(
IJavaStatusConstants.VALIDATE_EDIT_CHANGED_CONTENT,
Messages.format(
CorextMessages.Resources_fileModified,
BasicElementLabels.getPathLabel(file.getFullPath(), false)),
null);
if (status == null) {
return entry;
} else if (status.isMultiStatus()) {
((MultiStatus) status).add(entry);
return status;
} else {
MultiStatus result =
new MultiStatus(
JavaPlugin.getPluginId(),
IJavaStatusConstants.VALIDATE_EDIT_CHANGED_CONTENT,
CorextMessages.Resources_modifiedResources,
null);
result.add(status);
result.add(entry);
return result;
}
}
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:Resources.java
示例3: run
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入依赖的package包/类
/**
* Runs the operation.
*
* @param monitor the progress monitor
* @throws CoreException thrown when the operation failed
* @throws OperationCanceledException Runtime error thrown when operation is canceled.
*/
public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
try {
monitor.beginTask(
Messages.format(
CodeGenerationMessages.OrganizeImportsOperation_description,
BasicElementLabels.getFileName(fCompilationUnit)),
10);
edit = createTextEdit(new SubProgressMonitor(monitor, 9));
if (edit == null) return;
JavaModelUtil.applyEdit(fCompilationUnit, edit, fDoSave, new SubProgressMonitor(monitor, 1));
} finally {
monitor.done();
}
}
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:OrganizeImportsOperation.java
示例4: CorrectMainTypeNameProposal
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入依赖的package包/类
/**
* Constructor for CorrectTypeNameProposal.
*
* @param cu the compilation unit
* @param context the invocation context
* @param oldTypeName the old type name
* @param newTypeName the new type name
* @param relevance the relevance
*/
public CorrectMainTypeNameProposal(
ICompilationUnit cu,
IInvocationContext context,
String oldTypeName,
String newTypeName,
int relevance) {
super("", cu, null, relevance, null); // $NON-NLS-1$
fContext = context;
setDisplayName(
Messages.format(
CorrectionMessages.ReorgCorrectionsSubProcessor_renametype_description,
BasicElementLabels.getJavaElementName(newTypeName)));
setImage(JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE));
fOldName = oldTypeName;
fNewName = newTypeName;
}
开发者ID:eclipse,项目名称:che,代码行数:28,代码来源:CorrectMainTypeNameProposal.java
示例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;
}
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:UnresolvedElementsSubProcessor.java
示例6: rewriteAST
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModel model)
throws CoreException {
AST ast = cuRewrite.getRoot().getAST();
ListRewrite listRewrite =
cuRewrite
.getASTRewrite()
.getListRewrite(fBodyDeclaration, fBodyDeclaration.getModifiersProperty());
Annotation newAnnotation = ast.newMarkerAnnotation();
newAnnotation.setTypeName(ast.newSimpleName(fAnnotation));
TextEditGroup group =
createTextEditGroup(
Messages.format(
FixMessages.Java50Fix_AddMissingAnnotation_description,
BasicElementLabels.getJavaElementName(fAnnotation)),
cuRewrite);
listRewrite.insertFirst(newAnnotation, group);
}
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:Java50Fix.java
示例7: createRawTypeReferenceFix
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入依赖的package包/类
public static Java50Fix createRawTypeReferenceFix(
CompilationUnit compilationUnit, IProblemLocation problem) {
List<CompilationUnitRewriteOperation> operations =
new ArrayList<CompilationUnitRewriteOperation>();
SimpleType node =
createRawTypeReferenceOperations(
compilationUnit, new IProblemLocation[] {problem}, operations);
if (operations.size() == 0) return null;
return new Java50Fix(
Messages.format(
FixMessages.Java50Fix_AddTypeArguments_description,
BasicElementLabels.getJavaElementName(node.getName().getFullyQualifiedName())),
compilationUnit,
operations.toArray(new CompilationUnitRewriteOperation[operations.size()]));
}
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:Java50Fix.java
示例8: 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$
}
}
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:UnusedCodeFix.java
示例9: asString
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入依赖的package包/类
/**
* Returns this comment in a human-readable string representation.
*
* @return this comment in string representation
*/
public String asString() {
final StringBuffer buffer = new StringBuffer(256);
buffer.append(fHeader);
if (fProject != null && !"".equals(fProject)) { // $NON-NLS-1$
buffer.append(LINE_DELIMITER);
buffer.append(
Messages.format(
RefactoringCoreMessages.JavaRefactoringDescriptorComment_original_project,
BasicElementLabels.getResourceName(fProject)));
}
for (final Iterator<String> iterator = fSettings.iterator(); iterator.hasNext(); ) {
final String setting = iterator.next();
buffer.append(LINE_DELIMITER);
buffer.append(
Messages.format(
RefactoringCoreMessages.JavaRefactoringDescriptor_inferred_setting_pattern, setting));
}
return buffer.toString();
}
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:JDTRefactoringDescriptorComment.java
示例10: checkOriginalVarargs
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入依赖的package包/类
private RefactoringStatus checkOriginalVarargs() throws JavaModelException {
if (JdtFlags.isVarargs(fMethod)) fOldVarargIndex = fMethod.getNumberOfParameters() - 1;
List<ParameterInfo> notDeletedInfos = getNotDeletedInfos();
for (int i = 0; i < notDeletedInfos.size(); i++) {
ParameterInfo info = notDeletedInfos.get(i);
if (info.isOldVarargs() && !info.isNewVarargs())
return RefactoringStatus.createFatalErrorStatus(
Messages.format(
RefactoringCoreMessages.ChangeSignatureRefactoring_cannot_convert_vararg,
BasicElementLabels.getJavaElementName(info.getNewName())));
if (i != notDeletedInfos.size() - 1) {
// not the last parameter
if (info.isNewVarargs())
return RefactoringStatus.createFatalErrorStatus(
Messages.format(
RefactoringCoreMessages.ChangeSignatureRefactoring_vararg_must_be_last,
BasicElementLabels.getJavaElementName(info.getNewName())));
}
}
return null;
}
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:ChangeSignatureProcessor.java
示例11: getOldMethodSignature
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入依赖的package包/类
public String getOldMethodSignature() throws JavaModelException {
StringBuffer buff = new StringBuffer();
int flags = getMethod().getFlags();
buff.append(getVisibilityString(flags));
if (Flags.isStatic(flags)) {
buff.append("static "); // $NON-NLS-1$
} else if (Flags.isDefaultMethod(flags)) {
buff.append("default "); // $NON-NLS-1$
}
if (!getMethod().isConstructor()) buff.append(fReturnTypeInfo.getOldTypeName()).append(' ');
buff.append(
JavaElementLabels.getElementLabel(
fMethod.getParent(), JavaElementLabels.ALL_FULLY_QUALIFIED));
buff.append('.');
buff.append(fMethod.getElementName())
.append(Signature.C_PARAM_START)
.append(getOldMethodParameters())
.append(Signature.C_PARAM_END);
buff.append(getOldMethodThrows());
return BasicElementLabels.getJavaCodeString(buff.toString());
}
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:ChangeSignatureProcessor.java
示例12: getNewMethodSignature
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入依赖的package包/类
public String getNewMethodSignature() throws JavaModelException {
StringBuffer buff = new StringBuffer();
buff.append(getVisibilityString(fVisibility));
int flags = getMethod().getFlags();
if (Flags.isStatic(flags)) {
buff.append("static "); // $NON-NLS-1$
} else if (Flags.isDefaultMethod(flags)) {
buff.append("default "); // $NON-NLS-1$
}
if (!getMethod().isConstructor()) buff.append(getReturnTypeString()).append(' ');
buff.append(getMethodName())
.append(Signature.C_PARAM_START)
.append(getMethodParameters())
.append(Signature.C_PARAM_END);
buff.append(getMethodThrows());
return BasicElementLabels.getJavaCodeString(buff.toString());
}
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:ChangeSignatureProcessor.java
示例13: checkForDuplicateParameterNames
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入依赖的package包/类
private void checkForDuplicateParameterNames(RefactoringStatus result) {
Set<String> found = new HashSet<String>();
Set<String> doubled = new HashSet<String>();
for (Iterator<ParameterInfo> iter = getNotDeletedInfos().iterator(); iter.hasNext(); ) {
ParameterInfo info = iter.next();
String newName = info.getNewName();
if (found.contains(newName) && !doubled.contains(newName)) {
result.addFatalError(
Messages.format(
RefactoringCoreMessages.ChangeSignatureRefactoring_duplicate_name,
BasicElementLabels.getJavaElementName(newName)));
doubled.add(newName);
} else {
found.add(newName);
}
}
}
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:ChangeSignatureProcessor.java
示例14: 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;
}
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:ChangeSignatureProcessor.java
示例15: checkNativeMethods
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入依赖的package包/类
private RefactoringStatus checkNativeMethods() throws JavaModelException {
RefactoringStatus result = new RefactoringStatus();
for (int i = 0; i < fRippleMethods.length; i++) {
if (JdtFlags.isNative(fRippleMethods[i])) {
String message =
Messages.format(
RefactoringCoreMessages.ChangeSignatureRefactoring_native,
new String[] {
JavaElementUtil.createMethodSignature(fRippleMethods[i]),
BasicElementLabels.getJavaElementName(
fRippleMethods[i].getDeclaringType().getFullyQualifiedName('.'))
});
result.addError(message, JavaStatusContext.create(fRippleMethods[i]));
}
}
return result;
}
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:ChangeSignatureProcessor.java
示例16: getName
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入依赖的package包/类
@Override
public String getName() {
ICompilationUnit cu = getCompilationUnit();
IPackageFragment parentPack = (IPackageFragment) cu.getParent();
try {
IPackageDeclaration[] decls = cu.getPackageDeclarations();
if (parentPack.isDefaultPackage() && decls.length > 0) {
return Messages.format(
CorrectionMessages.CorrectPackageDeclarationProposal_remove_description,
BasicElementLabels.getJavaElementName(decls[0].getElementName()));
}
if (!parentPack.isDefaultPackage() && decls.length == 0) {
return (Messages.format(
CorrectionMessages.CorrectPackageDeclarationProposal_add_description,
JavaElementLabels.getElementLabel(parentPack, JavaElementLabels.ALL_DEFAULT)));
}
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
return (Messages.format(
CorrectionMessages.CorrectPackageDeclarationProposal_change_description,
JavaElementLabels.getElementLabel(parentPack, JavaElementLabels.ALL_DEFAULT)));
}
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:CorrectPackageDeclarationProposal.java
示例17: checkNewElementName
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入依赖的package包/类
public RefactoringStatus checkNewElementName(String newName) throws JavaModelException {
RefactoringStatus result = Checks.checkFieldName(newName, fCu);
if (!Checks.startsWithLowerCase(newName))
if (fIsComposite) {
final String nameOfParent =
JavaElementLabels.getElementLabel(
fLocalVariable.getParent(), JavaElementLabels.ALL_DEFAULT);
final String nameOfType =
JavaElementLabels.getElementLabel(
fLocalVariable.getAncestor(IJavaElement.TYPE), JavaElementLabels.ALL_DEFAULT);
result.addWarning(
Messages.format(
RefactoringCoreMessages.RenameTempRefactoring_lowercase2,
new String[] {
BasicElementLabels.getJavaElementName(newName), nameOfParent, nameOfType
}));
} else {
result.addWarning(RefactoringCoreMessages.RenameTempRefactoring_lowercase);
}
return result;
}
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:RenameLocalVariableProcessor.java
示例18: addMakeTypeAbstractProposal
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入依赖的package包/类
private static void addMakeTypeAbstractProposal(
IInvocationContext context,
TypeDeclaration parentTypeDecl,
Collection<ICommandAccess> proposals) {
MakeTypeAbstractOperation operation =
new UnimplementedCodeFix.MakeTypeAbstractOperation(parentTypeDecl);
String label =
Messages.format(
CorrectionMessages.ModifierCorrectionSubProcessor_addabstract_description,
BasicElementLabels.getJavaElementName(parentTypeDecl.getName().getIdentifier()));
UnimplementedCodeFix fix =
new UnimplementedCodeFix(
label, context.getASTRoot(), new CompilationUnitRewriteOperation[] {operation});
Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
FixCorrectionProposal proposal =
new FixCorrectionProposal(
fix, null, IProposalRelevance.MAKE_TYPE_ABSTRACT_FIX, image, context);
proposals.add(proposal);
}
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:ModifierCorrectionSubProcessor.java
示例19: checkNestedHierarchy
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入依赖的package包/类
private RefactoringStatus checkNestedHierarchy(IType type) throws CoreException {
IType[] nestedTypes = type.getTypes();
if (nestedTypes == null) return null;
RefactoringStatus result = new RefactoringStatus();
for (int i = 0; i < nestedTypes.length; i++) {
IField otherField = nestedTypes[i].getField(getNewElementName());
if (otherField.exists()) {
String msg =
Messages.format(
RefactoringCoreMessages.RenameFieldRefactoring_hiding,
new String[] {
BasicElementLabels.getJavaElementName(fField.getElementName()),
BasicElementLabels.getJavaElementName(getNewElementName()),
BasicElementLabels.getJavaElementName(nestedTypes[i].getFullyQualifiedName('.'))
});
result.addWarning(msg, JavaStatusContext.create(otherField));
}
result.merge(checkNestedHierarchy(nestedTypes[i]));
}
return result;
}
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:RenameFieldProcessor.java
示例20: checkEnclosingHierarchy
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; //导入依赖的package包/类
private RefactoringStatus checkEnclosingHierarchy() {
IType current = fField.getDeclaringType();
if (Checks.isTopLevel(current)) return null;
RefactoringStatus result = new RefactoringStatus();
while (current != null) {
IField otherField = current.getField(getNewElementName());
if (otherField.exists()) {
String msg =
Messages.format(
RefactoringCoreMessages.RenameFieldRefactoring_hiding2,
new String[] {
BasicElementLabels.getJavaElementName(getNewElementName()),
BasicElementLabels.getJavaElementName(current.getFullyQualifiedName('.')),
BasicElementLabels.getJavaElementName(otherField.getElementName())
});
result.addWarning(msg, JavaStatusContext.create(otherField));
}
current = current.getDeclaringType();
}
return result;
}
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:RenameFieldProcessor.java
注:本文中的org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论