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


Java IJavaElement.getElementName方法代碼示例

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


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

示例1: getTarget

import org.eclipse.jdt.core.IJavaElement; //導入方法依賴的package包/類
/**
 * Returns the target of this resource change.
 * @param elem the changed element
 * @return the target of the change, or an empty string if the target is not either a project, package, or file
 */
private String getTarget(IJavaElement elem) {
    if (elem == null) {
        return "";
    }
    
    int type = elem.getElementType();
    if (type == IJavaElement.JAVA_PROJECT) {
        return "Project";
        
    } else if (type == IJavaElement.PACKAGE_DECLARATION) {
        return "Package";
        
    } else if (type == IJavaElement.COMPILATION_UNIT) {
        return "File";
    }
    
    return elem.getElementName() + "@" + elem.getElementType();
}
 
開發者ID:liaoziyang,項目名稱:ContentAssist,代碼行數:24,代碼來源:ResourceMacro.java

示例2: getDefaultPackage

import org.eclipse.jdt.core.IJavaElement; //導入方法依賴的package包/類
public String getDefaultPackage() {
	WPILibJavaPlugin.logInfo("Project: "+project);
	String defaultPackage = null;
	if (project != null) {
		try {
			IPackageFragmentRoot root = JavaCore.create(project)
					.getPackageFragmentRoot(project.getFolder("src"));
			String backupPackage = "";
			for (IJavaElement child : root.getChildren()) {
				if (child.getElementType()==IJavaElement.PACKAGE_FRAGMENT
						&& child.getElementName().endsWith("."+ending)) {
					defaultPackage = child.getElementName();
				}
				backupPackage =  child.getElementName();
			}
			if (defaultPackage == null) defaultPackage = backupPackage;
		} catch (JavaModelException e) {
               WPILibJavaPlugin.logError("Error getting default package.", e);
		}
	}
	if (defaultPackage != null) return defaultPackage;
	else return "";
}
 
開發者ID:wpilibsuite,項目名稱:EclipsePlugins,代碼行數:24,代碼來源:FileTemplateWizardMainPage.java

示例3: getFullyQualifiedName

import org.eclipse.jdt.core.IJavaElement; //導入方法依賴的package包/類
/**
 * @param elt
 * @return
 * @throws JavaModelException
 */
public static String getFullyQualifiedName(IJavaElement elt) throws JavaModelException {
	IPackageFragmentRoot[] roots = elt.getJavaProject().getPackageFragmentRoots();
	for (int i = 0; i < roots.length; i++) {
		if (roots[i].getPath().isPrefixOf(elt.getPath())) {
			IPath p = elt.getPath().makeRelativeTo(roots[i].getPath());
			return p.toString();
		}
	}
	return elt.getElementName();
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:16,代碼來源:JDTManager.java

示例4: isInitializer

import org.eclipse.jdt.core.IJavaElement; //導入方法依賴的package包/類
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,代碼行數:10,代碼來源:DocumentSymbolHandler.java

示例5: getElementName

import org.eclipse.jdt.core.IJavaElement; //導入方法依賴的package包/類
/**
 * Returns the string for rendering the {@link IJavaElement#getElementName() element name} of
 * the given element.
 * <p>
 * <strong>Note:</strong> This class only calls this helper for those elements where (
 * {@link JavaElementLinks}) has the need to render the name differently.
 * </p>
 *
 * @param element the element to render
 * @return the string for rendering the element name
 */
protected String getElementName(IJavaElement element) {
	return element.getElementName();
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:15,代碼來源:JavaElementLabelComposer.java


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