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


Java EditorUtility.getActiveEditorJavaInput方法代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.getActiveEditorJavaInput方法的典型用法代码示例。如果您正苦于以下问题:Java EditorUtility.getActiveEditorJavaInput方法的具体用法?Java EditorUtility.getActiveEditorJavaInput怎么用?Java EditorUtility.getActiveEditorJavaInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.internal.ui.javaeditor.EditorUtility的用法示例。


在下文中一共展示了EditorUtility.getActiveEditorJavaInput方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMethodDeclaration

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
public static MethodDeclaration getMethodDeclaration(String methodName) {
	IJavaElement javaElem = EditorUtility.getActiveEditorJavaInput();
	if (javaElem.getElementType() == IJavaElement.COMPILATION_UNIT) {
		ICompilationUnit iCompUnit = (ICompilationUnit) javaElem;
		ASTNode astNode = Crystal.getInstance()
				.getASTNodeFromCompilationUnit(iCompUnit);
		if (astNode != null
				&& astNode.getNodeType() == ASTNode.COMPILATION_UNIT) {
			CompilationUnit compUnit = (CompilationUnit) astNode;
			for (Object declaration : compUnit.types()) {
				if (declaration instanceof TypeDeclaration) {
					for (MethodDeclaration method : ((TypeDeclaration) declaration)
							.getMethods()) {
						if (methodName.contentEquals(method.getName()
								.getFullyQualifiedName())) {
							return method;
						}
					}
				}
			}
		}
	}
	return null;
}
 
开发者ID:aroog,项目名称:code,代码行数:25,代码来源:ASTUtils.java

示例2: getTypeOfOpenJavaEditor

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的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;
}
 
开发者ID:aroog,项目名称:code,代码行数:27,代码来源:ASTUtils.java

示例3: init

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
public void init(IWorkbench workbench, IStructuredSelection structuredSelection) {
	IWorkbenchWindow window= workbench.getActiveWorkbenchWindow();
	List<?> selected= Collections.EMPTY_LIST;
	if (window != null) {
		ISelection selection= window.getSelectionService().getSelection();
		if (selection instanceof IStructuredSelection) {
			selected= ((IStructuredSelection) selection).toList();
		} else {
			IJavaElement element= EditorUtility.getActiveEditorJavaInput();
			if (element != null) {
				selected= Arrays.asList(element);
			}
		}
	}
	fStore= new JavadocOptionsManager(fXmlJavadocFile, getDialogSettings(), selected);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:JavadocWizard.java

示例4: getProjectPath

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
private String getProjectPath(IStructuredSelection selection) {
	Object selectedElement= null;
	if (selection == null || selection.isEmpty()) {
		selectedElement= EditorUtility.getActiveEditorJavaInput();
	} else if (selection.size() == 1) {
		selectedElement= selection.getFirstElement();
	}

	if (selectedElement instanceof IResource) {
		IProject proj= ((IResource)selectedElement).getProject();
		if (proj != null) {
			return proj.getFullPath().makeRelative().toString();
		}
	} else if (selectedElement instanceof IJavaElement) {
		IJavaProject jproject= ((IJavaElement)selectedElement).getJavaProject();
		if (jproject != null) {
			return jproject.getProject().getFullPath().makeRelative().toString();
		}
	}

	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:NewSourceFolderWizardPage.java

示例5: getASTNode

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
public static ASTNode getASTNode(int offset, int length, IEditorPart part) {
	IJavaElement activeEditorJavaInput = null;
	if (part != null) {
		IEditorInput editorInput = part.getEditorInput();
		if (editorInput != null) {
			activeEditorJavaInput = JavaUI
					.getEditorInputJavaElement(editorInput);
		}
	} else {
		activeEditorJavaInput = EditorUtility.getActiveEditorJavaInput();
		part = getActivePart();
	}

	if (activeEditorJavaInput != null
			&& activeEditorJavaInput.getElementType() == IJavaElement.COMPILATION_UNIT) {

		ICompilationUnit compilationUnit = (ICompilationUnit) activeEditorJavaInput;
		ASTParser parser = ASTParser.newParser(AST.JLS3);
		parser.setKind(ASTParser.K_COMPILATION_UNIT);
		parser.setSource(compilationUnit);
		parser.setResolveBindings(true);
		ASTNode root = parser.createAST(null);

		ASTNode node = NodeFinder.perform(root, offset, length);
		return node;
	}
	return null;
}
 
开发者ID:aroog,项目名称:code,代码行数:29,代码来源:ASTUtils.java

示例6: updateTabs

import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
public void updateTabs() {
	if(LogWriter.isEmptyProjectTypes())
		LogWriter.initProjectTypes();
	String fullName = "";
	RankedTableViewer.resetRank();
	
	
	if (edgeSummaryAll != null) {
		IJavaElement activeEditorJavaInput = EditorUtility
				.getActiveEditorJavaInput();

		Tab currentTab = getCurrentTab();
		if (activeEditorJavaInput != null) {
			if (currentTab.equals(Tab.MIC)) {
				tableViewer.setInput(edgeSummaryAll
						.getMostImportantClasses());
				setContentDescription("Not Class Specific");
			}
			if (!currentTab.equals(Tab.MCBI)) {
				IType currentType = ASTUtils.getTypeOfOpenJavaEditor();
				if(currentType != null){
					fullName = ASTUtils.getTypeOfOpenJavaEditor().getFullyQualifiedName();
					//Set opened type as Visited
					updateVisitedType(fullName);
					
					setContentDescription(fullName);
					ITypeBinding binding = Crystal.getInstance().getTypeBindingFromName(fullName);
					
					if (currentTab.equals(Tab.MIRC)) {
						tableViewer.setInput(edgeSummaryAll
								.getMostImportantRelatedClass(fullName));
						// add logs
						if (LogWriter.LogState == 1)
						if (LogWriter.CheckedTypes.add(fullName)) {
								// System.out.println(currentType.getElementName());
							//no need to leave comments when open a new type
								/*LogComment lc = new LogComment();
								synchronized (lc) {
									while (!LogWriter.CmmLock) {
										try {
											lc.wait();
										} catch (InterruptedException e) {
											e.printStackTrace();
										}
									}
								}
								LogWriter.CmmLock = false;*/
								LogWriter.Reason = "";
								LogWriter.setLogs(binding, edgeSummaryAll
														.getMostImportantRelatedClass(fullName), "Visited");
								LogWriter.OrderNum++;
							}
					}
					if (currentTab.equals(Tab.MIM)) {
						tableViewer.setInput(edgeSummaryAll.getMostImportantMethods(fullName));
					}
				}
			}
		}
	}
}
 
开发者ID:aroog,项目名称:code,代码行数:62,代码来源:SummaryView.java


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