本文整理匯總了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();
}