implements ITerminalSymbols, CompilerModifiers, ParserBasicInformation {
//internal data for the automat
protected final static int StackIncrement = 255;
-
+
protected int stateStackTop;
protected int[] stack = new int[StackIncrement];
// 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);
// /* 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
// .getCurrentTokenEndPosition());
// }
}
- implements_list();
+ implements_list(typeDecl);
} else {
typeDecl.name = new char[] { ' ' };
throwSyntaxError("Class name expected after keyword 'class'.", typeDecl.sourceStart, typeDecl.sourceEnd);
}
}
- 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) {
}
}
- private void implements_list() {
+ private void implements_list(TypeDeclaration typeDecl) {
// /* empty */
// | T_IMPLEMENTS interface_list
if (token == TokenNameimplements) {
- getNextToken();
+ getNextToken();
interface_list();
}
}
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;
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;
* @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);
// 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
// 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;
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 */);
}
/**
ident = fScanner.getCurrentStringLiteralSource();
addIdentifierInformation('d', ident, buf, phpdocOffset, phpdocLength);
getNextToken();
- }
+ }
}
}
} else {
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);
+
// }
}