当前位置: 首页>>代码示例>>Java>>正文


Java IClassFile.getType方法代码示例

本文整理汇总了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();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:MatchLocator.java

示例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;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:11,代码来源:ClassDetails.java

示例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();
}
 
开发者ID:eclipse,项目名称:eclemma,代码行数:15,代码来源:BinarySignatureResolverTest.java

示例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();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:SourceCreationOperation.java

示例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();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:StubCreationOperation.java

示例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
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:36,代码来源:PackageExplorerPart.java

示例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);

}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:38,代码来源:ClassFileDocumentProvider.java

示例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;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:29,代码来源:ClassFileEditorInputFactory.java

示例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);
}
 
开发者ID:eclipse,项目名称:eclemma,代码行数:7,代码来源:TypeTraverser.java


注:本文中的org.eclipse.jdt.core.IClassFile.getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。