/** * 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; }
/** * 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 : (ICompilationUnit) fMap.get(input); if (unit == null) unit= fDocumentProvider.getWorkingCopy(input); if (unit != null && (!primaryOnly || JavaModelUtil.isPrimary(unit))) return unit; return null; }
/** * 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; }
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; }
private boolean isProcessable() { if (fEditor != null) { IJavaElement je= EditorUtility.getEditorInputJavaElement(fEditor, false); if (je instanceof ICompilationUnit && !JavaModelUtil.isPrimary((ICompilationUnit)je)) return true; // can process non-primary working copies } return ActionUtil.isProcessable(fEditor); }
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; }
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; }
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; }
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); }
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); }
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); }
if (cu != null && !JavaModelUtil.isPrimary(cu)) return super.createSaveOperation(element, document, overwrite);
private static void releaseDocument(ICompilationUnit cu, IDocument document, IProgressMonitor monitor) throws CoreException { if (JavaModelUtil.isPrimary(cu)) { IFile file= (IFile) cu.getResource(); if (file.exists()) { ITextFileBufferManager bufferManager= FileBuffers.getTextFileBufferManager(); bufferManager.disconnect(file.getFullPath(), LocationKind.IFILE, monitor); return; } } cu.getBuffer().setContents(document.get()); monitor.done(); }
private static IDocument aquireDocument(ICompilationUnit cu, IProgressMonitor monitor) throws CoreException { if (JavaModelUtil.isPrimary(cu)) { IFile file= (IFile) cu.getResource(); if (file.exists()) { ITextFileBufferManager bufferManager= FileBuffers.getTextFileBufferManager(); IPath path= cu.getPath(); bufferManager.connect(path, LocationKind.IFILE, monitor); return bufferManager.getTextFileBuffer(path, LocationKind.IFILE).getDocument(); } } monitor.done(); return new Document(cu.getSource()); }
private static IMethod toOriginalMethod(IMethod method) { ICompilationUnit cu= method.getCompilationUnit(); if (cu == null || isPrimary(cu)) { return method; } try{ //use the workaround only if needed if (! method.getElementName().equals(method.getDeclaringType().getElementName())) return (IMethod) method.getPrimaryElement(); IType originalType = (IType) toOriginal(method.getDeclaringType()); IMethod[] methods = originalType.findMethods(method); boolean isConstructor = method.isConstructor(); for (int i=0; i < methods.length; i++) { if (methods[i].isConstructor() == isConstructor) return methods[i]; } return null; } catch (JavaModelException e){ return null; } }
private static void commitDocument(ICompilationUnit cu, IDocument document, TextEdit edit, IProgressMonitor monitor) throws CoreException, MalformedTreeException, BadLocationException { if (JavaModelUtil.isPrimary(cu)) { IFile file= (IFile) cu.getResource(); if (file.exists()) { IStatus status= Resources.makeCommittable(file, null); if (!status.isOK()) { throw new ValidateEditException(status); } new RewriteSessionEditProcessor(document, edit, TextEdit.UPDATE_REGIONS).performEdits(); // apply after file is commitable ITextFileBufferManager bufferManager= FileBuffers.getTextFileBufferManager(); bufferManager.getTextFileBuffer(file.getFullPath(), LocationKind.IFILE).commit(monitor, true); return; } } // no commit possible, make sure changes are in new RewriteSessionEditProcessor(document, edit, TextEdit.UPDATE_REGIONS).performEdits(); }
if (JavaModelUtil.isPrimary(original)) original.becomeWorkingCopy(requestor, getProgressMonitor()); cuInfo.fCopy= original;
if (JavaModelUtil.isPrimary(original) && (resource == null || resource.exists())) original.becomeWorkingCopy(requestor, getProgressMonitor()); cuInfo.fCopy= original;
if (JavaModelUtil.isPrimary(original) && (resource == null || resource.exists())) original.becomeWorkingCopy(requestor, getProgressMonitor()); cuInfo.fCopy= original;
case IJavaElement.COMPILATION_UNIT: ICompilationUnit cu= (ICompilationUnit)element; if (!JavaModelUtil.isPrimary(cu)) { return;