本文整理汇总了Java中org.eclipse.jdt.core.ICompilationUnit.getElementName方法的典型用法代码示例。如果您正苦于以下问题:Java ICompilationUnit.getElementName方法的具体用法?Java ICompilationUnit.getElementName怎么用?Java ICompilationUnit.getElementName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.ICompilationUnit
的用法示例。
在下文中一共展示了ICompilationUnit.getElementName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTypeOfOpenJavaEditor
import org.eclipse.jdt.core.ICompilationUnit; //导入方法依赖的package包/类
public static IType getTypeOfOpenJavaEditor() {
IJavaElement activeEditorJavaInput = EditorUtility.getActiveEditorJavaInput();
if (activeEditorJavaInput != null) {
if (activeEditorJavaInput.getElementType() == IJavaElement.COMPILATION_UNIT) {
try {
ICompilationUnit iCompilationUnit = (ICompilationUnit) activeEditorJavaInput;
String elementName = iCompilationUnit.getElementName();
elementName = elementName.substring(0,
elementName.lastIndexOf('.'));
IType[] types = iCompilationUnit.getTypes();
for (IType type : types) {
String fullyQualifiedName = type
.getFullyQualifiedName();
if (fullyQualifiedName.contains(elementName)) {
return type;
}
}
} catch (JavaModelException e1) {
e1.printStackTrace();
}
}
} else {
System.err.println("Java Editor is not open");
}
return null;
}
示例2: getClassName
import org.eclipse.jdt.core.ICompilationUnit; //导入方法依赖的package包/类
public String getClassName() {
if (isCreateMode()) {
return newClassnameText.getText();
}
if (isExtendMode()) {
return extendingClassnameText.getText();
}
IStructuredSelection selection = (IStructuredSelection) comboAppendClassnameViewer.getSelection();
ICompilationUnit unit = (ICompilationUnit) selection.getFirstElement();
return unit.getElementName();
}
示例3: build
import org.eclipse.jdt.core.ICompilationUnit; //导入方法依赖的package包/类
/**
* @see IBuilder#build
*/
@Override
public void build(Measure measure, ItemMeasured item) {
try {
ItemMeasured classItem;
for (ICompilationUnit unit : myPackage.getCompilationUnits()) {
classItem = new ItemMeasured(unit.getElementName(), item);
measure.measure(unit);
classItem.addValue(measure.getCalculatedValue());
classItem.addMean(measure.getMeanValue());
classItem.setMax(measure.getMaxValue());
classItem.setClassWithMax(measure.getClassWithMaxValue());
if (measure.isApplicableGranularity(Granularity.METHOD)) {
addMethodsBuilder(measure, unit, classItem);
item.addValue(classItem.getValue());
item.addMean(classItem.getMean());
item.setMax(classItem.getMax());
item.setClassWithMax(classItem.getClassWithMax());
} else {
item.addValue(measure.getCalculatedValue());
item.addMean(measure.getMeanValue());
item.setMax(measure.getMaxValue());
item.setClassWithMax(measure.getClassWithMaxValue());
}
item.addChild(classItem);
}
} catch (JavaModelException exception) {
logger.error(exception);
}
}