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


Java Signature.getSignatureSimpleName方法代码示例

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


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

示例1: execute

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {

	final IEditorPart editorPart = HandlerUtil.getActiveEditor(event);
	final ICompilationUnit icu = JavaUI.getWorkingCopyManager().getWorkingCopy(editorPart.getEditorInput());

	try {
		final IType type = icu.getTypes()[0];
		final List<Field> fields = new ArrayList<>();
		for (final IField field : type.getFields()) {
			final String fieldName = field.getElementName();
			final String fieldType = Signature.getSignatureSimpleName(field.getTypeSignature());
			fields.add(new Field(fieldName, fieldType));
		}

		new WizardDialog(HandlerUtil.getActiveShell(event), new BuilderGeneratorWizard(icu, fields)).open();

	}
	catch (final JavaModelException e) {
		e.printStackTrace();
	}

	return null;
}
 
开发者ID:khabali,项目名称:java-builders-generator,代码行数:25,代码来源:GenerateBuildersHandler.java

示例2: getInvocationExpression

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
public String getInvocationExpression() {
	String[] values = getValues();
	String[] parameterTypes = method.getParameterTypes();

	for(int i = 0; i < values.length; i++) {
		String pType = Signature.getSignatureSimpleName(parameterTypes[i]);
		values[i] = convertForTypedInvocation(values[i], pType);
	}

	try {
		return (method.isConstructor() ? "new " + method.getElementName() : methodName) + "(" + String.join(", ", values) + ")";
	} catch (JavaModelException e) {
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:17,代码来源:StaticInvocationWidget.java

示例3: createAnonymousTypeLabel

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private void createAnonymousTypeLabel(CompletionProposal proposal, CompletionItem item) {
	char[] declaringTypeSignature= proposal.getDeclarationSignature();
	declaringTypeSignature= Signature.getTypeErasure(declaringTypeSignature);
	String name = new String(Signature.getSignatureSimpleName(declaringTypeSignature));
	item.setInsertText(name);
	StringBuilder buf= new StringBuilder();
	buf.append(name);
	buf.append('(');
	appendUnboundedParameterList(buf, proposal);
	buf.append(')');
	buf.append("  "); //$NON-NLS-1$
	buf.append("Anonymous Inner Type"); //TODO: consider externalization
	item.setLabel(buf.toString());

	if (proposal.getRequiredProposals() != null) {
		char[] signatureQualifier= Signature.getSignatureQualifier(declaringTypeSignature);
		if (signatureQualifier.length > 0) {
			item.setDetail(String.valueOf(signatureQualifier));
		}
	}
	setDeclarationSignature(item, String.valueOf(declaringTypeSignature));
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:23,代码来源:CompletionProposalDescriptionProvider.java

示例4: resolve

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private void resolve(MultiVariable mv, JavaVariable master, int index, JavaContext context) {
  Object[] choices = master.getChoices();
  if (choices instanceof Variable[]) {
    context.addDependency(master, mv);
    Variable[] variables = (Variable[]) choices;
    String type = master.getParamType();
    for (int i = 0; i < choices.length; i++) {
      String[] bounds = variables[i].getTypeArgumentBoundSignatures(type, index);
      for (int j = 0; j < bounds.length; j++)
        bounds[j] = Signature.getSignatureSimpleName(bounds[j]);
      mv.setChoices(variables[i], bounds);
    }
    mv.setKey(master.getCurrentChoice());
  } else {
    super.resolve(mv, context);
    return;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:TypeVariableResolver.java

示例5: longSig

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private String longSig(IMethod method) {
	try {
		return Signature.getSignatureSimpleName(method.getReturnType()) + " " + method.getElementName() + "(" + String.join(", ", method.getParameterNames()) + ")";
	} catch (JavaModelException e) {
		return method.getElementName() + "(...)";
	}
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:8,代码来源:ObjectFigure.java

示例6: getInvocationExpression

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
public String getInvocationExpression() {
	String[] values = getValues();
	String[] parameterTypes = method.getParameterTypes();

	for(int i = 0; i < values.length; i++)
		if(!contains(paramBoxes[i].getItems(), values[i]))
			paramBoxes[i].add(values[i]);

	for(int i = 0; i < values.length; i++) {
		String pType = Signature.getSignatureSimpleName(parameterTypes[i]);
		values[i] = convertForTypedInvocation(values[i], pType);
	}

	return methodName + "(" + String.join(", ", values) + ")";
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:16,代码来源:StaticInvocationWidget.java

示例7: addToPaths

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private void addToPaths(
    final List<IImport> imports,
    final Path path,
    final Set<IPath> paths,
    final String parameterType) {
  String signatureSimpleName;
  signatureSimpleName = Signature.getSignatureSimpleName(parameterType);
  if ("void".equals(signatureSimpleName)) { //$NON-NLS-1$
    return;
  }
  paths.add(createTypePath(imports, path, signatureSimpleName));
}
 
开发者ID:AndreasWBartels,项目名称:libraries,代码行数:13,代码来源:WorkspaceDependenciesInvestigator.java

示例8: createSimpleLabelWithType

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private void createSimpleLabelWithType(CompletionProposal proposal, CompletionItem item) {
	StringBuilder nameBuffer= new StringBuilder();
	nameBuffer.append(proposal.getCompletion());
	item.setInsertText(nameBuffer.toString());
	char[] typeName= Signature.getSignatureSimpleName(proposal.getSignature());
	if (typeName.length > 0) {
		nameBuffer.append(VAR_TYPE_SEPARATOR);
		nameBuffer.append(typeName);
	}
	item.setLabel(nameBuffer.toString());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:12,代码来源:CompletionProposalDescriptionProvider.java

示例9: createLabelWithTypeAndDeclaration

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private void createLabelWithTypeAndDeclaration(CompletionProposal proposal, CompletionItem item) {
	char[] name= proposal.getCompletion();
	if (!isThisPrefix(name)) {
		name= proposal.getName();
	}
	StringBuilder buf= new StringBuilder();

	buf.append(name);
	item.setInsertText(buf.toString());
	char[] typeName= Signature.getSignatureSimpleName(proposal.getSignature());
	if (typeName.length > 0) {
		buf.append(VAR_TYPE_SEPARATOR);
		buf.append(typeName);
	}
	item.setLabel(buf.toString());

	char[] declaration= proposal.getDeclarationSignature();
	if (declaration != null) {
		setDeclarationSignature(item, String.valueOf(declaration));
		StringBuilder declBuf = new StringBuilder();
		declaration= Signature.getSignatureSimpleName(declaration);
		if (declaration.length > 0) {
			if (proposal.getRequiredProposals() != null) {
				String declaringType= extractDeclaringTypeFQN(proposal);
				String qualifier= Signature.getQualifier(declaringType);
				if (qualifier.length() > 0) {
					declBuf.append(qualifier);
					declBuf.append('.');
				}
			}
			declBuf.append(declaration);
			item.setDetail(declBuf.toString());
		}
	}
	setName(item,String.valueOf(name));
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:37,代码来源:CompletionProposalDescriptionProvider.java

示例10: getQualifiedNameFromTypeSignature

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
public static String getQualifiedNameFromTypeSignature(String typeSignature, IType declaringType)
		throws JavaModelException {
	typeSignature = Signature.getTypeErasure(typeSignature);
	String signatureQualifier = Signature.getSignatureQualifier(typeSignature);
	String signatureSimpleName = Signature.getSignatureSimpleName(typeSignature);
	String simpleName = signatureQualifier.isEmpty() ? signatureSimpleName
			: signatureQualifier + '.' + signatureSimpleName;

	// workaround https://bugs.eclipse.org/bugs/show_bug.cgi?id=494209.
	boolean isArray = false;
	if (simpleName.endsWith("[]")) {
		isArray = true;
		simpleName = simpleName.substring(0, simpleName.lastIndexOf('['));
	}

	String[][] allResults = declaringType.resolveType(simpleName);
	String fullName = null;
	if (allResults != null) {
		String[] nameParts = allResults[0];
		if (nameParts != null) {
			StringBuilder fullNameBuilder = new StringBuilder();
			for (String part : nameParts) {
				if (fullNameBuilder.length() > 0)
					fullNameBuilder.append('.');
				if (part != null)
					fullNameBuilder.append(part);
			}
			fullName = fullNameBuilder.toString();
		}
	} else
		fullName = simpleName;

	// workaround https://bugs.eclipse.org/bugs/show_bug.cgi?id=494209.
	if (isArray)
		fullName += "[]";

	return fullName;
}
 
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:39,代码来源:Util.java

示例11: createReturnType

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
public static String createReturnType(String returnType) {

		if (returnType != null && !returnType.equals("V")) {
			returnType = Signature.getSignatureSimpleName(returnType);
		} else {
			returnType = TYPE_VOID;
		}

		return returnType;
	}
 
开发者ID:junit-tools-team,项目名称:junit-tools,代码行数:11,代码来源:JDTUtils.java

示例12: createSimpleLabelWithType

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
StyledString createSimpleLabelWithType(CompletionProposal proposal) {
  StyledString buf = new StyledString();
  buf.append(proposal.getCompletion());
  char[] typeName = Signature.getSignatureSimpleName(proposal.getSignature());
  if (typeName.length > 0) {
    buf.append(VAR_TYPE_SEPARATOR);
    buf.append(typeName);
  }
  return Strings.markJavaElementLabelLTR(buf);
}
 
开发者ID:eclipse,项目名称:che,代码行数:11,代码来源:CompletionProposalLabelProvider.java

示例13: createLabelWithTypeAndDeclaration

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
StyledString createLabelWithTypeAndDeclaration(CompletionProposal proposal) {
  char[] name = proposal.getCompletion();
  if (!isThisPrefix(name)) name = proposal.getName();

  StyledString buf = new StyledString();
  buf.append(name);
  char[] typeName = Signature.getSignatureSimpleName(proposal.getSignature());
  if (typeName.length > 0) {
    buf.append(VAR_TYPE_SEPARATOR);
    buf.append(typeName);
  }
  char[] declaration = proposal.getDeclarationSignature();
  if (declaration != null) {
    declaration = Signature.getSignatureSimpleName(declaration);
    if (declaration.length > 0) {
      buf.append(QUALIFIER_SEPARATOR, StyledString.QUALIFIER_STYLER);
      if (proposal.getRequiredProposals() != null) {
        String declaringType = extractDeclaringTypeFQN(proposal);
        String qualifier = Signature.getQualifier(declaringType);
        if (qualifier.length() > 0) {
          buf.append(qualifier, StyledString.QUALIFIER_STYLER);
          buf.append('.', StyledString.QUALIFIER_STYLER);
        }
      }
      buf.append(declaration, StyledString.QUALIFIER_STYLER);
    }
  }

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

示例14: qualifySignature

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
 * Returns the qualified signature corresponding to <code>signature</code>.
 *
 * @param signature the signature to qualify
 * @param context the type inside which an unqualified type will be resolved to find the
 *     qualifier, or <code>null</code> if no context is available
 * @return the qualified signature
 */
public static String qualifySignature(final String signature, final IType context) {
  if (context == null) return signature;

  String qualifier = Signature.getSignatureQualifier(signature);
  if (qualifier.length() > 0) return signature;

  String elementType = Signature.getElementType(signature);
  String erasure = Signature.getTypeErasure(elementType);
  String simpleName = Signature.getSignatureSimpleName(erasure);
  String genericSimpleName = Signature.getSignatureSimpleName(elementType);

  int dim = Signature.getArrayCount(signature);

  try {
    String[][] strings = context.resolveType(simpleName);
    if (strings != null && strings.length > 0) qualifier = strings[0][0];
  } catch (JavaModelException e) {
    // ignore - not found
  }

  if (qualifier.length() == 0) return signature;

  String qualifiedType = Signature.toQualifiedName(new String[] {qualifier, genericSimpleName});
  String qualifiedSignature = Signature.createTypeSignature(qualifiedType, true);
  String newSignature = Signature.createArraySignature(qualifiedSignature, dim);

  return newSignature;
}
 
开发者ID:eclipse,项目名称:che,代码行数:37,代码来源:SignatureUtil.java

示例15: getQualifiedTypeName

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
 * Extract the fully-qualified type name out of a type signature, with dots as
 * package separators.
 */
public static String getQualifiedTypeName(String typeSignature) {
  // Make sure we're using dots for package separator, not /'s
  typeSignature = typeSignature.replace('/', '.');

  String pckg = Signature.getSignatureQualifier(typeSignature);
  String typeName = Signature.getSignatureSimpleName(typeSignature);

  if (pckg == null || pckg.length() == 0) {
    return typeName;
  }

  return pckg + "." + typeName;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:18,代码来源:JavaModelSearch.java


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