X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/Openable.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/Openable.java index 4fbafee..1364b4f 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/Openable.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/Openable.java @@ -1,10 +1,10 @@ /******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials + * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -20,6 +20,7 @@ import net.sourceforge.phpdt.core.BufferChangedEvent; import net.sourceforge.phpdt.core.IBuffer; import net.sourceforge.phpdt.core.IBufferChangedListener; import net.sourceforge.phpdt.core.IBufferFactory; +import net.sourceforge.phpdt.core.ICodeAssist; import net.sourceforge.phpdt.core.IJavaElement; import net.sourceforge.phpdt.core.IJavaModelStatusConstants; import net.sourceforge.phpdt.core.IOpenable; @@ -59,8 +60,8 @@ protected Openable(JavaElement parent, String name) { } else { JavaModelManager.getJavaModelManager().getElementsOutOfSynchWithBuffers().put(this, this); } - } - + } + /** * Builds this element's structure and properties in the given * info object, based on this element's current contents (reuse buffer @@ -81,7 +82,7 @@ protected Openable(JavaElement parent, String name) { //protected void buildStructure(OpenableElementInfo info, IProgressMonitor monitor) throws JavaModelException { // // if (monitor != null && monitor.isCanceled()) return; -// +// // // remove existing (old) infos // removeInfo(); // HashMap newElements = new HashMap(11); @@ -92,11 +93,11 @@ protected Openable(JavaElement parent, String name) { // Object value = newElements.get(key); // JavaModelManager.getJavaModelManager().putInfo(key, value); // } -// +// // // add the info for this at the end, to ensure that a getInfo cannot reply null in case the LRU cache needs // // to be flushed. Might lead to performance issues. // // see PR 1G2K5S7: ITPJCORE:ALL - NPE when accessing source for a binary type -// JavaModelManager.getJavaModelManager().putInfo(this, info); +// JavaModelManager.getJavaModelManager().putInfo(this, info); //} /* * Returns whether this element can be removed from the Java model cache to make space. @@ -147,9 +148,9 @@ protected void closing(Object info) { ///** // * @see ICodeAssist // */ -//protected void codeComplete(org.eclipse.jdt.internal.compiler.env.ICompilationUnit cu, org.eclipse.jdt.internal.compiler.env.ICompilationUnit unitToSkip, int position, ICompletionRequestor requestor) throws JavaModelException { +//protected void codeComplete(net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit cu, net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit unitToSkip, int position, ICompletionRequestor requestor) throws JavaModelException { // if (requestor == null) { -// throw new IllegalArgumentException(Util.bind("codeAssist.nullRequestor")); //$NON-NLS-1$ +// throw new IllegalArgumentException(ProjectPrefUtil.bind("codeAssist.nullRequestor")); //$NON-NLS-1$ // } // IBuffer buffer = getBuffer(); // if (buffer == null) { @@ -191,7 +192,7 @@ protected void closing(Object info) { // // fix for 1FVGGKF // JavaProject project = (JavaProject)getJavaProject(); // ISearchableNameEnvironment environment = project.getSearchableNameEnvironment(); -// +// // // fix for 1FVXGDK // SelectionEngine engine = new SelectionEngine(environment, requestor, project.getOptions(true)); // engine.select(cu, offset, offset + length - 1); @@ -219,7 +220,7 @@ protected void generateInfos(Object info, HashMap newElements, IProgressMonitor if (JavaModelManager.VERBOSE){ System.out.println("OPENING Element ("+ Thread.currentThread()+"): " + this.toStringWithAncestors()); //$NON-NLS-1$//$NON-NLS-2$ } - + // open the parent if necessary openParent(info, newElements, monitor); if (monitor != null && monitor.isCanceled()) return; @@ -237,7 +238,7 @@ protected void generateInfos(Object info, HashMap newElements, IProgressMonitor newElements.remove(this); throw e; } - + // remove out of sync buffer for this element JavaModelManager.getJavaModelManager().getElementsOutOfSynchWithBuffers().remove(this); @@ -252,7 +253,7 @@ protected void generateInfos(Object info, HashMap newElements, IProgressMonitor * is the first time a request is being made for the buffer, an attempt is * made to create and fill this element's buffer. If the buffer has been * closed since it was first opened, the buffer is re-created. - * + * * @see IOpenable */ public IBuffer getBuffer() throws JavaModelException { @@ -298,7 +299,7 @@ public IResource getCorrespondingResource() throws JavaModelException { * @see IJavaElement */ public IOpenable getOpenable() { - return this; + return this; } @@ -326,14 +327,14 @@ public IResource getUnderlyingResource() throws JavaModelException { } public boolean exists() { - + IPackageFragmentRoot root = this.getPackageFragmentRoot(); if (root == null || root == this || !root.isArchive()) { return parentExists() && resourceExists(); } else { return super.exists(); } -} +} /** * Returns true if this element may have an associated source buffer, @@ -343,7 +344,7 @@ protected boolean hasBuffer() { return false; } /** - * @see IParent + * @see IParent */ public boolean hasChildren() throws JavaModelException { return getChildren().length > 0; @@ -352,7 +353,7 @@ public boolean hasChildren() throws JavaModelException { * @see IOpenable */ public boolean hasUnsavedChanges() throws JavaModelException{ - + if (isReadOnly() || !isOpen()) { return false; } @@ -378,7 +379,7 @@ public boolean hasUnsavedChanges() throws JavaModelException{ } } } - + return false; } /** @@ -390,7 +391,7 @@ public boolean isConsistent() throws JavaModelException { return true; } /** - * + * * @see IOpenable */ public boolean isOpen() { @@ -416,10 +417,10 @@ protected boolean isSourceElement() { //} /** * @see IOpenable - */ + */ public void makeConsistent(IProgressMonitor monitor) throws JavaModelException { if (isConsistent()) return; - + // create a new info and make it the current info // (this will remove the info and its children just before storing the new infos) JavaModelManager manager = JavaModelManager.getJavaModelManager(); @@ -480,11 +481,11 @@ protected void openParent(Object childInfo, HashMap newElements, IProgressMonito // */ //protected void openWhenClosed(IProgressMonitor pm) throws JavaModelException { // try { -// +// // if (JavaModelManager.VERBOSE){ // System.out.println("OPENING Element ("+ Thread.currentThread()+"): " + this.toStringWithAncestors()); //$NON-NLS-1$//$NON-NLS-2$ // } -// +// // // 1) Parent must be open - open the parent if necessary // openParent(pm); // @@ -492,14 +493,14 @@ protected void openParent(Object childInfo, HashMap newElements, IProgressMonito // OpenableElementInfo info = createElementInfo(); // if (isSourceElement()) { // this.openBuffer(pm); -// } +// } // // // 3) build the structure of the openable // buildStructure(info, pm); // // // 4) anything special // opening(info); -// +// //// if (JavaModelManager.VERBOSE) { //// System.out.println("-> Package cache size = " + JavaModelManager.getJavaModelManager().cache.pkgSize()); //$NON-NLS-1$ //// System.out.println("-> Openable cache filling ratio = " + JavaModelManager.getJavaModelManager().cache.openableFillingRatio() + "%"); //$NON-NLS-1$//$NON-NLS-2$ @@ -516,10 +517,10 @@ protected void openParent(Object childInfo, HashMap newElements, IProgressMonito /** * Answers true if the parent exists (null parent is answering true) - * + * */ protected boolean parentExists(){ - + IJavaElement parent = this.getParent(); if (parent == null) return true; return parent.exists(); @@ -531,9 +532,9 @@ protected boolean parentExists(){ protected boolean resourceExists() { IWorkspace workspace = ResourcesPlugin.getWorkspace(); if (workspace == null) return false; // workaround for http://bugs.eclipse.org/bugs/show_bug.cgi?id=34069 - return + return JavaModel.getTarget( - workspace.getRoot(), + workspace.getRoot(), this.getPath().makeRelative(), // ensure path is relative (see http://dev.eclipse.org/bugs/show_bug.cgi?id=22517) true) != null; } @@ -542,7 +543,7 @@ protected boolean resourceExists() { * @see IOpenable */ public void save(IProgressMonitor pm, boolean force) throws JavaModelException { - if (isReadOnly() || this.getResource().isReadOnly()) { + if (isReadOnly() || this.getResource().getResourceAttributes().isReadOnly()) { throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.READ_ONLY, this)); } IBuffer buf = getBuffer(); @@ -567,7 +568,7 @@ public PackageFragmentRoot getPackageFragmentRoot() { // * @see ICodeAssist // * @deprecated - use codeComplete(ICompilationUnit, ICompilationUnit, int, ICompletionRequestor) instead // */ -//protected void codeComplete(org.eclipse.jdt.internal.compiler.env.ICompilationUnit cu, org.eclipse.jdt.internal.compiler.env.ICompilationUnit unitToSkip, int position, final ICodeCompletionRequestor requestor) throws JavaModelException { +//protected void codeComplete(net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit cu, net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit unitToSkip, int position, final ICodeCompletionRequestor requestor) throws JavaModelException { // // if (requestor == null){ // codeComplete(cu, unitToSkip, position, (ICompletionRequestor)null);