/*******************************************************************************
* 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
*******************************************************************************/
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;
} 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
//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);
// 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.
// // 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);
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;
newElements.remove(this);
throw e;
}
-
+
// remove out of sync buffer for this element
JavaModelManager.getJavaModelManager().getElementsOutOfSynchWithBuffers().remove(this);
* 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 {
* @see IJavaElement
*/
public IOpenable getOpenable() {
- return this;
+ return this;
}
}
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,
return false;
}
/**
- * @see IParent
+ * @see IParent
*/
public boolean hasChildren() throws JavaModelException {
return getChildren().length > 0;
* @see IOpenable
*/
public boolean hasUnsavedChanges() throws JavaModelException{
-
+
if (isReadOnly() || !isOpen()) {
return false;
}
}
}
}
-
+
return false;
}
/**
return true;
}
/**
- *
+ *
* @see IOpenable
*/
public boolean isOpen() {
//}
/**
* @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();
// */
//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);
//
// 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$
/**
* 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();
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;
}
* @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();