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