本文整理汇总了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();
}
示例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 "";
}
示例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();
}
示例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;
}
示例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();
}