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


Java IMethod.getParameterNames方法代码示例

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


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

示例1: createPlaceHolderFromSource

import org.eclipse.jdt.core.IMethod; //导入方法依赖的package包/类
private void createPlaceHolderFromSource(IMethod iMethod, String className) throws JavaModelException {
	StringBuffer buffer = new StringBuffer(iMethod.getSource());
	int indexOfPlaceHolder = buffer.lastIndexOf("@see");
	if (indexOfPlaceHolder != -1 && iMethod.getParameterNames() != null && iMethod.getParameterNames().length > 0) {
		buffer = buffer.delete(0, indexOfPlaceHolder + 4);
		buffer = buffer.delete(buffer.indexOf("\n")+1, buffer.capacity());
		if(StringUtils.contains(buffer.toString(), className + Constants.DOT+iMethod.getElementName())){
			placeHolder = StringUtils.trim(buffer.toString());
		}
		else
			placeHolder = createDefaultPlaceHolder(iMethod, className);
	} else {
		placeHolder = createDefaultPlaceHolder(iMethod, className);
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:16,代码来源:MethodDetails.java

示例2: createDefaultPlaceHolder

import org.eclipse.jdt.core.IMethod; //导入方法依赖的package包/类
public String createDefaultPlaceHolder(IMethod iMethod, String className) throws JavaModelException {
	StringBuffer buffer = new StringBuffer();
	buffer.append(className + Constants.DOT);
	buffer.append(iMethod.getElementName()+ Constants.OPENING_BRACKET);
	if (iMethod.getParameterNames() != null && iMethod.getParameterNames() != null)
		for (int index = 0; index < iMethod.getParameterNames().length; index++) {
			buffer.append(iMethod.getParameterNames()[index]);
			if (index != iMethod.getParameterTypes().length - 1) {
				buffer.append(Constants.COMMA + SWT.SPACE);
			}
		}
	buffer.append(Constants.CLOSING_BRACKET);
	return StringUtils.trim(buffer.toString());
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:15,代码来源:MethodDetails.java

示例3: StaticInvocationWidget

import org.eclipse.jdt.core.IMethod; //导入方法依赖的package包/类
public StaticInvocationWidget(Composite parent, InvokeDialog invokeDialog, IMethod method, InvocationAction action) {
	super(parent, SWT.NONE);
	this.invokeDialog = invokeDialog;
	
	this.method = method;

	setLayout(rowLayout);

	methodName = method.getElementName();
	parameterTypes = method.getParameterTypes();
	Label label = new Label(this, SWT.NONE);
	FontManager.setFont(label, PandionJConstants.VAR_FONT_SIZE);
	label.setText(method.getElementName() + " (");
	paramBoxes = new Combo[method.getNumberOfParameters()];
	String[] parameterNames = null;
	try {
		parameterNames = method.getParameterNames();
	} catch (JavaModelException e1) {
		e1.printStackTrace();
	}
	for(int i = 0; i < parameterTypes.length; i++) {
		if(i != 0) {
			Label comma = new Label(this, SWT.NONE);
			FontManager.setFont(comma, PandionJConstants.VAR_FONT_SIZE);
			comma.setText(", ");
		}
		paramBoxes[i] = createCombo(invokeDialog, parameterNames[i], parameterTypes[i]);
	}
	Label close = new Label(this, SWT.NONE);
	FontManager.setFont(close, PandionJConstants.VAR_FONT_SIZE);
	close.setText(")");

	addCacheValues(paramBoxes);
	checkValidity();
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:36,代码来源:StaticInvocationWidget.java

示例4: getBaseNameFromLocationInParent

import org.eclipse.jdt.core.IMethod; //导入方法依赖的package包/类
private static String getBaseNameFromLocationInParent(Expression assignedExpression, List<Expression> arguments, IMethodBinding binding) {
	if (binding == null) {
		return null;
	}

	ITypeBinding[] parameterTypes= binding.getParameterTypes();
	if (parameterTypes.length != arguments.size()) {
		return null;
	}

	int index= arguments.indexOf(assignedExpression);
	if (index == -1) {
		return null;
	}

	ITypeBinding expressionBinding= assignedExpression.resolveTypeBinding();
	if (expressionBinding != null && !expressionBinding.isAssignmentCompatible(parameterTypes[index])) {
		return null;
	}

	try {
		IJavaElement javaElement= binding.getJavaElement();
		if (javaElement instanceof IMethod) {
			IMethod method= (IMethod)javaElement;
			if (method.getOpenable().getBuffer() != null) { // avoid dummy names and lookup from Javadoc
				String[] parameterNames= method.getParameterNames();
				if (index < parameterNames.length) {
					return NamingConventions.getBaseName(NamingConventions.VK_PARAMETER, parameterNames[index], method.getJavaProject());
				}
			}
		}
	} catch (JavaModelException e) {
		// ignore
	}
	return null;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:37,代码来源:StubUtility.java

示例5: suggestArgumentNames

import org.eclipse.jdt.core.IMethod; //导入方法依赖的package包/类
public static String[] suggestArgumentNames(IJavaProject project, IMethodBinding binding) {
	int nParams = binding.getParameterTypes().length;

	if (nParams > 0) {
		try {
			IMethod method = (IMethod) binding.getMethodDeclaration().getJavaElement();
			if (method != null) {
				String[] paramNames = method.getParameterNames();
				if (paramNames.length == nParams) {
					String[] namesArray = EMPTY;
					ArrayList<String> newNames = new ArrayList<>(paramNames.length);
					// Ensure that the code generation preferences are respected
					for (int i = 0; i < paramNames.length; i++) {
						String curr = paramNames[i];
						String baseName = NamingConventions.getBaseName(NamingConventions.VK_PARAMETER, curr,
								method.getJavaProject());
						if (!curr.equals(baseName)) {
							// make the existing name the favorite
							newNames.add(curr);
						} else {
							newNames.add(suggestArgumentName(project, curr, namesArray));
						}
						namesArray = newNames.toArray(new String[newNames.size()]);
					}
					return namesArray;
				}
			}
		} catch (JavaModelException e) {
			// ignore
		}
	}
	String[] names = new String[nParams];
	for (int i = 0; i < names.length; i++) {
		names[i] = "arg" + i; //$NON-NLS-1$
	}
	return names;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:38,代码来源:StubUtility.java

示例6: getMethodComment

import org.eclipse.jdt.core.IMethod; //导入方法依赖的package包/类
/**
 * Returns the comment for a method or constructor using the comment code templates (constructor / method / overriding method).
 * <code>null</code> is returned if the template is empty.
 * <p>The returned string is unformatted and not indented.
 *
 * @param method The method to be documented. The method must exist.
 * @param overridden The method that will be overridden by the created method or
 * <code>null</code> for non-overriding methods. If not <code>null</code>, the method must exist.
 * @param lineDelimiter The line delimiter to be used.
 * @return Returns the constructed comment or <code>null</code> if
 * the comment code template is empty. The returned string is unformatted and and has no indent (formatting required).
 * @throws CoreException Thrown when the evaluation of the code template fails.
 */
public static String getMethodComment(IMethod method, IMethod overridden, String lineDelimiter) throws CoreException {
	String retType= method.isConstructor() ? null : method.getReturnType();
	String[] paramNames= method.getParameterNames();
	String[] typeParameterNames= StubUtility.shouldGenerateMethodTypeParameterTags(method.getJavaProject()) ? StubUtility.getTypeParameterNames(method.getTypeParameters()) : new String[0];

	return StubUtility.getMethodComment(method.getCompilationUnit(), method.getDeclaringType().getElementName(),
			method.getElementName(), paramNames, method.getExceptionTypes(), retType, typeParameterNames, overridden, false, lineDelimiter);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:22,代码来源:CodeGeneration.java


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