當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。