本文整理汇总了Java中org.eclipse.jdt.core.IClassFile.getType方法的典型用法代码示例。如果您正苦于以下问题:Java IClassFile.getType方法的具体用法?Java IClassFile.getType怎么用?Java IClassFile.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.IClassFile
的用法示例。
在下文中一共展示了IClassFile.getType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTypeHandle
import org.eclipse.jdt.core.IClassFile; //导入方法依赖的package包/类
/**
* Creates an IType from the given simple top level type name.
*/
protected IType createTypeHandle(String simpleTypeName) {
Openable openable = this.currentPossibleMatch.openable;
if (openable instanceof CompilationUnit)
return ((CompilationUnit) openable).getType(simpleTypeName);
IType binaryType = ((ClassFile) openable).getType();
String binaryTypeQualifiedName = binaryType.getTypeQualifiedName();
if (simpleTypeName.equals(binaryTypeQualifiedName))
return binaryType; // answer only top-level types, sometimes the classFile is for a member/local type
// type name may be null for anonymous (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=164791)
String classFileName = simpleTypeName.length() == 0 ? binaryTypeQualifiedName : simpleTypeName;
IClassFile classFile = binaryType.getPackageFragment().getClassFile(classFileName + SuffixConstants.SUFFIX_STRING_class);
return classFile.getType();
}
示例2: getJavaDoc
import org.eclipse.jdt.core.IClassFile; //导入方法依赖的package包/类
private String getJavaDoc(IClassFile classFile) throws JavaModelException {
BinaryType binaryType=(BinaryType)classFile.getType();
if(binaryType.getSource() !=null && binaryType.getJavadocRange()!=null){
String javaDoc=Constants.EMPTY_STRING;
javaDoc = StringUtils.substring(binaryType.getSource().toString(), 0, binaryType.getJavadocRange().getLength());
javaDoc = StringUtils.replaceEachRepeatedly(javaDoc, new String[] { "/*", "*/", "*" }, new String[] {
Constants.EMPTY_STRING, Constants.EMPTY_STRING, Constants.EMPTY_STRING });
}
return javaDoc;
}
示例3: setup
import org.eclipse.jdt.core.IClassFile; //导入方法依赖的package包/类
@Before
public void setup() throws Exception {
javaProject = new JavaProjectKit();
javaProject.enableJava5();
final IPackageFragmentRoot root = javaProject.createJAR(
"testdata/bin/signatureresolver.jar", "/signatureresolver.jar",
new Path("/UnitTestProject/signatureresolver.jar"), null);
JavaProjectKit.waitForBuild();
javaProject.assertNoErrors();
final IClassFile classFile = root.getPackageFragment("signatureresolver")
.getClassFile("Samples.class");
type = classFile.getType();
createMethodIndex();
}
示例4: run
import org.eclipse.jdt.core.IClassFile; //导入方法依赖的package包/类
/**
* Runs the stub generation on the specified class file.
*
* @param file
* the class file
* @param parent
* the parent store
* @param monitor
* the progress monitor to use
* @throws CoreException
* if an error occurs
*/
@Override
protected void run(final IClassFile file, final IFileStore parent, final IProgressMonitor monitor) throws CoreException {
try {
monitor.beginTask(getOperationLabel(), 2);
final IType type= file.getType();
if (type.isAnonymous() || type.isLocal() || type.isMember())
return;
final String source= file.getSource();
createCompilationUnit(parent, type.getElementName() + JavaModelUtil.DEFAULT_CU_SUFFIX, source != null ? source : "", monitor); //$NON-NLS-1$
} finally {
monitor.done();
}
}
示例5: run
import org.eclipse.jdt.core.IClassFile; //导入方法依赖的package包/类
/**
* Runs the stub generation on the specified class file.
*
* @param file
* the class file
* @param parent
* the parent store
* @param monitor
* the progress monitor to use
* @throws CoreException
* if an error occurs
*/
@Override
protected void run(final IClassFile file, final IFileStore parent, final IProgressMonitor monitor) throws CoreException {
try {
monitor.beginTask(RefactoringCoreMessages.StubCreationOperation_creating_type_stubs, 2);
SubProgressMonitor subProgressMonitor= new SubProgressMonitor(monitor, 1);
final IType type= file.getType();
if (type.isAnonymous() || type.isLocal() || type.isMember())
return;
String source= new StubCreator(fStubInvisible).createStub(type, subProgressMonitor);
createCompilationUnit(parent, type.getElementName() + JavaModelUtil.DEFAULT_CU_SUFFIX, source, monitor);
} finally {
monitor.done();
}
}
示例6: expandMainType
import org.eclipse.jdt.core.IClassFile; //导入方法依赖的package包/类
/**
* A compilation unit or class was expanded, expand
* the main type.
* @param element the element
*/
void expandMainType(Object element) {
try {
IType type= null;
if (element instanceof ICompilationUnit) {
ICompilationUnit cu= (ICompilationUnit)element;
IType[] types= cu.getTypes();
if (types.length > 0)
type= types[0];
}
else if (element instanceof IClassFile) {
IClassFile cf= (IClassFile)element;
type= cf.getType();
}
if (type != null) {
final IType type2= type;
Control ctrl= fViewer.getControl();
if (ctrl != null && !ctrl.isDisposed()) {
ctrl.getDisplay().asyncExec(new Runnable() {
public void run() {
Control ctrl2= fViewer.getControl();
if (ctrl2 != null && !ctrl2.isDisposed())
fViewer.expandToLevel(type2, 1);
}
});
}
}
} catch(JavaModelException e) {
// no reveal
}
}
示例7: handleDeleted
import org.eclipse.jdt.core.IClassFile; //导入方法依赖的package包/类
/**
* Handles the deletion of the element underlying the given class file editor input.
* @param input the editor input
*/
protected void handleDeleted(IClassFileEditorInput input) {
if (input == null) {
fireElementDeleted(input);
return;
}
if (input.exists())
return;
IClassFile cf= input.getClassFile();
try {
/*
* Let's try to find the class file - maybe the JAR changed
*/
IType type= cf.getType();
IJavaProject project= cf.getJavaProject();
if (project != null) {
type= project.findType(type.getFullyQualifiedName());
if (type != null) {
IEditorInput editorInput= EditorUtility.getEditorInput(type.getParent());
if (editorInput instanceof IClassFileEditorInput) {
fireInputChanged((IClassFileEditorInput)editorInput);
return;
}
}
}
} catch (JavaModelException x) {
// Don't log and fall through: element deleted
}
fireElementDeleted(input);
}
示例8: createElement
import org.eclipse.jdt.core.IClassFile; //导入方法依赖的package包/类
public IAdaptable createElement(IMemento memento) {
String identifier= memento.getString(KEY);
if (identifier == null)
return null;
IJavaElement element= JavaCore.create(identifier);
try {
if (!element.exists() && element instanceof IClassFile) {
/*
* Let's try to find the class file,
* see https://bugs.eclipse.org/bugs/show_bug.cgi?id=83221
*/
IClassFile cf= (IClassFile)element;
IType type= cf.getType();
IJavaProject project= element.getJavaProject();
if (project != null) {
type= project.findType(type.getFullyQualifiedName());
if (type == null)
return null;
element= type.getParent();
}
}
return EditorUtility.getEditorInput(element);
} catch (JavaModelException x) {
// Don't report but simply return null
return null;
}
}
示例9: processClassFile
import org.eclipse.jdt.core.IClassFile; //导入方法依赖的package包/类
private void processClassFile(ITypeVisitor visitor, IClassFile file,
IProgressMonitor monitor) throws JavaModelException {
visitor.visit(file);
final IType type = file.getType();
processType(visitor, new BinaryTypeName(type), type, monitor);
}