當前位置: 首頁>>代碼示例>>Java>>正文


Java IMethod類代碼示例

本文整理匯總了Java中org.eclipse.jdt.core.IMethod的典型用法代碼示例。如果您正苦於以下問題:Java IMethod類的具體用法?Java IMethod怎麽用?Java IMethod使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IMethod類屬於org.eclipse.jdt.core包,在下文中一共展示了IMethod類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testEnrichClass

import org.eclipse.jdt.core.IMethod; //導入依賴的package包/類
@Test
public void testEnrichClass() throws Exception {
	IJavaProject pj = ProjectHelper.getOrCreateSimpleGW4EProject(PROJECT_NAME,true,false);
	
	IFile impl = ProjectHelper.createDummyClass (pj);
	ICompilationUnit compilationUnit = JavaCore.createCompilationUnitFrom(impl);
	IMethod m = compilationUnit.getTypes() [0].getMethod("runFunctionalTest",new String[0]);
	assertFalse (m.exists());

	IFile file = (IFile) ResourceManager.getResource(pj.getProject().getFullPath().append("src/test/resources/Simple.json").toString());
	ResourceContext context =  GenerationFactory.getResourceContext(file);
	ClassExtension ce = context.getClassExtension();
	ce.setGenerateRunFunctionalTest(true);
	ce.setStartElementForJunitTest("start_app");	
	TestResourceGeneration trg = new TestResourceGeneration(context);	 
	JDTManager.enrichClass(impl, trg, new NullProgressMonitor());
	
	m = compilationUnit.getTypes() [0].getMethod("runFunctionalTest",new String[0]);
	assertTrue (m.exists());
	
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:22,代碼來源:JDTManagerTest.java

示例2: initByIMethodBinding

import org.eclipse.jdt.core.IMethod; //導入依賴的package包/類
public void initByIMethodBinding(IMethodBinding mBinding) {
	IMethod iMethod = (IMethod) mBinding.getJavaElement();
	try {
		key = iMethod.getKey().substring(0, iMethod.getKey().indexOf("("))
				+ iMethod.getSignature();
		projectName = mBinding.getJavaElement().getJavaProject()
				.getElementName();
	} catch (Exception e) {
		projectName = "";
	}
	packageName = mBinding.getDeclaringClass().getPackage().getName();
	className = mBinding.getDeclaringClass().getName();
	name = mBinding.getName();

	parameters = new ArrayList<>();
	ITypeBinding[] parameterBindings = mBinding.getParameterTypes();
	for (int i = 0; i < parameterBindings.length; i++) {
		parameters.add(parameterBindings[i].getName());
	}
}
 
開發者ID:linzeqipku,項目名稱:SnowGraph,代碼行數:21,代碼來源:APIMethodData.java

示例3: containsMethod

import org.eclipse.jdt.core.IMethod; //導入依賴的package包/類
public static boolean containsMethod (String path, String[] requiredMethods) throws JavaModelException {
	IResource resource = ResourceManager.getResource(path);
	IFile file = (IFile) resource;
	ICompilationUnit cu = JavaCore.createCompilationUnitFrom(file);
	IType[] types = cu.getAllTypes();
	List<String> list = new ArrayList<String>();
	for (int i = 0; i < types.length; i++) {
		IMethod[] methods = types[i].getMethods();
		for (int j = 0; j < methods.length; j++) {
			list.add(methods[j].getElementName());
		}
	} 
	for (int i = 0; i < requiredMethods.length; i++) {
		String method = requiredMethods[i];
		if (!list.contains(method)) return false;
	}     
	return true;
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:19,代碼來源:JDTHelper.java

示例4: getCallersOf

import org.eclipse.jdt.core.IMethod; //導入依賴的package包/類
/**
 * Find methods calling method 'm'
 */
public static HashSet<IMethod> getCallersOf(IMethod m) {

    CallHierarchy callHierarchy = CallHierarchy.getDefault();

    IMember[] members = { m };

    MethodWrapper[] methodWrappers = callHierarchy.getCallerRoots(members);
    HashSet<IMethod> callers = new HashSet<IMethod>();
    for (MethodWrapper mw : methodWrappers) {
        MethodWrapper[] mw2 = mw.getCalls(new NullProgressMonitor());
        HashSet<IMethod> temp = getIMethods(mw2);
        callers.addAll(temp);
    }

    return callers;
}
 
開發者ID:eclipse,項目名稱:gemoc-studio,代碼行數:20,代碼來源:CallHierarchyHelper.java

示例5: getCallLocationsOf

import org.eclipse.jdt.core.IMethod; //導入依賴的package包/類
/**
 * Find calling sites for method 'm' 
 */
public static HashSet<CallLocation> getCallLocationsOf(IMethod m) {
	CallHierarchy callHierarchy = CallHierarchy.getDefault();

    IMember[] members = { m };

    MethodWrapper[] methodWrappers = callHierarchy.getCallerRoots(members);
    HashSet<CallLocation> callers = new HashSet<CallLocation>();
    for (MethodWrapper mw : methodWrappers) {
        MethodWrapper[] mw2 = mw.getCalls(new NullProgressMonitor());
        HashSet<CallLocation> temp = getCallLocations(mw2);
        callers.addAll(temp);
    }

    return callers;
}
 
開發者ID:eclipse,項目名稱:gemoc-studio,代碼行數:19,代碼來源:CallHierarchyHelper.java

示例6: ClassDetails

import org.eclipse.jdt.core.IMethod; //導入依賴的package包/類
public ClassDetails(IClassFile classFile, String jarFileName, String packageName, boolean isUserDefined) {
	LOGGER.debug("Extracting methods from "+classFile.getElementName());

	try {
		this.javaDoc=getJavaDoc(classFile);	
		intialize(classFile,jarFileName,packageName, isUserDefined);
		for (IJavaElement iJavaElement : classFile.getChildren()) {
			if (iJavaElement instanceof IType) {
				IType iType = (IType) iJavaElement;
				for (IMethod iMethod : iType.getMethods()) {
					addMethodsToClass(iMethod);
				}
			}
		}
	} catch (JavaModelException e) {
		LOGGER.error("Error occurred while fetching methods from class"+cName);
	}
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:19,代碼來源:ClassDetails.java

示例7: createSignature

import org.eclipse.jdt.core.IMethod; //導入依賴的package包/類
private String createSignature(IMethod iMethod) throws JavaModelException {
	StringBuffer buffer = new StringBuffer();
	returnType = DataTypes.getDataTypefromString(ExpressionEditorUtil.INSTANCE.lastString(iMethod.getReturnType(), Constants.DOT));
	buffer.append(iMethod.getElementName() + SWT.SPACE + Constants.OPENING_BRACKET);
	if (iMethod.getParameters() != null && iMethod.getParameters().length > 0) {
		for (int index = 0; index < iMethod.getParameters().length; index++) {
			buffer.append(DataTypes.getDataTypefromString(ExpressionEditorUtil.INSTANCE.lastString(
					iMethod.getParameters()[index].getTypeSignature(), Constants.DOT)));
			buffer.append(SWT.SPACE);
			buffer.append(iMethod.getParameters()[index].getElementName());
			if (index != iMethod.getParameters().length - 1)
				buffer.append(Constants.COMMA);
		}
	}
	buffer.append(Constants.CLOSING_BRACKET);
	buffer.append(SWT.SPACE + Constants.DASH + SWT.SPACE + returnType);
	return buffer.toString();
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:19,代碼來源:MethodDetails.java

示例8: handleType

import org.eclipse.jdt.core.IMethod; //導入依賴的package包/類
private void handleType(IType type, IFile file, List<ServiceImplementation> serviceImplementations) throws JavaModelException {
	/* Parcourt les méthodes. */
	for (IMethod method : type.getMethods()) {
		/* Filtre pour ne garder que les méthodes publiques d'instance */
		if (method.isConstructor() || Flags.isStatic(method.getFlags()) || Flags.isPrivate(method.getFlags())) {
			continue;
		}

		/* Créé le ServiceImplementation. */
		String javaName = method.getElementName();
		ISourceRange nameRange = method.getNameRange();
		FileRegion fileRegion = new FileRegion(file, nameRange.getOffset(), nameRange.getLength());
		ServiceImplementation serviceImplementation = new ServiceImplementation(fileRegion, javaName);
		serviceImplementations.add(serviceImplementation);
	}
}
 
開發者ID:sebez,項目名稱:vertigo-chroma-kspplugin,代碼行數:17,代碼來源:ServiceManager.java

示例9: handleType

import org.eclipse.jdt.core.IMethod; //導入依賴的package包/類
private void handleType(IType type, IFile file, List<DaoImplementation> daoImplementations) throws JavaModelException {
	/* Parcourt les méthodes. */
	for (IMethod method : type.getMethods()) {
		/* Filtre pour ne garder que les méthodes publiques d'instance */
		if (method.isConstructor() || Flags.isStatic(method.getFlags()) || Flags.isPrivate(method.getFlags())) {
			continue;
		}

		/* Créé le DaoImplementation. */
		String javaName = method.getElementName();
		ISourceRange nameRange = method.getNameRange();
		FileRegion fileRegion = new FileRegion(file, nameRange.getOffset(), nameRange.getLength());
		DaoImplementation daoImplementation = new DaoImplementation(fileRegion, javaName);
		daoImplementations.add(daoImplementation);
	}
}
 
開發者ID:sebez,項目名稱:vertigo-chroma-kspplugin,代碼行數:17,代碼來源:DaoManager.java

示例10: parseVertigoDtoField

import org.eclipse.jdt.core.IMethod; //導入依賴的package包/類
private static void parseVertigoDtoField(IMethod method, List<DtoField> fields) {
	try {
		if (method.isConstructor() || !Flags.isPublic(method.getFlags())) {
			return;
		}
		IAnnotation fieldAnnotation = JdtUtils.getAnnotation(method, FIELD_ANNOTATION_NAME);
		if (fieldAnnotation == null) {
			return;
		}
		String domain = (String) JdtUtils.getMemberValue(fieldAnnotation, DOMAIN_FIELD_NAME);

		/* Cas d'un champ de composition DTO/DTC : on filtre. */
		if (domain == null || domain.startsWith(DTO_DOMAIN_PREFIX)) {
			return;
		}

		String constantCaseName = StringUtils.toConstantCase(KspStringUtils.getFieldNameFromGetter(method.getElementName()));
		String label = (String) JdtUtils.getMemberValue(fieldAnnotation, LABEL_FIELD_NAME);
		Boolean persistent = (Boolean) JdtUtils.getMemberValue(fieldAnnotation, PERSISTENT_FIELD_NAME);

		DtoField field = new DtoField(constantCaseName, label, domain, persistent);
		fields.add(field);
	} catch (JavaModelException e) {
		ErrorUtils.handle(e);
	}
}
 
開發者ID:sebez,項目名稱:vertigo-chroma-kspplugin,代碼行數:27,代碼來源:DtoUtils.java

示例11: resolveMethodSignature

import org.eclipse.jdt.core.IMethod; //導入依賴的package包/類
/**
 * Copied from org.eclipse.jdt.internal.debug.ui.actions.ToggleBreakpointAdapter
 * TODO: is there a public API to do this?
 *
 * Returns the resolved signature of the given method
 * @param method method to resolve
 * @return the resolved method signature or <code>null</code> if none
 * @throws JavaModelException
 * @since 3.4
 */
public static String resolveMethodSignature(IMethod method) throws JavaModelException {
	String signature = method.getSignature();
	String[] parameterTypes = Signature.getParameterTypes(signature);
	int length = parameterTypes.length;
	String[] resolvedParameterTypes = new String[length];
	for (int i = 0; i < length; i++) {
		resolvedParameterTypes[i] = resolveTypeSignature(method, parameterTypes[i]);
		if (resolvedParameterTypes[i] == null) {
			return null;
		}
	}
	String resolvedReturnType = resolveTypeSignature(method, Signature.getReturnType(signature));
	if (resolvedReturnType == null) {
		return null;
	}
	return Signature.createMethodSignature(resolvedParameterTypes, resolvedReturnType);
}
 
開發者ID:VisuFlow,項目名稱:visuflow-plugin,代碼行數:28,代碼來源:BreakpointLocator.java

示例12: getInstanceMethods

import org.eclipse.jdt.core.IMethod; //導入依賴的package包/類
public List<IMethod> getInstanceMethods() {
	if(jType == null)
		return Collections.emptyList();

	try {
		List<IMethod> list = new ArrayList<>();
		IMethod[] methods = jType.getMethods();
		for(IMethod m : methods)

			if(!m.isConstructor() && !Flags.isStatic(m.getFlags()) && isMethodVisible(m))
				list.add(m);
		return list;
	} catch (JavaModelException e) {
		e.printStackTrace();
		return Collections.emptyList();
	}
	//		return info.getMethods(EnumSet.of(VisibilityInfo.PUBLIC));
}
 
開發者ID:andre-santos-pt,項目名稱:pandionj,代碼行數:19,代碼來源:ObjectModel.java

示例13: isMethodVisible

import org.eclipse.jdt.core.IMethod; //導入依賴的package包/類
private boolean isMethodVisible(IMethod m) {
		try {
			int f = m.getFlags();
			return 	extension.includeMethod(m.getElementName()) && !jType.isMember() && isVisibleMember(m);
//					(
//							!jType.isMember() && jType.getPackageFragment().isDefaultPackage() && 
//							(Flags.isPackageDefault(f) || Flags.isProtected(f) || Flags.isPublic(f))
//							||
//							Flags.isPublic(f)
//							);
		}
		catch (JavaModelException e) {
			e.printStackTrace();
			return false;
		}
	}
 
開發者ID:andre-santos-pt,項目名稱:pandionj,代碼行數:17,代碼來源:ObjectModel.java

示例14: MethodWidget

import org.eclipse.jdt.core.IMethod; //導入依賴的package包/類
MethodWidget(IMethod method) {
	setLayoutManager(new FlowLayout());
	button = new Button(shortSig(method));
	button.setToolTip(new Label(longSig(method)));
	button.setForegroundColor(ColorConstants.black);
	FontManager.setFont(button, PandionJConstants.BUTTON_FONT_SIZE);
	button.setEnabled(methodsEnabled);
	add(button);
	resultLabel = new Label();
	resultLabel.setForegroundColor(ColorConstants.black);
	add(resultLabel);
	button.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent event) {
			invoke(model, method, resultLabel);
		}
	});
}
 
開發者ID:andre-santos-pt,項目名稱:pandionj,代碼行數:18,代碼來源:ObjectFigure.java

示例15: createFigure

import org.eclipse.jdt.core.IMethod; //導入依賴的package包/類
@Override
		public IFigure createFigure(IObjectModel e) {
			Label label = new Label();
			label.setForegroundColor(PandionJConstants.Colors.OBJECT_HEADER_FONT);
			FontManager.setFont(label, PandionJConstants.OBJECT_HEADER_FONT_SIZE);
			IType type = e.getType();
			if(type != null) {
				IMethod method = type.getMethod("toString", new String[0]);
				if(!method.exists()) {
					label.setText(":" + type.getElementName());
					return label;
				}
			}
			invokeToString(e, label);
			label.setToolTip(new Label("returned by toString()"));
			e.getRuntimeModel().registerDisplayObserver((event) -> {
				if(event.type == IRuntimeModel.Event.Type.STEP ||event.type == IRuntimeModel.Event.Type.EVALUATION) {
					invokeToString(e, label);
//					label.setText(e.getStringValue());
				}
			});
			return label;
		}
 
開發者ID:andre-santos-pt,項目名稱:pandionj,代碼行數:24,代碼來源:ITypeWidgetExtension.java


注:本文中的org.eclipse.jdt.core.IMethod類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。