From: axelcl Date: Fri, 28 Jan 2005 18:12:42 +0000 (+0000) Subject: Moved the project.index file to eclipse/workspace/.metadata/.plugins/org.eclipse... X-Git-Url: http://git.phpeclipse.com Moved the project.index file to eclipse/workspace/.metadata/.plugins/org.eclipse.core.resources/.projects//net.sourceforge.phpeclipse/project.index --- diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java index cc9ce7a..ad67bec 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java @@ -50,7 +50,7 @@ public class Parser //extends PHPParserSuperclass implements ITerminalSymbols, CompilerModifiers, ParserBasicInformation { //internal data for the automat protected final static int StackIncrement = 255; - + protected int stateStackTop; protected int[] stack = new int[StackIncrement]; @@ -1168,7 +1168,7 @@ public class Parser //extends PHPParserSuperclass // typeDecl.sourceStart, typeDecl.sourceEnd); } getNextToken(); - interface_extends_list(); + interface_extends_list(typeDecl); } else { typeDecl.name = new char[] { ' ' }; throwSyntaxError("Interface name expected after keyword 'interface'.", typeDecl.sourceStart, typeDecl.sourceEnd); @@ -1197,7 +1197,7 @@ public class Parser //extends PHPParserSuperclass // /* empty */ // | T_EXTENDS fully_qualified_class_name if (token == TokenNameextends) { - interface_extends_list(); + interface_extends_list(typeDecl); // getNextToken(); // if (token != TokenNameIdentifier) { // throwSyntaxError("Class name expected after keyword @@ -1206,7 +1206,7 @@ public class Parser //extends PHPParserSuperclass // .getCurrentTokenEndPosition()); // } } - implements_list(); + implements_list(typeDecl); } else { typeDecl.name = new char[] { ' ' }; throwSyntaxError("Class name expected after keyword 'class'.", typeDecl.sourceStart, typeDecl.sourceEnd); @@ -1260,7 +1260,21 @@ public class Parser //extends PHPParserSuperclass } } - private void interface_extends_list() { + private void class_extends(TypeDeclaration typeDecl) { + // /* empty */ + // | T_EXTENDS interface_list + if (token == TokenNameextends) { + getNextToken(); + + if (token == TokenNameIdentifier) { + getNextToken(); + } else { + throwSyntaxError("Class name expected after keyword 'extends'."); + } + } + } + + private void interface_extends_list(TypeDeclaration typeDecl) { // /* empty */ // | T_EXTENDS interface_list if (token == TokenNameextends) { @@ -1269,11 +1283,11 @@ public class Parser //extends PHPParserSuperclass } } - private void implements_list() { + private void implements_list(TypeDeclaration typeDecl) { // /* empty */ // | T_IMPLEMENTS interface_list if (token == TokenNameimplements) { - getNextToken(); + getNextToken(); interface_list(); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaModelManager.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaModelManager.java index 3410fbc..9285302 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaModelManager.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaModelManager.java @@ -1191,6 +1191,7 @@ public class JavaModelManager implements ISaveParticipant { 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. @@ -1317,8 +1318,8 @@ public class JavaModelManager implements ISaveParticipant { // } // // // load variables and containers from preferences into cache -// Preferences preferences = PHPCore.getPlugin().getPluginPreferences(); -// +// Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences(); + // // only get variable from preferences not set to their default // String[] propertyNames = preferences.propertyNames(); // int variablePrefixLength = CP_VARIABLE_PREFERENCES_PREFIX.length(); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java index 61c802a..db6ef26 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java @@ -28,6 +28,7 @@ import net.sourceforge.phpdt.externaltools.internal.model.ColorManager; import net.sourceforge.phpdt.externaltools.internal.model.ExternalToolsPlugin; import net.sourceforge.phpdt.internal.core.BatchOperation; import net.sourceforge.phpdt.internal.core.JavaModelManager; +import net.sourceforge.phpdt.internal.core.util.Util; import net.sourceforge.phpdt.internal.corext.template.php.CodeTemplateContextType; import net.sourceforge.phpdt.internal.corext.template.php.HTMLContextType; import net.sourceforge.phpdt.internal.corext.template.php.JavaContextType; @@ -77,6 +78,7 @@ import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.ISchedulingRule; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.action.GroupMarker; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.Separator; @@ -609,7 +611,10 @@ IWorkspace w; * @return */ public IdentifierIndexManager getIndexManager(IProject iProject) { - String indexFilename = iProject.getLocation() + File.separator + "project.index"; + IPath path = iProject.getWorkingLocation(PHPeclipsePlugin.PLUGIN_ID); + path = path.append("project.index"); + String indexFilename = path.toString(); +// System.out.println(indexFilename); IdentifierIndexManager indexManager = (IdentifierIndexManager) fIndexManagerMap.get(indexFilename); if (indexManager == null) { indexManager = new IdentifierIndexManager(indexFilename); @@ -1162,9 +1167,9 @@ IWorkspace w; // JavaCore.getPlugin().getStateLocation(); getStateLocation(); // retrieve variable values - //JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new - // JavaModelManager.PluginPreferencesListener()); - // manager.loadVariablesAndContainers(); + PHPeclipsePlugin.getDefault().getPluginPreferences().addPropertyChangeListener(new + JavaModelManager.PluginPreferencesListener()); +// manager.loadVariablesAndContainers(); final IWorkspace workspace = ResourcesPlugin.getWorkspace(); workspace.addResourceChangeListener(manager.deltaState, IResourceChangeEvent.PRE_BUILD | IResourceChangeEvent.POST_BUILD @@ -1175,33 +1180,33 @@ IWorkspace w; // process deltas since last activated in indexer thread so that indexes are up-to-date. // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38658 - // Job processSavedState = new Job(ProjectPrefUtil.bind("savedState.jobName")) { //$NON-NLS-1$ - // protected IStatus run(IProgressMonitor monitor) { - // try { - // // add save participant and process delta atomically - // // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=59937 - // workspace.run( - // new IWorkspaceRunnable() { - // public void run(IProgressMonitor progress) throws CoreException { - // ISavedState savedState = workspace.addSaveParticipant(PHPeclipsePlugin.this, manager); - // if (savedState != null) { - // // the event type coming from the saved state is always POST_AUTO_BUILD - // // force it to be POST_CHANGE so that the delta processor can handle it - // manager.deltaState.getDeltaProcessor().overridenEventType = IResourceChangeEvent.POST_CHANGE; - // savedState.processResourceChangeEvents(manager.deltaState); - // } - // } - // }, - // monitor); - // } catch (CoreException e) { - // return e.getStatus(); - // } - // return Status.OK_STATUS; - // } - // }; - // processSavedState.setSystem(true); - // processSavedState.setPriority(Job.SHORT); // process asap - // processSavedState.schedule(); + Job processSavedState = new Job(Util.bind("savedState.jobName")) { //$NON-NLS-1$ + protected IStatus run(IProgressMonitor monitor) { + try { + // add save participant and process delta atomically + // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=59937 + workspace.run( + new IWorkspaceRunnable() { + public void run(IProgressMonitor progress) throws CoreException { + ISavedState savedState = workspace.addSaveParticipant(PHPeclipsePlugin.this, manager); + if (savedState != null) { + // the event type coming from the saved state is always POST_AUTO_BUILD + // force it to be POST_CHANGE so that the delta processor can handle it + manager.deltaState.getDeltaProcessor().overridenEventType = IResourceChangeEvent.POST_CHANGE; + savedState.processResourceChangeEvents(manager.deltaState); + } + } + }, + monitor); + } catch (CoreException e) { + return e.getStatus(); + } + return Status.OK_STATUS; + } + }; + processSavedState.setSystem(true); + processSavedState.setPriority(Job.SHORT); // process asap + processSavedState.schedule(); } catch (RuntimeException e) { manager.shutdown(); throw e; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/IdentifierIndexManager.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/IdentifierIndexManager.java index cd647e3..7b7954c 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/IdentifierIndexManager.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/IdentifierIndexManager.java @@ -41,7 +41,7 @@ public class IdentifierIndexManager { private int fToken; public LineCreator() { - fScanner = new Scanner(true, false, false, false, true, null, null, true /*taskCaseSensitive*/); + fScanner = new Scanner(true, false, false, false, true, null, null, true /* taskCaseSensitive */); } /** @@ -303,7 +303,7 @@ public class IdentifierIndexManager { ident = fScanner.getCurrentStringLiteralSource(); addIdentifierInformation('d', ident, buf, phpdocOffset, phpdocLength); getNextToken(); - } + } } } } else { @@ -425,106 +425,112 @@ public class IdentifierIndexManager { boolean tokenExists = false; tokenizer = new StringTokenizer(line, "\t"); // first token contains the filename: - if (tokenizer.hasMoreTokens()) { - phpFileName = tokenizer.nextToken(); - //System.out.println(token); - } else { - return; - } - // all the other tokens are identifiers: - while (tokenizer.hasMoreTokens()) { - token = tokenizer.nextToken(); - //System.out.println(token); - switch (token.charAt(0)) { - case 'c': - // class name - identifier = token.substring(1); - classname = identifier; - phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.CLASS, phpFileName); - break; - case 'd': - // define - identifier = token.substring(1); - phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.DEFINE, phpFileName); - break; - case 'f': - // function name - identifier = token.substring(1); - phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.FUNCTION, phpFileName); - break; - case 'g': - // global variable - identifier = token.substring(1); - phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.GLOBAL_VARIABLE, phpFileName); - break; - case 'k': - // constructor function name - identifier = token.substring(1); - phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.CONSTRUCTOR, phpFileName); - break; - case 'm': - //method inside a class - identifier = token.substring(1); - phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.METHOD, phpFileName, classname); - break; - case 'v': - // variable inside a class - identifier = token.substring(1); - phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.VARIABLE, phpFileName, classname); - break; - case 'o': - // offset information - identifier = null; - if (phpIdentifier != null) { - offset = token.substring(1); - phpIdentifier.setOffset(Integer.parseInt(offset)); - } - break; - case 'p': - // PHPdoc offset information - identifier = null; - if (phpIdentifier != null) { - offset = token.substring(1); - phpIdentifier.setPHPDocOffset(Integer.parseInt(offset)); - } - break; - case 'l': - // PHPdoc length information - identifier = null; - if (phpIdentifier != null) { - offset = token.substring(1); - phpIdentifier.setPHPDocLength(Integer.parseInt(offset)); - } - break; - default: - PHPeclipsePlugin.log(IStatus.ERROR, "Unknown token character in IdentifierIndexManager: " + token.charAt(0)); - identifier = null; - phpIdentifier = null; - classname = null; + try { + if (tokenizer.hasMoreTokens()) { + phpFileName = tokenizer.nextToken(); + //System.out.println(token); + } else { + return; } - if (identifier != null && phpIdentifier != null) { - tokenExists = true; - ArrayList list = (ArrayList) fIndentifierMap.get(identifier); - if (list == null) { - list = new ArrayList(); - list.add(phpIdentifier); - fIndentifierMap.put(identifier, list); - } else { - boolean flag = false; - for (int i = 0; i < list.size(); i++) { - if (list.get(i).equals(phpIdentifier)) { - flag = true; - break; - } + // all the other tokens are identifiers: + while (tokenizer.hasMoreTokens()) { + token = tokenizer.nextToken(); + //System.out.println(token); + switch (token.charAt(0)) { + case 'c': + // class name + identifier = token.substring(1); + classname = identifier; + phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.CLASS, phpFileName); + break; + case 'd': + // define + identifier = token.substring(1); + phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.DEFINE, phpFileName); + break; + case 'f': + // function name + identifier = token.substring(1); + phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.FUNCTION, phpFileName); + break; + case 'g': + // global variable + identifier = token.substring(1); + phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.GLOBAL_VARIABLE, phpFileName); + break; + case 'k': + // constructor function name + identifier = token.substring(1); + phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.CONSTRUCTOR, phpFileName); + break; + case 'm': + //method inside a class + identifier = token.substring(1); + phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.METHOD, phpFileName, classname); + break; + case 'v': + // variable inside a class + identifier = token.substring(1); + phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.VARIABLE, phpFileName, classname); + break; + case 'o': + // offset information + identifier = null; + if (phpIdentifier != null) { + offset = token.substring(1); + phpIdentifier.setOffset(Integer.parseInt(offset)); + } + break; + case 'p': + // PHPdoc offset information + identifier = null; + if (phpIdentifier != null) { + offset = token.substring(1); + phpIdentifier.setPHPDocOffset(Integer.parseInt(offset)); + } + break; + case 'l': + // PHPdoc length information + identifier = null; + if (phpIdentifier != null) { + offset = token.substring(1); + phpIdentifier.setPHPDocLength(Integer.parseInt(offset)); } - if (flag == false) { + break; + default: + PHPeclipsePlugin.log(IStatus.ERROR, "Unknown token character in IdentifierIndexManager: " + token.charAt(0)); + identifier = null; + phpIdentifier = null; + classname = null; + } + if (identifier != null && phpIdentifier != null) { + tokenExists = true; + ArrayList list = (ArrayList) fIndentifierMap.get(identifier); + if (list == null) { + list = new ArrayList(); list.add(phpIdentifier); + fIndentifierMap.put(identifier, list); + } else { + boolean flag = false; + for (int i = 0; i < list.size(); i++) { + if (list.get(i).equals(phpIdentifier)) { + flag = true; + break; + } + } + if (flag == false) { + list.add(phpIdentifier); + } } } } + fFileMap.put(phpFileName, line); + } catch (Throwable e) { + // write to workspace/.metadata/.log file + PHPeclipsePlugin.log(e); } // if (tokenExists) { - fFileMap.put(phpFileName, line); + // } }