当前位置: 首页>>代码示例>>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;未经允许,请勿转载。