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


Java IJavaElement.METHOD屬性代碼示例

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


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

示例1: processType

private void processType(ITypeVisitor visitor, BinaryTypeName btn,
    IType type, IProgressMonitor monitor) throws JavaModelException {
  final String binaryname = btn.toString();
  monitor.subTask(binaryname);
  visitor.visit(type, binaryname);
  for (final IJavaElement child : type.getChildren()) {
    if (monitor.isCanceled()) {
      break;
    }
    switch (child.getElementType()) {
    case IJavaElement.TYPE:
      IType nestedtype = (IType) child;
      processType(visitor, btn.nest(nestedtype), nestedtype, monitor);
      break;
    case IJavaElement.METHOD:
    case IJavaElement.INITIALIZER:
    case IJavaElement.FIELD:
      processAnonymousInnerTypes(visitor, btn, (IMember) child, monitor);
      break;
    }
  }
}
 
開發者ID:eclipse,項目名稱:eclemma,代碼行數:22,代碼來源:TypeTraverser.java

示例2: collectCodeLenses

private void collectCodeLenses(ITypeRoot unit, IJavaElement[] elements, List<ICodeLens> lenses,
		IProgressMonitor monitor) throws JavaModelException {
	for (IJavaElement element : elements) {
		if (monitor.isCanceled()) {
			return;
		}
		if (element.getElementType() == IJavaElement.TYPE) {
			collectCodeLenses(unit, ((IType) element).getChildren(), lenses, monitor);
		} else if (element.getElementType() != IJavaElement.METHOD || JDTUtils.isHiddenGeneratedElement(element)) {
			continue;
		}

		// if (preferenceManager.getPreferences().isReferencesCodeLensEnabled()) {
		ICodeLens lens = getCodeLens(REFERENCES_TYPE, element, unit);
		lenses.add(lens);
		// }
		// if (preferenceManager.getPreferences().isImplementationsCodeLensEnabled() &&
		// element instanceof IType) {
		if (element instanceof IType) {
			IType type = (IType) element;
			if (type.isInterface() || Flags.isAbstract(type.getFlags())) {
				lens = getCodeLens(IMPLEMENTATION_TYPE, element, unit);
				lenses.add(lens);
			}
		}
	}
}
 
開發者ID:angelozerr,項目名稱:codelens-eclipse,代碼行數:27,代碼來源:JavaCodeLensProvider.java

示例3: getIMethodFromMethodWrapper

private static IMethod getIMethodFromMethodWrapper(MethodWrapper m) {
	try {
		IMember im = m.getMember();
		if (im.getElementType() == IJavaElement.METHOD) {
			return (IMethod) m.getMember();
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	return null;
}
 
開發者ID:eclipse,項目名稱:gemoc-studio,代碼行數:11,代碼來源:CallHierarchyHelper.java

示例4: getCurrentSelectedJavaMethod

/**
 * Returns currently selected method or <code>null</code>
 * @param editor
 * @return method or <code>null</code>
 * 
 */
public IMethod getCurrentSelectedJavaMethod(ITextEditor editor) {
	if (editor==null){
		return null;
	}
	
	IEditorInput editorInput = editor.getEditorInput();
	if (editorInput==null){
		return null;
	}
	IJavaElement elem = JavaUI.getEditorInputJavaElement(editorInput);
	if (elem instanceof ICompilationUnit) {
	    ITextSelection sel = (ITextSelection) editor.getSelectionProvider().getSelection();
	    IJavaElement selected;
		try {
			selected = ((ICompilationUnit) elem).getElementAt(sel.getOffset());
		} catch (JavaModelException e) {
			JunitUtil.logError("Was not able to get element at selection",e);
			return null;
		}
		if (selected==null){
			return null;
		}
	    if (selected.getElementType() == IJavaElement.METHOD) {
	         return (IMethod) selected;
	    }
	}
	return null;
}
 
開發者ID:de-jcup,項目名稱:egradle,代碼行數:34,代碼來源:JavaHelper.java

示例5: getCoverageFor

public ICoverageNode getCoverageFor(IJavaElement element) {
  final ICoverageNode coverage = coveragemap.get(element);
  if (coverage != null) {
    return coverage;
  }
  if (IJavaElement.METHOD == element.getElementType()) {
    resolveMethods((IType) element.getParent());
    return coveragemap.get(element);
  }
  return null;
}
 
開發者ID:eclipse,項目名稱:eclemma,代碼行數:11,代碼來源:JavaModelCoverage.java

示例6: collectChildren

private void collectChildren(ITypeRoot unit, IJavaElement[] elements, ArrayList<SymbolInformation> symbols,
		IProgressMonitor monitor)
		throws JavaModelException {
	for(IJavaElement element : elements ){
		if (monitor.isCanceled()) {
			return;
		}
		if(element instanceof IParent){
			collectChildren(unit, filter(((IParent) element).getChildren()), symbols, monitor);
		}
		int type = element.getElementType();
		if (type != IJavaElement.TYPE && type != IJavaElement.FIELD && type != IJavaElement.METHOD) {
			continue;
		}

		Location location = JDTUtils.toLocation(element);
		if (location != null) {
			SymbolInformation si = new SymbolInformation();
			String name = JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT);
			si.setName(name == null ? element.getElementName() : name);
			si.setKind(mapKind(element));
			if (element.getParent() != null) {
				si.setContainerName(element.getParent().getElementName());
			}
			location.setUri(ResourceUtils.toClientUri(location.getUri()));
			si.setLocation(location);
			if (!symbols.contains(si)) {
				symbols.add(si);
			}
		}
	}
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:32,代碼來源:DocumentSymbolHandler.java

示例7: isInitializer

private boolean isInitializer(IJavaElement element) {
	if (element.getElementType() == IJavaElement.METHOD) {
		String name = element.getElementName();
		if ((name != null && name.indexOf('<') >= 0)) {
			return true;
		}
	}
	return false;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:9,代碼來源:DocumentSymbolHandler.java

示例8: mapKind

public static SymbolKind mapKind(IJavaElement element) {
	switch (element.getElementType()) {
	case IJavaElement.ANNOTATION:
		return SymbolKind.Property; // TODO: find a better mapping
	case IJavaElement.CLASS_FILE:
	case IJavaElement.COMPILATION_UNIT:
		return SymbolKind.File;
	case IJavaElement.FIELD:
		return SymbolKind.Field;
	case IJavaElement.IMPORT_CONTAINER:
	case IJavaElement.IMPORT_DECLARATION:
		return SymbolKind.Module;
	case IJavaElement.INITIALIZER:
		return SymbolKind.Constructor;
	case IJavaElement.LOCAL_VARIABLE:
	case IJavaElement.TYPE_PARAMETER:
		return SymbolKind.Variable;
	case IJavaElement.METHOD:
		return SymbolKind.Method;
	case IJavaElement.PACKAGE_DECLARATION:
		return SymbolKind.Package;
	case IJavaElement.TYPE:
		try {
			return ( ((IType)element).isInterface() ? SymbolKind.Interface : SymbolKind.Class);
		} catch (JavaModelException e) {
			return SymbolKind.Class;
		}
	}
	return SymbolKind.String;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:30,代碼來源:DocumentSymbolHandler.java

示例9: getKind

private String getKind(IMember member) {
	switch (member.getElementType()) {
	case IJavaElement.METHOD:
		return KIND_METHOD;
	case IJavaElement.INITIALIZER:
		return KIND_INITIALIZER;
	case IJavaElement.FIELD:
		return KIND_FIELD;
	case IJavaElement.TYPE:
		IType type = (IType) member;
		try {
			if (type.isAnnotation()) {
				return KIND_ANNOTATION;
			}
			if (type.isInterface()) {
				return KIND_INTERFACE;
			}
			if (type.isEnum()) {
				return KIND_ENUM;
			}
			if (type.isClass()) {
				return KIND_CLASS;
			}
		} catch (JavaModelException e) {
			return KIND_TYPE;
		}
		return KIND_TYPE;
	default:
		return null;
	}
}
 
開發者ID:cchabanois,項目名稱:mesfavoris,代碼行數:31,代碼來源:JavaTypeMemberBookmarkPropertiesProvider.java

示例10: appendElementLabel

/**
 * Appends the label for a Java element with the flags as defined by this class.
 *
 * @param element the element to render
 * @param flags the rendering flags.
 */
public void appendElementLabel(IJavaElement element, long flags) {
	int type= element.getElementType();
	IPackageFragmentRoot root= null;

	if (type != IJavaElement.JAVA_MODEL && type != IJavaElement.JAVA_PROJECT && type != IJavaElement.PACKAGE_FRAGMENT_ROOT) {
		root= JavaModelUtil.getPackageFragmentRoot(element);
	}
	if (root != null && getFlag(flags, JavaElementLabels.PREPEND_ROOT_PATH)) {
		appendPackageFragmentRootLabel(root, JavaElementLabels.ROOT_QUALIFIED);
		fBuilder.append(JavaElementLabels.CONCAT_STRING);
	}

	switch (type) {
	case IJavaElement.METHOD:
		appendMethodLabel((IMethod) element, flags);
		break;
	case IJavaElement.FIELD:
		appendFieldLabel((IField) element, flags);
		break;
	case IJavaElement.LOCAL_VARIABLE:
		appendLocalVariableLabel((ILocalVariable) element, flags);
		break;
	case IJavaElement.TYPE_PARAMETER:
		appendTypeParameterLabel((ITypeParameter) element, flags);
		break;
	case IJavaElement.INITIALIZER:
		appendInitializerLabel((IInitializer) element, flags);
		break;
	case IJavaElement.TYPE:
		appendTypeLabel((IType) element, flags);
		break;
	case IJavaElement.CLASS_FILE:
		appendClassFileLabel((IClassFile) element, flags);
		break;
	case IJavaElement.COMPILATION_UNIT:
		appendCompilationUnitLabel((ICompilationUnit) element, flags);
		break;
	case IJavaElement.PACKAGE_FRAGMENT:
		appendPackageFragmentLabel((IPackageFragment) element, flags);
		break;
	case IJavaElement.PACKAGE_FRAGMENT_ROOT:
		appendPackageFragmentRootLabel((IPackageFragmentRoot) element, flags);
		break;
	case IJavaElement.IMPORT_CONTAINER:
	case IJavaElement.IMPORT_DECLARATION:
	case IJavaElement.PACKAGE_DECLARATION:
		appendDeclarationLabel(element, flags);
		break;
	case IJavaElement.JAVA_PROJECT:
	case IJavaElement.JAVA_MODEL:
		fBuilder.append(element.getElementName());
		break;
	default:
		fBuilder.append(element.getElementName());
	}

	if (root != null && getFlag(flags, JavaElementLabels.APPEND_ROOT_PATH)) {
		fBuilder.append(JavaElementLabels.CONCAT_STRING);
		appendPackageFragmentRootLabel(root, JavaElementLabels.ROOT_QUALIFIED);
	}
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:67,代碼來源:JavaElementLabelComposer.java

示例11: getHTMLContentReader

/**
 * Gets a reader for an IMember's Javadoc comment content from the source
 * attachment. and renders the tags in HTML. Returns <code>null</code> if
 * the member does not contain a Javadoc comment or if no source is
 * available.
 *
 * @param member
 *            the member to get the Javadoc of.
 * @param allowInherited
 *            for methods with no (Javadoc) comment, the comment of the
 *            overridden class is returned if <code>allowInherited</code> is
 *            <code>true</code>
 * @param useAttachedJavadoc
 *            if <code>true</code> Javadoc will be extracted from attached
 *            Javadoc if there's no source
 * @return a reader for the Javadoc comment content in HTML or
 *         <code>null</code> if the member does not contain a Javadoc
 *         comment or if no source is available
 * @throws JavaModelException
 *             is thrown when the elements Javadoc can not be accessed
 * @since 3.2
 */
static Reader getHTMLContentReader(IMember member, boolean allowInherited, boolean useAttachedJavadoc)
		throws JavaModelException {
	Reader contentReader= internalGetContentReader(member);
	if (contentReader != null) {
		return contentReader;
	}

	if (useAttachedJavadoc && member.getOpenable().getBuffer() == null) { // only if no source available
		String s= member.getAttachedJavadoc(null);
		if (s != null) {
			return new StringReader(s);
		}
	}

	if (allowInherited && (member.getElementType() == IJavaElement.METHOD)) {
		return findDocInHierarchy((IMethod) member, useAttachedJavadoc);
	}

	return null;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:42,代碼來源:JavadocContentAccess.java


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