Merging code from trunk that fixes #774, this work was done by incastrix
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / builder / IdentifierIndexManager.java
index 499bd82..741ff32 100644 (file)
@@ -61,8 +61,6 @@ public class IdentifierIndexManager {
                        line.append('\t');
                        line.append(typeOfIdentifier);
                        line.append(identifier);
-                       // line.append("\to"); // Offset
-                       // line.append(fScanner.getCurrentTokenStartPosition());
                }
 
                /**
@@ -128,11 +126,6 @@ public class IdentifierIndexManager {
                                System.out.println(fScanner.toStringAction(fToken));
                        }
                        return;
-                       // } catch (InvalidInputException e) {
-                       // // ignore errors
-                       // // e.printStackTrace();
-                       // }
-                       // fToken = TokenNameERROR;
                }
 
                private void parseDeclarations(char[] parent, StringBuffer buf,
@@ -324,7 +317,6 @@ public class IdentifierIndexManager {
                                StringBuffer buf) {
                        char[] ident;
                        String identifier;
-                       int counter = 0;
                        boolean hasModifiers = false;
                        int phpdocOffset = -1;
                        int phpdocLength = -1;
@@ -334,7 +326,7 @@ public class IdentifierIndexManager {
                        try {
                                getNextToken();
                                while (fToken != TokenNameEOF) { // && fToken !=
-                                                                                                       // TokenNameERROR) {
+                                       // TokenNameERROR) {
                                        phpdocOffset = -1;
                                        hasModifiers = false;
                                        if (fToken == TokenNameCOMMENT_PHPDOC) {
@@ -508,12 +500,11 @@ public class IdentifierIndexManager {
         * 
         */
        public void addFile(IFile fileToParse) {
-               // InputStream iStream;
                LineCreator lineCreator = createLineCreator();
                try {
                        addInputStream(new BufferedInputStream(fileToParse.getContents()),
                                        fileToParse.getProjectRelativePath().toString(),
-                                       lineCreator);
+                                       lineCreator, fileToParse.getCharset());
                } catch (CoreException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
@@ -526,17 +517,13 @@ public class IdentifierIndexManager {
         * @throws CoreException
         */
        public void addInputStream(InputStream stream, String filePath,
-                       LineCreator lineCreator) throws CoreException {
+                       LineCreator lineCreator, String charset) throws CoreException {
                try {
                        StringBuffer lineBuffer = new StringBuffer();
                        lineBuffer.append(filePath);
-                       int lineLength = lineBuffer.length();
                        lineCreator.parseIdentifiers(Util.getInputStreamAsCharArray(stream,
-                                       -1, null), lineBuffer);
-                       // if (lineLength != lineBuffer.length()) {
-                       // always add the file for Open Include Action
+                                       -1, charset), lineBuffer);
                        addLine(lineBuffer.toString());
-                       // }
                } catch (IOException e) {
                        e.printStackTrace();
                } finally {
@@ -545,6 +532,7 @@ public class IdentifierIndexManager {
                                        stream.close();
                                }
                        } catch (IOException e) {
+                               // do nothing
                        }
                }
        }