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


Java JavaElementLabels类代码示例

本文整理汇总了Java中org.eclipse.jdt.ui.JavaElementLabels的典型用法代码示例。如果您正苦于以下问题:Java JavaElementLabels类的具体用法?Java JavaElementLabels怎么用?Java JavaElementLabels使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JavaElementLabels类属于org.eclipse.jdt.ui包,在下文中一共展示了JavaElementLabels类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkAccessedTypes

import org.eclipse.jdt.ui.JavaElementLabels; //导入依赖的package包/类
private RefactoringStatus checkAccessedTypes(IMethod sourceMethod, final Optional<IProgressMonitor> monitor,
		final ITypeHierarchy hierarchy) throws JavaModelException {
	final RefactoringStatus result = new RefactoringStatus();
	final IType[] accessedTypes = getTypesReferencedInMovedMembers(sourceMethod, monitor);
	final IType destination = getDestinationInterface(sourceMethod).get();
	final List<IMember> pulledUpList = Arrays.asList(sourceMethod);
	for (IType type : accessedTypes) {
		if (!type.exists())
			continue;

		if (!canBeAccessedFrom(sourceMethod, type, destination, hierarchy) && !pulledUpList.contains(type)) {
			final String message = org.eclipse.jdt.internal.corext.util.Messages.format(
					PreconditionFailure.TypeNotAccessible.getMessage(),
					new String[] { JavaElementLabels.getTextLabel(type, JavaElementLabels.ALL_FULLY_QUALIFIED),
							JavaElementLabels.getTextLabel(destination, JavaElementLabels.ALL_FULLY_QUALIFIED) });
			result.addEntry(RefactoringStatus.ERROR, message, JavaStatusContext.create(type),
					MigrateSkeletalImplementationToInterfaceRefactoringDescriptor.REFACTORING_ID,
					PreconditionFailure.TypeNotAccessible.ordinal(), sourceMethod);
			this.getUnmigratableMethods().add(sourceMethod);
		}
	}
	monitor.ifPresent(IProgressMonitor::done);
	return result;
}
 
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:25,代码来源:MigrateSkeletalImplementationToInterfaceRefactoringProcessor.java

示例2: getInitializes

import org.eclipse.jdt.ui.JavaElementLabels; //导入依赖的package包/类
private List<Initializer> getInitializes(Object parent) throws JavaModelException {
  List<Initializer> result = new ArrayList<>();
  Set<Object> objects = childrens.get(parent);
  if (objects == null) {
    return result;
  }

  for (Object object : objects) {
    if (object instanceof IInitializer) {
      IInitializer initializer = (IInitializer) object;
      Initializer init = DtoFactory.newDto(Initializer.class);
      init.setElementName(initializer.getElementName());
      init.setHandleIdentifier(initializer.getHandleIdentifier());
      init.setFlags(initializer.getFlags());
      init.setLabel(
          JavaElementLabels.getElementLabel(initializer, JavaElementLabels.ALL_DEFAULT));
      result.add(init);
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:JavaElementToDtoConverter.java

示例3: getMethods

import org.eclipse.jdt.ui.JavaElementLabels; //导入依赖的package包/类
private List<Method> getMethods(Object parent) throws JavaModelException {
  List<Method> result = new ArrayList<>();
  Set<Object> objects = childrens.get(parent);
  if (objects == null) {
    return result;
  }

  for (Object object : objects) {
    if (object instanceof IMethod) {
      IMethod method = (IMethod) object;
      Method met = DtoFactory.newDto(Method.class);
      met.setHandleIdentifier(method.getHandleIdentifier());
      met.setFlags(method.getFlags());
      met.setElementName(method.getElementName());
      met.setLabel(JavaElementLabels.getElementLabel(method, JavaElementLabels.ALL_DEFAULT));
      result.add(met);
    }
  }

  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:JavaElementToDtoConverter.java

示例4: getFields

import org.eclipse.jdt.ui.JavaElementLabels; //导入依赖的package包/类
private List<Field> getFields(Object parent) throws JavaModelException {
  List<Field> result = new ArrayList<>();
  Set<Object> objects = childrens.get(parent);
  if (objects == null) {
    return result;
  }

  for (Object object : objects) {
    if (object instanceof IField) {
      IField iField = (IField) object;
      Field field = DtoFactory.newDto(Field.class);
      field.setElementName(iField.getElementName());
      field.setHandleIdentifier(iField.getHandleIdentifier());
      field.setFlags(iField.getFlags());
      field.setLabel(JavaElementLabels.getElementLabel(iField, JavaElementLabels.ALL_DEFAULT));
      result.add(field);
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:JavaElementToDtoConverter.java

示例5: getMethodParametersAsString

import org.eclipse.jdt.ui.JavaElementLabels; //导入依赖的package包/类
private String getMethodParametersAsString(IMethod method) throws JavaModelException {
  ILocalVariable[] parameters = method.getParameters();

  int paramsLength = parameters.length;
  int index = 0;

  StringBuffer buffer = new StringBuffer();

  for (ILocalVariable parameter : parameters) {
    JavaElementLabels.getLocalVariableLabel(
        parameter, JavaElementLabels.F_PRE_TYPE_SIGNATURE, buffer);
    index++;

    if (index < paramsLength) {
      buffer.append(", ");
    }
  }

  return buffer.toString();
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:ParametersHints.java

示例6: createAnonymousTypeLabel

import org.eclipse.jdt.ui.JavaElementLabels; //导入依赖的package包/类
StyledString createAnonymousTypeLabel(CompletionProposal proposal) {
  char[] declaringTypeSignature = proposal.getDeclarationSignature();
  declaringTypeSignature = Signature.getTypeErasure(declaringTypeSignature);

  StyledString buffer = new StyledString();
  buffer.append(Signature.getSignatureSimpleName(declaringTypeSignature));
  buffer.append('(');
  appendUnboundedParameterList(buffer, proposal);
  buffer.append(')');
  buffer.append("  "); // $NON-NLS-1$
  buffer.append(JavaTextMessages.ResultCollector_anonymous_type);

  if (proposal.getRequiredProposals() != null) {
    char[] signatureQualifier = Signature.getSignatureQualifier(declaringTypeSignature);
    if (signatureQualifier.length > 0) {
      buffer.append(JavaElementLabels.CONCAT_STRING, StyledString.QUALIFIER_STYLER);
      buffer.append(signatureQualifier, StyledString.QUALIFIER_STYLER);
    }
  }

  return Strings.markJavaElementLabelLTR(buffer);
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:CompletionProposalLabelProvider.java

示例7: getOldMethodSignature

import org.eclipse.jdt.ui.JavaElementLabels; //导入依赖的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

示例8: checkNewElementName

import org.eclipse.jdt.ui.JavaElementLabels; //导入依赖的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

示例9: checkIfOverridesAnother

import org.eclipse.jdt.ui.JavaElementLabels; //导入依赖的package包/类
public static RefactoringStatus checkIfOverridesAnother(IMethod method, ITypeHierarchy hierarchy)
    throws JavaModelException {
  IMethod overrides = MethodChecks.overridesAnotherMethod(method, hierarchy);
  if (overrides == null) return null;

  RefactoringStatusContext context = JavaStatusContext.create(overrides);
  String message =
      Messages.format(
          RefactoringCoreMessages.MethodChecks_overrides,
          new String[] {
            JavaElementUtil.createMethodSignature(overrides),
            JavaElementLabels.getElementLabel(
                overrides.getDeclaringType(), JavaElementLabels.ALL_FULLY_QUALIFIED)
          });
  return RefactoringStatus.createStatus(
      RefactoringStatus.FATAL,
      message,
      context,
      Corext.getPluginId(),
      RefactoringStatusCodes.OVERRIDES_ANOTHER_METHOD,
      overrides);
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:MethodChecks.java

示例10: checkIfComesFromInterface

import org.eclipse.jdt.ui.JavaElementLabels; //导入依赖的package包/类
public static RefactoringStatus checkIfComesFromInterface(
    IMethod method, ITypeHierarchy hierarchy, IProgressMonitor monitor)
    throws JavaModelException {
  IMethod inInterface = MethodChecks.isDeclaredInInterface(method, hierarchy, monitor);

  if (inInterface == null) return null;

  RefactoringStatusContext context = JavaStatusContext.create(inInterface);
  String message =
      Messages.format(
          RefactoringCoreMessages.MethodChecks_implements,
          new String[] {
            JavaElementUtil.createMethodSignature(inInterface),
            JavaElementLabels.getElementLabel(
                inInterface.getDeclaringType(), JavaElementLabels.ALL_FULLY_QUALIFIED)
          });
  return RefactoringStatus.createStatus(
      RefactoringStatus.FATAL,
      message,
      context,
      Corext.getPluginId(),
      RefactoringStatusCodes.METHOD_DECLARED_IN_INTERFACE,
      inInterface);
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:MethodChecks.java

示例11: checkInitialConditions

import org.eclipse.jdt.ui.JavaElementLabels; //导入依赖的package包/类
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
  IType primary = (IType) fType.getPrimaryElement();
  if (primary == null || !primary.exists()) {
    String qualifiedTypeName =
        JavaElementLabels.getElementLabel(fType, JavaElementLabels.F_FULLY_QUALIFIED);
    String message =
        Messages.format(
            RefactoringCoreMessages.RenameTypeRefactoring_does_not_exist,
            new String[] {
              BasicElementLabels.getJavaElementName(qualifiedTypeName),
              BasicElementLabels.getFileName(fType.getCompilationUnit())
            });
    return RefactoringStatus.createFatalErrorStatus(message);
  }
  fType = primary;
  return Checks.checkIfCuBroken(fType);
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:RenameTypeProcessor.java

示例12: analyzeImportedTypes

import org.eclipse.jdt.ui.JavaElementLabels; //导入依赖的package包/类
private void analyzeImportedTypes(IType[] types, RefactoringStatus result, IImportDeclaration imp)
    throws CoreException {
  for (int i = 0; i < types.length; i++) {
    // could this be a problem (same package imports)?
    if (JdtFlags.isPublic(types[i]) && types[i].getElementName().equals(getNewElementName())) {
      String msg =
          Messages.format(
              RefactoringCoreMessages.RenameTypeRefactoring_name_conflict1,
              new Object[] {
                JavaElementLabels.getElementLabel(
                    types[i], JavaElementLabels.ALL_FULLY_QUALIFIED),
                BasicElementLabels.getPathLabel(getCompilationUnit(imp).getPath(), false)
              });
      result.addError(msg, JavaStatusContext.create(imp));
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:RenameTypeProcessor.java

示例13: checkPackageName

import org.eclipse.jdt.ui.JavaElementLabels; //导入依赖的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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:RenamePackageProcessor.java

示例14: createInputFatalStatus

import org.eclipse.jdt.ui.JavaElementLabels; //导入依赖的package包/类
/**
 * Creates a fatal error status telling that the input element does not exist.
 *
 * @param element the input element, or <code>null</code>
 * @param name the name of the refactoring
 * @param id the id of the refactoring
 * @return the refactoring status
 */
public static RefactoringStatus createInputFatalStatus(
    final Object element, final String name, final String id) {
  Assert.isNotNull(name);
  Assert.isNotNull(id);
  if (element != null)
    return RefactoringStatus.createFatalErrorStatus(
        Messages.format(
            RefactoringCoreMessages.InitializableRefactoring_input_not_exists,
            new String[] {
              JavaElementLabels.getTextLabel(element, JavaElementLabels.ALL_FULLY_QUALIFIED),
              name,
              id
            }));
  else
    return RefactoringStatus.createFatalErrorStatus(
        Messages.format(
            RefactoringCoreMessages.InitializableRefactoring_inputs_do_not_exist,
            new String[] {name, id}));
}
 
开发者ID:eclipse,项目名称:che,代码行数:28,代码来源:JavaRefactoringDescriptorUtil.java

示例15: createInputWarningStatus

import org.eclipse.jdt.ui.JavaElementLabels; //导入依赖的package包/类
/**
 * Creates a warning status telling that the input element does not exist.
 *
 * @param element the input element, or <code>null</code>
 * @param name the name of the refactoring
 * @param id the id of the refactoring
 * @return the refactoring status
 */
public static RefactoringStatus createInputWarningStatus(
    final Object element, final String name, final String id) {
  Assert.isNotNull(name);
  Assert.isNotNull(id);
  if (element != null)
    return RefactoringStatus.createWarningStatus(
        Messages.format(
            RefactoringCoreMessages.InitializableRefactoring_input_not_exists,
            new String[] {
              JavaElementLabels.getTextLabel(element, JavaElementLabels.ALL_FULLY_QUALIFIED),
              name,
              id
            }));
  else
    return RefactoringStatus.createWarningStatus(
        Messages.format(
            RefactoringCoreMessages.InitializableRefactoring_inputs_do_not_exist,
            new String[] {name, id}));
}
 
开发者ID:eclipse,项目名称:che,代码行数:28,代码来源:JavaRefactoringDescriptorUtil.java


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