From c90bcdd6440ee694f75d7f310695cdcaa4548160 Mon Sep 17 00:00:00 2001 From: musk Date: Thu, 1 May 2003 12:22:40 +0000 Subject: [PATCH] Added state reset --- .../phpeditor/php/PHPPartitionScanner.java | 51 ++++++++++++++++---- 1 files changed, 42 insertions(+), 9 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPPartitionScanner.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPPartitionScanner.java index d1a64ad..c4715e0 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPPartitionScanner.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPPartitionScanner.java @@ -6,7 +6,7 @@ * Created on 05.03.2003 * * @author Stefan Langer (musk) - * @version $Revision: 1.16 $ + * @version $Revision: 1.17 $ */ package net.sourceforge.phpeclipse.phpeditor.php; @@ -27,7 +27,6 @@ public class PHPPartitionScanner implements IPartitionTokenScanner private int fOffset = -1; private String fContentType = IPHPPartitionScannerConstants.HTML; private String fPrevContentType = IPHPPartitionScannerConstants.HTML; - private boolean partitionBorder = false; private int fTokenOffset; private int fEnd = -1; @@ -74,8 +73,8 @@ public class PHPPartitionScanner implements IPartitionTokenScanner } } catch (BadLocationException e) - { - // TODO Auto-generated catch block + { // should never happen + // TODO Write stacktrace to log e.printStackTrace(); } } @@ -131,9 +130,6 @@ public class PHPPartitionScanner implements IPartitionTokenScanner // sometimes we get a wrong partition so we retrieve the partition // directly from the document fContentType = fDocument.getContentType(partitionOffset); - //TODO determine the previouse contenttypes as a stack - //if(partitionOffset > 1) - // fPrevContentType = fDocument.getContentType(partitionOffset-1); } else this.setRange(document, offset, length); @@ -387,7 +383,8 @@ public class PHPPartitionScanner implements IPartitionTokenScanner fEnd = fOffset + length; fInString = false; fInDoubString = false; - //partitionBorder = false; + fContentType = IPHPPartitionScannerConstants.HTML; +// String[] prev = getPartitionStack(offset); } private int read() @@ -489,5 +486,41 @@ public class PHPPartitionScanner implements IPartitionTokenScanner else return false; } - + + /** + * Returns the previouse partition stack for the given offset. + * + * @param offset The offset to return the previouse partitionstack for. + * + * @return The stack as a string array. + */ + private String[] getPartitionStack(int offset) + { + ArrayList types = new ArrayList(); + int tmpOffset = 0; + try + { + ITypedRegion region = fDocument.getPartition(offset); + tmpOffset = region.getOffset(); + while(tmpOffset-1 > 0) + { + region = fDocument.getPartition(tmpOffset-1); + tmpOffset = region.getOffset(); + types.add(0, region.getType()); + } + } + catch (BadLocationException e) + { + if(DEBUG) + { + e.printStackTrace(); + } + } + + String[] retVal = new String[types.size()]; + + retVal = (String[])types.toArray(retVal); + return retVal; + } + } -- 1.7.1