From b6b85c36bafd81b535f1b158503a6072e5b07121 Mon Sep 17 00:00:00 2001 From: Edward Mann Date: Mon, 21 Sep 2009 03:15:33 +0000 Subject: [PATCH] Merging code from trunk that fixes #774, this work was done by incastrix --- .../phpeclipse/builder/IdentifierIndexManager.java | 125 +++++++++----------- 1 files changed, 56 insertions(+), 69 deletions(-) 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 526ff4b..741ff32 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/IdentifierIndexManager.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/IdentifierIndexManager.java @@ -128,19 +128,6 @@ public class IdentifierIndexManager { return; } - private void skipComments() - { - try { - getNextToken(); - while (fToken == TokenNameCOMMENT_BLOCK || fToken == TokenNameCOMMENT_PHPDOC) { - getNextToken(); - } - } catch (InvalidInputException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - } - private void parseDeclarations(char[] parent, StringBuffer buf, boolean goBack) { char[] ident; @@ -172,7 +159,7 @@ public class IdentifierIndexManager { } } if (fToken == TokenNamefunction) { - skipComments(); + getNextToken(); if (fToken == TokenNameAND) { getNextToken(); } @@ -194,41 +181,40 @@ public class IdentifierIndexManager { phpdocOffset, phpdocLength); } } - skipComments(); + getNextToken(); parseDeclarations(null, buf, true); } } else if (fToken == TokenNameclass || fToken == TokenNameinterface) { - skipComments(); + getNextToken(); if (fToken == TokenNameIdentifier) { ident = fScanner.getCurrentIdentifierSource(); addIdentifierInformation('c', ident, buf, phpdocOffset, phpdocLength); - skipComments(); + getNextToken(); if (fToken == TokenNameextends) { - skipComments(); + getNextToken(); while (fToken == TokenNameIdentifier) { ident = fScanner .getCurrentIdentifierSource(); // extends ident addIdentifierInformation('e', ident, buf); - skipComments(); - if (fToken == TokenNameCOMMA) { - skipComments(); + getNextToken(); + if (fToken == TokenNameCOMMA) { + getNextToken(); } } } if (fToken == TokenNameimplements) { - skipComments(); + getNextToken(); while (fToken == TokenNameIdentifier) { ident = fScanner .getCurrentIdentifierSource(); // implements ident addIdentifierInformation('e', ident, buf); - skipComments(); + getNextToken(); if (fToken == TokenNameCOMMA) { - skipComments(); -// getNextToken(); + getNextToken(); } } } @@ -254,7 +240,7 @@ public class IdentifierIndexManager { || fToken == TokenNamepublic || fToken == TokenNameprotected || fToken == TokenNameprivate) { - skipComments(); + getNextToken(); } while (fToken == TokenNameVariable) { ident = fScanner.getCurrentIdentifierSource(); @@ -263,9 +249,9 @@ public class IdentifierIndexManager { ident.length - 1); addClassVariableInformation('v', classVariable, buf, phpdocOffset, phpdocLength); - skipComments(); + getNextToken(); if (fToken == TokenNameCOMMA) { - skipComments(); + getNextToken(); } } } else if (!hasModifiers && fToken == TokenNameIdentifier) { @@ -343,8 +329,7 @@ public class IdentifierIndexManager { // TokenNameERROR) { phpdocOffset = -1; hasModifiers = false; - switch (fToken) { - case TokenNameCOMMENT_PHPDOC: + if (fToken == TokenNameCOMMENT_PHPDOC) { phpdocOffset = fScanner.getCurrentTokenStartPosition(); phpdocLength = fScanner.getCurrentTokenEndPosition() - fScanner.getCurrentTokenStartPosition() + 1; @@ -361,10 +346,9 @@ public class IdentifierIndexManager { if (fToken == TokenNameEOF || fToken == TokenNameERROR) { break; } - break; - - case TokenNamefunction: - skipComments(); + } + if (fToken == TokenNamefunction) { + getNextToken(); if (fToken == TokenNameAND) { getNextToken(); } @@ -372,56 +356,40 @@ public class IdentifierIndexManager { ident = fScanner.getCurrentIdentifierSource(); addIdentifierInformation('f', ident, buf, phpdocOffset, phpdocLength); - skipComments(); - if (fToken == TokenNameLPAREN) { - skipComments(); - do { - if (fToken == TokenNameVariable) { - ident = fScanner.getCurrentIdentifierSource(); - addIdentifierInformation('v', ident, buf, - phpdocOffset, phpdocLength); - } - skipComments(); - if (fToken == TokenNameCOMMA) { - skipComments(); - } - } while (fToken != TokenNameRPAREN ); - } + getNextToken(); parseDeclarations(null, buf, true); } - break; - - case TokenNameclass: - case TokenNameinterface: - skipComments(); + } else if (fToken == TokenNameclass + || fToken == TokenNameinterface) { + getNextToken(); if (fToken == TokenNameIdentifier) { ident = fScanner.getCurrentIdentifierSource(); addIdentifierInformation('c', ident, buf, phpdocOffset, phpdocLength); - skipComments(); + getNextToken(); if (fToken == TokenNameextends) { - skipComments(); + getNextToken(); while (fToken == TokenNameIdentifier) { ident = fScanner .getCurrentIdentifierSource(); // extends ident addIdentifierInformation('e', ident, buf); - skipComments(); + getNextToken(); if (fToken == TokenNameCOMMA) { - skipComments(); + getNextToken(); } } } if (fToken == TokenNameimplements) { - skipComments(); + getNextToken(); while (fToken == TokenNameIdentifier) { ident = fScanner .getCurrentIdentifierSource(); // implements ident addIdentifierInformation('e', ident, buf); - skipComments(); + getNextToken(); if (fToken == TokenNameCOMMA) { - skipComments(); + getNextToken(); } } } @@ -435,20 +403,39 @@ public class IdentifierIndexManager { } parseDeclarations(ident, buf, true); } - break; - - case TokenNameVariable: + } else if (fToken == TokenNameVariable) { // global variable ident = fScanner.getCurrentIdentifierSource(); addIdentifierInformation('g', ident, buf, phpdocOffset, phpdocLength); getNextToken(); - break; - - default: + } else if (!hasModifiers && fToken == TokenNameIdentifier) { + ident = fScanner.getCurrentIdentifierSource(); + getNextToken(); + if (ident.length == 6 && ident[0] == 'd' + && ident[1] == 'e' && ident[2] == 'f' + && ident[3] == 'i' && ident[4] == 'n' + && ident[5] == 'e') { + if (fToken == TokenNameLPAREN) { + getNextToken(); + if (fToken == TokenNameStringDoubleQuote) { + ident = fScanner + .getCurrentStringLiteralSource(); + addIdentifierInformation('d', ident, buf, + phpdocOffset, phpdocLength); + getNextToken(); + } else if (fToken == TokenNameStringSingleQuote) { + ident = fScanner + .getCurrentStringLiteralSource(); + addIdentifierInformation('d', ident, buf, + phpdocOffset, phpdocLength); + getNextToken(); + } + } + } + } else { getNextToken(); } - } } catch (InvalidInputException e) { // ignore errors @@ -458,7 +445,7 @@ public class IdentifierIndexManager { } } } - + class StringComparator implements Comparator { public int compare(Object o1, Object o2) { String s1 = (String) o1; -- 1.7.1