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


Java JavaElementLabels.getTextLabel方法代码示例

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


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

示例1: createChange

import org.eclipse.jdt.ui.JavaElementLabels; //导入方法依赖的package包/类
@Override
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
  pm.beginTask("", 1); // $NON-NLS-1$
  try {
    DynamicValidationStateChange result =
        new DynamicValidationStateChange(
            RefactoringCoreMessages.InferTypeArgumentsRefactoring_name,
            fChangeManager.getAllChanges()) {

          @Override
          public final ChangeDescriptor getDescriptor() {
            final Map<String, String> arguments = new HashMap<String, String>();
            final IJavaProject project = getSingleProject();
            final String description =
                RefactoringCoreMessages.InferTypeArgumentsRefactoring_descriptor_description;
            final String header =
                project != null
                    ? Messages.format(
                        RefactoringCoreMessages
                            .InferTypeArgumentsRefactoring_descriptor_description_project,
                        BasicElementLabels.getJavaElementName(project.getElementName()))
                    : RefactoringCoreMessages
                        .InferTypeArgumentsRefactoring_descriptor_description;
            final String name = project != null ? project.getElementName() : null;
            final JDTRefactoringDescriptorComment comment =
                new JDTRefactoringDescriptorComment(name, this, header);
            final String[] settings = new String[fElements.length];
            for (int index = 0; index < settings.length; index++)
              settings[index] =
                  JavaElementLabels.getTextLabel(
                      fElements[index], JavaElementLabels.ALL_FULLY_QUALIFIED);
            comment.addSetting(
                JDTRefactoringDescriptorComment.createCompositeSetting(
                    RefactoringCoreMessages.InferTypeArgumentsRefactoring_original_elements,
                    settings));
            if (fAssumeCloneReturnsSameType)
              comment.addSetting(
                  RefactoringCoreMessages.InferTypeArgumentsRefactoring_assume_clone);
            if (fLeaveUnconstrainedRaw)
              comment.addSetting(
                  RefactoringCoreMessages.InferTypeArgumentsRefactoring_leave_unconstrained);
            final InferTypeArgumentsDescriptor descriptor =
                RefactoringSignatureDescriptorFactory.createInferTypeArgumentsDescriptor(
                    name,
                    description,
                    comment.asString(),
                    arguments,
                    RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE);
            for (int index = 0; index < fElements.length; index++)
              arguments.put(
                  JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (index + 1),
                  JavaRefactoringDescriptorUtil.elementToHandle(name, fElements[index]));
            arguments.put(
                ATTRIBUTE_CLONE, Boolean.valueOf(fAssumeCloneReturnsSameType).toString());
            arguments.put(ATTRIBUTE_LEAVE, Boolean.valueOf(fLeaveUnconstrainedRaw).toString());
            return new RefactoringChangeDescriptor(descriptor);
          }
        };
    return result;
  } finally {
    pm.done();
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:64,代码来源:InferTypeArgumentsRefactoring.java

示例2: resolveSourceProvider

import org.eclipse.jdt.ui.JavaElementLabels; //导入方法依赖的package包/类
private static SourceProvider resolveSourceProvider(
    RefactoringStatus status, ITypeRoot typeRoot, ASTNode invocation) {
  CompilationUnit root = (CompilationUnit) invocation.getRoot();
  IMethodBinding methodBinding = Invocations.resolveBinding(invocation);
  if (methodBinding == null) {
    status.addFatalError(
        RefactoringCoreMessages.InlineMethodRefactoring_error_noMethodDeclaration);
    return null;
  }
  MethodDeclaration declaration = (MethodDeclaration) root.findDeclaringNode(methodBinding);
  if (declaration != null) {
    return new SourceProvider(typeRoot, declaration);
  }
  IMethod method = (IMethod) methodBinding.getJavaElement();
  if (method != null) {
    CompilationUnit methodDeclarationAstRoot;
    ICompilationUnit methodCu = method.getCompilationUnit();
    if (methodCu != null) {
      methodDeclarationAstRoot =
          new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(methodCu, true);
    } else {
      IClassFile classFile = method.getClassFile();
      if (!JavaElementUtil.isSourceAvailable(classFile)) {
        String methodLabel =
            JavaElementLabels.getTextLabel(
                method,
                JavaElementLabels.M_FULLY_QUALIFIED | JavaElementLabels.M_PARAMETER_TYPES);
        status.addFatalError(
            Messages.format(
                RefactoringCoreMessages.InlineMethodRefactoring_error_classFile, methodLabel));
        return null;
      }
      methodDeclarationAstRoot =
          new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(classFile, true);
    }
    ASTNode node =
        methodDeclarationAstRoot.findDeclaringNode(methodBinding.getMethodDeclaration().getKey());
    if (node instanceof MethodDeclaration) {
      return new SourceProvider(methodDeclarationAstRoot.getTypeRoot(), (MethodDeclaration) node);
    }
  }
  status.addFatalError(RefactoringCoreMessages.InlineMethodRefactoring_error_noMethodDeclaration);
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:45,代码来源:InlineMethodRefactoring.java

示例3: getDestinationLabel

import org.eclipse.jdt.ui.JavaElementLabels; //导入方法依赖的package包/类
protected String getDestinationLabel() {
  Object destination = getJavaElementDestination();
  if (destination == null) destination = getResourceDestination();
  return JavaElementLabels.getTextLabel(destination, JavaElementLabels.ALL_FULLY_QUALIFIED);
}
 
开发者ID:eclipse,项目名称:che,代码行数:6,代码来源:ReorgPolicyFactory.java


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