/*******************************************************************************
* 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
*******************************************************************************/
* The single instance of <code>JavaModelManager</code> is available from
* the static method <code>JavaModelManager.getJavaModelManager()</code>.
*/
-public class JavaModelManager implements ISaveParticipant {
+public class JavaModelManager implements ISaveParticipant {
/**
* Unique handle onto the JavaModel
*/
public final static String CP_VARIABLE_PREFERENCES_PREFIX = PHPeclipsePlugin.PLUGIN_ID+".classpathVariable."; //$NON-NLS-1$
public final static String CP_CONTAINER_PREFERENCES_PREFIX = PHPeclipsePlugin.PLUGIN_ID+".classpathContainer."; //$NON-NLS-1$
public final static String CP_ENTRY_IGNORE = "##<cp entry ignore>##"; //$NON-NLS-1$
-
+
/**
* Classpath containers pool
*/
/**
* Name of the extension point for contributing a source code formatter
*/
- public static final String FORMATTER_EXTPOINT_ID = "codeFormatter" ; //$NON-NLS-1$
-
+ public static final String FORMATTER_EXTPOINT_ID = "codeFormatter" ; //$/**
+
+ /**
+ * Value of the content-type for Java source files
+ */
+ public static final String JAVA_SOURCE_CONTENT_TYPE = PHPeclipsePlugin.PLUGIN_ID+".phpSource" ; //$NON-NLS-1$NON-NLS-1$
+
/**
* Special value used for recognizing ongoing initialization and breaking initialization cycles
*/
// public IPath getPath() { return null; }
// public String toString() { return getDescription(); }
// };
-
+
private static final String INDEX_MANAGER_DEBUG = PHPeclipsePlugin.PLUGIN_ID + "/debug/indexmanager" ; //$NON-NLS-1$
private static final String COMPILER_DEBUG = PHPeclipsePlugin.PLUGIN_ID + "/debug/compiler" ; //$NON-NLS-1$
private static final String JAVAMODEL_DEBUG = PHPeclipsePlugin.PLUGIN_ID + "/debug/javamodel" ; //$NON-NLS-1$
private static final String SEARCH_DEBUG = PHPeclipsePlugin.PLUGIN_ID + "/debug/search" ; //$NON-NLS-1$
public final static IWorkingCopy[] NoWorkingCopy = new IWorkingCopy[0];
-
+
/**
* Table from WorkingCopyOwner to a table of ICompilationUnit (working copy handle) to PerWorkingCopyInfo.
* NOTE: this object itself is used as a lock to synchronize creation/removal of per working copy infos
}
}
-// public static IClasspathContainer containerGet(IJavaProject project, IPath containerPath) {
+// public static IClasspathContainer containerGet(IJavaProject project, IPath containerPath) {
// Map projectContainers = (Map)Containers.get(project);
// if (projectContainers == null){
// return null;
if (project == null) {
project = JavaCore.create(file.getProject());
}
-
+
if (file.getFileExtension() != null) {
String name = file.getName();
if (PHPFileUtil.isValidPHPUnitName(name))
/**
* Returns the package fragment or package fragment root corresponding to the given folder,
- * its parent or great parent being the given project.
+ * its parent or great parent being the given project.
* or <code>null</code> if unable to associate the given folder with a Java element.
* <p>
* Note that a package fragment root is returned rather than a default package.
}
IJavaElement element = determineIfOnClasspath(folder, project);
if (conflictsWithOutputLocation(folder.getFullPath(), (JavaProject)project)
- || (folder.getName().indexOf('.') >= 0
+ || (folder.getName().indexOf('.') >= 0
&& !(element instanceof IPackageFragmentRoot))) {
return null; // only package fragment roots are allowed with dot names
} else {
// }
// return pkg.getClassFile(file.getName());
// }
-
+
/**
- * Creates and returns a compilation unit element for the given <code>.java</code>
+ * Creates and returns a compilation unit element for the given <code>.java</code>
* file, its project being the given project. Returns <code>null</code> if unable
* to recognize the compilation unit.
*/
// not on classpath - make the root its folder, and a default package
IPackageFragmentRoot root = project.getPackageFragmentRoot(file.getParent());
pkg = root.getPackageFragment(IPackageFragment.DEFAULT_PACKAGE_NAME);
-
+
if (VERBOSE){
System.out.println("WARNING : creating unit element outside classpath ("+ Thread.currentThread()+"): " + file.getFullPath()); //$NON-NLS-1$//$NON-NLS-2$
}
/**
* Creates and returns a handle for the given JAR file, its project being the given project.
* The Java model associated with the JAR's project may be
- * created as a side effect.
+ * created as a side effect.
* Returns <code>null</code> if unable to create a JAR package fragment root.
* (for example, if the JAR file represents a non-Java resource)
*/
// if (project == null) {
// project = PHPCore.create(file.getProject());
// }
-//
+//
// // Create a jar package fragment root only if on the classpath
// IPath resourcePath = file.getFullPath();
// try {
// }
// return null;
// }
-
+
/**
* Returns the package fragment root represented by the resource, or
* the package fragment the given resource is located in, or <code>null</code>
public static IJavaElement determineIfOnClasspath(
IResource resource,
IJavaProject project) {
-
+
IPath resourcePath = resource.getFullPath();
try {
- IClasspathEntry[] entries =
+ IClasspathEntry[] entries =
net.sourceforge.phpdt.internal.compiler.util.Util.isJavaFileName(resourcePath.lastSegment())
? project.getRawClasspath() // JAVA file can only live inside SRC folder (on the raw path)
: ((JavaProject)project).getResolvedClasspath(true);
-
+
for (int i = 0; i < entries.length; i++) {
IClasspathEntry entry = entries[i];
if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) continue;
IPath rootPath = entry.getPath();
if (rootPath.equals(resourcePath)) {
- return project.getPackageFragmentRoot(resource);
+ return project.getPackageFragmentRoot(resource);
} else if (rootPath.isPrefixOf(resourcePath) && !Util.isExcluded(resource, null, ((ClasspathEntry)entry).fullExclusionPatternChars())) {
// given we have a resource child of the root, it cannot be a JAR pkg root
IPackageFragmentRoot root = ((JavaProject) project).getFolderPackageFragmentRoot(rootPath);
// if the resource is a file, then remove the last segment which
// is the file name in the package
pkgPath = pkgPath.removeLastSegments(1);
-
+
// don't check validity of package name (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=26706)
// String pkgName = pkgPath.toString().replace('/', '.');
String pkgName = pkgPath.toString();
}
return null;
}
-
+
/**
* The singleton manager
*/
*/
private final ModelUpdater modelUpdater =new ModelUpdater();
/**
- * Workaround for bug 15168 circular errors not reported
+ * Workaround for bug 15168 circular errors not reported
* This is a cache of the projects before any project addition/deletion has started.
*/
public IJavaProject[] javaProjectsCache;
* NOTE: this object itself is used as a lock to synchronize creation/removal of per project infos
*/
protected Map perProjectInfo = new HashMap(5);
-
+
/**
* A map from ICompilationUnit to IWorkingCopy
* of the shared working copies.
*/
public Map sharedWorkingCopies = new HashMap();
-
+
/**
* A weak set of the known scopes.
*/
// this.project = project;
// }
// }
-
+
public static class PerProjectInfo {
-
+
public IProject project;
public Object savedState;
public boolean triedRead;
public Map resolvedPathToRawEntries; // reverse map from resolved path to raw entries
public IPath outputLocation;
public Preferences preferences;
-
+
public PerProjectInfo(IProject project) {
this.triedRead = false;
this.savedState = null;
this.project = project;
}
-
+
// updating raw classpath need to flush obsoleted cached information about resolved entries
public synchronized void updateClasspathInformation(IClasspathEntry[] newRawClasspath) {
return buffer.toString();
}
}
-
+
public static class PerWorkingCopyInfo implements IProblemRequestor {
int useCount = 0;
IProblemRequestor problemRequestor;
public static boolean VERBOSE = false;
public static boolean CP_RESOLVE_VERBOSE = false;
public static boolean ZIP_ACCESS_VERBOSE = false;
-
+
/**
* A cache of opened zip files per thread.
* (map from Thread to map of IPath to java.io.ZipFile)
* NOTE: this object itself is used as a lock to synchronize creation/removal of entries
*/
private HashMap zipFiles = new HashMap();
-
-
+
+
/**
* Update the classpath variable cache
*/
public void addElementChangedListener(IElementChangedListener listener, int eventMask) {
for (int i = 0; i < this.elementChangedListenerCount; i++){
if (this.elementChangedListeners[i].equals(listener)){
-
+
// only clone the masks, since we could be in the middle of notifications and one listener decide to change
// any event mask of another listeners (yet not notified).
int cloneLength = this.elementChangedListenerMasks.length;
}
}
}
-
+
/**
public void configurePluginDebugOptions(){
if(JavaCore.getPlugin().isDebugging()){
// TODO jsurfer temp-del
-
+
String option = Platform.getDebugOption(BUILDER_DEBUG);
// if(option != null) JavaBuilder.DEBUG = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
-//
+//
// option = Platform.getDebugOption(COMPILER_DEBUG);
// if(option != null) Compiler.DEBUG = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
//
// option = Platform.getDebugOption(COMPLETION_DEBUG);
// if(option != null) CompletionEngine.DEBUG = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
-//
+//
option = Platform.getDebugOption(CP_RESOLVE_DEBUG);
if(option != null) JavaModelManager.CP_RESOLVE_VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
//
// option = Platform.getDebugOption(INDEX_MANAGER_DEBUG);
// if(option != null) IndexManager.VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
-
+
option = Platform.getDebugOption(JAVAMODEL_DEBUG);
if(option != null) JavaModelManager.VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
if(option != null) JavaModelManager.ZIP_ACCESS_VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
}
}
-
+
/*
* Discards the per working copy info for the given working copy (making it a compilation unit)
WorkingCopyOwner owner = workingCopy.owner;
Map workingCopyToInfos = (Map)this.perWorkingCopyInfos.get(owner);
if (workingCopyToInfos == null) return -1;
-
+
PerWorkingCopyInfo info = (PerWorkingCopyInfo)workingCopyToInfos.get(workingCopy);
if (info == null) return -1;
-
+
if (--info.useCount == 0) {
// create the delta builder (this remembers the current content of the working copy)
JavaElementDeltaBuilder deltaBuilder = null;
getDeltaProcessor().registerJavaModelDelta(deltaBuilder.delta);
}
}
-
+
}
return info.useCount;
}
}
-
+
/**
* @see ISaveParticipant
*/
public void doneSaving(ISaveContext context){
}
-
+
/**
* Fire Java Model delta, flushing them after the fact after post_change notification.
- * If the firing mode has been turned off, this has no effect.
+ * If the firing mode has been turned off, this has no effect.
*/
public void fire(IJavaElementDelta customDelta, int eventType) {
if (!this.isFiring) return;
-
+
if (DeltaProcessor.VERBOSE && (eventType == DEFAULT_CHANGE_EVENT || eventType == ElementChangedEvent.PRE_AUTO_BUILD)) {
System.out.println("-----------------------------------------------------------------------------------------------------------------------");//$NON-NLS-1$
}
} else {
deltaToNotify = customDelta;
}
-
+
// Refresh internal scopes
if (deltaToNotify != null) {
// TODO temp-del
// scope.processDelta(deltaToNotify);
// }
}
-
+
// Notification
-
+
// Important: if any listener reacts to notification by updating the listeners list or mask, these lists will
// be duplicated, so it is necessary to remember original lists in a variable (since field values may change under us)
IElementChangedListener[] listeners = this.elementChangedListeners;
IElementChangedListener[] listeners,
int[] listenerMask,
int listenerCount) {
-
+
if (DeltaProcessor.VERBOSE){
System.out.println("FIRING PRE_AUTO_BUILD Delta ["+Thread.currentThread()+"]:"); //$NON-NLS-1$//$NON-NLS-2$
System.out.println(deltaToNotify == null ? "<NONE>" : deltaToNotify.toString()); //$NON-NLS-1$
IElementChangedListener[] listeners,
int[] listenerMask,
int listenerCount) {
-
+
// post change deltas
if (DeltaProcessor.VERBOSE){
System.out.println("FIRING POST_CHANGE Delta ["+Thread.currentThread()+"]:"); //$NON-NLS-1$//$NON-NLS-2$
if (deltaToNotify != null) {
// flush now so as to keep listener reactions to post their own deltas for subsequent iteration
this.flush();
-
+
notifyListeners(deltaToNotify, ElementChangedEvent.POST_CHANGE, listeners, listenerMask, listenerCount);
- }
- }
+ }
+ }
private void fireReconcileDelta(
IElementChangedListener[] listeners,
int[] listenerMask,
if (deltaToNotify != null) {
// flush now so as to keep listener reactions to post their own deltas for subsequent iteration
this.reconcileDeltas = new HashMap();
-
+
notifyListeners(deltaToNotify, ElementChangedEvent.POST_RECONCILE, listeners, listenerMask, listenerCount);
- }
+ }
}
public void notifyListeners(IJavaElementDelta deltaToNotify, int eventType, IElementChangedListener[] listeners, int[] listenerMask, int listenerCount) {
}
}
}
-
+
/**
* Flushes all deltas without firing them.
*/
} catch (IOException e) {
}
}
- }
+ }
}
-
+
public DeltaProcessor getDeltaProcessor() {
return this.deltaState.getDeltaProcessor();
}
- /**
+ /**
* Returns the set of elements which are out of synch with their buffers.
*/
protected Map getElementsOutOfSynchWithBuffers() {
// return this.indexManager;
// }
/**
- * Returns the <code>IJavaElement</code> represented by the
+ * Returns the <code>IJavaElement</code> represented by the
* <code>String</code> memento.
*/
public IJavaElement getHandleFromMemento(String memento) throws JavaModelException {
}
return info;
}
- }
-
+ }
+
/*
* Returns the per-project info for the given project.
* If the info doesn't exist, check for the project existence and create the info.
if (info != null && recordUsage) info.useCount++;
return info;
}
- }
+ }
/**
* Returns the name of the variables for which an CP variable initializer is registered through an extension point
*/
public static String[] getRegisteredVariableNames(){
-
+
Plugin jdtCorePlugin = JavaCore.getPlugin();
if (jdtCorePlugin == null) return null;
// String varAttribute = configElements[j].getAttribute("variable"); //$NON-NLS-1$
// if (varAttribute != null) variableList.add(varAttribute);
// }
-// }
+// }
// }
String[] variableNames = new String[variableList.size()];
variableList.toArray(variableNames);
return variableNames;
- }
+ }
/**
* Returns the name of the container IDs for which an CP container initializer is registered through an extension point
*/
// public static String[] getRegisteredContainerIDs(){
-//
+//
// Plugin jdtCorePlugin = PHPCore.getPlugin();
// if (jdtCorePlugin == null) return null;
//
// String idAttribute = configElements[j].getAttribute("id"); //$NON-NLS-1$
// if (idAttribute != null) containerIDList.add(idAttribute);
// }
-// }
+// }
// }
// String[] containerIDs = new String[containerIDList.size()];
// containerIDList.toArray(containerIDs);
// return containerIDs;
-// }
+// }
/**
* Returns the File to use for saving and restoring the last built state for the given project.
IPath workingLocation = project.getWorkingLocation(JavaCore.PLUGIN_ID);
return workingLocation.append("state.dat").toFile(); //$NON-NLS-1$
}
-
+
/*
* Returns the temporary cache for newly opened elements for the current thread.
* Creates it if not already created.
* @exception CoreException If unable to create/open the ZipFile
*/
public ZipFile getZipFile(IPath path) throws CoreException {
-
+
synchronized(this.zipFiles) { // TODO: use PeThreadObject which does synchronization
Thread currentThread = Thread.currentThread();
HashMap map = null;
ZipFile zipFile;
- if ((map = (HashMap)this.zipFiles.get(currentThread)) != null
+ if ((map = (HashMap)this.zipFiles.get(currentThread)) != null
&& (zipFile = (ZipFile)map.get(path)) != null) {
-
+
return zipFile;
}
String fileSystemPath= null;
} else {
fileSystemPath= path.toOSString();
}
-
+
try {
if (ZIP_ACCESS_VERBOSE) {
System.out.println("(" + currentThread + ") [JavaModelManager.getZipFile(IPath)] Creating ZipFile on " + fileSystemPath ); //$NON-NLS-1$ //$NON-NLS-2$
}
// public void loadVariablesAndContainers() throws CoreException {
//
-// // backward compatibility, consider persistent property
+// // backward compatibility, consider persistent property
// QualifiedName qName = new QualifiedName(PHPCore.PLUGIN_ID, "variables"); //$NON-NLS-1$
// String xmlString = ResourcesPlugin.getWorkspace().getRoot().getPersistentProperty(qName);
-//
+//
// try {
// if (xmlString != null){
// StringReader reader = new StringReader(xmlString);
// if (!cpElement.getNodeName().equalsIgnoreCase("variables")) { //$NON-NLS-1$
// return;
// }
-//
+//
// NodeList list= cpElement.getChildNodes();
// int length= list.getLength();
// for (int i= 0; i < length; ++i) {
// if (type == Node.ELEMENT_NODE) {
// Element element= (Element) node;
// if (element.getNodeName().equalsIgnoreCase("variable")) { //$NON-NLS-1$
-// variablePut(
+// variablePut(
// element.getAttribute("name"), //$NON-NLS-1$
// new Path(element.getAttribute("path"))); //$NON-NLS-1$
// }
// if (xmlString != null){
// ResourcesPlugin.getWorkspace().getRoot().setPersistentProperty(qName, null); // flush old one
// }
-//
+//
// }
-//
+//
// // load variables and containers from preferences into cache
// Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences();
// if (propertyName.startsWith(CP_VARIABLE_PREFERENCES_PREFIX)){
// String varName = propertyName.substring(variablePrefixLength);
// IPath varPath = new Path(preferences.getString(propertyName).trim());
-//
-// Variables.put(varName, varPath);
+//
+// Variables.put(varName, varPath);
// PreviousSessionVariables.put(varName, varPath);
// }
// if (propertyName.startsWith(CP_CONTAINER_PREFERENCES_PREFIX)){
public IJavaElementDelta mergeDeltas(Collection deltas) {
if (deltas.size() == 0) return null;
if (deltas.size() == 1) return (IJavaElementDelta)deltas.iterator().next();
-
+
if (DeltaProcessor.VERBOSE) {
System.out.println("MERGING " + deltas.size() + " DELTAS ["+Thread.currentThread()+"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
-
+
Iterator iterator = deltas.iterator();
IJavaElement javaModel = this.getJavaModel();
JavaElementDelta rootDelta = new JavaElementDelta(javaModel);
else {
return null;
}
- }
+ }
/**
* Returns the info for this element without
*/
public void prepareToSave(ISaveContext context) throws CoreException {
}
-
+
protected void putInfo(IJavaElement element, Object info) {
this.cache.putInfo(element, info);
}
/*
* Puts the infos in the given map (keys are IJavaElements and values are JavaElementInfos)
* in the Java model cache in an atomic way.
- * First checks that the info for the opened element (or one of its ancestors) has not been
+ * First checks that the info for the opened element (or one of its ancestors) has not been
* added to the cache. If it is the case, another thread has opened the element (or one of
* its ancestors). So returns without updating the cache.
*/
}
}
}
-
+
Iterator iterator = newElements.keySet().iterator();
while (iterator.hasNext()) {
IJavaElement element = (IJavaElement)iterator.next();
// final String projectName = propertyName.substring(containerPrefixLength, index).trim();
// JavaProject project = (JavaProject)getJavaModelManager().getJavaModel().getJavaProject(projectName);
// final IPath containerPath = new Path(propertyName.substring(index+1).trim());
-//
+//
// if (containerString == null || containerString.equals(CP_ENTRY_IGNORE)) {
// containerPut(project, containerPath, null);
// } else {
// return "Persisted container ["+containerPath+" for project ["+ projectName+"]"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
// }
// public int getKind() {
-// return 0;
+// return 0;
// }
// public IPath getPath() {
// return containerPath;
protected void registerJavaModelDelta(IJavaElementDelta delta) {
this.javaModelDeltas.add(delta);
}
-
+
/**
* Remembers the given scope in a weak set
* (so no need to remove it: it will be removed by the garbage collector)
*/
// public void rememberScope(AbstractSearchScope scope) {
// // NB: The value has to be null so as to not create a strong reference on the scope
-// this.scopes.put(scope, null);
+// this.scopes.put(scope, null);
// }
/**
* removeElementChangedListener method comment.
*/
public void removeElementChangedListener(IElementChangedListener listener) {
-
+
for (int i = 0; i < this.elementChangedListenerCount; i++){
-
+
if (this.elementChangedListeners[i].equals(listener)){
-
+
// need to clone defensively since we might be in the middle of listener notifications (#fire)
int length = this.elementChangedListeners.length;
IElementChangedListener[] newListeners = new IElementChangedListener[length];
System.arraycopy(this.elementChangedListeners, 0, newListeners, 0, i);
int[] newMasks = new int[length];
System.arraycopy(this.elementChangedListenerMasks, 0, newMasks, 0, i);
-
+
// copy trailing listeners
int trailingLength = this.elementChangedListenerCount - i - 1;
if (trailingLength > 0){
System.arraycopy(this.elementChangedListeners, i+1, newListeners, i, trailingLength);
System.arraycopy(this.elementChangedListenerMasks, i+1, newMasks, i, trailingLength);
}
-
+
// update manager listener state (#fire need to iterate over original listeners through a local variable to hold onto
// the original ones)
this.elementChangedListeners = newListeners;
}
}
}
-
+
/**
* Remembers the given scope in a weak set
* (so no need to remove it: it will be removed by the garbage collector)
*/
// public void rememberScope(AbstractSearchScope scope) {
// // NB: The value has to be null so as to not create a strong reference on the scope
-// this.searchScopes.put(scope, null);
-// }
+// this.searchScopes.put(scope, null);
+// }
/*
* Removes all cached info for the given element (including all children)
* from the cache.
return info;
}
return null;
- }
+ }
public void removePerProjectInfo(JavaProject javaProject) {
synchronized(perProjectInfo) { // use the perProjectInfo collection as its own lock
IProject project = javaProject.getProject();
// passed this point, save actions are non trivial
if (context.getKind() == ISaveContext.SNAPSHOT) return;
-
+
// save built state
if (info.triedRead) saveBuiltState(info);
}
-
+
/**
* Saves the built state for the project.
*/
}
}
private synchronized Map containerClone(IJavaProject project) {
- Map originalProjectContainers = (Map)this.containers.get(project);
+ Map originalProjectContainers = (Map)this.containers.get(project);
if (originalProjectContainers == null) return null;
Map projectContainers = new HashMap(originalProjectContainers.size());
projectContainers.putAll(originalProjectContainers);
* @see ISaveParticipant
*/
public void saving(ISaveContext context) throws CoreException {
-
+
// save container values on snapshot/full save
Preferences preferences = JavaCore.getPlugin().getPluginPreferences();
IJavaProject[] projects = getJavaModel().getJavaProjects();
}
}
JavaCore.getPlugin().savePluginPreferences();
-
+
// if (context.getKind() == ISaveContext.FULL_SAVE) {
// // will need delta since this save (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38658)
// context.needDelta();
-//
+//
// // clean up indexes on workspace full save
// // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=52347)
// IndexManager manager = this.indexManager;
// manager.cleanUpIndexes();
// }
// }
-
+
IProject savedProject = context.getProject();
if (savedProject != null) {
if (!JavaProject.hasJavaNature(savedProject)) return; // ignore
* @see ISaveParticipant
*/
// public void saving(ISaveContext context) throws CoreException {
-//
+//
// IProject savedProject = context.getProject();
// if (savedProject != null) {
// if (!JavaProject.hasJavaNature(savedProject)) return; // ignore
// optional behaviour
// possible value of index 0 is Compute
if (!JavaCore.COMPUTE.equals(JavaCore.getOption(JavaCore.CORE_JAVA_BUILD_ORDER))) return; // cannot be customized at project level
-
+
if (javaBuildOrder == null || javaBuildOrder.length <= 1) return;
-
+
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceDescription description = workspace.getDescription();
String[] wksBuildOrder = description.getBuildOrder();
public void stopDeltas() {
this.isFiring= false;
}
-
+
/**
* Update Java Model given some delta
*/
}
-
+
public static IPath variableGet(String variableName){
return (IPath)Variables.get(variableName);
}
}
return result;
}
-
- public static void variablePut(String variableName, IPath variablePath){
- // update cache - do not only rely on listener refresh
+ public static void variablePut(String variableName, IPath variablePath){
+
+ // update cache - do not only rely on listener refresh
if (variablePath == null) {
Variables.remove(variableName);
PreviousSessionVariables.remove(variableName);
// do not write out intermediate initialization value
if (variablePath == JavaModelManager.VariableInitializationInProgress){
return;
- }
+ }
Preferences preferences = JavaCore.getPlugin().getPluginPreferences();
String variableKey = CP_VARIABLE_PREFERENCES_PREFIX+variableName;
String variableString = variablePath == null ? CP_ENTRY_IGNORE : variablePath.toString();
*/
public ICompilationUnit[] getWorkingCopies(WorkingCopyOwner owner, boolean addPrimary) {
synchronized(perWorkingCopyInfos) {
- ICompilationUnit[] primaryWCs = addPrimary && owner != DefaultWorkingCopyOwner.PRIMARY
- ? getWorkingCopies(DefaultWorkingCopyOwner.PRIMARY, false)
+ ICompilationUnit[] primaryWCs = addPrimary && owner != DefaultWorkingCopyOwner.PRIMARY
+ ? getWorkingCopies(DefaultWorkingCopyOwner.PRIMARY, false)
: null;
Map workingCopyToInfos = (Map)perWorkingCopyInfos.get(owner);
if (workingCopyToInfos == null) return primaryWCs;
result[index++] = ((JavaModelManager.PerWorkingCopyInfo)iterator.next()).getWorkingCopy();
}
return result;
- }
+ }
}
-
+
/*
* A HashSet that contains the IJavaProject whose classpath is being resolved.
*/
private ThreadLocal classpathsBeingResolved = new ThreadLocal();
-
+
private HashSet getClasspathBeingResolved() {
HashSet result = (HashSet) this.classpathsBeingResolved.get();
if (result == null) {
public boolean isClasspathBeingResolved(IJavaProject project) {
return getClasspathBeingResolved().contains(project);
}
-
+
public void setClasspathBeingResolved(IJavaProject project, boolean classpathIsResolved) {
if (classpathIsResolved) {
getClasspathBeingResolved().add(project);
/*
* Created on 09.08.2003
- *
+ *
*/
package net.sourceforge.phpdt.internal.ui.util;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.ui.IEditorDescriptor;
+import org.eclipse.ui.IEditorRegistry;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
public class PHPFileUtil {
- private static String[] PHP_EXTENSIONS = null;
+// private static String[] PHP_EXTENSIONS = null;
public final static String[] SMARTY_EXTENSIONS = { "tpl" };
public static boolean isPHPFile(IFile file) {
- String extension = file.getFileExtension();
+// String extension = file.getFileExtension();
return isPHPFileName(file.getLocation().toString());
}
- public final static String getFileExtension(String name) {
- int index = name.lastIndexOf('.');
- if (index == -1)
- return null;
- if (index == (name.length() - 1))
- return null; //$NON-NLS-1$
- return name.substring(index + 1);
- }
+// public final static String getFileExtension(String name) {
+// int index = name.lastIndexOf('.');
+// if (index == -1)
+// return null;
+// if (index == (name.length() - 1))
+// return null; //$NON-NLS-1$
+// return name.substring(index + 1);
+// }
/**
* Returns true iff str.toLowerCase().endsWith(".php") implementation is not creating extra strings.
*/
public final static boolean isPHPFileName(String name) {
- String extension = getFileExtension(name);
- if (extension == null) {
- return false;
- }
- extension = extension.toLowerCase();
- PHP_EXTENSIONS = getExtensions();
- if (PHP_EXTENSIONS == null) {
- return false;
- }
- for (int i = 0; i < PHP_EXTENSIONS.length; i++) {
- if (extension.equals(PHP_EXTENSIONS[i])) {
+
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IEditorRegistry registry = workbench.getEditorRegistry();
+ IEditorDescriptor[] descriptors = registry.getEditors(name);
+
+ for (int i = 0; i < descriptors.length; i++) {
+ if (descriptors[i].getId().equals(PHPeclipsePlugin.EDITOR_ID)) {
return true;
- }
- }
+ }
+ }
+// String extension = getFileExtension(name);
+// if (extension == null) {
+// return false;
+// }
+// extension = extension.toLowerCase();
+// PHP_EXTENSIONS = getExtensions();
+// if (PHP_EXTENSIONS == null) {
+// return false;
+// }
+// for (int i = 0; i < PHP_EXTENSIONS.length; i++) {
+// if (extension.equals(PHP_EXTENSIONS[i])) {
+// return true;
+// }
+// }
return false;
}
/**
* @return Returns the PHP extensions.
*/
- public static String[] getExtensions() {
- if (PHP_EXTENSIONS == null) {
- ArrayList list = new ArrayList();
- final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
- String extensions = store.getString(PHPeclipsePlugin.PHP_EXTENSION_PREFS);
- extensions = extensions.trim();
- if (extensions.length() != 0) {
- StringTokenizer tokenizer = new StringTokenizer(extensions, " ,;:/-|");
- String token;
- while (tokenizer.hasMoreTokens()) {
- token = tokenizer.nextToken();
- if (token != null && token.length() >= 1) {
- list.add(token);
- }
- }
- if (list.size() != 0) {
- PHP_EXTENSIONS = new String[list.size()];
- for (int i = 0; i < list.size(); i++) {
- PHP_EXTENSIONS[i] = (String) list.get(i);
- }
- }
- }
- }
- return PHP_EXTENSIONS;
- }
+// public static String[] getExtensions() {
+// if (PHP_EXTENSIONS == null) {
+// ArrayList list = new ArrayList();
+// final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
+// String extensions = store.getString(PHPeclipsePlugin.PHP_EXTENSION_PREFS);
+// extensions = extensions.trim();
+// if (extensions.length() != 0) {
+// StringTokenizer tokenizer = new StringTokenizer(extensions, " ,;:/-|");
+// String token;
+// while (tokenizer.hasMoreTokens()) {
+// token = tokenizer.nextToken();
+// if (token != null && token.length() >= 1) {
+// list.add(token);
+// }
+// }
+// if (list.size() != 0) {
+// PHP_EXTENSIONS = new String[list.size()];
+// for (int i = 0; i < list.size(); i++) {
+// PHP_EXTENSIONS[i] = (String) list.get(i);
+// }
+// }
+// }
+// }
+// return PHP_EXTENSIONS;
+// }
/**
* @param php_extensions
* The PHP extensions to set.
*/
- public static void setExtensions(String[] php_extensions) {
- PHP_EXTENSIONS = php_extensions;
- }
+// public static void setExtensions(String[] php_extensions) {
+// PHP_EXTENSIONS = php_extensions;
+// }
/**
* Creata the file for the given absolute file path
- *
+ *
* @param absoluteFilePath
* @param project
* @return the file for the given absolute file path or <code>null</code> if no existing file can be found
/**
* Determine the path of an include name string
- *
+ *
* @param includeNameString
* @param resource
* @param project
import net.sourceforge.phpdt.ui.PreferenceConstants;
import net.sourceforge.phpeclipse.IPreferenceConstants;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-import net.sourceforge.phpeclipse.phpeditor.html.HTMLFormattingStrategy;
import net.sourceforge.phpeclipse.phpeditor.php.HTMLCompletionProcessor;
import net.sourceforge.phpeclipse.phpeditor.php.PHPAutoIndentStrategy;
import net.sourceforge.phpeclipse.phpeditor.php.PHPCodeScanner;
public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
/**
* Preference key used to look up display tab width.
- *
+ *
* @since 2.0
*/
public final static String PREFERENCE_TAB_WIDTH = PreferenceConstants.EDITOR_TAB_WIDTH;
/**
* Preference key for inserting spaces rather than tabs.
- *
+ *
* @since 2.0
*/
public final static String SPACES_FOR_TABS = PreferenceConstants.EDITOR_SPACES_FOR_TABS;
// public static final String HTML_DEFAULT =
// IPHPPartitionScannerConstants.HTML;
//IDocument.DEFAULT_CONTENT_TYPE;
- private JavaTextTools fJavaTextTools;
+// private JavaTextTools fJavaTextTools;
private ITextEditor fTextEditor;
/**
* The document partitioning.
- *
+ *
* @since 3.0
*/
private String fDocumentPartitioning;
private ContentFormatter fFormatter;
- private HTMLFormattingStrategy fFormattingStrategy;
-
/**
* Single token scanner.
*/
/**
* The document partitioning.
- *
+ *
* @since 3.0
*/
// private String fDocumentPartitioning;
/**
* The Java source code scanner
- *
+ *
* @since 3.0
*/
private AbstractJavaScanner fCodeScanner;
/**
* The Java multi-line comment scanner
- *
+ *
* @since 3.0
*/
private AbstractJavaScanner fMultilineCommentScanner;
/**
* The Java single-line comment scanner
- *
+ *
* @since 3.0
*/
private AbstractJavaScanner fSinglelineCommentScanner;
* The PHP single quoted string scanner
*/
private AbstractJavaScanner fStringSQScanner;
-
+
/**
* The Javadoc scanner
- *
+ *
* @since 3.0
*/
private AbstractJavaScanner fJavaDocScanner;
/**
* The preference store, can be read-only
- *
+ *
* @since 3.0
*/
private IPreferenceStore fPreferenceStore;
/**
* The color manager
- *
+ *
* @since 3.0
*/
private IColorManager fColorManager;
* {@link JavaSourceViewerConfiguration#handlePropertyChangeEvent(PropertyChangeEvent)}and disallowed to call
* {@link JavaSourceViewerConfiguration#getPreferenceStore()}on the resulting Java source viewer configuration.
* </p>
- *
+ *
* @param colorManager
* the color manager
* @param preferenceStore
/**
* Creates a new Java source viewer configuration for viewers in the given editor using the given Java tools.
- *
+ *
* @param tools
* the Java text tools to be used
* @param editor
// }
/**
* Returns the color manager for this configuration.
- *
+ *
* @return the color manager
*/
protected IColorManager getColorManager() {
/**
* Initializes the scanners.
- *
+ *
* @since 3.0
*/
private void initializeScanners() {
- Assert.isTrue(isNewSetup());
+// Assert.isTrue(isNewSetup());
fCodeScanner = new PHPCodeScanner(getColorManager(), fPreferenceStore);
fMultilineCommentScanner = new SingleTokenPHPScanner(getColorManager(), fPreferenceStore,
IPreferenceConstants.PHP_MULTILINE_COMMENT);
/**
* Determines whether the preference change encoded by the given event changes the behavior of one of its contained components.
- *
+ *
* @param event
* the event to be investigated
* @return <code>true</code> if event causes a behavioral change
* <p>
* Clients are not allowed to call this method if the old setup with text tools is in use.
* </p>
- *
+ *
* @param event
* the event to which to adapt
* @see JavaSourceViewerConfiguration#JavaSourceViewerConfiguration(IColorManager, IPreferenceStore, ITextEditor, String)
* @since 3.0
*/
public void handlePropertyChangeEvent(PropertyChangeEvent event) {
- Assert.isTrue(isNewSetup());
+// Assert.isTrue(isNewSetup());
if (fCodeScanner.affectsBehavior(event))
fCodeScanner.adaptToPreferenceChange(event);
if (fMultilineCommentScanner.affectsBehavior(event))
/**
* Returns the names of the document position categories used by the document partitioners created by this object to manage their
* partition information. If the partitioners don't use document position categories, the returned result is <code>null</code>.
- *
+ *
* @return the partition managing position categories or <code>null</code> if there is none
*/
public String[] getPartitionManagingPositionCategories() {
/**
* Returns the preference store used by this configuration to initialize the individual bits and pieces.
- *
+ *
* @return the preference store used to initialize this configuration
- *
+ *
* @since 2.0
*/
protected IPreferenceStore getPreferenceStore() {
* (non-Javadoc) Method declared on SourceViewerConfiguration
*/
public IAutoIndentStrategy getAutoIndentStrategy(ISourceViewer sourceViewer, String contentType) {
- if (IPHPPartitions.PHP_PHPDOC_COMMENT.equals(contentType)
+ if (IPHPPartitions.PHP_PHPDOC_COMMENT.equals(contentType)
|| IPHPPartitions.PHP_MULTILINE_COMMENT.equals(contentType))
return new JavaDocAutoIndentStrategy(getConfiguredDocumentPartitioning(sourceViewer));
if (IPHPPartitions.PHP_STRING_DQ.equals(contentType))
/**
* Returns the PHP source code scanner for this configuration.
- *
+ *
* @return the PHP source code scanner
*/
protected RuleBasedScanner getCodeScanner() {
/**
* Returns the Java multi-line comment scanner for this configuration.
- *
+ *
* @return the Java multi-line comment scanner
* @since 2.0
*/
/**
* Returns the Java single-line comment scanner for this configuration.
- *
+ *
* @return the Java single-line comment scanner
* @since 2.0
*/
/**
* Returns the PHP double quoted string scanner for this configuration.
- *
+ *
* @return the PHP double quoted string scanner
*/
protected RuleBasedScanner getStringDQScanner() {
/**
* Returns the PHP single quoted string scanner for this configuration.
- *
+ *
* @return the PHP single quoted string scanner
*/
protected RuleBasedScanner getStringSQScanner() {
}
/**
* Returns the HTML source code scanner for this configuration.
- *
+ *
* @return the HTML source code scanner
*/
// protected RuleBasedScanner getHTMLScanner() {
// }
/**
* Returns the Smarty source code scanner for this configuration.
- *
+ *
* @return the Smarty source code scanner
*/
// protected RuleBasedScanner getSmartyScanner() {
/**
* Returns the SmartyDoc source code scanner for this configuration.
- *
+ *
* @return the SmartyDoc source code scanner
*/
// protected RuleBasedScanner getSmartyDocScanner() {
// }
/**
* Returns the PHPDoc source code scanner for this configuration.
- *
+ *
* @return the PHPDoc source code scanner
*/
protected RuleBasedScanner getPHPDocScanner() {
/**
* @return <code>true</code> iff the new setup without text tools is in use.
- *
+ *
* @since 3.0
*/
- private boolean isNewSetup() {
- return fJavaTextTools == null;
- }
+// private boolean isNewSetup() {
+// return fJavaTextTools == null;
+// }
/**
* Creates and returns a preference store which combines the preference stores from the text tools and which is read-only.
- *
+ *
* @return the read-only preference store
* @since 3.0
*/
- private IPreferenceStore createPreferenceStore() {
- Assert.isTrue(!isNewSetup());
- IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
- if (fJavaTextTools.getCorePreferenceStore() == null)
- return new ChainedPreferenceStore(new IPreferenceStore[] { fJavaTextTools.getPreferenceStore(), generalTextStore });
-
- return new ChainedPreferenceStore(new IPreferenceStore[] { fJavaTextTools.getPreferenceStore(),
- new PreferencesAdapter(fJavaTextTools.getCorePreferenceStore()), generalTextStore });
- }
+// private IPreferenceStore createPreferenceStore() {
+// Assert.isTrue(!isNewSetup());
+// IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
+// if (fJavaTextTools.getCorePreferenceStore() == null)
+// return new ChainedPreferenceStore(new IPreferenceStore[] { fJavaTextTools.getPreferenceStore(), generalTextStore });
+//
+// return new ChainedPreferenceStore(new IPreferenceStore[] { fJavaTextTools.getPreferenceStore(),
+// new PreferencesAdapter(fJavaTextTools.getCorePreferenceStore()), generalTextStore });
+// }
/*
* (non-Javadoc) Method declared on SourceViewerConfiguration
phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_STRING_DQ);
phpDR = new DefaultDamagerRepairer(getStringSQScanner());
phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_STRING_SQ);
- phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_STRING_SQ);
+ phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_STRING_SQ);
phpDR = new DefaultDamagerRepairer(getSinglelineCommentScanner());
phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_SINGLELINE_COMMENT);
phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_SINGLELINE_COMMENT);
PresentationReconciler reconciler = new PresentationReconciler();
reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
//
- JavaTextTools jspTextTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
+// JavaTextTools jspTextTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getPHPDocScanner());//jspTextTools.getJSPTextScanner());
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
/**
* Returns the information presenter control creator. The creator is a factory creating the presenter controls for the given
* source viewer. This implementation always returns a creator for <code>DefaultInformationControl</code> instances.
- *
+ *
* @param sourceViewer
* the source viewer to be configured by this configuration
* @return an information control creator
/**
* Returns the outline presenter control creator. The creator is a factory creating outline presenter controls for the given
* source viewer. This implementation always returns a creator for <code>JavaOutlineInformationControl</code> instances.
- *
+ *
* @param sourceViewer
* the source viewer to be configured by this configuration
* @return an information control creator
/**
* Returns the outline presenter which will determine and shown information requested for the current cursor position.
- *
+ *
* @param sourceViewer
* the source viewer to be configured by this configuration
* @param doCodeResolve
public interface IPreferenceConstants {
/**
* Preference key suffix for bold text style preference keys.
- *
+ *
* @since 2.1
*/
public static final String EDITOR_BOLD_SUFFIX = "_bold"; //$NON-NLS-1$
/**
* Preference key suffix for italic text style preference keys.
- *
+ *
* @since 3.0
*/
public static final String EDITOR_ITALIC_SUFFIX = "_italic"; //$NON-NLS-1$
// public static final String APACHE_RESTART_BACKGROUND = "_apache_restart_background";
//
// public static final String APACHE_RESTART_PREF = "__apache_restart";
-
+
// public static final String HTTPD_CONF_PATH_PREF = "__httpd_conf_path";
-//
+//
// public static final String ETC_HOSTS_PATH_PREF = "__etc_hosts_path";
// public static final String SHOW_OUTPUT_IN_CONSOLE = "_show_output_in_console";
//
// public static final String EXTERNAL_PARSER_PREF = "_external_parser";
- public static final String PHP_EXTENSION_PREFS = "_php_parser_extensions";
-
+// public static final String PHP_EXTENSION_PREFS = "_php_parser_extensions";
+
// public static final String PHP_PARSER_DEFAULT = "_php_parser_default";
// public static final String PHP_INTERNAL_PARSER = "_php_internal_parser";
/**
* The color key for operators and brackets in PHP code (value <code>"__php_operator"</code>).
- *
+ *
* @since 3.0
*/
public static final String PHP_OPERATOR = "__php_operator"; //$NON-NLS-1$
/**
* The color key for {} in PHP code (value <code>"__php_brace_operator"</code>).
- *
+ *
* @since 3.0
*/
public static final String PHP_BRACE_OPERATOR = "__php_brace_operator"; //$NON-NLS-1$
* <p>
* Value is of type <code>String</code>. A RGB color value encoded as a string using class <code>PreferenceConverter</code>
* </p>
- *
+ *
* @see org.eclipse.jface.resource.StringConverter
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 3.0
* <p>
* Value is of type <code>Boolean</code>.
* </p>
- *
+ *
* @since 3.0
*/
public final static String EDITOR_PHP_OPERATOR_BOLD = PHP_OPERATOR + EDITOR_BOLD_SUFFIX;
* <p>
* Value is of type <code>Boolean</code>.
* </p>
- *
+ *
* @since 3.0
*/
public final static String EDITOR_PHP_OPERATOR_ITALIC = PHP_OPERATOR + EDITOR_ITALIC_SUFFIX;
* <p>
* Value is of type <code>String</code>. A RGB color value encoded as a string using class <code>PreferenceConverter</code>
* </p>
- *
+ *
* @see org.eclipse.jface.resource.StringConverter
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 3.0
* <p>
* Value is of type <code>Boolean</code>.
* </p>
- *
+ *
* @since 3.0
*/
public final static String EDITOR_PHP_BRACE_OPERATOR_BOLD = PHP_BRACE_OPERATOR + EDITOR_BOLD_SUFFIX;
* <p>
* Value is of type <code>Boolean</code>.
* </p>
- *
+ *
* @since 3.0
*/
public final static String EDITOR_PHP_BRACE_OPERATOR_ITALIC = PHP_BRACE_OPERATOR + EDITOR_ITALIC_SUFFIX;
/**
* The color key for keyword 'return' in PHP code (value <code>"__php_keyword_return"</code>).
- *
+ *
* @since 3.0
*/
public static final String PHP_KEYWORD_RETURN = "__php_keyword_return"; //$NON-NLS-1$
* <p>
* Value is of type <code>String</code>. A RGB color value encoded as a string using class <code>PreferenceConverter</code>
* </p>
- *
+ *
* @see org.eclipse.jface.resource.StringConverter
* @see org.eclipse.jface.preference.PreferenceConverter
* @since 3.0
* <p>
* Value is of type <code>Boolean</code>.
* </p>
- *
+ *
* @since 3.0
*/
public final static String EDITOR_PHP_KEYWORD_RETURN_BOLD = PHP_KEYWORD_RETURN + EDITOR_BOLD_SUFFIX;
* <p>
* Value is of type <code>Boolean</code>.
* </p>
- *
+ *
* @since 3.0
*/
public final static String EDITOR_PHP_KEYWORD_RETURN_ITALIC = PHP_KEYWORD_RETURN + EDITOR_ITALIC_SUFFIX;
public static final String PHP_STRING_ITALIC_SQ = "_php_string_sq_italic";
public static final String PHP_STRING_UNDERLINE_SQ = "_php_string_sq_underline";
-
+
public static final String PHP_DEFAULT = "_php_default";
public static final String PHP_DEFAULT_BOLD = "_php_default_bold";
// public static final String PHP_BOOKMARK_DEFAULT = "_php_bookmark_default";
// public static final String PHP_LOCALHOST_PREF = "_php_localhost";
// public static final String PHP_DOCUMENTROOT_PREF = "_php_documentroot";
- //
+ //
// public static final String PHP_AUTO_PREVIEW_DEFAULT = "_auto_preview";
// public static final String PHP_BRING_TO_TOP_PREVIEW_DEFAULT = "_bring_to_top_preview";
// public static final String PHP_SHOW_HTML_FILES_LOCAL = "_show_html_files_local";
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;
import org.eclipse.ui.console.IConsoleConstants;
-
+import org.eclipse.core.internal.content.ContentType;
//import org.eclipse.update.internal.ui.UpdatePerspective;
public class PHPPerspectiveFactory implements IPerspectiveFactory {
public static final String ID_PROGRESS_VIEW= "org.eclipse.ui.views.ProgressView"; // see bug 63563 //$NON-NLS-1$
-
+
public PHPPerspectiveFactory() {
super();
}
outputfolder.addPlaceholder(NewSearchUI.SEARCH_VIEW_ID);
outputfolder.addView(IConsoleConstants.ID_CONSOLE_VIEW);
outputfolder.addView(IPageLayout.ID_BOOKMARKS);
+ outputfolder.addView(BrowserView.ID_BROWSER);
outputfolder.addPlaceholder(ID_PROGRESS_VIEW);
-
+
layout.addView(IPageLayout.ID_OUTLINE, IPageLayout.RIGHT, (float) 0.75,
editorArea);
layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET);
* The id of the PHP plugin (value <code>"net.sourceforge.phpeclipse"</code>).
*/
public static final String PLUGIN_ID = "net.sourceforge.phpeclipse"; //$NON-NLS-1$
+ public static final String EDITOR_ID = PHPeclipsePlugin.PLUGIN_ID+".PHPUnitEditor";
public static final String ID_PERSPECTIVE = "net.sourceforge.phpeclipse.PHPPerspective"; //$NON-NLS-1$
-
+
IWorkspace w;
/**
/**
* The key to store customized templates.
- *
+ *
* @since 3.0
*/
private static final String TEMPLATES_KEY = "net.sourceforge.phpdt.ui.text.custom_templates"; //$NON-NLS-1$
/**
* The key to store customized code templates.
- *
+ *
* @since 3.0
*/
private static final String CODE_TEMPLATES_KEY = "net.sourceforge.phpdt.ui.text.custom_code_templates"; //$NON-NLS-1$
/**
* The key to store whether the legacy templates have been migrated
- *
+ *
* @since 3.0
*/
// private static final String TEMPLATES_MIGRATION_KEY= "net.sourceforge.phpdt.ui.text.templates_migrated"; //$NON-NLS-1$
/**
* The key to store whether the legacy code templates have been migrated
- *
+ *
* @since 3.0
*/
// private static final String CODE_TEMPLATES_MIGRATION_KEY= "net.sourceforge.phpdt.ui.text.code_templates_migrated";
/**
* The template context type registry for the java editor.
- *
+ *
* @since 3.0
*/
private ContextTypeRegistry fContextTypeRegistry;
/**
* The code template context type registry for the java editor.
- *
+ *
* @since 3.0
*/
private ContextTypeRegistry fCodeTemplateContextTypeRegistry;
/**
* The template store for the java editor.
- *
+ *
* @since 3.0
*/
private TemplateStore fTemplateStore;
/**
* The coded template store for the java editor.
- *
+ *
* @since 3.0
*/
private TemplateStore fCodeTemplateStore;
/**
* Property change listener on this plugin's preference store.
- *
+ *
* @since 3.0
*/
// private IPropertyChangeListener fPropertyChangeListener;
/**
* The combined preference store.
- *
+ *
* @since 3.0
*/
private IPreferenceStore fCombinedPreferenceStore;
/**
* The extension point registry for the <code>net.sourceforge.phpdt.ui.javaFoldingStructureProvider</code> extension point.
- *
+ *
* @since 3.0
*/
private JavaFoldingStructureProviderRegistry fFoldingStructureProviderRegistry;
/**
* Mockup preference store for firing events and registering listeners on project setting changes. FIXME: Temporary solution.
- *
+ *
* @since 3.0
*/
private MockupPreferenceStore fMockupPreferenceStore;
// }
/**
* Returns all Java editor text hovers contributed to the workbench.
- *
+ *
* @return an array of JavaEditorTextHoverDescriptor
* @since 2.1
*/
* <p>
* This will force a rebuild of the descriptors the next time a client asks for them.
* </p>
- *
+ *
* @return an array of JavaEditorTextHoverDescriptor
* @since 2.1
*/
/**
* Returns an array of all editors that have an unsaved content. If the identical content is presented in more than one editor,
* only one of those editor parts is part of the result.
- *
+ *
* @return an array of all dirty editor parts.
*/
public static IEditorPart[] getDirtyEditors() {
public static void log(Throwable t) {
log(error(t));
}
-
+
public static void log(String message, Throwable t) {
- log(error(message, t));
+ log(error(message, t));
}
public static void logErrorMessage(String message) {
log(new Status(IStatus.ERROR, getPluginId(), IJavaStatusConstants.INTERNAL_ERROR, message, null));
}
-
+
public static IStatus error(Throwable t) {
return error("PHPeclipsePlugin.internalErrorOccurred", t); //$NON-NLS-1$
}
-
+
public static IStatus error(String message, Throwable t) {
return new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, message, t);
}
/**
* Get the identifier index manager for the given project
- *
+ *
* @param iProject
* the current project
* @return
// e.printStackTrace();
// } catch (SQLException e) {
// e.printStackTrace();
-// }
+// }
IdentifierIndexManager indexManager = (IdentifierIndexManager) fIndexManagerMap.get(indexFilename);
if (indexManager == null) {
indexManager = new IdentifierIndexManager(indexFilename);
// store.setDefault(EXTERNAL_BROWSER_PREF, "netscape {0}");
// }
- store.setDefault(PHP_EXTENSION_PREFS, "php,php3,php4,php5,phtml,inc,module,class");
-
+// store.setDefault(PHP_EXTENSION_PREFS, "php,php3,php4,php5,phtml,inc,module,class");
+
// store.setDefault(PHP_PARSER_DEFAULT, PHP_EXTERNAL_PARSER);
// store.setDefault(PHP_INTERNAL_PARSER, "false");
// store.setDefault(PHP_EXTERNAL_PARSER, "true");
PreferenceConverter.setDefault(store, PHP_CONSTANT, PHPColorProvider.CONSTANT);
PreferenceConverter.setDefault(store, PHP_TYPE, PHPColorProvider.TYPE);
// PreferenceConverter.setDefault(store, PHP_STRING_DQ, PHPColorProvider.STRING_DQ);
-// store.setDefault(PHP_STRING_BOLD_DQ, true);
-// PreferenceConverter.setDefault(store, PHP_STRING_SQ, PHPColorProvider.STRING_SQ);
+// store.setDefault(PHP_STRING_BOLD_DQ, true);
+// PreferenceConverter.setDefault(store, PHP_STRING_SQ, PHPColorProvider.STRING_SQ);
PreferenceConverter.setDefault(store, PHP_DEFAULT, PHPColorProvider.DEFAULT);
PreferenceConverter.setDefault(store, PHPDOC_KEYWORD, PHPColorProvider.PHPDOC_KEYWORD);
PreferenceConverter.setDefault(store, PHPDOC_TAG, PHPColorProvider.PHPDOC_TAG);
/**
* Open a file in the Workbench that may or may not exist in the workspace. Must be run on the UI thread.
- *
+ *
* @param filename
* @throws CoreException
*/
/**
* Open a file in the Workbench that may or may not exist in the workspace. Must be run on the UI thread.
- *
+ *
* @param filename
* @param line
* @throws CoreException
/**
* Open a file in the Workbench that may or may not exist in the workspace. Must be run on the UI thread.
- *
+ *
* @param filename
* @param offset
* @throws CoreException
/**
* Returns a combined preference store, this store is read-only.
- *
+ *
* @return the combined preference store
- *
+ *
* @since 3.0
*/
public IPreferenceStore getCombinedPreferenceStore() {
/**
* Returns the registry of the extensions to the <code>net.sourceforge.phpdt.ui.javaFoldingStructureProvider</code> extension
* point.
- *
+ *
* @return the registry of contributed <code>IJavaFoldingStructureProvider</code>
* @since 3.0
*/
* <p>
* If this method is called in the dynamic scope of another such call, this method simply runs the action.
* </p>
- *
+ *
* @param action
* the action to perform
* @param monitor
* The supplied scheduling rule is used to determine whether this operation can be run simultaneously with workspace changes in
* other threads. See <code>IWorkspace.run(...)</code> for more details.
* </p>
- *
+ *
* @param action
* the action to perform
* @param rule
/**
* Returns the template context type registry for the java plugin.
- *
+ *
* @return the template context type registry for the java plugin
* @since 3.0
*/
/**
* Returns the template store for the java editor templates.
- *
+ *
* @return the template store for the java editor templates
* @since 3.0
*/
/**
* Returns the template context type registry for the code generation templates.
- *
+ *
* @return the template context type registry for the code generation templates
* @since 3.0
*/
/**
* Returns the template store for the code generation templates.
- *
+ *
* @return the template store for the code generation templates
* @since 3.0
*/
+++ /dev/null
- package net.sourceforge.phpeclipse.phpeditor.html;
-
-import java.io.StringWriter;
-import java.util.HashSet;
-import java.util.Set;
-
-import net.sourceforge.phpdt.ui.text.PHPSourceViewerConfiguration;
-import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-/**
- * Modified from the XMLFormatter. Some tags in HTML do not indent.
- *
- * @fixme The HTML parser cannot recognize < tag> as tag due to the extra space.
- *
- * @author chrisl
- */
-public class HTMLFormatter implements IHTMLConstants {
-
- ////////////////////////////////////////////////////////////////////////
-
- private static final String NAME = "HTMLFormatter";
- private static final boolean TRACE = false;
-// private static boolean VERBOSE = false;
-
- private static Set fBLOCK_TAG_SET;
- private static Set fSTART_TAG_SET;
- static {
- fBLOCK_TAG_SET = new HashSet();
- for (int i = 0; i < BLOCK_TAGS.length; ++i)
- fBLOCK_TAG_SET.add(BLOCK_TAGS[i]);
- //
- fSTART_TAG_SET = new HashSet();
- for (int i = 0; i < START_TAGS.length; ++i)
- fSTART_TAG_SET.add(START_TAGS[i]);
- }
-
- ////////////////////////////////////////////////////////////////////////
-
- private PHPSourceViewerConfiguration fConfig;
- private SourceViewer fViewer;
- //
- private ITextEditor fEditor;
- private String fFilename;
-
- ////////////////////////////////////////////////////////////////////////
-
- /**
- * Constructor for XMLFormatter.
- */
- public HTMLFormatter(PHPSourceViewerConfiguration cf, SourceViewer viewer) {
- fConfig=cf;
- fViewer = viewer;
- //
- fEditor = fConfig.getEditor();
- }
-
- ////////////////////////////////////////////////////////////////////////
-
- /**
- * Formats the String <code>sourceString</code>,
- * and returns a string containing the formatted version.
- *
- * @param string the string to format
- * @param indentationLevel the initial indentation level, used
- * to shift left/right the entire source fragment. An initial indentation
- * level of zero has no effect.
- * @param positions an array of positions to map. These are
- * character-based source positions inside the original source,
- * for which corresponding positions in the formatted source will
- * be computed (so as to relocate elements associated with the original
- * source). It updates the positions array with updated positions.
- * If set to <code>null</code>, then no positions are mapped.
- * @param lineSeparator the line separator to use in formatted source,
- * if set to <code>null</code>, then the platform default one will be used.
- * @return the formatted output string.
- */
- public String format(
- String string,
- int indentationLevel,
- int[] positions,
- String lineSeparator,
- String inputname) {
- StringWriter ret = new StringWriter(2048);
- try {
- if (PHPeclipsePlugin.DEBUG) {
- System.err.println(NAME + ".format(): inputname=" + inputname);
- }
-// TidyHTMLParser parser = new TidyHTMLParser(new TidyConfiguration(fEditor, fViewer));
-// parser.setCompactFormat(
-// ((Boolean) fViewer.getData(IConstants.KEY_COMPACT_FORMAT)).booleanValue());
-// parser.parse(new StringReader(string), inputname, new PrintWriter(ret));
-// if (parser.getParseErrors() != 0) {
-// PHPeclipsePlugin.log(IStatus.INFO, "Parse error");
-// return string;
-// }
- return ret.toString();
- } catch (Exception e) {
- // PHPeclipsePlugin.error("Unknown parse error: "+e.getMessage(), null, fEditor.getEditorInput(), fViewer);
- PHPeclipsePlugin.log(IStatus.ERROR, e.getMessage());
- return string;
- }
- }
-
-}
+++ /dev/null
-package net.sourceforge.phpeclipse.phpeditor.html;
-
-import net.sourceforge.phpdt.ui.text.PHPSourceViewerConfiguration;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.formatter.IFormattingStrategy;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-/**
- * @author chrisl
- *
- * To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>ObfuscatorIgnores.
- * To enable and disable the creation of type comments go to
- * Window>Preferences>Java>Code Generation.
- */
-public class HTMLFormattingStrategy implements IFormattingStrategy, IHTMLConstants {
-
- ////////////////////////////////////////////////////////////////////////
-
- private PHPSourceViewerConfiguration fConfig;
- private ISourceViewer fViewer;
- //
- private ITextEditor fEditor;
- private int fTabWidth;
-
- ////////////////////////////////////////////////////////////////////////
-
- public HTMLFormattingStrategy(PHPSourceViewerConfiguration cf, ISourceViewer viewer) {
- fConfig = cf;
- fViewer = viewer;
- //
- fEditor = fConfig.getEditor();
- initPreferences();
- }
-
- public void initPreferences() {
- fTabWidth=fConfig.getTabWidth(fViewer);
- }
-
- ////////////////////////////////////////////////////////////////////////
-
- /**
- * @see IFormattingStrategy#formatterStarts(String)
- */
- public void formatterStarts(String initialIndentation) {
- }
-
- /**
- * @see IFormattingStrategy#formatterStops()
- */
- public void formatterStops() {
- }
-
- /**
- * @see IFormattingStrategy#format(String, boolean, String, int[])
- */
- public String format(String content, boolean isLineStart, String indentation, int[] positions) {
- HTMLFormatter formatter = new HTMLFormatter(fConfig, (SourceViewer) fViewer);
- IDocument doc = fViewer.getDocument();
- String lineDelimiter = getLineDelimiterFor(doc);
- int indent = 0;
- if (indentation != null) {
- indent = computeIndent(indentation, fTabWidth);
- }
- return formatter.format(content, indent, positions, lineDelimiter, fEditor.getEditorInput().getName());
- }
-
- public static String getLineDelimiterFor(IDocument doc) {
- String lineDelim = null;
- try {
- lineDelim = doc.getLineDelimiter(0);
- } catch (BadLocationException e) {
- }
- if (lineDelim == null) {
- String systemDelimiter = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
- String[] lineDelims = doc.getLegalLineDelimiters();
- for (int i = 0; i < lineDelims.length; i++) {
- if (lineDelims[i].equals(systemDelimiter)) {
- lineDelim = systemDelimiter;
- break;
- }
- }
- if (lineDelim == null) {
- lineDelim = lineDelims.length > 0 ? lineDelims[0] : systemDelimiter;
- }
- }
- return lineDelim;
- }
-
- /**
- * Returns the indent of the given string.
- *
- * @param line the text line
- * @param tabWidth the width of the '\t' character.
- *
- * @see net.sourceforge.phpdt.internal.corext.util.Strings.computeIndent(String,int)
- */
- public static int computeIndent(String line, int tabWidth) {
- int result = 0;
- int blanks = 0;
- int size = line.length();
- for (int i = 0; i < size; i++) {
- char c = line.charAt(i);
- if (c == '\t') {
- result++;
- blanks = 0;
- } else if (Character.isSpaceChar(c)) {
- blanks++;
- if (blanks == tabWidth) {
- result++;
- blanks = 0;
- }
- } else {
- return result;
- }
- }
- return result;
- }
-
- ////////////////////////////////////////////////////////////////////////
-
-}
+++ /dev/null
-package net.sourceforge.phpeclipse.phpeditor.html;
-
-
-/**
- * @author chrisl
- */
-public interface IHTMLConstants {
-
- int NONE=0;
- int TEXT=1;
- int FOLDER=2;
- int ANCHOR=3;
-
- /**
- * Tags that do not allow end tag.
- * Required that tags that allow optional end tag should always have end tag.
- */
- String[] EMPTY_TAGS =
- new String[] {
- "AREA",
- "BASE",
- "BASEFONT",
- "BR",
- "COL",
- "FRAME",
- "HR",
- "IMG",
- "INPUT",
- "ISINDEX",
- "LINK",
- "META",
- "PARAM",
- };
-
- String[] START_TAGS =
- new String[] {
- "A",
- "ADDRESS",
- "APPLET",
- "B",
- "BIG",
- "BLOCKQUOTE",
- "BODY",
- "CAPTION",
- "CENTER",
- "CITE",
- "CODE",
- "COL",
- "COLGROUP",
- "DD",
- "DFN",
- "DIR",
- "DIV",
- "DL",
- "DT",
- "EM",
- "FONT",
- "FORM",
- "FRAMESET",
- "H1",
- "H2",
- "H3",
- "H4",
- "H5",
- "H6",
- "HEAD",
- "HTML",
- "I",
- "KBD",
- "LI",
- "MAP",
- "MENU",
- "NOBR",
- "NOFRAMES",
- "OBJECT",
- "OL",
- "OPTION",
- "P",
- "PRE",
- "SAMP",
- "SCRIPT",
- "SELECT",
- "SMALL",
- "SPAN",
- "STRIKE",
- "S",
- "STRONG",
- "STYLE",
- "SUB",
- "SUP",
- "TABLE",
- "TD",
- "TEXTAREA",
- "TH",
- "TITLE",
- "TR",
- "TT",
- "U",
- "UL",
- "VAR",
- };
-
- /** Line break before and after tag. */
- String[] BLOCK_TAGS =
- new String[] {
- "A",
- "APPLET",
- "AREA",
- "BASE",
- "BASEFONT",
- "BLOCKQUOTE",
- "BODY",
- "BR",
- "CAPTION",
- "CITE",
- "CODE",
- "DD",
- "DFN",
- "DIR",
- "DIV",
- "DL",
- "DT",
- "FORM",
- "FRAME",
- "FRAMESET",
- "H1",
- "H2",
- "H3",
- "H4",
- "H5",
- "H6",
- "HEAD",
- "HR",
- "HTML",
- "IMG",
- "INPUT",
- "ISINDEX",
- "LI",
- "LINK",
- "MAP",
- "MENU",
- "META",
- "NOBR",
- "NOFRAMES",
- "OBJECT",
- "OL",
- "OPTION",
- "P",
- "PARAM",
- "PRE",
- "SAMP",
- "SCRIPT",
- "SELECT",
- "STRIKE",
- "TABLE",
- "TD",
- "TEXTAREA",
- "TH",
- "TITLE",
- "TR",
- "UL",
- };
-}
Contributors:
Igor Malinin - initial contribution
- $Id: PHPPartitionScanner.java,v 1.29 2005-05-15 23:24:41 axelcl Exp $
+ $Id: PHPPartitionScanner.java,v 1.30 2005-09-30 18:10:36 axelcl Exp $
**********************************************************************/
package net.sourceforge.phpeclipse.phpeditor.php;
import org.eclipse.jface.text.rules.Token;
/**
- *
- *
+ *
+ *
* @author Igor Malinin
*/
public class PHPPartitionScanner implements IPartitionTokenScanner {
private IDocument document;
- private int begin;
+// private int begin;
private int end;
private int position;
- private int state;
+// private int state;
private Map tokens = new HashMap();
switch (read()) {
case ICharacterScanner.EOF:
- state = STATE_DEFAULT;
+// state = STATE_DEFAULT;
return getToken(null);
case '<':
switch (read()) {
case ICharacterScanner.EOF:
- state = STATE_DEFAULT;
+// state = STATE_DEFAULT;
return getToken(null);
case '?': // <?
loop: while (true) {
switch (read()) {
case ICharacterScanner.EOF:
- state = STATE_DEFAULT;
+// state = STATE_DEFAULT;
return getToken(null);
case '<':
switch (read()) {
case ICharacterScanner.EOF:
- state = STATE_DEFAULT;
+// state = STATE_DEFAULT;
return getToken(null);
case '?':
unread();
- state = STATE_DEFAULT;
+// state = STATE_DEFAULT;
return getToken(null);
}
}
while (true) {
switch (ch) {
case ICharacterScanner.EOF:
- state = STATE_DEFAULT;
+// state = STATE_DEFAULT;
return getToken(token);
case '"': // double quoted string
// read until end of double quoted string
if (!readUntilEscapedDQ()) {
- state = STATE_DEFAULT;
+// state = STATE_DEFAULT;
return getToken(token);
}
break;
case '\'': // single quoted string
// read until end of single quoted string
if (!readUntilEscapedSQ()) {
- state = STATE_DEFAULT;
+// state = STATE_DEFAULT;
return getToken(token);
}
break;
case '/':
// read until end of line
if (!readSingleLine()) {
- state = STATE_DEFAULT;
+// state = STATE_DEFAULT;
return getToken(token);
}
break;
case '*':
// read until end of comment
if (!readMultiLineComment()) {
- state = STATE_DEFAULT;
+// state = STATE_DEFAULT;
return getToken(token);
}
break;
case '#': // line comment
// read until end of line
if (!readSingleLine()) {
- state = STATE_DEFAULT;
+// state = STATE_DEFAULT;
return getToken(token);
}
break;
switch (ch) {
case ICharacterScanner.EOF:
case '>':
- state = STATE_DEFAULT;
+// state = STATE_DEFAULT;
return getToken(token);
case '?':
// e.printStackTrace();
// }
// }
-
+
if (type == null) {
return Token.UNDEFINED;
}
}
return false;
}
-
+
private boolean readUntilEscapedSQ() {
// search last single quoted character
- try {
+ try {
char ch;
while (true) {
if (position >= end) {
return false;
}
- ch = document.getChar(position++);
+ ch = document.getChar(position++);
if (ch == '\\') {
if (position >= end) {
return false;
if (position >= end) {
return false;
}
- } while (document.getChar(position++) != '\n');
+ } while (document.getChar(position++) != '\n');
return true;
} catch (BadLocationException e) {
--position;
*/
public void setRange(IDocument document, int offset, int length) {
this.document = document;
- this.begin = offset;
+// this.begin = offset;
this.end = offset + length;
this.offset = offset;
* @see org.eclipse.jface.text.rules.IPartitionTokenScanner
*/
public void setPartialRange(IDocument document, int offset, int length, String contentType, int partitionOffset) {
- state = STATE_DEFAULT;
+// state = STATE_DEFAULT;
if (partitionOffset > -1) {
int delta = offset - partitionOffset;
if (delta > 0) {
+++ /dev/null
-/*
- * Created on 28.04.2003
- *
- */
-package net.sourceforge.phpeclipse.phpeditor.php;
-
-import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.rules.ICharacterScanner;
-import org.eclipse.jface.text.rules.IToken;
-import org.eclipse.jface.text.rules.Token;
-
-
-/**
- * Defines a partition in a phpdocument. This class keeps tracks of
- * partitions contained within other partitions.
- *
- * @author Stefan Langer
- * @version $Revision: 1.4 $
- */
-public abstract class Partition
-{
- private IDocument fDocument;
- private IToken fContentToken;
- private String fParentPartition;
- private char[] fTextBuffer;
- private int fOffset = 0;
- private char entry;
- private char exit;
- private boolean inDoubleString = false;
- private boolean inSingleString = false;
-
- public Partition(IDocument document, char[] delim, String contentType, String parentPartition)
- {
- fDocument = document;
- fContentToken = new Token(contentType);
- fParentPartition = parentPartition;
- entry = delim[0];
- exit = delim[1];
- }
-
- public Partition(IDocument document, char[] delim, String contentType)
- {
- this(document, delim, contentType, IPHPPartitions.HTML);
- }
-
- /**
- * Checks wether the specified type is allowed within this
- * partition type.
- *
- * @param type The type of the partition to check.
- *
- * @return <code>true</code> if the partition is allowed within this
- * partition otherwise <code>false</code>.
- */
- abstract protected boolean allowedPartition(String type);
-
- abstract protected boolean scan();
-
- protected boolean isEnd()
- {
- return fOffset >= fTextBuffer.length;
- }
-
- protected int read()
- {
- if(fOffset > fTextBuffer.length)
- return ICharacterScanner.EOF;
-
- char ret = fTextBuffer[fOffset++];
- switch(ret)
- {
- case '\'':
- if(!inDoubleString)
- inSingleString = !inSingleString;
- break;
- case '"':
- if(!inSingleString)
- inDoubleString = !inDoubleString;
- break;
- }
- return ret;
- }
-
- protected void unread(int i)
- {
- for (int j = 0; j < i && fOffset > 0; j++)
- {
- char read = fTextBuffer[--fOffset];
-
- switch (read)
- {
- case '\'' :
- if (!inDoubleString)
- inSingleString = !inSingleString;
- break;
- case '"' :
- if (!inSingleString)
- inDoubleString = !inDoubleString;
- break;
- }
- } // END FOR
- }
-
- public boolean scanRange(int offset, int length)
- throws BadLocationException
- { // short circuit scanning if entry is not correct
- if (fDocument.getChar(offset) != entry)
- return false;
- // read the full range into the internal buffer
- fOffset = 0;
- inSingleString = false;
- inDoubleString = false;
- fTextBuffer = fDocument.get(offset, length).toCharArray();
- return scan();
- }
-
- protected boolean checkPattern(String pattern, boolean ignoreCase)
- {
- char[] checkPattern = pattern.toCharArray();
- int offset = fOffset;
- for(int i=0; i<checkPattern.length; i++)
- {
- if(isEnd() || !letterEquals(read(), checkPattern[i], ignoreCase))
- {
- fOffset = offset;
- return false;
- }
- }
- return true;
- }
-
- private boolean letterEquals(int test, char letter, boolean ignoreCase)
- {
- if (test == letter)
- return true;
- else if (
- ignoreCase
- && Character.isLowerCase(letter)
- && test == Character.toUpperCase(letter))
- return true;
- else if (
- ignoreCase
- && Character.isUpperCase(letter)
- && test == Character.toLowerCase(letter))
- return true;
-
- return false;
- }
-
-
-
- protected boolean inString()
- {
- return inDoubleString || inSingleString;
- }
-
-
-
-
- public IToken getToken()
- {
- return fContentToken;
- }
-
- public int getLength()
- {
- return fOffset;
- }
-
- /**
- * @return
- */
- public IDocument getDocument()
- {
- return fDocument;
- }
-
- /**
- * @return
- */
- public String getParentPartition()
- {
- return fParentPartition;
- }
-
- /**
- * @param document
- */
- public void setDocument(IDocument document)
- {
- fDocument = document;
- }
-
- /**
- * @param string
- */
- public void setParentPartition(String string)
- {
- fParentPartition = string;
- }
-
-
- /**
- * @return
- */
- public char getEntry()
- {
- return entry;
- }
-
- /**
- * @return
- */
- public char getExit()
- {
- return exit;
- }
-
- /**
- * @return
- */
- protected int getOffset()
- {
- return fOffset;
- }
-
- /**
- * @param i
- */
- protected void setOffset(int i)
- {
- fOffset = i;
- }
-
-}
+++ /dev/null
-/*
- * Created on 28.04.2003
- *
- */
-package net.sourceforge.phpeclipse.phpeditor.php;
-
-import java.util.ArrayList;
-
-import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
-
-import org.eclipse.jface.text.IDocument;
-
-/**
- * A stack for keeping track of the contenttypes for partitions that
- * contain other partitions.
- *
- * @author Stefan Langer
- * @version $Revision: 1.4 $
- */
-public class PartitionStack
-{
- private ArrayList fPartitionStack = new ArrayList(5);
- private int fStackTop = -1;
-
- /**
- * Pushes the specified contenttype onto the partitionstack.
- * This will keep track of the last partitions read.
- * @param contentType The contenttype to push onto the stack.
- */
- public void pushStack(String contentType)
- {
- if(fStackTop < fPartitionStack.size())
- {
- fPartitionStack.add(++fStackTop, contentType);
- }
- }
- /**
- * Returns the contentype of the last partition on the partition stack.
- * If no partition is currently on the stack this function simply returns
- * the HTML contenttype as default.
- * @return The contenttype of the last partition on stack.
- */
- public String popStack()
- {
- if(fStackTop >= 0)
- {
- return (String)fPartitionStack.get(fStackTop--);
- }
-
- return IPHPPartitions.HTML;
- }
-
- public boolean isEmpty()
- {
- return (fStackTop < 0);
- }
-
- /**
- * Initializes this stack from the specified document for the
- * specified offset.
- * @param offset The offset to initialize from
- * @param fDocument The document to initialize from
- */
- public void initializeStack(int offset, IDocument fDocument)
- {
-
- }
-
-}