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


Java JavaModelUtil.isPrimary方法代码示例

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


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

示例1: isRenameAvailable

import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
public static boolean isRenameAvailable(final ICompilationUnit unit) {
	if (unit == null)
		return false;
	if (!unit.exists())
		return false;
	if (!JavaModelUtil.isPrimary(unit))
		return false;
	if (unit.isReadOnly())
		return false;
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:RefactoringAvailabilityTester.java

示例2: updateSelectionProvider

import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
private void updateSelectionProvider(IPageSite site) {
	ISelectionProvider provider= fOutlineViewer;
	if (fInput != null) {
		ICompilationUnit cu= (ICompilationUnit)fInput.getAncestor(IJavaElement.COMPILATION_UNIT);
		if (cu != null && !JavaModelUtil.isPrimary(cu))
			provider= new EmptySelectionProvider();
	}
	site.setSelectionProvider(provider);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:JavaOutlinePage.java

示例3: findEditor

import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
/**
 * Tries to find the editor for the given input element.
 * 
 * @param inputElement the input element
 * @param activate <code>true</code> if the found editor should be activated
 * @return the editor or <code>null</code>
 * @since 3.5
 */
private static IEditorPart findEditor(Object inputElement, boolean activate) {
	/*
	 * Support to navigate inside non-primary working copy.
	 * For now we only support to navigate inside the currently
	 * active editor.
	 *
	 * XXX: once we have FileStoreEditorInput as API,
	 * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=111887
	 * we can fix this code by creating the correct editor input
	 * in getEditorInput(Object)
	 */
	if (inputElement instanceof IJavaElement) {
		ICompilationUnit cu= (ICompilationUnit)((IJavaElement)inputElement).getAncestor(IJavaElement.COMPILATION_UNIT);
		if (cu != null) {
			IWorkbenchPage page= JavaPlugin.getActivePage();
			IEditorPart editor= page != null ? editor= page.getActiveEditor() : null;
			if (editor != null) {
				boolean isCompareEditorInput= isCompareEditorInput(editor.getEditorInput());
				if (isCompareEditorInput || !JavaModelUtil.isPrimary(cu)) {
					IEditorInput editorInput;
					if (isCompareEditorInput)
						editorInput= (IEditorInput)editor.getAdapter(IEditorInput.class);
					else
						editorInput= editor.getEditorInput();
					IJavaElement editorCU= getEditorInputJavaElement(editorInput, false);
					if (cu.equals(editorCU)) {
						if (activate && page.getActivePart() != editor)
							page.activate(editor);
						return editor;
					}
				}
			}
		}
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:45,代码来源:EditorUtility.java

示例4: createFileInfo

import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
@Override
protected FileInfo createFileInfo(Object element) throws CoreException {
	ICompilationUnit original= null;
	if (element instanceof IFileEditorInput) {
		IFileEditorInput input= (IFileEditorInput) element;
		original= createCompilationUnit(input.getFile());
		if (original == null)
			return null;
	}

	FileInfo info= super.createFileInfo(element);
	if (!(info instanceof CompilationUnitInfo))
		return null;

	if (original == null)
		original= createFakeCompiltationUnit(element, false);
	if (original == null)
		return null;

	CompilationUnitInfo cuInfo= (CompilationUnitInfo) info;
	setUpSynchronization(cuInfo);

	IProblemRequestor requestor= cuInfo.fModel instanceof IProblemRequestor ? (IProblemRequestor) cuInfo.fModel : null;
	if (requestor instanceof IProblemRequestorExtension) {
		IProblemRequestorExtension extension= (IProblemRequestorExtension) requestor;
		extension.setIsActive(false);
		extension.setIsHandlingTemporaryProblems(isHandlingTemporaryProblems());
	}

	IResource resource= original.getResource();
	if (JavaModelUtil.isPrimary(original) && (resource == null || resource.exists()))
		original.becomeWorkingCopy(requestor, getProgressMonitor());
	cuInfo.fCopy= original;

	if (cuInfo.fModel instanceof CompilationUnitAnnotationModel)   {
		CompilationUnitAnnotationModel model= (CompilationUnitAnnotationModel) cuInfo.fModel;
		model.setCompilationUnit(cuInfo.fCopy);
	}

	if (cuInfo.fModel != null)
		cuInfo.fModel.addAnnotationModelListener(fGlobalAnnotationModelListener);

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

示例5: createSaveOperation

import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
@Override
protected DocumentProviderOperation createSaveOperation(final Object element, final IDocument document, final boolean overwrite) throws CoreException {
	final FileInfo info= getFileInfo(element);
	if (info instanceof CompilationUnitInfo) {

		// Delegate handling of non-primary CUs
		ICompilationUnit cu= ((CompilationUnitInfo)info).fCopy;
		if (cu != null && !JavaModelUtil.isPrimary(cu))
			return super.createSaveOperation(element, document, overwrite);

		if (info.fTextFileBuffer.getDocument() != document) {
			// the info exists, but not for the given document
			// -> saveAs was executed with a target that is already open
			// in another editor
			// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=85519
			Status status= new Status(IStatus.WARNING, EditorsUI.PLUGIN_ID, IStatus.ERROR, JavaEditorMessages.CompilationUnitDocumentProvider_saveAsTargetOpenInEditor, null);
			throw new CoreException(status);
		}

		return new DocumentProviderOperation() {
			/*
			 * @see org.eclipse.ui.editors.text.TextFileDocumentProvider.DocumentProviderOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
			 */
			@Override
			protected void execute(IProgressMonitor monitor) throws CoreException {
				commitWorkingCopy(monitor, element, (CompilationUnitInfo) info, overwrite);
			}
			/*
			 * @see org.eclipse.ui.editors.text.TextFileDocumentProvider.DocumentProviderOperation#getSchedulingRule()
			 */
			@Override
			public ISchedulingRule getSchedulingRule() {
				if (info.fElement instanceof IFileEditorInput) {
					IFile file= ((IFileEditorInput) info.fElement).getFile();
					return computeSchedulingRule(file);
				} else
					return null;
			}
		};
	}

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

示例6: processDelta

import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
private void processDelta(IJavaElementDelta delta, ArrayList<IType> changedTypes) {
	IJavaElement element= delta.getElement();
	switch (element.getElementType()) {
		case IJavaElement.TYPE:
			processTypeDelta((IType) element, changedTypes);
			processChildrenDelta(delta, changedTypes); // (inner types)
			break;
		case IJavaElement.JAVA_MODEL:
		case IJavaElement.JAVA_PROJECT:
		case IJavaElement.PACKAGE_FRAGMENT_ROOT:
		case IJavaElement.PACKAGE_FRAGMENT:
			processChildrenDelta(delta, changedTypes);
			break;
		case IJavaElement.COMPILATION_UNIT:
			ICompilationUnit cu= (ICompilationUnit)element;
			if (!JavaModelUtil.isPrimary(cu)) {
				return;
			}

			if (delta.getKind() == IJavaElementDelta.CHANGED && isPossibleStructuralChange(delta.getFlags())) {
				try {
					if (cu.exists()) {
						IType[] types= cu.getAllTypes();
						for (int i= 0; i < types.length; i++) {
							processTypeDelta(types[i], changedTypes);
						}
					}
				} catch (JavaModelException e) {
					JavaPlugin.log(e);
				}
			} else {
				processChildrenDelta(delta, changedTypes);
			}
			break;
		case IJavaElement.CLASS_FILE:
			if (delta.getKind() == IJavaElementDelta.CHANGED) {
				IType type= ((IClassFile) element).getType();
				processTypeDelta(type, changedTypes);
			} else {
				processChildrenDelta(delta, changedTypes);
			}
			break;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:45,代码来源:TypeHierarchyLifeCycle.java

示例7: processDelta

import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
@Override
protected void processDelta(IJavaElementDelta delta, List<IJavaElement> result) {
	IJavaElement elem= delta.getElement();

	boolean isChanged= delta.getKind() == IJavaElementDelta.CHANGED;
	boolean isRemoved= delta.getKind() == IJavaElementDelta.REMOVED;
	int flags= delta.getFlags();

	switch (elem.getElementType()) {
		case IJavaElement.JAVA_PROJECT:
			if (isRemoved || (isChanged &&
					(flags & IJavaElementDelta.F_CLOSED) != 0)) {
				return;
			}
			processChildrenDelta(delta, result);
			return;
		case IJavaElement.PACKAGE_FRAGMENT_ROOT:
			if (isRemoved || (isChanged && (
					(flags & IJavaElementDelta.F_ARCHIVE_CONTENT_CHANGED) != 0 ||
					(flags & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) != 0))) {
				return;
			}
			processChildrenDelta(delta, result);
			return;
		case IJavaElement.PACKAGE_FRAGMENT:
			if (isRemoved)
				return;
			processChildrenDelta(delta, result);
			return;
		case IJavaElement.TYPE:
		case IJavaElement.CLASS_FILE:
			return;
		case IJavaElement.JAVA_MODEL:
			processChildrenDelta(delta, result);
			return;
		case IJavaElement.COMPILATION_UNIT:
			// Not the primary compilation unit. Ignore it
			if (!JavaModelUtil.isPrimary((ICompilationUnit) elem)) {
				return;
			}

			if (isChanged &&  ((flags & IJavaElementDelta.F_CONTENT) != 0 || (flags & IJavaElementDelta.F_FINE_GRAINED) != 0)) {
				if (delta.getAffectedChildren().length == 0)
					return;

				result.add(elem);
			}
			return;
		default:
			// fields, methods, imports ect
			return;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:54,代码来源:InterfaceIndicatorLabelDecorator.java

示例8: getWorkingCopy

import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
/**
 * Returns the working copy remembered for the compilation unit encoded in the
 * given editor input.
 * <p>
 * Note: This method must not be part of the public {@link IWorkingCopyManager} API.
 * </p>
 *
 * @param input the editor input
 * @param primaryOnly if <code>true</code> only primary working copies will be returned
 * @return the working copy of the compilation unit, or <code>null</code> if the
 *   input does not encode an editor input, or if there is no remembered working
 *   copy for this compilation unit
 * @since 3.2
 */
public ICompilationUnit getWorkingCopy(IEditorInput input, boolean primaryOnly) {
	ICompilationUnit unit= fMap == null ? null : fMap.get(input);
	if (unit == null)
		unit= fDocumentProvider.getWorkingCopy(input);
	if (unit != null && (!primaryOnly || JavaModelUtil.isPrimary(unit)))
		return unit;
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:WorkingCopyManager.java


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