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


Java Signature.getSimpleName方法代码示例

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


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

示例1: createTypeDisplayName

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
 * Returns the display string for a java type signature.
 *
 * @param typeSignature the type signature to create a display name for
 * @return the display name for <code>typeSignature</code>
 * @throws IllegalArgumentException if <code>typeSignature</code> is not a
 *         valid signature
 * @see Signature#toCharArray(char[])
 * @see Signature#getSimpleName(char[])
 */
private char[] createTypeDisplayName(char[] typeSignature) throws IllegalArgumentException {
	char[] displayName= Signature.getSimpleName(Signature.toCharArray(typeSignature));

	// XXX see https://bugs.eclipse.org/bugs/show_bug.cgi?id=84675
	boolean useShortGenerics= false;
	if (useShortGenerics) {
		StringBuilder buf= new StringBuilder();
		buf.append(displayName);
		int pos;
		do {
			pos= buf.indexOf("? extends "); //$NON-NLS-1$
			if (pos >= 0) {
				buf.replace(pos, pos + 10, "+"); //$NON-NLS-1$
			} else {
				pos= buf.indexOf("? super "); //$NON-NLS-1$
				if (pos >= 0)
				{
					buf.replace(pos, pos + 8, "-"); //$NON-NLS-1$
				}
			}
		} while (pos >= 0);
		return buf.toString().toCharArray();
	}
	return displayName;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:36,代码来源:CompletionProposalDescriptionProvider.java

示例2: displayTraceItem

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private String displayTraceItem(BaseTraceability traceItem) {
	StringBuffer sb = new StringBuffer();
	
	AstNode expr = traceItem.getExpression();
	if (expr != null) {
		BodyDeclaration enclDecl = expr.enclosingDeclaration;
		
		// Inline this?
		TypeDeclaration enclTypeDeclaration = MiniAstUtils.getEnclosingTypeDeclaration(expr);
		
		String type = Signature.getSimpleName(enclTypeDeclaration.getFullyQualifiedName());
		sb.append(type);
		sb.append("\t");
		if (enclDecl instanceof MethodDeclaration) {
			MethodDeclaration md = (MethodDeclaration) enclDecl;
			sb.append(md.methodName);
		}
		if (enclDecl instanceof FieldDeclaration) {
			FieldDeclaration fd = (FieldDeclaration)enclDecl;
			sb.append(fd.fieldName);
		}
		sb.append("\t");
		sb.append(expr);
	}
	return sb.toString();
}
 
开发者ID:aroog,项目名称:code,代码行数:27,代码来源:SecurityAnalysis.java

示例3: getEdgesWithType

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private Set<DisplayEdge> getEdgesWithType(
		String inputElement) {
	Set<DisplayEdge> edges = RuntimeModel.getInstance().getDisplayModel().getEdges();
	Set<DisplayEdge> retEdges = new HashSet<DisplayEdge>();
	for(DisplayEdge edge: edges){
		DisplayObject toObject = edge.getToObject();
		DisplayObject fromObject = edge.getFromObject();
		String toTypeDisplayName = toObject.getTypeDisplayName();
		String fromTypeDisplayName = fromObject.getTypeDisplayName();
		String simpleName = Signature.getSimpleName(inputElement);
		if(toTypeDisplayName.contentEquals(simpleName)||
				fromTypeDisplayName.contentEquals(simpleName)){
			retEdges.add(edge);
		}
	}
	return retEdges;
}
 
开发者ID:aroog,项目名称:code,代码行数:18,代码来源:ContentProviderOOGSearch.java

示例4: getSummaryViewLabel

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
public static String getSummaryViewLabel(Object element) {
	String label ="";
	if(element instanceof Info<?>){
		switch(((Info) element).getType()){
		case CLASS:
			label =  Signature.getSimpleName(((Info) element).getKey());
			break;
		case METHOD:
			label =  ((Info) element).getKey();
			break;
			
		}
	}else{
		label = element!=null? element.toString(): label;
	}
	return label;
}
 
开发者ID:aroog,项目名称:code,代码行数:18,代码来源:LabelUtil.java

示例5: findModule

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
 * Finds a particular GWT module by its fully-qualified name.
 *
 * @param javaProject project in which to search for modules
 * @param qualifiedName fully-qualified module name
 * @param includeJars indicates whether to include JAR files in search
 * @return the module, if found; otherwise <code>null</code>
 */
public static IModule findModule(IJavaProject javaProject, String qualifiedName, final boolean includeJars) {
  final String modulePckg = Signature.getQualifier(qualifiedName);
  final String simpleName = Signature.getSimpleName(qualifiedName);

  return visitFragments(javaProject, includeJars, new IPackageFragmentVisitor<IModule>() {
    @Override
    public IModule visit(IPackageFragment pckg) throws JavaModelException {
      // Look for the package fragment matching the module qualifier
      if (modulePckg.equals(pckg.getElementName())) {
        for (Object resource : pckg.getNonJavaResources()) {
          IModule module = create(resource, includeJars);
          // Now compare the resource name to the module name
          if (module != null && module.getSimpleName().equals(simpleName)) {
            return module;
          }
        }
      }

      return null;
    }
  });
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:31,代码来源:ModuleUtils.java

示例6: sameParams

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private static boolean sameParams(IMethod method, IMethod method2) {

    if (method.getNumberOfParameters() != method2.getNumberOfParameters()) return false;

    String[] params = method.getParameterTypes();
    String[] params2 = method2.getParameterTypes();

    for (int i = 0; i < params.length; i++) {
      String t1 = Signature.getSimpleName(Signature.toString(params[i]));
      String t2 = Signature.getSimpleName(Signature.toString(params2[i]));
      if (!t1.equals(t2)) {
        return false;
      }
    }
    return true;
  }
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:RenameTypeProcessor.java

示例7: JavaTypeCompletionProposal

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
public JavaTypeCompletionProposal(
    String replacementString,
    ICompilationUnit cu,
    int replacementOffset,
    int replacementLength,
    Image image,
    StyledString displayString,
    int relevance,
    String fullyQualifiedTypeName,
    JavaContentAssistInvocationContext invocationContext) {
  super(
      replacementString,
      replacementOffset,
      replacementLength,
      image,
      displayString,
      relevance,
      false,
      invocationContext);
  fCompilationUnit = cu;
  fFullyQualifiedTypeName = fullyQualifiedTypeName;
  fUnqualifiedTypeName =
      fullyQualifiedTypeName != null ? Signature.getSimpleName(fullyQualifiedTypeName) : null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:JavaTypeCompletionProposal.java

示例8: isSameMethodSignature

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
 * Tests if a method equals to the given signature. Parameter types are only compared by the
 * simple name, no resolving for the fully qualified type name is done. Constructors are only
 * compared by parameters, not the name.
 *
 * @param name Name of the method
 * @param paramTypes The type signatures of the parameters e.g. <code>{"QString;","I"}</code>
 * @param isConstructor Specifies if the method is a constructor
 * @param curr the method
 * @return Returns <code>true</code> if the method has the given name and parameter types and
 *     constructor state.
 * @throws JavaModelException thrown when the method can not be accessed
 */
public static boolean isSameMethodSignature(
    String name, String[] paramTypes, boolean isConstructor, IMethod curr)
    throws JavaModelException {
  if (isConstructor || name.equals(curr.getElementName())) {
    if (isConstructor == curr.isConstructor()) {
      String[] currParamTypes = curr.getParameterTypes();
      if (paramTypes.length == currParamTypes.length) {
        for (int i = 0; i < paramTypes.length; i++) {
          String t1 = Signature.getSimpleName(Signature.toString(paramTypes[i]));
          String t2 = Signature.getSimpleName(Signature.toString(currParamTypes[i]));
          if (!t1.equals(t2)) {
            return false;
          }
        }
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:34,代码来源:JavaModelUtil.java

示例9: isSourceAnnotation

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private static boolean isSourceAnnotation(ASTNode node) {
  if (node instanceof Annotation) {
    Annotation annotation = (Annotation) node;
    String typeName = annotation.getTypeName().getFullyQualifiedName();

    // Annotation can be used with its fully-qualified name
    if (typeName.equals(ClientBundleUtilities.CLIENT_BUNDLE_SOURCE_ANNOTATION_NAME)) {
      return true;
    }

    // Simple name is fine, too
    String sourceAnnotationSimpleName =
        Signature.getSimpleName(ClientBundleUtilities.CLIENT_BUNDLE_SOURCE_ANNOTATION_NAME);
    if (typeName.equals(sourceAnnotationSimpleName)) {
      return true;
    }
  }
  return false;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:20,代码来源:ClientBundleValidator.java

示例10: addToTestProject

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
public void addToTestProject() throws Exception {
  IProject testProject = Util.getWorkspaceRoot().getProject(TEST_PROJECT_NAME);
  if (!testProject.exists()) {
    throw new Exception("The test project does not exist");
  }

  IJavaProject javaProject = JavaCore.create(testProject);

  IPath srcPath = new Path("/" + TEST_PROJECT_NAME + "/src");
  IPackageFragmentRoot pckgRoot = javaProject.findPackageFragmentRoot(srcPath);

  String packageName = Signature.getQualifier(typeName);
  String cuName = Signature.getSimpleName(typeName) + ".java";

  // If the package fragment already exists, this call does nothing
  IPackageFragment pckg = pckgRoot.createPackageFragment(packageName, false, null);

  cu = pckg.createCompilationUnit(cuName, contents, true, null);
  JobsUtilities.waitForIdle();
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:21,代码来源:AbstractGWTPluginTestCase.java

示例11: createCompilationUnit

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
 * Creates an {@link ICompilationUnit} with the given fully qualified name and
 * code in the <code>javaProject</code>.
 * 
 * @param javaProject java project to host the new class
 * @param fullyQualifiedClassName fully qualified name for the class
 * @param source code for the classs
 * @return newly created {@link ICompilationUnit}
 * @throws JavaModelException
 */
public static ICompilationUnit createCompilationUnit(
    IJavaProject javaProject, String fullyQualifiedClassName, String source)
    throws JavaModelException {
  IPackageFragmentRoot root = javaProject.findPackageFragmentRoot(javaProject.getPath());
  if (root == null) {
    addRawClassPathEntry(javaProject,
        JavaCore.newSourceEntry(javaProject.getPath()));
    root = javaProject.findPackageFragmentRoot(javaProject.getPath());
  }

  String qualifier = Signature.getQualifier(fullyQualifiedClassName);
  IProgressMonitor monitor = new NullProgressMonitor();
  IPackageFragment packageFragment = root.createPackageFragment(qualifier,
      true, monitor);
  String name = Signature.getSimpleName(fullyQualifiedClassName);
  return packageFragment.createCompilationUnit(name + ".java", source, false,
      monitor);
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:29,代码来源:JavaProjectTestUtilities.java

示例12: createCompilationUnit

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
 * Creates an {@link ICompilationUnit} with the given fully qualified name and
 * code in the <code>javaProject</code>.
 *
 * @param javaProject java project to host the new class
 * @param fullyQualifiedClassName fully qualified name for the class
 * @param source code for the classs
 * @return newly created {@link ICompilationUnit}
 * @throws JavaModelException
 */
public static ICompilationUnit createCompilationUnit(
    IJavaProject javaProject, String fullyQualifiedClassName, String source)
    throws JavaModelException {
  IPackageFragmentRoot root = javaProject.findPackageFragmentRoot(javaProject.getPath());
  if (root == null) {
    addRawClassPathEntry(javaProject,
        JavaCore.newSourceEntry(javaProject.getPath()));
    root = javaProject.findPackageFragmentRoot(javaProject.getPath());
  }

  String qualifier = Signature.getQualifier(fullyQualifiedClassName);
  IProgressMonitor monitor = new NullProgressMonitor();
  IPackageFragment packageFragment = root.createPackageFragment(qualifier,
      true, monitor);
  String name = Signature.getSimpleName(fullyQualifiedClassName);
  ICompilationUnit cu = packageFragment.createCompilationUnit(name + ".java",
      source, false, monitor);
  JobsUtilities.waitForIdle();
  return cu;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:31,代码来源:JavaProjectUtilities.java

示例13: getText

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
@Override
public String getText(Object element) {
  if (element == null) {
    return null;
  }
  String simpleName = Signature.getSimpleName(element.toString());
  return String.format("%s - %s", simpleName, element.toString()); //$NON-NLS-1$
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:9,代码来源:PipelineOptionsSelectionDialog.java

示例14: createMethodProposalLabel

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
 * Updates a display label for the given method proposal to item. The display label
 * consists of:
 * <ul>
 *   <li>the method name</li>
 *   <li>the parameter list (see {@link #createParameterList(CompletionProposal)})</li>
 *   <li>the upper bound of the return type (see {@link SignatureUtil#getUpperBound(String)})</li>
 *   <li>the raw simple name of the declaring type</li>
 * </ul>
 * <p>
 * Examples:
 * For the <code>get(int)</code> method of a variable of type <code>List<? extends Number></code>, the following
 * display name is returned: <code>get(int index)  Number - List</code>.<br>
 * For the <code>add(E)</code> method of a variable of type <code>List<? super Number></code>, the following
 * display name is returned: <code>add(Number o)  void - List</code>.<br>
 * </p>
 *
 * @param methodProposal the method proposal to display
 * @param item to update
 */
private void createMethodProposalLabel(CompletionProposal methodProposal, CompletionItem item) {
	StringBuilder description = this.createMethodProposalDescription(methodProposal);
	item.setLabel(description.toString());
	item.setInsertText(String.valueOf(methodProposal.getName()));

	// declaring type
	StringBuilder typeInfo = new StringBuilder();
	String declaringType= extractDeclaringTypeFQN(methodProposal);

	if (methodProposal.getRequiredProposals() != null) {
		String qualifier= Signature.getQualifier(declaringType);
		if (qualifier.length() > 0) {
			typeInfo.append(qualifier);
			typeInfo.append('.');
		}
	}

	declaringType= Signature.getSimpleName(declaringType);
	typeInfo.append(declaringType);
	item.setDetail(typeInfo.toString());

	setSignature(item, String.valueOf(methodProposal.getSignature()));
	setDeclarationSignature(item, String.valueOf(methodProposal.getDeclarationSignature()));
	setName(item, String.valueOf(methodProposal.getName()));

}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:47,代码来源:CompletionProposalDescriptionProvider.java

示例15: getSrcObject

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
@Override
public String getSrcObject() {
	if(changedVar instanceof SourceVariable){
		return changedVar == null ? "" : Signature.getSimpleName(((SourceVariable)changedVar).getBinding().getType().getQualifiedName());
	}
	else {
		return changedVar == null ? "" : Signature.getSimpleName(((TACVariable)changedVar).getVarDecl().getType().getQualifiedName());
	}
}
 
开发者ID:aroog,项目名称:code,代码行数:10,代码来源:InferPDHeuristic.java


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