1) Moved net.sourceforge.phpeclipse.ui\src\net\sourceforge\phpdt back to net.sourcefo...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / text / folding / DefaultJavaFoldingStructureProvider.java
index 2b8c0ee..074e4e9 100644 (file)
@@ -36,6 +36,7 @@ import net.sourceforge.phpdt.core.JavaModelException;
 import net.sourceforge.phpdt.core.ToolFactory;
 import net.sourceforge.phpdt.core.compiler.IScanner;
 import net.sourceforge.phpdt.core.compiler.ITerminalSymbols;
+import net.sourceforge.phpdt.core.compiler.ITerminalSymbols.TokenName;
 import net.sourceforge.phpdt.core.compiler.InvalidInputException;
 import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
 import net.sourceforge.phpdt.internal.ui.text.DocumentCharacterIterator;
@@ -47,7 +48,9 @@ import net.sourceforge.phpeclipse.phpeditor.PHPEditor;
 import net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor;
 
 import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.Assert;
+//incastrix
+//import org.eclipse.jface.text.Assert;
+import org.eclipse.core.runtime.Assert;
 import org.eclipse.jface.text.BadLocationException;
 import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.IRegion;
@@ -695,20 +698,20 @@ public class DefaultJavaFoldingStructureProvider implements
                                        scanner.setSource(contents.toCharArray());
                                        scanner.setPHPMode(true);
 
-                                       int token = scanner.getNextToken();
-                                       while (token != ITerminalSymbols.TokenNameEOF) {
+                                       TokenName token = scanner.getNextToken();
+                                       while (token != ITerminalSymbols.TokenName.EOF) {
 
                                                token = scanner.getNextToken();
                                                start = shift + scanner.getCurrentTokenStartPosition();
 
                                                switch (token) {
-                                               case ITerminalSymbols.TokenNameCOMMENT_PHPDOC:
-                                               case ITerminalSymbols.TokenNameCOMMENT_BLOCK: {
+                                               case COMMENT_PHPDOC:
+                                               case COMMENT_BLOCK: {
                                                        int end = shift
                                                                        + scanner.getCurrentTokenEndPosition() + 1;
                                                        regions.add(new Region(start, end - start));
                                                }
-                                               case ITerminalSymbols.TokenNameCOMMENT_LINE:
+                                               case COMMENT_LINE:
                                                        continue;
                                                }
                                        }
@@ -764,14 +767,14 @@ public class DefaultJavaFoldingStructureProvider implements
                        int headerEnd = -1;
                        try {
                                boolean foundComment = false;
-                               int terminal = scanner.getNextToken();
-                               while (terminal != ITerminalSymbols.TokenNameEOF
-                                               && !(terminal == ITerminalSymbols.TokenNameclass
-                                                               || terminal == ITerminalSymbols.TokenNameinterface || foundComment)) {
-
-                                       if (terminal == ITerminalSymbols.TokenNameCOMMENT_PHPDOC
-                                                       || terminal == ITerminalSymbols.TokenNameCOMMENT_BLOCK
-                                                       || terminal == ITerminalSymbols.TokenNameCOMMENT_LINE) {
+                               TokenName terminal = scanner.getNextToken();
+                               while (terminal != ITerminalSymbols.TokenName.EOF
+                                               && !(terminal == ITerminalSymbols.TokenName.CLASS
+                                                               || terminal == ITerminalSymbols.TokenName.INTERFACE || foundComment)) {
+
+                                       if (terminal == ITerminalSymbols.TokenName.COMMENT_PHPDOC
+                                                       || terminal == ITerminalSymbols.TokenName.COMMENT_BLOCK
+                                                       || terminal == ITerminalSymbols.TokenName.COMMENT_LINE) {
                                                if (!foundComment)
                                                        headerStart = scanner
                                                                        .getCurrentTokenStartPosition();
@@ -860,42 +863,47 @@ public class DefaultJavaFoldingStructureProvider implements
                        while (e.hasNext()) {
                                JavaProjectionAnnotation newAnnotation = (JavaProjectionAnnotation) e
                                                .next();
-                               IJavaElement element = newAnnotation.getElement();
+//+
                                Position newPosition = (Position) updated.get(newAnnotation);
-
-                               List annotations = (List) previous.get(element);
-                               if (annotations == null) {
-
-                                       additions.put(newAnnotation, newPosition);
-
-                               } else {
-                                       Iterator x = annotations.iterator();
-                                       boolean matched = false;
-                                       while (x.hasNext()) {
-                                               Tuple tuple = (Tuple) x.next();
-                                               JavaProjectionAnnotation existingAnnotation = tuple.annotation;
-                                               Position existingPosition = tuple.position;
-                                               if (newAnnotation.isComment() == existingAnnotation
-                                                               .isComment()) {
-                                                       if (existingPosition != null
-                                                                       && (!newPosition.equals(existingPosition))) {
-                                                               existingPosition.setOffset(newPosition
-                                                                               .getOffset());
-                                                               existingPosition.setLength(newPosition
-                                                                               .getLength());
-                                                               updates.add(existingAnnotation);
-                                                       }
-                                                       matched = true;
-                                                       x.remove();
-                                                       break;
-                                               }
-                                       }
-                                       if (!matched)
-                                               additions.put(newAnnotation, newPosition);
-
-                                       if (annotations.isEmpty())
-                                               previous.remove(element);
-                               }
+                               additions.put(newAnnotation, newPosition);
+//-
+//                             IJavaElement element = newAnnotation.getElement();
+//                             Position newPosition = (Position) updated.get(newAnnotation);
+//
+//                             List annotations = (List) previous.get(element);
+//                             if (annotations == null) {
+//
+//                                     additions.put(newAnnotation, newPosition);
+//
+//                             } else {
+//                                     Iterator x = annotations.iterator();
+//                                     boolean matched = false;
+//                                     while (x.hasNext()) {
+//                                             Tuple tuple = (Tuple) x.next();
+//                                             JavaProjectionAnnotation existingAnnotation = tuple.annotation;
+//                                             Position existingPosition = tuple.position;
+//                                             if (newAnnotation.isComment() == existingAnnotation
+//                                                             .isComment()) {
+//                                                     if (existingPosition != null
+//                                                                     && (!newPosition.equals(existingPosition))) {
+//                                                             existingPosition.setOffset(newPosition
+//                                                                             .getOffset());
+//                                                             existingPosition.setLength(newPosition
+//                                                                             .getLength());
+//                                                             updates.add(existingAnnotation);
+//                                                     }
+//                                                     matched = true;
+//                                                     x.remove();
+//                                                     break;
+//                                             }
+//                                     }
+//                                     if (!matched)
+//                                             additions.put(newAnnotation, newPosition);
+//
+//                                     if (annotations.isEmpty())
+//                                             previous.remove(element);
+//                             }
+//-
                        }
 
                        e = previous.values().iterator();