本文整理汇总了Java中org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput.getClassFile方法的典型用法代码示例。如果您正苦于以下问题:Java IClassFileEditorInput.getClassFile方法的具体用法?Java IClassFileEditorInput.getClassFile怎么用?Java IClassFileEditorInput.getClassFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput
的用法示例。
在下文中一共展示了IClassFileEditorInput.getClassFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createJavaProjectThroughActiveEditor
import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; //导入方法依赖的package包/类
private IJavaProject createJavaProjectThroughActiveEditor() {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if(page.getActiveEditor().getEditorInput() instanceof IFileEditorInput)
{
IFileEditorInput input = (IFileEditorInput) page.getActiveEditor().getEditorInput();
IFile file = input.getFile();
IProject activeProject = file.getProject();
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(activeProject.getName());
return JavaCore.create(project);
}
else if(page.getActiveEditor().getEditorInput() instanceof IClassFileEditorInput)
{
IClassFileEditorInput classFileEditorInput=(InternalClassFileEditorInput)page.getActiveEditor().getEditorInput() ;
IClassFile classFile=classFileEditorInput.getClassFile();
return classFile.getJavaProject();
}
return null;
}
示例2: setActiveEditor
import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; //导入方法依赖的package包/类
@Override
public void setActiveEditor(IAction action, IEditorPart part) {
if (part != null && part.getEditorInput() instanceof IClassFileEditorInput) {
Set<IPackageFragmentRoot> queue = new LinkedHashSet<>();
try {
IClassFileEditorInput input = (IClassFileEditorInput) part.getEditorInput();
IJavaElement element = input.getClassFile();
while (element.getParent() != null) {
element = element.getParent();
if (element instanceof IPackageFragmentRoot) {
IPackageFragmentRoot fragment = (IPackageFragmentRoot) element;
if (canProcess(fragment)) {
queue.add(fragment);
}
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
findSources(queue);
}
}
示例3: getProject
import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; //导入方法依赖的package包/类
private IJavaProject getProject() {
ITextEditor editor= getEditor();
if (editor == null)
return null;
IJavaElement element= null;
IEditorInput input= editor.getEditorInput();
IDocumentProvider provider= editor.getDocumentProvider();
if (provider instanceof ICompilationUnitDocumentProvider) {
ICompilationUnitDocumentProvider cudp= (ICompilationUnitDocumentProvider) provider;
element= cudp.getWorkingCopy(input);
} else if (input instanceof IClassFileEditorInput) {
IClassFileEditorInput cfei= (IClassFileEditorInput) input;
element= cfei.getClassFile();
}
if (element == null)
return null;
return element.getJavaProject();
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:JavaSourceViewerConfiguration.java
示例4: computeContainedMatches
import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; //导入方法依赖的package包/类
public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) {
//TODO same code in JavaSearchResult
IEditorInput editorInput= editor.getEditorInput();
if (editorInput instanceof IFileEditorInput) {
IFileEditorInput fileEditorInput= (IFileEditorInput) editorInput;
return computeContainedMatches(result, fileEditorInput.getFile());
} else if (editorInput instanceof IClassFileEditorInput) {
IClassFileEditorInput classFileEditorInput= (IClassFileEditorInput) editorInput;
IClassFile classFile= classFileEditorInput.getClassFile();
Object[] elements= getElements();
if (elements.length == 0)
return NO_MATCHES;
//all matches from same file:
JavaElementLine jel= (JavaElementLine) elements[0];
if (jel.getJavaElement().equals(classFile))
return collectMatches(elements);
}
return NO_MATCHES;
}
示例5: getCodeAssist
import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; //导入方法依赖的package包/类
protected ICodeAssist getCodeAssist() {
if (fEditor != null) {
IEditorInput input= fEditor.getEditorInput();
if (input instanceof IClassFileEditorInput) {
IClassFileEditorInput cfeInput= (IClassFileEditorInput) input;
return cfeInput.getClassFile();
}
WorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();
return manager.getWorkingCopy(input, false);
}
return null;
}