diff options
Diffstat (limited to 'bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser')
26 files changed, 0 insertions, 5860 deletions
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/BlockStructuredDocumentRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/BlockStructuredDocumentRegion.java deleted file mode 100644 index 7754a80622..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/BlockStructuredDocumentRegion.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.parser; - - - -import org.eclipse.wst.sse.core.internal.ltk.parser.IBlockedStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocumentRegion; - - -public class BlockStructuredDocumentRegion extends BasicStructuredDocumentRegion implements IBlockedStructuredDocumentRegion { - - private String partitionType; - - /** - * A BlockStructuredDocumentRegion is like a IStructuredDocumentRegion, - * but is the result of a "block scan". - */ - public BlockStructuredDocumentRegion() { - super(); - } - - public String getPartitionType() { - if (partitionType == null) { - // eventually can look up surroundingTag name - // but this field is primarily entended for future - // extensibility. This may change. - //partitionType = "org.eclipse.wst.sse.core." + tagname; - } - return partitionType; - } - - public void setPartitionType(String partitionType) { - this.partitionType = partitionType; - } -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/ContextRegionContainer.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/ContextRegionContainer.java deleted file mode 100644 index 0de33025b0..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/ContextRegionContainer.java +++ /dev/null @@ -1,327 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.parser; - - - -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList; -import org.eclipse.wst.sse.core.internal.text.TextRegionListImpl; -import org.eclipse.wst.xml.core.internal.Logger; - - -public class ContextRegionContainer implements ITextRegionContainer { - protected int length; - protected ITextRegionCollection parent; - protected ITextRegionList regions; - protected int start; - protected int textLength; - protected String type; - - public ContextRegionContainer() { - super(); - regions = new TextRegionListImpl(); - - } - - /** - * these "deep" parenting is not normal, but just in case. - */ - private IStructuredDocument _getParentDocument() { - // go up enough parents to get to document - ITextRegionCollection parent = getParent(); - while (!(parent instanceof IStructuredDocumentRegion)) { - // would be an error not to be container, but - // won't check for it now - parent = ((ITextRegionContainer) parent).getParent(); - } - return ((IStructuredDocumentRegion) parent).getParentDocument(); - } - - - public void adjust(int i) { - - start += i; - // I erroneously added length and textLength - // TODO: may want to rename this method to adjustStart - //length += i; - //textLength += i; - - } - - public void adjustLength(int i) { - length += i; - } - - public void adjustStart(int i) { - start += i; - } - - - public void adjustTextLength(int i) { - textLength += i; - - } - - public boolean containsOffset(int i) { - - return getStartOffset() <= i && i < getEndOffset(); - } - - public boolean containsOffset(ITextRegion containedRegion, int offset) { - return getStartOffset(containedRegion) <= offset && offset < getEndOffset(containedRegion); - } - - /** - * This method is just to equate positions. clients may (will probably) - * still need to make calls to equate regions, parent, etc. - */ - public void equatePositions(ITextRegion region) { - start = region.getStart(); - length = region.getLength(); - textLength = region.getTextLength(); - } - - public int getEnd() { - return start + length; - } - - public int getEndOffset() { - // our startOffset take into account our parent, and our start - return getStartOffset() + getLength(); - } - - public int getEndOffset(ITextRegion containedRegion) { - return getStartOffset(containedRegion) + containedRegion.getLength(); - } - - public ITextRegion getFirstRegion() { - return getRegions().get(0); - } - - public String getFullText() { - return getParent().getFullText(this); - } - - public String getFullText(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion aRegion) { - // Must be proxied here since aRegion should always be a child of - // *this* container and indexed from - // this container's offset - return parent.getFullText().substring(start + aRegion.getStart(), start + aRegion.getEnd()); - } - - public ITextRegion getLastRegion() { - return getRegions().get(getRegions().size() - 1); - } - - public int getLength() { - return length; - } - - - public int getNumberOfRegions() { - return getRegions().size(); - } - - public ITextRegionCollection getParent() { - return parent; - } - - /** - * The parameter offset refers to the overall offset in the document. - */ - public ITextRegion getRegionAtCharacterOffset(int offset) { - ITextRegion result = null; - if (regions != null) { - int thisStartOffset = getStartOffset(); - if (offset < thisStartOffset) - return null; - int thisEndOffset = getStartOffset() + getLength(); - if (offset > thisEndOffset) - return null; - // transform the requested offset to the "scale" that - // regions are stored in, which are all relative to the - // start point. - //int transformedOffset = offset - getStartOffset(); - // - ITextRegionList regions = getRegions(); - int length = regions.size(); - int low = 0; - int high = length; - int mid = 0; - // Binary search for the region - while (low < high) { - mid = low + ((high - low) >> 1); - ITextRegion region = regions.get(mid); - if (org.eclipse.wst.sse.core.internal.util.Debug.debugStructuredDocument) { - System.out.println("region(s) in IStructuredDocumentRegion::getRegionAtCharacterOffset: " + region); //$NON-NLS-1$ - System.out.println(" midpoint of search:" + mid); //$NON-NLS-1$ - System.out.println(" requested offset: " + offset); //$NON-NLS-1$ - //System.out.println(" transformedOffset: " + - // transformedOffset); //$NON-NLS-1$ - System.out.println(" region start: " + region.getStart()); //$NON-NLS-1$ - System.out.println(" region end: " + region.getEnd()); //$NON-NLS-1$ - System.out.println(" region type: " + region.getType()); //$NON-NLS-1$ - System.out.println(" region class: " + region.getClass()); //$NON-NLS-1$ - - } - // Region is before this one - if (offset < region.getStart() + thisStartOffset) - high = mid; - else if (offset > (region.getEnd() + thisStartOffset - 1)) - low = mid + 1; - else - return region; - } - return null; - } - return result; - } - - public ITextRegionList getRegions() { - return regions; - } - - public int getStart() { - return start; - } - - public int getStartOffset() { - return getParent().getStartOffset() + getStart(); - } - - public int getStartOffset(ITextRegion containedRegion) { - // it is an error to pass null to this method - // ISSUE: need better "spec" on error behavior: - // for now will return zero as this will roughly - // work for some cases (and avoid NPE). - if (containedRegion == null) { - return getStartOffset(); - } - return getStartOffset() + containedRegion.getStart(); - } - - /** - * same as getFullText for this region type ... do we need to take white - * space off? - */ - - public String getText() { - String result = null; - try { - IStructuredDocument parentDocument = _getParentDocument(); - result = parentDocument.get(start, length); - } catch (BadLocationException e) { - Logger.logException("program error: unreachable exception", e); //$NON-NLS-1$ - } - return result; - } - - public String getText(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion aRegion) { - // Must be proxied here since aRegion should always be a child of - // *this* container and indexed from - // this container's offset - return parent.getText().substring(start + aRegion.getStart(), start + aRegion.getTextEnd()); - } - - public int getTextEnd() { - return start + textLength; - } - - public int getTextEndOffset() { - ITextRegion region = regions.get(regions.size() - 1); - // our startOffset take into account our parent, and our start - // (pa) 10/4 changed to be based on text end - // it used to return incorrect value for embedded region containers - // - - // TODO CRITICAL -- need to re-work this work around, so doesn't - // depend on XMLRegionContext - // // this is a workaround for 226823/////////// - // for (int i = regions.size() - 1; i >= 0 && region.getType() == - // XMLRegionContext.WHITE_SPACE; i--) - // region = (ITextRegion) regions.get(i); - // ///////////////////////////////////////////// - - return getStartOffset() + region.getTextEnd(); - } - - public int getTextEndOffset(ITextRegion containedRegion) { - int result = 0; - if (regions != null) { - int length = getRegions().size(); - for (int i = 0; i < length; i++) { - ITextRegion region = getRegions().get(i); - if (region == containedRegion) { - result = getStartOffset(region) + region.getTextEnd(); - break; - } - } - } - return result; - } - - public int getTextLength() { - return textLength; - } - - public String getType() { - return type; - } - - public void setLength(int i) { - length = i; - } - - public void setParent(ITextRegionCollection parentRegion) { - parent = parentRegion; - } - - public void setRegions(ITextRegionList containedRegions) { - regions = containedRegions; - } - - public void setStart(int i) { - start = i; - } - - public void setTextLength(int i) { - textLength = i; - } - - public void setType(String string) { - type = string; - } - - public String toString() { - String className = getClass().getName(); - String shortClassName = className.substring(className.lastIndexOf(".") + 1); //$NON-NLS-1$ - String result = "Container!!! " + shortClassName + "--> " + getType() + ": " + getStart() + "-" + getTextEnd() + (getTextEnd() != getEnd() ? ("/" + getEnd()) : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ - return result; - } - - public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) { - org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent result = null; - // FUTURE_TO_DO: need to implement region level parsing in - // ITextRegionContainer::updateModel - // never being called? - return result; - } - -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/IntStack.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/IntStack.java deleted file mode 100644 index 5cb8d5a6f8..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/IntStack.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.parser; - - - -/* - * - * A non-resizable class implementing the behavior of java.util.Stack, but - * directly for the <code> integer </code> primitive. - */ -import java.util.EmptyStackException; - -public class IntStack { - private int[] list = null; - - private int size = 0; - - public IntStack() { - this(100); - } - - public IntStack(int maxdepth) { - super(); - list = new int[maxdepth]; - initialize(); - } - - public boolean empty() { - return size == 0; - } - - public int get(int slot) { - return list[slot]; - } - - void initialize() { - for (int i = 0; i < list.length; i++) - list[i] = -1; - } - - /** - * Returns the int at the top of the stack without removing it - * - * @return int at the top of this stack. - * @exception EmptyStackException - * when empty. - */ - public int peek() { - if (size == 0) - throw new EmptyStackException(); - return list[size - 1]; - } - - /** - * Removes and returns the int at the top of the stack - * - * @return int at the top of this stack. - * @exception EmptyStackException - * when empty. - */ - public int pop() { - int value = peek(); - list[size - 1] = -1; - size--; - return value; - } - - /** - * Pushes an item onto the top of this stack. - * - * @param newValue - - * the int to be pushed onto this stack. - * @return the <code>newValue</code> argument. - */ - public int push(int newValue) { - if (size == list.length) { - throw new StackOverflowError(); - } - list[size++] = newValue; - return newValue; - } - - public int size() { - return size; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - public String toString() { - StringBuffer s = new StringBuffer(getClass().getName() + ":" +size + " ["); - for (int i = 0; i < size; i++) { - s.append(list[i]); - if(i < size - 1) { - s.append(", "); - } - } - s.append("]"); - return s.toString(); - } -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/RegionFactory.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/RegionFactory.java deleted file mode 100644 index 1315a77980..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/RegionFactory.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.parser; - - - -import org.eclipse.wst.sse.core.internal.parser.ContextRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer; - - -public class RegionFactory { - - public RegionFactory() { - super(); - } - - public ITextRegion createToken(ITextRegionContainer parent, String context, int start, int textLength, int length) { - return this.createToken(parent, context, start, textLength, length, null, null); - } - - public ITextRegion createToken(ITextRegionContainer parent, String context, int start, int textLength, int length, String lang, String surroundingTag) { - ITextRegion newRegion = createToken(context, start, textLength, length); - // DW, 4/16/2003 token regions no longer have parents - //newRegion.setParent(parent); - return newRegion; - } - - public ITextRegion createToken(String context, int start, int textLength, int length) { - return this.createToken(context, start, textLength, length, null, null); - } - - public ITextRegion createToken(String context, int start, int textLength, int length, String lang, String surroundingTag) { - ITextRegion newRegion = new ContextRegion(context, start, textLength, length); - return newRegion; - - - } -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XML10Names.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XML10Names.java deleted file mode 100644 index af91c63cf0..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XML10Names.java +++ /dev/null @@ -1,595 +0,0 @@ -/* The following code was generated by JFlex 1.4 on 2/25/08 10:25 AM */ - -/******************************************************************************* - * Copyright (c) 2004,2008 IBM Corporation, and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * kb.huang - Bug 214416 Dot char is not escaped in XML10Names.jFlex - *******************************************************************************/ -/*nlsXXX*/ -package org.eclipse.wst.xml.core.internal.parser; - - - - -/** - * This class is a scanner generated by - * <a href="http://www.jflex.de/">JFlex</a> 1.4 - * on 2/25/08 10:25 AM from the specification file - * <tt>XML10Names.jflex</tt> - */ -public final class XML10Names { - - /** This character denotes the end of file */ - private static final int YYEOF = -1; - - /** initial size of the lookahead buffer */ - private static final int ZZ_BUFFERSIZE = 2048; - - /** lexical states */ - private static final int YYINITIAL = 0; - - /** - * Translates characters to character classes - */ - private static final String ZZ_CMAP_PACKED = - "\12\0\1\3\42\0\1\2\1\2\1\0\12\2\1\1\6\0\32\1"+ - "\4\0\1\1\1\0\32\1\74\0\1\2\10\0\27\1\1\0\37\1"+ - "\1\0\72\1\2\0\13\1\2\0\10\1\1\0\65\1\1\0\104\1"+ - "\11\0\44\1\3\0\2\1\4\0\36\1\70\0\131\1\22\0\7\1"+ - "\16\0\2\2\56\0\106\2\32\0\2\2\44\0\1\1\1\2\3\1"+ - "\1\0\1\1\1\0\24\1\1\0\54\1\1\0\7\1\3\0\1\1"+ - "\1\0\1\1\1\0\1\1\1\0\1\1\1\0\22\1\15\0\14\1"+ - "\1\0\102\1\1\0\14\1\1\0\44\1\1\0\4\2\11\0\65\1"+ - "\2\0\2\1\2\0\2\1\3\0\34\1\2\0\10\1\2\0\2\1"+ - "\67\0\46\1\2\0\1\1\7\0\46\1\12\0\21\2\1\0\27\2"+ - "\1\0\3\2\1\0\1\2\1\0\2\2\1\0\1\2\13\0\33\1"+ - "\5\0\3\1\56\0\32\1\5\0\1\2\12\1\10\2\15\0\12\2"+ - "\6\0\1\2\107\1\2\0\5\1\1\0\17\1\1\0\4\1\1\0"+ - "\1\1\17\2\2\1\2\2\1\0\4\2\2\0\12\2\u0207\0\3\2"+ - "\1\0\65\1\2\0\1\2\1\1\20\2\3\0\4\2\3\0\12\1"+ - "\2\2\2\0\12\2\21\0\3\2\1\0\10\1\2\0\2\1\2\0"+ - "\26\1\1\0\7\1\1\0\1\1\3\0\4\1\2\0\1\2\1\0"+ - "\7\2\2\0\2\2\2\0\3\2\11\0\1\2\4\0\2\1\1\0"+ - "\3\1\2\2\2\0\12\2\2\1\20\0\1\2\2\0\6\1\4\0"+ - "\2\1\2\0\26\1\1\0\7\1\1\0\2\1\1\0\2\1\1\0"+ - "\2\1\2\0\1\2\1\0\5\2\4\0\2\2\2\0\3\2\13\0"+ - "\4\1\1\0\1\1\7\0\12\2\2\2\3\1\14\0\3\2\1\0"+ - "\7\1\1\0\1\1\1\0\3\1\1\0\26\1\1\0\7\1\1\0"+ - "\2\1\1\0\5\1\2\0\1\2\1\1\10\2\1\0\3\2\1\0"+ - "\3\2\22\0\1\1\5\0\12\2\21\0\3\2\1\0\10\1\2\0"+ - "\2\1\2\0\26\1\1\0\7\1\1\0\2\1\2\0\4\1\2\0"+ - "\1\2\1\1\6\2\3\0\2\2\2\0\3\2\10\0\2\2\4\0"+ - "\2\1\1\0\3\1\4\0\12\2\22\0\2\2\1\0\6\1\3\0"+ - "\3\1\1\0\4\1\3\0\2\1\1\0\1\1\1\0\2\1\3\0"+ - "\2\1\3\0\3\1\3\0\10\1\1\0\3\1\4\0\5\2\3\0"+ - "\3\2\1\0\4\2\11\0\1\2\17\0\11\2\21\0\3\2\1\0"+ - "\10\1\1\0\3\1\1\0\27\1\1\0\12\1\1\0\5\1\4\0"+ - "\7\2\1\0\3\2\1\0\4\2\7\0\2\2\11\0\2\1\4\0"+ - "\12\2\22\0\2\2\1\0\10\1\1\0\3\1\1\0\27\1\1\0"+ - "\12\1\1\0\5\1\4\0\7\2\1\0\3\2\1\0\4\2\7\0"+ - "\2\2\7\0\1\1\1\0\2\1\4\0\12\2\22\0\2\2\1\0"+ - "\10\1\1\0\3\1\1\0\27\1\1\0\20\1\4\0\6\2\2\0"+ - "\3\2\1\0\4\2\11\0\1\2\10\0\2\1\4\0\12\2\221\0"+ - "\56\1\1\0\1\1\1\2\2\1\7\2\5\0\6\1\1\2\10\2"+ - "\1\0\12\2\47\0\2\1\1\0\1\1\2\0\2\1\1\0\1\1"+ - "\2\0\1\1\6\0\4\1\1\0\7\1\1\0\3\1\1\0\1\1"+ - "\1\0\1\1\2\0\2\1\1\0\2\1\1\0\1\1\1\2\2\1"+ - "\6\2\1\0\2\2\1\1\2\0\5\1\1\0\1\2\1\0\6\2"+ - "\2\0\12\2\76\0\2\2\6\0\12\2\13\0\1\2\1\0\1\2"+ - "\1\0\1\2\4\0\2\2\10\1\1\0\41\1\7\0\24\2\1\0"+ - "\6\2\4\0\6\2\1\0\1\2\1\0\25\2\3\0\7\2\1\0"+ - "\1\2\346\0\46\1\12\0\47\1\11\0\1\1\1\0\2\1\1\0"+ - "\3\1\1\0\1\1\1\0\2\1\1\0\5\1\51\0\1\1\1\0"+ - "\1\1\1\0\1\1\13\0\1\1\1\0\1\1\1\0\1\1\3\0"+ - "\2\1\3\0\1\1\5\0\3\1\1\0\1\1\1\0\1\1\1\0"+ - "\1\1\1\0\1\1\3\0\2\1\3\0\2\1\1\0\1\1\50\0"+ - "\1\1\11\0\1\1\2\0\1\1\2\0\2\1\7\0\2\1\1\0"+ - "\1\1\1\0\7\1\50\0\1\1\4\0\1\1\10\0\1\1\u0c06\0"+ - "\234\1\4\0\132\1\6\0\26\1\2\0\6\1\2\0\46\1\2\0"+ - "\6\1\2\0\10\1\1\0\1\1\1\0\1\1\1\0\1\1\1\0"+ - "\37\1\2\0\65\1\1\0\7\1\1\0\1\1\3\0\3\1\1\0"+ - "\7\1\3\0\4\1\2\0\6\1\4\0\15\1\5\0\3\1\1\0"+ - "\7\1\323\0\15\2\4\0\1\2\104\0\1\1\3\0\2\1\2\0"+ - "\1\1\121\0\3\1\u0e82\0\1\2\1\0\1\1\31\0\11\1\6\2"+ - "\1\0\5\2\13\0\124\1\4\0\2\2\2\0\2\2\2\0\132\1"+ - "\1\0\3\2\6\0\50\1\u1cd3\0\u51a6\1\u0c5a\0\u2ba4\1\u285c\0"; - - /** - * Translates characters to character classes - */ - private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); - - /** - * Translates DFA states to action switch labels. - */ - private static final int [] ZZ_ACTION = zzUnpackAction(); - - private static final String ZZ_ACTION_PACKED_0 = - "\1\0\1\1\1\2\1\3"; - - private static int [] zzUnpackAction() { - int [] result = new int[4]; - int offset = 0; - offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); - return result; - } - - private static int zzUnpackAction(String packed, int offset, int [] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - do result[j++] = value; while (--count > 0); - } - return j; - } - - - /** - * Translates a state to a row index in the transition table - */ - private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); - - private static final String ZZ_ROWMAP_PACKED_0 = - "\0\0\0\4\0\10\0\14"; - - private static int [] zzUnpackRowMap() { - int [] result = new int[4]; - int offset = 0; - offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); - return result; - } - - private static int zzUnpackRowMap(String packed, int offset, int [] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int high = packed.charAt(i++) << 16; - result[j++] = high | packed.charAt(i++); - } - return j; - } - - /** - * The transition table of the DFA - */ - private static final int ZZ_TRANS [] = { - 1, 2, 1, -1, -1, -1, -1, -1, 3, 2, - 2, -1, 3, 3, 3, -1 - }; - - /* error codes */ - private static final int ZZ_UNKNOWN_ERROR = 0; - private static final int ZZ_NO_MATCH = 1; -// private static final int ZZ_PUSHBACK_2BIG = 2; - - /* error messages for the codes above */ - private static final String ZZ_ERROR_MSG[] = { - "Unkown internal scanner error", - "Error: could not match input", - "Error: pushback value was too large" - }; - - /** - * ZZ_ATTRIBUTE[aState] contains the attributes of state <code>aState</code> - */ - private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); - - private static final String ZZ_ATTRIBUTE_PACKED_0 = - "\1\0\1\11\2\1"; - - private static int [] zzUnpackAttribute() { - int [] result = new int[4]; - int offset = 0; - offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); - return result; - } - - private static int zzUnpackAttribute(String packed, int offset, int [] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - do result[j++] = value; while (--count > 0); - } - return j; - } - - /** the input device */ - private java.io.Reader zzReader; - - /** the current state of the DFA */ - private int zzState; - - /** the current lexical state */ - private int zzLexicalState = YYINITIAL; - - /** this buffer contains the current text to be matched and is - the source of the yytext() string */ - private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; - - /** the textposition at the last accepting state */ - private int zzMarkedPos; - - /** the textposition at the last state to be included in yytext */ - private int zzPushbackPos; - - /** the current text position in the buffer */ - private int zzCurrentPos; - - /** startRead marks the beginning of the yytext() string in the buffer */ - private int zzStartRead; - - /** endRead marks the last character in the buffer, that has been read - from input */ - private int zzEndRead; - - /** number of newlines encountered up to the start of the matched text */ -// private int yyline; - - /** the number of characters up to the start of the matched text */ -// private int yychar; - - /** - * the number of characters from the last newline up to the start of the - * matched text - */ -// private int yycolumn; - - /** - * zzAtBOL == true <=> the scanner is currently at the beginning of a line - */ -// private boolean zzAtBOL = true; - - /** zzAtEOF == true <=> the scanner is at the EOF */ - private boolean zzAtEOF; - - /* user code: */ - boolean result; - /** - * Creates a new scanner - */ - public XML10Names() { - this.zzReader = null; - } - - public boolean isValidXML10Name(String stringToCheck) { - boolean result = false; - yyreset(new java.io.StringReader(stringToCheck)); - try { - result = isValidXML10Name(); - } - catch (java.io.IOException e) { - // should be impossible with strings, but if occurs, just means - // "not" - result = false; - } - return result; - } - - - - /** - * Creates a new scanner - * There is also a java.io.InputStream version of this constructor. - * - * @param in the java.io.Reader to read input from. - */ - public XML10Names(java.io.Reader in) { - this.zzReader = in; - } - - /** - * Creates a new scanner. - * There is also java.io.Reader version of this constructor. - * - * @param in the java.io.Inputstream to read input from. - */ - public XML10Names(java.io.InputStream in) { - this(new java.io.InputStreamReader(in)); - } - - /** - * Unpacks the compressed character translation table. - * - * @param packed the packed character translation table - * @return the unpacked character translation table - */ - private static char [] zzUnpackCMap(String packed) { - char [] map = new char[0x10000]; - int i = 0; /* index in packed string */ - int j = 0; /* index in unpacked array */ - while (i < 1218) { - int count = packed.charAt(i++); - char value = packed.charAt(i++); - do map[j++] = value; while (--count > 0); - } - return map; - } - - - /** - * Refills the input buffer. - * - * @return <code>false</code>, iff there was new input. - * - * @exception java.io.IOException if any I/O-Error occurs - */ - private boolean zzRefill() throws java.io.IOException { - - /* first: make room (if you can) */ - if (zzStartRead > 0) { - System.arraycopy(zzBuffer, zzStartRead, - zzBuffer, 0, - zzEndRead-zzStartRead); - - /* translate stored positions */ - zzEndRead-= zzStartRead; - zzCurrentPos-= zzStartRead; - zzMarkedPos-= zzStartRead; - zzPushbackPos-= zzStartRead; - zzStartRead = 0; - } - - /* is the buffer big enough? */ - if (zzCurrentPos >= zzBuffer.length) { - /* if not: blow it up */ - char newBuffer[] = new char[zzCurrentPos*2]; - System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); - zzBuffer = newBuffer; - } - - /* finally: fill the buffer with new input */ - int numRead = zzReader.read(zzBuffer, zzEndRead, - zzBuffer.length-zzEndRead); - - if (numRead < 0) { - return true; - } - else { - zzEndRead+= numRead; - return false; - } - } - - - /** - * Closes the input stream. - */ -// private final void yyclose() throws java.io.IOException { -// zzAtEOF = true; /* indicate end of file */ -// zzEndRead = zzStartRead; /* invalidate buffer */ -// -// if (zzReader != null) -// zzReader.close(); -// } - - - /** - * Resets the scanner to read from a new input stream. - * Does not close the old reader. - * - * All internal variables are reset, the old input stream - * <b>cannot</b> be reused (internal buffer is discarded and lost). - * Lexical state is set to <tt>ZZ_INITIAL</tt>. - * - * @param reader the new input stream - */ - private final void yyreset(java.io.Reader reader) { - zzReader = reader; -// zzAtBOL = true; - zzAtEOF = false; - zzEndRead = zzStartRead = 0; - zzCurrentPos = zzMarkedPos = zzPushbackPos = 0; -// yyline = yychar = yycolumn = 0; - zzLexicalState = YYINITIAL; - } - - - /** - * Returns the current lexical state. - */ -// private final int yystate() { -// return zzLexicalState; -// } - - - /** - * Enters a new lexical state - * - * @param newState the new lexical state - */ -// private final void yybegin(int newState) { -// zzLexicalState = newState; -// } - - - /** - * Returns the text matched by the current regular expression. - */ -// private final String yytext() { -// return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead ); -// } - - - /** - * Returns the character at position <tt>pos</tt> from the - * matched text. - * - * It is equivalent to yytext().charAt(pos), but faster - * - * @param pos the position of the character to fetch. - * A value from 0 to yylength()-1. - * - * @return the character at position pos - */ -// private final char yycharat(int pos) { -// return zzBuffer[zzStartRead+pos]; -// } - - - /** - * Returns the length of the matched text region. - */ -// private final int yylength() { -// return zzMarkedPos-zzStartRead; -// } - - - /** - * Reports an error that occured while scanning. - * - * In a wellformed scanner (no or only correct usage of - * yypushback(int) and a match-all fallback rule) this method - * will only be called with things that "Can't Possibly Happen". - * If this method is called, something is seriously wrong - * (e.g. a JFlex bug producing a faulty scanner etc.). - * - * Usual syntax/scanner level error handling should be done - * in error fallback rules. - * - * @param errorCode the code of the errormessage to display - */ - private void zzScanError(int errorCode) { - String message; - try { - message = ZZ_ERROR_MSG[errorCode]; - } - catch (ArrayIndexOutOfBoundsException e) { - message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; - } - - throw new Error(message); - } - - - /** - * Pushes the specified amount of characters back into the input stream. - * - * They will be read again by then next call of the scanning method - * - * @param number the number of characters to be read again. - * This number must not be greater than yylength()! - */ -// private void yypushback(int number) { -// if ( number > yylength() ) -// zzScanError(ZZ_PUSHBACK_2BIG); -// -// zzMarkedPos -= number; -// } - - - /** - * Resumes scanning until the next regular expression is matched, - * the end of input is encountered or an I/O-Error occurs. - * - * @return the next token - * @exception java.io.IOException if any I/O-Error occurs - */ - private boolean isValidXML10Name() throws java.io.IOException { - int zzInput; - int zzAction; - - // cached fields: - int zzCurrentPosL; - int zzMarkedPosL; - int zzEndReadL = zzEndRead; - char [] zzBufferL = zzBuffer; - char [] zzCMapL = ZZ_CMAP; - - int [] zzTransL = ZZ_TRANS; - int [] zzRowMapL = ZZ_ROWMAP; - int [] zzAttrL = ZZ_ATTRIBUTE; - - while (true) { - zzMarkedPosL = zzMarkedPos; - - zzAction = -1; - - zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; - - zzState = zzLexicalState; - - - zzForAction: { - while (true) { - - if (zzCurrentPosL < zzEndReadL) - zzInput = zzBufferL[zzCurrentPosL++]; - else if (zzAtEOF) { - zzInput = YYEOF; - break zzForAction; - } - else { - // store back cached positions - zzCurrentPos = zzCurrentPosL; - zzMarkedPos = zzMarkedPosL; - boolean eof = zzRefill(); - // get translated positions and possibly new buffer - zzCurrentPosL = zzCurrentPos; - zzMarkedPosL = zzMarkedPos; - zzBufferL = zzBuffer; - zzEndReadL = zzEndRead; - if (eof) { - zzInput = YYEOF; - break zzForAction; - } - else { - zzInput = zzBufferL[zzCurrentPosL++]; - } - } - int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ]; - if (zzNext == -1) break zzForAction; - zzState = zzNext; - - int zzAttributes = zzAttrL[zzState]; - if ( (zzAttributes & 1) == 1 ) { - zzAction = zzState; - zzMarkedPosL = zzCurrentPosL; - if ( (zzAttributes & 8) == 8 ) break zzForAction; - } - - } - } - - // store back cached position - zzMarkedPos = zzMarkedPosL; - - switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { - case 1: - { return false; /* matched wild */ - } - case 4: break; - case 2: - { return true; /* exact name */ - } - case 5: break; - case 3: - { return false; /* more than name */ - } - case 6: break; - default: - if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { - zzAtEOF = true; - { {return false; /* hit end with no match */} } - } - else { - zzScanError(ZZ_NO_MATCH); - } - } - } - } - - -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLSourceParser.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLSourceParser.java deleted file mode 100644 index 7fe73f83f8..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLSourceParser.java +++ /dev/null @@ -1,625 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.parser; - - - -import java.io.StringReader; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.wst.sse.core.internal.document.DocumentReader; -import org.eclipse.wst.sse.core.internal.ltk.parser.BlockMarker; -import org.eclipse.wst.sse.core.internal.ltk.parser.BlockTagParser; -import org.eclipse.wst.sse.core.internal.ltk.parser.BlockTokenizer; -import org.eclipse.wst.sse.core.internal.ltk.parser.RegionParser; -import org.eclipse.wst.sse.core.internal.ltk.parser.StructuredDocumentRegionHandler; -import org.eclipse.wst.sse.core.internal.ltk.parser.StructuredDocumentRegionParser; -import org.eclipse.wst.sse.core.internal.ltk.parser.StructuredDocumentRegionParserExtension; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList; -import org.eclipse.wst.sse.core.internal.text.CharSequenceReader; -import org.eclipse.wst.sse.core.internal.text.IRegionComparible; -import org.eclipse.wst.sse.core.internal.util.Debug; -import org.eclipse.wst.xml.core.internal.Logger; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; - - -/** - * Takes input from the HTMLTokenizer and creates a tag list - */ - -public class XMLSourceParser implements RegionParser, BlockTagParser, StructuredDocumentRegionParser, IRegionComparible, StructuredDocumentRegionParserExtension { - // made public to aid access from inner classes in hierarchy. - // TODO: in future, figure out how to solve without exposing data. - public CharSequence fCharSequenceSource = null; - private IDocument fDocumentInput; - protected int fOffset = 0; - // DMW: 2/12/03. Removed some state data, since not really needed, - // and since it added a lot to overhead (since so many regions are - // created. - // protected IStructuredDocumentRegion fCurrentNode = null; - // protected IStructuredDocumentRegion fNodes = null; - // protected List fRegions = null; - // protected Object fInput = null; - protected String fStringInput = null; - protected List fStructuredDocumentRegionHandlers; - - protected BlockTokenizer fTokenizer = null; - protected long startTime; - protected long stopTime; - - /** - * HTMLSourceParser constructor comment. - */ - public XMLSourceParser() { - super(); - fStructuredDocumentRegionHandlers = new ArrayList(); - } - - /** - * This is a simple utility to count nodes. Used only for debug - * statements. - */ - protected int _countNodes(IStructuredDocumentRegion nodes) { - int result = 0; - IStructuredDocumentRegion countNode = nodes; - while (countNode != null) { - result++; - countNode = countNode.getNext(); - } - return result; - } - - public void addBlockMarker(BlockMarker marker) { - getTokenizer().addBlockMarker(marker); - } - - public void addStructuredDocumentRegionHandler(StructuredDocumentRegionHandler handler) { - if (fStructuredDocumentRegionHandlers == null) - fStructuredDocumentRegionHandlers = new ArrayList(); - fStructuredDocumentRegionHandlers.add(handler); - } - - public void beginBlockScan(String newTagName) { - getTokenizer().beginBlockTagScan(newTagName); - } - - /** - * @return IStructuredDocumentRegion - */ - protected IStructuredDocumentRegion createStructuredDocumentRegion(String type) { - IStructuredDocumentRegion newNode = null; - if (type == DOMRegionContext.BLOCK_TEXT) - newNode = XMLStructuredRegionFactory.createRegion(XMLStructuredRegionFactory.XML_BLOCK); - else - newNode = XMLStructuredRegionFactory.createRegion(XMLStructuredRegionFactory.XML); - return newNode; - } - - protected void fireNodeParsed(IStructuredDocumentRegion fCurrentNode) { - /* - * Never let an Exceptions from foreign code interfere with completion - * of parsing. To get an exception here is definitely a program error - * somewhere, but we can't afford to interrupt the flow of control. or - * backwards typing can result! - * - * Protect the user's data above everything. - */ - if (fCurrentNode != null && fStructuredDocumentRegionHandlers != null) { - for (int i = 0; i < fStructuredDocumentRegionHandlers.size(); i++) { - try { - ((StructuredDocumentRegionHandler) fStructuredDocumentRegionHandlers.get(i)).nodeParsed(fCurrentNode); - } - catch (Exception e) { - Logger.log(Logger.ERROR, "Error occurred while firing Node Parsed event", e); //$NON-NLS-1$ - } - } - } - } - - public BlockMarker getBlockMarker(String tagName) { - List markers = getTokenizer().getBlockMarkers(); - for (int i = 0; i < markers.size(); i++) { - BlockMarker marker = (BlockMarker) markers.get(i); - if (marker.isCaseSensitive()) { - if (marker.getTagName().equals(tagName)) - return marker; - } - else { - if (marker.getTagName().equalsIgnoreCase(tagName)) - return marker; - } - } - return null; - } - - public List getBlockMarkers() { - return getTokenizer().getBlockMarkers(); - } - - /** - * @return IStructuredDocumentRegion - */ - public IStructuredDocumentRegion getDocumentRegions() { - IStructuredDocumentRegion headnode = null; - if (headnode == null) { - if (Debug.perfTest) { - startTime = System.currentTimeMillis(); - } - headnode = parseNodes(); - if (Debug.perfTest) { - stopTime = System.currentTimeMillis(); - System.out.println(" -- creating nodes of IStructuredDocument -- "); //$NON-NLS-1$ - System.out.println(" Time parse and init all regions: " + (stopTime - startTime) + " (msecs)"); //$NON-NLS-2$//$NON-NLS-1$ - // System.out.println(" for " + fRegions.size() + " - // Regions");//$NON-NLS-2$//$NON-NLS-1$ - System.out.println(" and " + _countNodes(headnode) + " Nodes"); //$NON-NLS-2$//$NON-NLS-1$ - } - } - return headnode; - } - - protected ITextRegion getNextRegion() { - ITextRegion region = null; - try { - region = getTokenizer().getNextToken(); - // DMW: 2/12/03 Removed state - // if (region != null) { - // fRegions.add(region); - // } - return region; - } - catch (StackOverflowError e) { - Logger.logException(getClass().getName() + ": input could not be parsed correctly at position " + getTokenizer().getOffset(), e); //$NON-NLS-1$ - throw e; - } - catch (Exception e) { - Logger.logException(getClass().getName() + ": input could not be parsed correctly at position " + getTokenizer().getOffset() + " (" + e.getLocalizedMessage() + ")", e); //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ - } - return null; - } - - /** - * Return the full list of known regions. Typically getNodes should be - * used instead of this method. - */ - public List getRegions() { - IStructuredDocumentRegion headNode = null; - if (!getTokenizer().isEOF()) { - headNode = getDocumentRegions(); - // throw new IllegalStateException("parsing has not finished"); - } - // for memory recovery, we assume if someone - // requests all regions, we can reset our big - // memory consuming objects - // but the new "getRegions" method is then more expensive. - // I don't think its used much, though. - List localRegionsList = getRegions(headNode); - primReset(); - return localRegionsList; - } - - /** - * Method getRegions. - * - * @param headNode - * @return List - */ - protected List getRegions(IStructuredDocumentRegion headNode) { - List allRegions = new ArrayList(); - IStructuredDocumentRegion currentNode = headNode; - while (currentNode != null) { - ITextRegionList nodeRegions = currentNode.getRegions(); - for (int i = 0; i < nodeRegions.size(); i++) { - allRegions.add(nodeRegions.get(i)); - } - currentNode = currentNode.getNext(); - } - return allRegions; - } - - /** - * @deprecated - use the add/remove methods instead - * @return java.util.List - */ - public List getStructuredDocumentRegionHandlers() { - if (fStructuredDocumentRegionHandlers == null) { - fStructuredDocumentRegionHandlers = new ArrayList(0); - } - return fStructuredDocumentRegionHandlers; - } - - /** - * Returns text from the current input. Text is only valid before - * getNodes() has been called and only when a raw String or DocumentReader - * is given as the input. - */ - public String getText(int offset, int length) { - String text = null; - if (fCharSequenceSource != null) { - int start = fOffset + offset; - int end = start + length; - text = fCharSequenceSource.subSequence(start, end).toString(); - } - else if (fDocumentInput != null) { - try { - text = fDocumentInput.get(offset, length); - } - catch (BadLocationException e) { - text = ""; //$NON-NLS-1$ - } - } - else { - if (fStringInput == null || fStringInput.length() == 0 || offset + length > fStringInput.length() || offset < 0) { - text = ""; //$NON-NLS-1$ - } - else { - // offset is entirely valid during parsing as the parse - // numbers haven't been adjusted. - text = fStringInput.substring(offset, offset + length); - } - } - return text; - } - - protected BlockTokenizer getTokenizer() { - if (fTokenizer == null) { - fTokenizer = new XMLTokenizer(); - } - return fTokenizer; - } - - - public RegionParser newInstance() { - XMLSourceParser newInstance = new XMLSourceParser(); - newInstance.setTokenizer(getTokenizer().newInstance()); - return newInstance; - } - - protected IStructuredDocumentRegion parseNodes() { - // regions are initially reported as complete offsets within the - // scanned input - // they are adjusted here to be indexes from the currentNode's start - // offset - IStructuredDocumentRegion headNode = null; - IStructuredDocumentRegion lastNode = null; - ITextRegion region = null; - IStructuredDocumentRegion currentNode = null; - String type = null; - - while ((region = getNextRegion()) != null) { - type = region.getType(); - // these types (might) demand a IStructuredDocumentRegion for each - // of them - if (type == DOMRegionContext.BLOCK_TEXT) { - if (currentNode != null && currentNode.getLastRegion().getType() == DOMRegionContext.BLOCK_TEXT) { - // multiple block texts indicated embedded containers; no - // new IStructuredDocumentRegion - currentNode.addRegion(region); - currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart()); - region.adjustStart(-currentNode.getStart()); - // DW 4/16/2003 regions no longer have parents - // region.setParent(currentNode); - } - else { - // not continuing a IStructuredDocumentRegion - if (currentNode != null) { - // ensure that any existing node is at least - // terminated - if (!currentNode.isEnded()) { - currentNode.setLength(region.getStart() - currentNode.getStart()); - // fCurrentNode.setTextLength(region.getStart() - - // fCurrentNode.getStart()); - } - lastNode = currentNode; - } - fireNodeParsed(currentNode); - currentNode = createStructuredDocumentRegion(type); - if (lastNode != null) { - lastNode.setNext(currentNode); - } - currentNode.setPrevious(lastNode); - currentNode.setStart(region.getStart()); - currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart()); - currentNode.setEnded(true); - region.adjustStart(-currentNode.getStart()); - currentNode.addRegion(region); - // DW 4/16/2003 regions no longer have parents - // region.setParent(currentNode); - } - } - // the following contexts OPEN new StructuredDocumentRegions - else if ((currentNode != null && currentNode.isEnded()) || (type == DOMRegionContext.XML_CONTENT) || (type == DOMRegionContext.XML_CHAR_REFERENCE) || (type == DOMRegionContext.XML_ENTITY_REFERENCE) || (type == DOMRegionContext.XML_PI_OPEN) || (type == DOMRegionContext.XML_TAG_OPEN) || (type == DOMRegionContext.XML_END_TAG_OPEN) || (type == DOMRegionContext.XML_COMMENT_OPEN) || (type == DOMRegionContext.XML_CDATA_OPEN) || (type == DOMRegionContext.XML_DECLARATION_OPEN)) { - if (currentNode != null) { - // ensure that any existing node is at least terminated - if (!currentNode.isEnded()) { - currentNode.setLength(region.getStart() - currentNode.getStart()); - // fCurrentNode.setTextLength(region.getStart() - - // fCurrentNode.getStart()); - } - lastNode = currentNode; - } - fireNodeParsed(currentNode); - currentNode = createStructuredDocumentRegion(type); - if (lastNode != null) { - lastNode.setNext(currentNode); - } - currentNode.setPrevious(lastNode); - currentNode.setStart(region.getStart()); - currentNode.addRegion(region); - currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart()); - region.adjustStart(-currentNode.getStart()); - // DW 4/16/2003 regions no longer have parents - // region.setParent(currentNode); - } - // the following contexts neither open nor close - // StructuredDocumentRegions; just add to them - else if ((type == DOMRegionContext.XML_TAG_NAME) || (type == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) || (type == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) || (type == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) || (type == DOMRegionContext.XML_COMMENT_TEXT) || (type == DOMRegionContext.XML_PI_CONTENT) || (type == DOMRegionContext.XML_DOCTYPE_INTERNAL_SUBSET)) { - currentNode.addRegion(region); - currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart()); - region.adjustStart(-currentNode.getStart()); - // DW 4/16/2003 regions no longer have parents - // region.setParent(currentNode); - } - // the following contexts close off StructuredDocumentRegions - // cleanly - else if ((type == DOMRegionContext.XML_PI_CLOSE) || (type == DOMRegionContext.XML_TAG_CLOSE) || (type == DOMRegionContext.XML_EMPTY_TAG_CLOSE) || (type == DOMRegionContext.XML_COMMENT_CLOSE) || (type == DOMRegionContext.XML_DECLARATION_CLOSE) || (type == DOMRegionContext.XML_CDATA_CLOSE)) { - currentNode.setEnded(true); - currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart()); - currentNode.addRegion(region); - region.adjustStart(-currentNode.getStart()); - // DW 4/16/2003 regions no longer have parents - // region.setParent(currentNode); - } - // this is extremely rare, but valid - else if (type == DOMRegionContext.WHITE_SPACE) { - ITextRegion lastRegion = currentNode.getLastRegion(); - // pack the embedded container with this region - if (lastRegion instanceof ITextRegionContainer) { - ITextRegionContainer container = (ITextRegionContainer) lastRegion; - container.getRegions().add(region); - // containers must have parent set ... - // setting for EACH subregion is redundent, but not sure - // where else to do, so will do here for now. - container.setParent(currentNode); - // DW 4/16/2003 regions no longer have parents - // region.setParent(container); - region.adjustStart(container.getLength() - region.getStart()); - } - currentNode.getLastRegion().adjustLength(region.getLength()); - currentNode.adjustLength(region.getLength()); - } - else if (type == DOMRegionContext.UNDEFINED && currentNode != null) { - // skip on a very-first region situation as the default - // behavior is good enough - // combine with previous if also undefined - if (currentNode.getLastRegion() != null && currentNode.getLastRegion().getType() == DOMRegionContext.UNDEFINED) { - currentNode.getLastRegion().adjustLength(region.getLength()); - currentNode.adjustLength(region.getLength()); - } - // previous wasn't undefined - else { - currentNode.addRegion(region); - currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart()); - region.adjustStart(-currentNode.getStart()); - } - } - else { - // if an unknown type is the first region in the document, - // ensure that a node exists - if (currentNode == null) { - currentNode = createStructuredDocumentRegion(type); - currentNode.setStart(region.getStart()); - } - currentNode.addRegion(region); - currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart()); - region.adjustStart(-currentNode.getStart()); - // DW 4/16/2003 regions no longer have parents - // region.setParent(currentNode); - if (Debug.debugTokenizer) - System.out.println(getClass().getName() + " found region of not specifically handled type " + region.getType() + " @ " + region.getStart() + "[" + region.getLength() + "]"); //$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ - //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ - } - - // these regions also get their own node, so close them cleanly - // NOTE: these regions have new StructuredDocumentRegions created - // for them above; it may - // be more readable if that is handled here as well, but the - // current layout - // ensures that they open StructuredDocumentRegions the same way - if ((type == DOMRegionContext.XML_CONTENT) || (type == DOMRegionContext.XML_CHAR_REFERENCE) || (type == DOMRegionContext.XML_ENTITY_REFERENCE)) { - currentNode.setEnded(true); - } - if (headNode == null && currentNode != null) { - headNode = currentNode; - } - } - if (currentNode != null) { - fireNodeParsed(currentNode); - currentNode.setPrevious(lastNode); - } - // fStringInput = null; - primReset(); - return headNode; - } - - protected void primReset() { - // fNodes = null; - // fRegions = null; - // fInput = null; - fStringInput = null; - fCharSequenceSource = null; - fDocumentInput = null; - fOffset = 0; - // fCurrentNode = null; - // DMW: also reset tokenizer so it doesn't hold on - // to large arrays - getTokenizer().reset(new char[0]); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.sse.core.internal.text.IRegionComparible#regionMatches(int, - * int, java.lang.String) - */ - public boolean regionMatches(int offset, int length, String stringToCompare) { - // by definition - if (stringToCompare == null) - return false; - - int ajustedOffset = fOffset + offset; - boolean result = false; - if (fCharSequenceSource != null && fCharSequenceSource instanceof IRegionComparible) { - result = ((IRegionComparible) fCharSequenceSource).regionMatches(ajustedOffset, length, stringToCompare); - } - else { - // old fashioned ways - String test = null; - if (fCharSequenceSource != null) { - test = fCharSequenceSource.subSequence(ajustedOffset, ajustedOffset + length).toString(); - } - else if (fStringInput != null) { - test = fStringInput.substring(ajustedOffset, ajustedOffset + length); - } - result = stringToCompare.equals(test); - } - return result; - } - - public boolean regionMatchesIgnoreCase(int offset, int length, String stringToCompare) { - // by definition - if (stringToCompare == null) - return false; - - int ajustedOffset = fOffset + offset; - boolean result = false; - if (fCharSequenceSource != null && fCharSequenceSource instanceof IRegionComparible) { - result = ((IRegionComparible) fCharSequenceSource).regionMatchesIgnoreCase(ajustedOffset, length, stringToCompare); - } - else { - // old fashioned ways - String test = null; - if (fCharSequenceSource != null) { - test = fCharSequenceSource.subSequence(ajustedOffset, ajustedOffset + length).toString(); - } - else if (fStringInput != null) { - test = fStringInput.substring(ajustedOffset, ajustedOffset + length); - } - result = stringToCompare.equalsIgnoreCase(test); - } - return result; - } - - public void removeBlockMarker(BlockMarker marker) { - getTokenizer().removeBlockMarker(marker); - } - - public void removeBlockMarker(String tagName) { - getTokenizer().removeBlockMarker(tagName); - } - - public void removeStructuredDocumentRegionHandler(StructuredDocumentRegionHandler handler) { - if (fStructuredDocumentRegionHandlers == null) - return; - if (fStructuredDocumentRegionHandlers.contains(handler)) - fStructuredDocumentRegionHandlers.remove(handler); - } - - /** - * Resets the input. - */ - public void reset(java.io.FileInputStream instream) { - primReset(); - // fInput = instream; - getTokenizer().reset(instream); - } - - /** - * Resets the input. - */ - public void reset(java.io.Reader reader) { - reset(reader, 0); - } - - /** - * Resets the input. - */ - public void reset(java.io.Reader reader, int position) { - primReset(); - fOffset = position; - getTokenizer().reset(reader, position); - if (reader instanceof DocumentReader) { - IDocument doc = ((DocumentReader) reader).getDocument(); - if (doc instanceof CharSequence) { - fCharSequenceSource = (CharSequence) doc; - } - else { - // old fashioned IDocument - fDocumentInput = ((DocumentReader) reader).getDocument(); - } - - } - else if (reader instanceof CharSequenceReader) { - fCharSequenceSource = ((CharSequenceReader) reader).getOriginalSource(); - } - } - - /** - * Resets the input. Use this version to allow text to be retrieved - * <em>during</em> parsing, such as by the - * StructuredDocumentRegionHandler. - */ - public void reset(String sourceString) { - reset(new StringReader(sourceString)); - fStringInput = sourceString; - } - - /** - * Resets the input. Use this version to allow text to be retrieved - * <em>during</em> parsing, such as by the - * StructuredDocumentRegionHandler. - */ - public void reset(String sourceString, int position) { - StringReader reader = new StringReader(sourceString); - reset(reader, position); - fStringInput = sourceString; - } - - public void resetHandlers() { - if (fStructuredDocumentRegionHandlers != null) { - int size = fStructuredDocumentRegionHandlers.size(); - for (int i = 0; i < size; i++) - ((StructuredDocumentRegionHandler) fStructuredDocumentRegionHandlers.get(i)).resetNodes(); - } - } - - /** - * - * @param List - */ - public void setStructuredDocumentRegionHandlers(List newStructuredDocumentRegionHandlers) { - fStructuredDocumentRegionHandlers = newStructuredDocumentRegionHandlers; - } - - protected void setTokenizer(BlockTokenizer newTokenizer) { - // DMW: changed from private to protected, so subclass could use in - // creation of 'newInstance'. - fTokenizer = newTokenizer; - } -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLStructuredDocumentReParser.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLStructuredDocumentReParser.java deleted file mode 100644 index c185520fa7..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLStructuredDocumentReParser.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.parser; - -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredTextReParser; -import org.eclipse.wst.sse.core.internal.text.StructuredDocumentReParser; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; - - -public class XMLStructuredDocumentReParser extends StructuredDocumentReParser { - - public XMLStructuredDocumentReParser() { - super(); - } - - protected IStructuredDocumentRegion findDirtyEnd(int end) { - // Caution: here's one place we have to cast - IStructuredDocumentRegion result = fStructuredDocument.getRegionAtCharacterOffset(end); - // if not well formed, get one past, if there is something there - if ((result != null) && (!result.isEnded())) { - if (result.getNext() != null) { - result = result.getNext(); - } - } - // also, get one past if exactly equal to the end (this was needed - // as a simple fix to when a whole exact region is deleted. - // there's probably a better way. - if ((result != null) && (end == result.getEnd())) { - if (result.getNext() != null) { - result = result.getNext(); - } - } - - // 12/6/2001 - Since we've changed the parser/scanner to allow a lone - // '<' without - // always interpretting it as start of a tag name, we need to be a - // little fancier, in order - // to "skip" over any plain 'ol content between the lone '<' and any - // potential meating - // regions past plain 'ol content. - if (isLoneOpenFollowedByContent(result) && (result.getNext() != null)) { - result = result.getNext(); - } - - if (result != null) - fStructuredDocument.setCachedDocumentRegion(result); - dirtyEnd = result; - - return dirtyEnd; - } - - protected void findDirtyStart(int start) { - IStructuredDocumentRegion result = fStructuredDocument.getRegionAtCharacterOffset(start); - // heuristic: if the postion is exactly equal to the start, then - // go back one more, if it exists. This prevents problems with - // insertions - // of text that should be merged with the previous node instead of - // simply hung - // off of it as a separate node (ex.: XML content inserted right - // before an open - // bracket should become part of the previous content node) - if (result != null) { - IStructuredDocumentRegion previous = result.getPrevious(); - if ((previous != null) && ((!(previous.isEnded())) || (start == result.getStart()))) { - result = previous; - } - // If we are now at the end of a "tag dependent" content area (or - // JSP area) - // then we need to back up all the way to the beginning of that. - IStructuredDocumentRegion potential = result; - while (isPartOfBlockRegion(potential)) { - potential = potential.getPrevious(); - } - if (potential != null) { - result = potential; - fStructuredDocument.setCachedDocumentRegion(result); - } - } - dirtyStart = result; - } - - /** - * The rule is, that is we are content, preceded by lone <, then we need - * to advance one more for dirty end. - */ - protected boolean isLoneOpenFollowedByContent(IStructuredDocumentRegion flatNode) { - boolean result = false; - String type = flatNode.getType(); - if (type == DOMRegionContext.XML_CONTENT) { - IStructuredDocumentRegion previous = flatNode.getPrevious(); - String previousType = null; - if (previous != null) { - previousType = previous.getType(); - } - if (previousType != null) { - result = (previousType == DOMRegionContext.XML_TAG_OPEN); - } - } - return result; - } - - protected boolean isPartOfBlockRegion(IStructuredDocumentRegion flatNode) { - boolean result = false; - String type = flatNode.getType(); - result = (type == DOMRegionContext.BLOCK_TEXT); - return result; - } - - public IStructuredTextReParser newInstance() { - return new XMLStructuredDocumentReParser(); - } - -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLStructuredRegionFactory.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLStructuredRegionFactory.java deleted file mode 100644 index 8a98dc2d9b..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLStructuredRegionFactory.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.parser; - -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.xml.core.internal.text.XMLStructuredDocumentRegion; - - -/** - * A simple class to generate instances of StructuredRegions. - */ -public class XMLStructuredRegionFactory { - public final static int JSP_DIRECTIVE = 1003; - public final static int XML = 1001; - public final static int XML_BLOCK = 1002; - - public static IStructuredDocumentRegion createRegion(int type) { - IStructuredDocumentRegion instance = null; - switch (type) { - case XML : - instance = new XMLStructuredDocumentRegion(); - break; - case XML_BLOCK : - instance = new BlockStructuredDocumentRegion(); - break; - default : - throw new IllegalArgumentException("AbstractRegion::createRegion. Invalid type."); //$NON-NLS-1$ - } - return instance; - } - -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLTokenizer.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLTokenizer.java deleted file mode 100644 index b4607a28d6..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLTokenizer.java +++ /dev/null @@ -1,1937 +0,0 @@ -/* The following code was generated by JFlex 1.2.2 on 10/17/07 4:27 AM */ - -/******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.xml.core.internal.parser; - -import java.io.CharArrayReader; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.wst.sse.core.internal.ltk.parser.BlockMarker; -import org.eclipse.wst.sse.core.internal.ltk.parser.BlockTokenizer; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.sse.core.internal.util.Debug; -import org.eclipse.wst.sse.core.utils.StringUtils; -import org.eclipse.wst.xml.core.internal.Logger; -import org.eclipse.wst.xml.core.internal.parser.regions.XMLParserRegionFactory; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; - - -/** - * This class is a scanner generated by - * <a href="http://www.informatik.tu-muenchen.de/~kleing/jflex/">JFlex</a> 1.2.2 - * on 10/17/07 4:27 AM from the specification file - * <tt>file:/D:/eclipse.wtp/workspace/org.eclipse.wst.sse.core/DevTimeSupport/SedModel/HTMLTokenizer/devel/XMLTokenizer.jflex</tt> - */ -public class XMLTokenizer implements BlockTokenizer, DOMRegionContext { - - /** this character denotes the end of file */ - final public static int YYEOF = -1; - - /** lexical states */ - final public static int ST_XML_DOCTYPE_EXTERNAL_ID = 23; - final public static int ST_XML_ELEMENT_DECLARATION_CONTENT = 27; - final public static int ST_DHTML_ATTRIBUTE_NAME = 12; - final public static int ST_XML_PI_TAG_CLOSE = 11; - final public static int ST_XML_DECLARATION_CLOSE = 21; - final public static int ST_XML_PI_ATTRIBUTE_VALUE = 10; - final public static int ST_DHTML_EQUALS = 13; - final public static int ST_XML_TAG_NAME = 16; - final public static int ST_XML_ATTRIBUTE_VALUE = 19; - final public static int ST_DHTML_ATTRIBUTE_VALUE = 14; - final public static int ST_XML_DOCTYPE_ID_SYSTEM = 25; - final public static int ST_XML_ATTRIBUTE_NAME = 17; - final public static int ST_XML_ELEMENT_DECLARATION = 26; - final public static int ST_XML_DOCTYPE_DECLARATION = 22; - final public static int ST_XML_ATTLIST_DECLARATION = 28; - final public static int ST_XML_COMMENT_END = 4; - final public static int ST_CDATA_TEXT = 1; - final public static int ST_DHTML_TAG_CLOSE = 15; - final public static int ST_XML_COMMENT = 3; - final public static int ST_PI_CONTENT = 7; - final public static int ST_PI_WS = 6; - final public static int ST_CDATA_END = 2; - final public static int ST_XML_ATTLIST_DECLARATION_CONTENT = 29; - final public static int ST_BLOCK_TAG_SCAN = 30; - final public static int ST_XML_PI_EQUALS = 9; - final public static int ST_XML_DECLARATION = 20; - final public static int YYINITIAL = 0; - final public static int ST_XML_DOCTYPE_ID_PUBLIC = 24; - final public static int ST_XML_EQUALS = 18; - final public static int ST_PI = 5; - final public static int ST_XML_PI_ATTRIBUTE_NAME = 8; - - /** - * Translates characters to character classes - */ - final private static String yycmap_packed = - "\11\0\1\5\1\22\2\0\1\14\22\0\1\14\1\21\1\11\1\55"+ - "\1\16\1\17\1\12\1\13\1\16\1\16\1\16\1\16\1\16\1\7"+ - "\1\6\1\3\12\15\1\10\1\61\1\1\1\45\1\2\1\4\1\16"+ - "\1\34\1\62\1\32\1\33\1\50\1\57\1\36\1\36\1\42\1\36"+ - "\1\36\1\27\1\25\1\44\1\43\1\47\1\36\1\40\1\56\1\35"+ - "\1\60\2\36\1\23\1\46\1\36\1\31\1\0\1\20\1\0\1\10"+ - "\1\0\1\52\1\62\1\63\1\53\1\37\1\57\1\36\1\66\1\42"+ - "\2\36\1\30\1\26\1\44\1\43\1\47\1\36\1\40\1\41\1\51"+ - "\1\60\1\36\1\36\1\24\1\54\1\36\1\0\1\0\72\0\1\65"+ - "\10\0\27\64\1\0\37\64\1\0\72\64\2\0\13\64\2\0\10\64"+ - "\1\0\65\64\1\0\104\64\11\0\44\64\3\0\2\64\4\0\36\64"+ - "\70\0\131\64\22\0\7\64\16\0\2\65\56\0\106\65\32\0\2\65"+ - "\44\0\1\64\1\65\3\64\1\0\1\64\1\0\24\64\1\0\54\64"+ - "\1\0\7\64\3\0\1\64\1\0\1\64\1\0\1\64\1\0\1\64"+ - "\1\0\22\64\15\0\14\64\1\0\102\64\1\0\14\64\1\0\44\64"+ - "\1\0\4\65\11\0\65\64\2\0\2\64\2\0\2\64\3\0\34\64"+ - "\2\0\10\64\2\0\2\64\67\0\46\64\2\0\1\64\7\0\46\64"+ - "\12\0\21\65\1\0\27\65\1\0\3\65\1\0\1\65\1\0\2\65"+ - "\1\0\1\65\13\0\33\64\5\0\3\64\56\0\32\64\5\0\1\65"+ - "\12\64\10\65\15\0\12\65\6\0\1\65\107\64\2\0\5\64\1\0"+ - "\17\64\1\0\4\64\1\0\1\64\17\65\2\64\2\65\1\0\4\65"+ - "\2\0\12\65\u0207\0\3\65\1\0\65\64\2\0\1\65\1\64\20\65"+ - "\3\0\4\65\3\0\12\64\2\65\2\0\12\65\21\0\3\65\1\0"+ - "\10\64\2\0\2\64\2\0\26\64\1\0\7\64\1\0\1\64\3\0"+ - "\4\64\2\0\1\65\1\0\7\65\2\0\2\65\2\0\3\65\11\0"+ - "\1\65\4\0\2\64\1\0\3\64\2\65\2\0\12\65\2\64\20\0"+ - "\1\65\2\0\6\64\4\0\2\64\2\0\26\64\1\0\7\64\1\0"+ - "\2\64\1\0\2\64\1\0\2\64\2\0\1\65\1\0\5\65\4\0"+ - "\2\65\2\0\3\65\13\0\4\64\1\0\1\64\7\0\12\65\2\65"+ - "\3\64\14\0\3\65\1\0\7\64\1\0\1\64\1\0\3\64\1\0"+ - "\26\64\1\0\7\64\1\0\2\64\1\0\5\64\2\0\1\65\1\64"+ - "\10\65\1\0\3\65\1\0\3\65\22\0\1\64\5\0\12\65\21\0"+ - "\3\65\1\0\10\64\2\0\2\64\2\0\26\64\1\0\7\64\1\0"+ - "\2\64\2\0\4\64\2\0\1\65\1\64\6\65\3\0\2\65\2\0"+ - "\3\65\10\0\2\65\4\0\2\64\1\0\3\64\4\0\12\65\22\0"+ - "\2\65\1\0\6\64\3\0\3\64\1\0\4\64\3\0\2\64\1\0"+ - "\1\64\1\0\2\64\3\0\2\64\3\0\3\64\3\0\10\64\1\0"+ - "\3\64\4\0\5\65\3\0\3\65\1\0\4\65\11\0\1\65\17\0"+ - "\11\65\21\0\3\65\1\0\10\64\1\0\3\64\1\0\27\64\1\0"+ - "\12\64\1\0\5\64\4\0\7\65\1\0\3\65\1\0\4\65\7\0"+ - "\2\65\11\0\2\64\4\0\12\65\22\0\2\65\1\0\10\64\1\0"+ - "\3\64\1\0\27\64\1\0\12\64\1\0\5\64\4\0\7\65\1\0"+ - "\3\65\1\0\4\65\7\0\2\65\7\0\1\64\1\0\2\64\4\0"+ - "\12\65\22\0\2\65\1\0\10\64\1\0\3\64\1\0\27\64\1\0"+ - "\20\64\4\0\6\65\2\0\3\65\1\0\4\65\11\0\1\65\10\0"+ - "\2\64\4\0\12\65\221\0\56\64\1\0\1\64\1\65\2\64\7\65"+ - "\5\0\6\64\1\65\10\65\1\0\12\65\47\0\2\64\1\0\1\64"+ - "\2\0\2\64\1\0\1\64\2\0\1\64\6\0\4\64\1\0\7\64"+ - "\1\0\3\64\1\0\1\64\1\0\1\64\2\0\2\64\1\0\2\64"+ - "\1\0\1\64\1\65\2\64\6\65\1\0\2\65\1\64\2\0\5\64"+ - "\1\0\1\65\1\0\6\65\2\0\12\65\76\0\2\65\6\0\12\65"+ - "\13\0\1\65\1\0\1\65\1\0\1\65\4\0\2\65\10\64\1\0"+ - "\41\64\7\0\24\65\1\0\6\65\4\0\6\65\1\0\1\65\1\0"+ - "\25\65\3\0\7\65\1\0\1\65\346\0\46\64\12\0\47\64\11\0"+ - "\1\64\1\0\2\64\1\0\3\64\1\0\1\64\1\0\2\64\1\0"+ - "\5\64\51\0\1\64\1\0\1\64\1\0\1\64\13\0\1\64\1\0"+ - "\1\64\1\0\1\64\3\0\2\64\3\0\1\64\5\0\3\64\1\0"+ - "\1\64\1\0\1\64\1\0\1\64\1\0\1\64\3\0\2\64\3\0"+ - "\2\64\1\0\1\64\50\0\1\64\11\0\1\64\2\0\1\64\2\0"+ - "\2\64\7\0\2\64\1\0\1\64\1\0\7\64\50\0\1\64\4\0"+ - "\1\64\10\0\1\64\u0c06\0\234\64\4\0\132\64\6\0\26\64\2\0"+ - "\6\64\2\0\46\64\2\0\6\64\2\0\10\64\1\0\1\64\1\0"+ - "\1\64\1\0\1\64\1\0\37\64\2\0\65\64\1\0\7\64\1\0"+ - "\1\64\3\0\3\64\1\0\7\64\3\0\4\64\2\0\6\64\4\0"+ - "\15\64\5\0\3\64\1\0\7\64\323\0\15\65\4\0\1\65\104\0"+ - "\1\64\3\0\2\64\2\0\1\64\121\0\3\64\u0e82\0\1\65\1\0"+ - "\1\64\31\0\11\64\6\65\1\0\5\65\13\0\124\64\4\0\2\65"+ - "\2\0\2\65\2\0\132\64\1\0\3\65\6\0\50\64\u1cd3\0\u51a6\64"+ - "\u0c5a\0\u2ba4\64\134\0\u0800\0\u1ffe\0\2\0"; - - /** - * Translates characters to character classes - */ - final private static char [] yycmap = yy_unpack_cmap(yycmap_packed); - - /** - * Translates a state to a row index in the transition table - */ - final private static int yy_rowMap [] = { - 0, 55, 110, 165, 220, 275, 330, 385, 440, 495, - 550, 605, 660, 715, 770, 825, 880, 935, 990, 1045, - 1100, 1155, 1210, 1265, 1320, 1375, 1430, 1485, 1540, 1595, - 1650, 1705, 1760, 1815, 1870, 1925, 1980, 1925, 1980, 2035, - 1925, 1925, 1980, 2090, 2145, 2200, 2255, 2310, 2365, 2420, - 2475, 1925, 1980, 2530, 2585, 2640, 1925, 2695, 2695, 2750, - 2805, 2860, 2530, 1925, 2915, 2970, 1925, 3025, 3080, 3135, - 3190, 3245, 3300, 1925, 3355, 3410, 3465, 3520, 1925, 3575, - 3630, 3685, 3740, 3795, 1925, 3850, 3905, 3960, 4015, 4070, - 4125, 4180, 4235, 4235, 4290, 4345, 4400, 4455, 4455, 4510, - 4565, 4620, 4675, 4675, 4730, 4785, 4840, 4895, 1925, 4950, - 4950, 5005, 5060, 5115, 5170, 1925, 1925, 1980, 1925, 1925, - 5225, 5280, 5335, 5390, 5445, 5500, 5555, 5610, 1925, 5665, - 5720, 5775, 1925, 1925, 2695, 5830, 2805, 1925, 5885, 2860, - 2915, 3025, 3080, 5940, 3135, 1925, 5995, 3190, 1925, 3575, - 6050, 3685, 1925, 6105, 3740, 5225, 6160, 6215, 6270, 4015, - 1925, 6325, 6380, 4235, 6435, 4290, 1925, 6490, 6545, 6600, - 6600, 6655, 6710, 4400, 4235, 4455, 6765, 4510, 1925, 6820, - 4565, 4620, 4455, 4675, 6875, 4730, 1925, 6930, 6985, 7040, - 7040, 7095, 7150, 7205, 4950, 7260, 5005, 1925, 7315, 7370, - 7425, 7425, 7480, 7535, 7590, 7645, 7700, 7755, 7810, 1925, - 7865, 7920, 1925, 1925, 1925, 2255, 7975, 8030, 8085, 8140, - 8195, 8250, 8305, 6490, 8360, 8360, 6930, 8415, 8415, 8470, - 7315, 8525, 8525, 8580, 1925, 8635, 8690, 1925, 8745, 8800, - 8855, 8910, 8965, 9020, 9075, 9130, 6655, 7095, 9185, 7480, - 9240, 9295, 9350, 9405, 9460, 9515, 9570, 9625, 9680, 9735, - 9790, 9845, 9900, 9955, 10010, 10065, 10120, 1925, 1925, 10175, - 10230, 10285, 10340, 10395, 1925, 1925, 1925, 10450, 10505, 10560, - 10615, 10670, 10725, 1925, 10780, 4840, 5115, 10835, 10890, 10945, - 11000, 2255 - }; - - /** - * The packed transition table of the DFA - */ - final private static String yy_packed = - "\1\40\1\41\10\40\1\42\4\40\1\43\47\40\1\44"+ - "\1\45\65\44\1\46\1\47\16\46\1\50\1\46\1\51"+ - "\44\46\1\52\1\53\65\52\1\46\1\47\5\46\1\54"+ - "\12\46\1\51\45\46\1\47\2\46\1\55\1\56\2\46"+ - "\1\57\3\46\1\56\5\46\1\56\1\60\1\61\4\57"+ - "\1\46\10\57\1\62\2\57\1\46\7\57\1\46\3\57"+ - "\1\46\3\57\1\46\1\57\1\46\1\47\2\46\1\55"+ - "\1\63\6\46\1\63\5\46\1\63\44\46\1\64\1\65"+ - "\2\64\1\66\15\64\1\51\44\64\1\46\1\47\2\46"+ - "\1\67\1\56\2\46\1\70\3\46\1\56\5\46\1\56"+ - "\6\70\1\46\13\70\1\46\7\70\1\46\3\70\1\46"+ - "\3\70\1\46\1\70\1\46\1\47\2\46\1\67\1\56"+ - "\2\46\1\70\3\46\1\56\5\46\1\56\6\70\1\46"+ - "\13\70\1\71\7\70\1\46\3\70\1\46\3\70\1\46"+ - "\1\70\1\72\1\47\1\46\1\73\1\74\1\56\3\72"+ - "\1\75\1\72\1\76\1\56\5\72\1\56\44\72\1\46"+ - "\1\47\2\46\1\77\15\46\1\51\45\46\1\47\1\100"+ - "\1\101\1\46\1\56\2\46\1\102\3\46\1\56\5\46"+ - "\1\56\6\102\1\46\13\102\1\46\7\102\1\46\3\102"+ - "\1\46\3\102\1\46\1\102\1\46\1\47\1\100\1\101"+ - "\1\46\1\56\2\46\1\102\3\46\1\56\5\46\1\56"+ - "\6\102\1\46\13\102\1\103\7\102\1\46\3\102\1\46"+ - "\3\102\1\46\1\102\1\104\1\47\1\100\1\105\1\104"+ - "\1\56\3\104\1\106\1\104\1\107\1\56\5\104\1\56"+ - "\44\104\1\46\1\47\3\46\1\56\6\46\1\56\5\46"+ - "\1\56\44\46\1\110\1\111\1\112\1\113\4\110\1\114"+ - "\12\110\6\115\1\110\13\115\1\110\7\115\1\110\3\115"+ - "\1\110\3\115\1\110\1\115\1\46\1\111\1\112\1\113"+ - "\1\46\1\56\2\46\1\116\3\46\1\56\5\46\1\56"+ - "\6\116\1\46\13\116\1\46\7\116\1\46\3\116\1\46"+ - "\3\116\1\46\1\116\1\46\1\111\1\112\1\113\1\46"+ - "\1\56\2\46\1\116\3\46\1\56\5\46\1\56\6\116"+ - "\1\46\13\116\1\117\7\116\1\46\3\116\1\46\3\116"+ - "\1\46\1\116\1\120\1\111\1\112\1\121\1\120\1\56"+ - "\3\120\1\122\1\120\1\123\1\56\5\120\1\56\44\120"+ - "\1\46\1\124\1\125\2\46\1\56\6\46\1\56\5\46"+ - "\1\56\10\46\1\126\1\127\2\46\1\130\10\46\1\130"+ - "\1\46\1\127\1\126\14\46\1\47\1\125\2\46\1\56"+ - "\6\46\1\56\5\46\1\56\6\46\1\131\36\46\1\47"+ - "\1\125\2\46\1\56\2\46\1\132\3\46\1\56\5\46"+ - "\1\56\6\132\1\131\13\132\1\46\7\132\1\46\3\132"+ - "\1\46\3\132\1\46\1\132\1\46\1\47\1\125\2\46"+ - "\1\56\6\46\1\56\5\46\1\56\6\46\1\131\7\46"+ - "\1\133\5\46\1\134\6\46\1\133\10\46\1\135\1\47"+ - "\1\125\1\136\1\135\1\56\3\135\1\137\1\135\1\140"+ - "\1\56\5\135\1\56\6\135\1\141\35\135\1\142\1\47"+ - "\1\125\1\143\1\142\1\56\3\142\1\144\1\142\1\145"+ - "\1\56\5\142\1\56\6\142\1\146\35\142\1\147\1\47"+ - "\1\125\1\150\1\147\1\56\3\147\1\151\1\147\1\152"+ - "\1\56\5\147\1\56\44\147\1\153\1\154\1\155\64\153"+ - "\1\156\1\47\1\125\1\157\1\156\1\56\3\156\1\160"+ - "\1\156\1\161\1\56\5\156\1\56\44\156\1\162\1\163"+ - "\1\164\64\162\1\165\1\166\65\165\1\40\1\0\10\40"+ - "\1\0\4\40\1\0\47\40\3\0\1\167\1\170\14\0"+ - "\1\171\52\0\1\172\2\0\1\173\3\0\1\172\5\0"+ - "\1\172\6\173\1\0\13\173\1\0\7\173\1\174\3\173"+ - "\1\0\3\173\1\0\1\173\5\0\1\172\2\0\1\175"+ - "\3\0\1\172\5\0\1\172\6\175\1\0\13\175\1\0"+ - "\7\175\1\0\3\175\1\0\3\175\1\0\1\175\110\0"+ - "\1\176\65\0\1\177\55\0\1\200\61\0\1\201\71\0"+ - "\1\56\6\0\1\56\5\0\1\56\52\0\3\57\4\0"+ - "\1\57\5\0\6\57\1\0\13\57\1\0\7\57\1\0"+ - "\3\57\1\0\5\57\6\0\3\57\4\0\1\57\5\0"+ - "\2\57\2\202\2\57\1\0\13\57\1\0\7\57\1\0"+ - "\3\57\1\0\5\57\6\0\3\57\4\0\1\57\5\0"+ - "\2\57\1\202\1\203\2\57\1\0\13\57\1\0\7\57"+ - "\1\0\3\57\1\0\5\57\6\0\3\57\4\0\1\57"+ - "\5\0\2\57\2\204\2\57\1\0\13\57\1\0\7\57"+ - "\1\0\3\57\1\0\5\57\5\0\1\63\6\0\1\63"+ - "\5\0\1\63\46\0\1\205\66\0\1\206\72\0\3\70"+ - "\4\0\1\70\5\0\6\70\1\0\13\70\1\0\7\70"+ - "\1\0\3\70\1\0\5\70\1\72\2\0\1\207\1\72"+ - "\1\0\3\72\1\0\1\72\2\0\5\72\1\0\45\72"+ - "\1\0\1\206\1\207\1\72\1\0\3\72\1\0\1\72"+ - "\2\0\5\72\1\0\44\72\1\75\1\0\1\210\1\211"+ - "\1\75\1\210\3\75\1\212\1\75\2\210\5\75\1\210"+ - "\44\75\1\76\1\0\1\213\1\214\1\76\1\213\3\76"+ - "\1\213\1\76\1\212\1\213\5\76\1\213\44\76\2\0"+ - "\1\100\1\215\71\0\3\102\4\0\1\102\5\0\6\102"+ - "\1\0\13\102\1\0\7\102\1\0\3\102\1\0\5\102"+ - "\1\104\2\0\1\216\1\104\1\0\3\104\1\0\1\104"+ - "\2\0\5\104\1\0\45\104\1\0\1\100\1\217\1\104"+ - "\1\0\3\104\1\0\1\104\2\0\5\104\1\0\44\104"+ - "\1\106\1\0\1\220\1\221\1\106\1\220\3\106\1\222"+ - "\1\106\2\220\5\106\1\220\44\106\1\107\1\0\1\223"+ - "\1\224\1\107\1\223\3\107\1\223\1\107\1\222\1\223"+ - "\5\107\1\223\44\107\1\110\3\0\17\110\6\0\1\110"+ - "\13\0\1\110\7\0\1\110\3\0\1\110\3\0\1\110"+ - "\4\0\1\167\15\0\1\171\47\0\1\225\64\0\1\110"+ - "\3\0\2\110\3\114\4\110\1\114\5\110\6\115\1\110"+ - "\13\115\1\110\7\115\1\110\3\115\1\110\3\115\1\114"+ - "\1\115\6\0\3\115\4\0\1\115\5\0\6\115\1\0"+ - "\13\115\1\0\7\115\1\0\3\115\1\0\5\115\6\0"+ - "\3\116\4\0\1\116\5\0\6\116\1\0\13\116\1\0"+ - "\7\116\1\0\3\116\1\0\5\116\1\120\2\0\1\226"+ - "\1\120\1\0\3\120\1\0\1\120\2\0\5\120\1\0"+ - "\45\120\1\0\1\225\1\226\1\120\1\0\3\120\1\0"+ - "\1\120\2\0\5\120\1\0\44\120\1\122\1\0\1\227"+ - "\1\230\1\122\1\227\3\122\1\231\1\122\2\227\5\122"+ - "\1\227\44\122\1\123\1\0\1\232\1\233\1\123\1\232"+ - "\3\123\1\232\1\123\1\231\1\232\5\123\1\232\44\123"+ - "\3\0\1\167\15\0\1\234\110\0\1\235\60\0\1\236"+ - "\13\0\1\236\44\0\2\237\36\0\20\240\1\241\46\240"+ - "\6\0\3\132\4\0\1\132\5\0\6\132\1\0\13\132"+ - "\1\0\7\132\1\0\3\132\1\0\5\132\46\0\1\242"+ - "\5\0\1\242\72\0\1\243\6\0\1\135\2\0\1\244"+ - "\1\135\1\0\3\135\1\0\1\135\2\0\5\135\1\0"+ - "\44\135\1\137\1\0\1\245\1\246\1\137\1\245\3\137"+ - "\1\247\1\137\2\245\5\137\1\245\44\137\1\250\1\0"+ - "\1\251\1\252\1\253\1\251\3\253\1\251\1\250\1\254"+ - "\1\255\3\253\1\250\1\253\1\255\6\253\1\250\32\253"+ - "\2\250\1\253\1\141\2\240\1\256\1\141\1\240\3\141"+ - "\1\240\1\141\2\240\3\141\1\257\1\141\1\240\44\141"+ - "\1\142\2\0\1\260\1\142\1\0\3\142\1\0\1\142"+ - "\2\0\5\142\1\0\44\142\1\144\2\261\1\262\1\144"+ - "\1\261\3\144\1\263\1\144\2\261\5\144\1\261\44\144"+ - "\1\145\2\264\1\265\1\145\1\264\3\145\1\264\1\145"+ - "\1\263\1\264\5\145\1\264\44\145\1\146\2\240\1\266"+ - "\1\146\1\240\3\146\1\240\1\146\2\240\3\146\1\267"+ - "\1\146\1\240\44\146\1\147\2\0\1\270\1\147\1\0"+ - "\3\147\1\0\1\147\2\0\5\147\1\0\44\147\1\151"+ - "\1\0\1\271\1\272\1\151\1\271\3\151\1\273\1\151"+ - "\2\271\5\151\1\271\44\151\1\274\1\0\1\275\1\276"+ - "\1\277\1\275\3\277\1\275\1\274\1\300\1\301\3\277"+ - "\1\274\1\277\1\301\6\277\1\274\32\277\2\274\1\277"+ - "\2\153\1\0\66\153\1\0\16\153\1\302\45\153\1\156"+ - "\2\0\1\303\1\156\1\0\3\156\1\0\1\156\2\0"+ - "\5\156\1\0\44\156\1\160\1\0\1\304\1\305\1\160"+ - "\1\304\3\160\1\306\1\160\2\304\5\160\1\304\44\160"+ - "\1\307\1\0\1\310\1\311\1\312\1\310\3\312\1\310"+ - "\1\307\1\313\1\314\3\312\1\307\1\312\1\314\6\312"+ - "\1\307\32\312\2\307\1\312\2\162\1\0\66\162\1\0"+ - "\16\162\1\315\45\162\7\0\1\316\21\0\1\317\42\0"+ - "\1\172\2\0\1\40\3\0\1\172\5\0\1\172\6\40"+ - "\1\0\13\40\1\0\7\40\1\0\3\40\1\0\3\40"+ - "\1\0\1\40\1\320\1\0\3\320\1\321\3\173\1\320"+ - "\1\0\1\320\1\321\1\173\1\320\1\0\2\320\1\321"+ - "\6\173\1\320\13\173\1\320\7\173\1\320\3\173\1\322"+ - "\5\173\15\0\1\323\6\0\1\324\42\0\1\320\1\0"+ - "\3\320\1\321\3\175\1\320\1\0\1\320\1\321\1\175"+ - "\1\320\1\0\2\320\1\321\6\175\1\320\13\175\1\320"+ - "\7\175\1\320\3\175\1\325\5\175\31\0\1\317\37\0"+ - "\1\326\66\0\1\327\72\0\3\57\4\0\1\57\5\0"+ - "\4\57\2\330\1\0\13\57\1\0\7\57\1\0\3\57"+ - "\1\0\5\57\6\0\3\57\4\0\1\57\5\0\4\57"+ - "\1\330\1\331\1\0\13\57\1\0\7\57\1\0\3\57"+ - "\1\0\5\57\6\0\3\57\4\0\1\57\5\0\6\57"+ - "\1\0\13\57\1\0\1\57\1\332\5\57\1\0\3\57"+ - "\1\0\5\57\1\210\1\0\7\210\1\212\55\210\1\213"+ - "\1\0\11\213\1\212\53\213\1\220\1\0\7\220\1\222"+ - "\55\220\1\223\1\0\11\223\1\222\53\223\1\227\1\0"+ - "\7\227\1\231\55\227\1\232\1\0\11\232\1\231\53\232"+ - "\32\0\1\333\30\0\1\333\40\0\1\334\13\0\1\334"+ - "\54\0\1\335\10\0\1\335\57\0\1\336\14\0\1\336"+ - "\72\0\1\337\4\0\1\245\1\0\7\245\1\247\55\245"+ - "\1\250\1\0\1\251\1\340\1\250\1\251\3\250\1\251"+ - "\1\250\1\247\1\251\5\250\1\251\44\250\1\251\1\0"+ - "\11\251\1\247\53\251\1\250\1\0\1\251\1\340\1\250"+ - "\1\251\3\250\1\251\1\250\1\341\1\251\5\250\1\251"+ - "\44\250\13\0\1\342\53\0\1\251\1\0\11\251\1\341"+ - "\53\251\11\261\1\263\55\261\13\264\1\263\53\264\1\271"+ - "\1\0\7\271\1\273\55\271\1\274\1\0\1\275\1\343"+ - "\1\274\1\275\3\274\1\275\1\274\1\273\1\275\5\274"+ - "\1\275\44\274\1\275\1\0\11\275\1\273\53\275\1\274"+ - "\1\0\1\275\1\343\1\274\1\275\3\274\1\275\1\274"+ - "\1\344\1\275\5\274\1\275\44\274\13\0\1\345\53\0"+ - "\1\275\1\0\11\275\1\344\53\275\2\153\1\0\26\153"+ - "\1\346\35\153\1\304\1\0\7\304\1\306\55\304\1\307"+ - "\1\0\1\310\1\347\1\307\1\310\3\307\1\310\1\307"+ - "\1\306\1\310\5\307\1\310\44\307\1\310\1\0\11\310"+ - "\1\306\53\310\1\307\1\0\1\310\1\347\1\307\1\310"+ - "\3\307\1\310\1\307\1\350\1\310\5\307\1\310\44\307"+ - "\13\0\1\351\53\0\1\310\1\0\11\310\1\350\53\310"+ - "\2\162\1\0\26\162\1\352\35\162\7\0\1\353\111\0"+ - "\1\354\34\0\1\320\1\0\10\320\1\0\4\320\1\0"+ - "\41\320\1\0\6\320\1\0\3\320\1\321\4\320\1\0"+ - "\1\320\1\321\2\320\1\0\2\320\1\321\36\320\1\355"+ - "\5\320\15\0\1\323\43\0\1\356\22\0\1\357\14\0"+ - "\3\357\2\0\1\357\10\0\1\357\1\0\2\357\3\0"+ - "\1\357\2\0\2\357\11\0\1\57\1\360\1\57\4\0"+ - "\1\57\5\0\6\57\1\0\13\57\1\0\7\57\1\0"+ - "\3\57\1\0\5\57\6\0\3\57\4\0\1\57\5\0"+ - "\6\57\1\0\11\57\1\361\1\57\1\0\7\57\1\0"+ - "\3\57\1\0\5\57\35\0\1\362\13\0\1\362\44\0"+ - "\2\363\63\0\2\364\75\0\1\365\13\0\1\365\44\0"+ - "\2\366\41\0\2\367\1\0\3\367\2\0\1\254\4\367"+ - "\1\0\10\367\1\0\32\367\2\0\1\367\3\0\2\370"+ - "\1\0\3\370\2\0\1\300\4\370\1\0\10\370\1\0"+ - "\32\370\2\0\1\370\2\153\1\0\27\153\1\371\34\153"+ - "\3\0\2\372\1\0\3\372\2\0\1\313\4\372\1\0"+ - "\10\372\1\0\32\372\2\0\1\372\2\162\1\0\27\162"+ - "\1\373\34\162\33\0\1\374\114\0\1\355\22\0\1\357"+ - "\14\0\3\357\2\0\1\357\10\0\1\357\1\0\2\357"+ - "\3\0\1\357\1\0\1\356\2\357\11\0\3\57\4\0"+ - "\1\57\5\0\6\57\1\0\7\57\1\375\3\57\1\0"+ - "\7\57\1\0\3\57\1\0\5\57\6\0\3\57\4\0"+ - "\1\57\5\0\6\57\1\0\6\57\1\376\4\57\1\0"+ - "\7\57\1\0\3\57\1\0\5\57\46\0\1\377\5\0"+ - "\1\377\54\0\1\u0100\63\0\1\u0101\10\0\1\u0101\55\0"+ - "\1\u0102\10\0\1\u0102\60\0\1\u0103\24\0\2\153\1\0"+ - "\30\153\1\u0104\33\153\2\162\1\0\30\162\1\u0105\33\162"+ - "\34\0\1\u0106\40\0\3\57\4\0\1\57\5\0\6\57"+ - "\1\0\13\57\1\0\3\57\1\u0107\3\57\1\0\3\57"+ - "\1\0\5\57\6\0\3\57\4\0\1\57\5\0\6\57"+ - "\1\0\3\57\1\u0108\7\57\1\0\3\57\1\u0108\3\57"+ - "\1\0\3\57\1\0\5\57\47\0\1\u0109\60\0\1\u010a"+ - "\14\0\1\u010a\54\0\1\u010b\47\0\2\u010c\72\0\1\u010d"+ - "\30\0\1\u010d\3\0\2\153\1\0\31\153\1\u010e\32\153"+ - "\2\162\1\0\31\162\1\u010f\32\162\35\0\1\u0110\37\0"+ - "\3\57\4\0\1\57\5\0\6\57\1\0\13\57\1\0"+ - "\6\57\1\u0111\1\0\3\57\1\0\5\57\5\0\1\u0112"+ - "\3\57\3\0\1\u0112\1\57\4\0\1\u0112\6\57\1\0"+ - "\13\57\1\0\7\57\1\0\3\57\1\0\5\57\37\0"+ - "\1\u0113\10\0\1\u0113\53\0\1\u0114\13\0\1\u0114\52\0"+ - "\1\u0115\13\0\1\u0115\15\0\2\153\1\0\32\153\1\u0116"+ - "\31\153\2\162\1\0\32\162\1\u0117\31\162\34\0\1\u0118"+ - "\40\0\3\57\4\0\1\57\5\0\5\57\1\u0119\1\0"+ - "\13\57\1\0\7\57\1\0\3\57\1\0\5\57\5\0"+ - "\1\u0112\6\0\1\u0112\5\0\1\u0112\44\0\2\153\1\0"+ - "\31\153\1\u011a\32\153\2\162\1\0\31\162\1\u011b\32\162"+ - "\31\0\1\u011c\43\0\3\57\4\0\1\57\5\0\6\57"+ - "\1\0\5\57\1\u011d\5\57\1\0\7\57\1\0\3\57"+ - "\1\0\5\57\2\153\1\0\26\153\1\u011e\35\153\2\162"+ - "\1\0\26\162\1\u011f\35\162\6\0\3\57\4\0\1\57"+ - "\5\0\6\57\1\0\7\57\1\u0120\3\57\1\0\7\57"+ - "\1\0\3\57\1\0\5\57\6\0\3\57\4\0\1\57"+ - "\5\0\6\57\1\0\13\57\1\0\7\57\1\0\3\57"+ - "\1\0\4\57\1\u0121\6\0\3\57\4\0\1\57\5\0"+ - "\6\57\1\0\5\57\1\u0122\5\57\1\0\7\57\1\0"+ - "\3\57\1\0\5\57\6\0\3\57\4\0\1\57\5\0"+ - "\6\57\1\0\5\57\1\u0123\5\57\1\0\7\57\1\0"+ - "\3\57\1\0\5\57\6\0\3\57\4\0\1\57\5\0"+ - "\6\57\1\0\13\57\1\0\3\57\1\u0124\3\57\1\0"+ - "\3\57\1\0\5\57"; - - /** - * The transition table of the DFA - */ - final private static int yytrans [] = yy_unpack(yy_packed); - - - /* error codes */ - final private static int YY_UNKNOWN_ERROR = 0; - // final private static int YY_ILLEGAL_STATE = 1; - final private static int YY_NO_MATCH = 2; - final private static int YY_PUSHBACK_2BIG = 3; - - /* error messages for the codes above */ - final private static String YY_ERROR_MSG[] = { - "Unkown internal scanner error", //$NON-NLS-1$ - "Internal error: unknown state", //$NON-NLS-1$ - "Error: could not match input", //$NON-NLS-1$ - "Error: pushback value was too large" //$NON-NLS-1$ - }; - - /** - * YY_ATTRIBUTE[aState] contains the attributes of state <code>aState</code> - */ - private final static byte YY_ATTRIBUTE[] = { - 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, - 1, 1, 1, 9, 1, 9, 1, 1, 9, 9, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 9, 1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 1, 9, - 1, 1, 9, 1, 1, 1, 1, 1, 1, 9, 1, 1, 1, 1, 9, 1, - 1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 1, 1, 1, - 1, 1, 1, 9, 9, 1, 9, 9, 1, 0, 1, 0, 1, 0, 0, 0, - 9, 1, 1, 1, 9, 9, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, - 0, 9, 0, 0, 9, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, - 9, 0, 0, 0, 0, 0, 9, 1, 0, 0, 1, 1, 0, 0, 1, 0, - 0, 0, 9, 0, 0, 0, 1, 0, 0, 0, 9, 1, 0, 0, 1, 1, - 0, 1, 0, 0, 0, 9, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, - 1, 9, 0, 0, 9, 9, 9, 1, 1, 1, 0, 0, 0, 0, 0, 0, - 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 9, 0, 1, 9, 0, 1, - 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, - 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 9, 9, 1, 1, 0, - 1, 1, 9, 9, 9, 1, 1, 0, 1, 1, 1, 9, 1, 1, 1, 1, - 1, 1, 1, 1 - }; - - /** the input device */ - private java.io.Reader yy_reader; - - /** the current state of the DFA */ - private int yy_state; - - /** the current lexical state */ - private int yy_lexical_state = YYINITIAL; - - /** this buffer contains the current text to be matched and is - the source of the yytext() string */ - private char yy_buffer[] = new char[16384]; - - /** the textposition at the last accepting state */ - private int yy_markedPos; - - /** the textposition at the last state to be included in yytext */ - private int yy_pushbackPos; - - /** the current text position in the buffer */ - private int yy_currentPos; - - /** startRead marks the beginning of the yytext() string in the buffer */ - private int yy_startRead; - - /** endRead marks the last character in the buffer, that has been read - from input */ - private int yy_endRead; - - /** number of newlines encountered up to the start of the matched text */ - private int yyline; - - /** the number of characters up to the start of the matched text */ - private int yychar; - - /** - * the number of characters from the last newline up to the start of the - * matched text - */ - // private int yycolumn; - - /** - * yy_atBOL == true <=> the scanner is currently at the beginning of a line - */ - // private boolean yy_atBOL; - - /** yy_atEOF == true <=> the scanner has returned a value for EOF */ - private boolean yy_atEOF; - - /** denotes if the user-EOF-code has already been executed */ - private boolean yy_eof_done; - - /* user code: */ - private int fTokenCount = 0; - - // required holders for white-space compacting - private boolean fShouldLoadBuffered = false; - private String fBufferedContext = null; - private int fBufferedStart = 1; - private int fBufferedLength = 0; - private String f_context = null; - - // state stack for handling embedded regions - private IntStack fStateStack = new IntStack(); - - private String context = null; - private int start = 0; - private int textLength = 0; - private int length = 0; - - // offset for tracking position specific block tags - private int fOffset = 0; - - // the name of the current tag being opened - private String fCurrentTagName = null; - - // the list of tag name BlockMarkers - private List fBlockMarkers = new ArrayList(); - - // required to not seek text blocks on an end tag - private boolean fIsBlockingEnabled = false; - private boolean fIsCaseSensitiveBlocking = true; - - private XMLParserRegionFactory fRegionFactory = new XMLParserRegionFactory(); -/** - * user method - */ -public final void addBlockMarker(BlockMarker marker) { - if(containsTagName(marker.getTagName())) - return; - fBlockMarkers.add(marker); -} -/** - * user method - */ -public final void removeBlockMarker(BlockMarker marker) { - fBlockMarkers.remove(marker); -} -/** - * user method - */ -public final void removeBlockMarker(String tagname) { - if (fBlockMarkers != null) { - Iterator blocks = fBlockMarkers.iterator(); - while (blocks.hasNext()) { - if (((BlockMarker) blocks.next()).getTagName().equals(tagname)) - blocks.remove(); - } - } -} -/* user method */ -public final boolean isCaseSensitiveBlocking() { - return fIsCaseSensitiveBlocking; -} -/* user method */ -public final void setCaseSensitiveBlocking(boolean newValue) { - fIsCaseSensitiveBlocking = newValue; -} -/* user method */ -public boolean getBlockMarkerCaseSensitivity() { - return getBlockMarkerCaseSensitivity(fCurrentTagName); -} -/* user method */ -public boolean getBlockMarkerCaseSensitivity(String name) { - Iterator iterator = fBlockMarkers.iterator(); - while(iterator.hasNext()) { - BlockMarker marker = (BlockMarker)iterator.next(); - boolean casesensitive = marker.isCaseSensitive(); - if(casesensitive && marker.getTagName().equals(name)) - return casesensitive; - else if(!casesensitive && marker.getTagName().equalsIgnoreCase(name)) - return casesensitive; - } - return true; -} -/* user method */ -public String getBlockMarkerContext() { - return getBlockMarkerContext(fCurrentTagName); -} -/* user method */ -public String getBlockMarkerContext(String name) { - Iterator iterator = fBlockMarkers.iterator(); - while(iterator.hasNext()) { - BlockMarker marker = (BlockMarker)iterator.next(); - if(marker.getTagName().equals(name)) - return marker.getContext(); - } - return BLOCK_TEXT; -} -/* user method */ -public List getBlockMarkers() { - return fBlockMarkers; -} -/* user method */ -public final int getOffset() { - return fOffset + yychar; -} -private final boolean isBlockMarker() { - return isBlockMarker(fCurrentTagName); -} -private final boolean isBlockMarker(String tagName) { - if (!fIsBlockingEnabled) - return false; - return containsTagName(tagName); -} -/** - * user method - */ -public final void beginBlockTagScan(String newTagName) { - beginBlockMarkerScan(newTagName, BLOCK_TEXT); -} -/** - * user method - * - * Special tokenizer setup. Allows tokenization to be initiated at the - * start of a text block within a "newTagName" tag. - * - * Example: - * Tokenizer toker = new Tokenizer(); - * toker.setCaseSensitiveBlocking(false); - * toker.reset(new java.io.StringReader("afiuhqwkejhtasihgalkwhtq</scripter></scr></script>asgdasga")); - * toker.beginBlockMarkerScan("script", BLOCK_TEXT); - * toker.getRegions(); - * - * Returns: - * BLOCK_TEXT: 0-40 - * XML_END_TAG_OPEN: 41-42 - * XML_TAG_NAME: 43-48 - * XML_TAG_CLOSE: 49-49 - * XML_CONTENT: 50-57 - * - */ -public final void beginBlockMarkerScan(String newTagName, String blockcontext) { - yybegin(ST_BLOCK_TAG_SCAN); - fCurrentTagName = newTagName; -} -/** - * Method doScan. - * - * Returns a context region for all of the text from the current position upto the end of input or - * to right *before* the first occurence of searchString - * - * @param searchString - target string to search for ex.: "-->", "</tagname" - * @param requireTailSeparator - whether the target must be immediately followed by whitespace or '>' - * @param context - the context of the scanned region if non-zero length - * @param exitState - the state to go to if the region was of non-zero length - * @param abortState - the state to go to if the searchString was found immediately - * @return String - the context found: the desired context on a non-zero length match, the abortContext on immediate success - * @throws IOException - */ -private final String doScan(String searchString, boolean requireTailSeparator, String searchContext, int exitState, int immediateFallbackState) throws IOException { - boolean stillSearching = true; - // Disable further block (probably) - fIsBlockingEnabled = false; - int searchStringLength = searchString.length(); - int n = 0; - char lastCheckChar; - int i; - boolean same = false; - while (stillSearching) { - n = 0; - // Ensure that enough data from the input exists to compare against the search String. - n = yy_advance(); - while(n != YYEOF && yy_currentPos < searchStringLength) - n = yy_advance(); - // If the input was too short or we've exhausted the input, stop immediately. - if (n == YYEOF) { - stillSearching = false; - } - else { - same = true; - // Ensure that we've not encountered a complete block (<%%>) that was *shorter* than the closeTagString and - // thus found twice at current-targetLength [since the first scan would have come out this far anyway]. - // Check the characters in the target versus the last targetLength characters read from the buffer - // and see if it matches - - // safety check for array accesses (yy_currentPos is the *last* character we can check against) - if(yy_currentPos >= searchStringLength && yy_currentPos <= yy_buffer.length) { - for(i = 0; i < searchStringLength; i++) { - if(same && fIsCaseSensitiveBlocking) - same = yy_buffer[i + yy_currentPos - searchStringLength] == searchString.charAt(i); - else if(same && !fIsCaseSensitiveBlocking) - same = Character.toLowerCase(yy_buffer[i + yy_currentPos - searchStringLength]) == Character.toLowerCase(searchString.charAt(i)); - } - } - // safety check failed; no match is possible right now - else { - same = false; - } - if (same && requireTailSeparator && yy_currentPos < yy_buffer.length) { - // Additional check for close tags to ensure that targetString="</script" doesn't match - // "</scriptS" - lastCheckChar = yy_buffer[yy_currentPos]; - // Succeed on "</script>" and "</script " - if(lastCheckChar == '>' || Character.isWhitespace(lastCheckChar)) - stillSearching = false; - } - else { - stillSearching = !same || (yy_currentPos < yy_startRead + searchStringLength); - } - } - } - if (n != YYEOF || same) { - // We've stopped short of the end or definitely found a match - yy_markedPos = yy_currentPos - searchStringLength; - yy_currentPos = yy_markedPos + 1; - // If the searchString occurs at the very beginning of what would have - // been a Block, resume scanning normally immediately - if (yy_markedPos == yy_startRead) { - yybegin(immediateFallbackState); - return primGetNextToken(); - } - } - else { - // We ran through the rest of the input - yy_markedPos = yy_currentPos; - yy_currentPos++; - } - yybegin(exitState); - // If the ending occurs at the very beginning of what would have - // been a Block, resume scanning normally immediately - if(yy_markedPos == yy_startRead) - return primGetNextToken(); - return searchContext; -} -/** - * user method - * - * A generic lookahead-like operation - */ -private final String doBlockScan(String target, String targetContext, int immediateFallbackState) throws IOException { - return doScan(target, false, targetContext, immediateFallbackState, immediateFallbackState); -} -/** - * user method - * does a lookahead for the current tag name - */ -private final String doBlockTagScan() throws IOException { - fIsCaseSensitiveBlocking = getBlockMarkerCaseSensitivity(); - return doScan("</" + fCurrentTagName, true, getBlockMarkerContext(fCurrentTagName), YYINITIAL, YYINITIAL); -} -/** - * user method - * - * Converts the raw context String returned by the primGetNextToken() - * method into a full ITextRegion by pulling in values for the - * current offset within the scanning text. - * - * Returns null when EOF is encountered and attaches intermittently - * discovered whitespace onto the end of useful regions. - * - * Note that this algorithm caches the token following the one being returned - * so that whitespace can be collapsed. - */ -public final ITextRegion getNextToken() throws IOException { - // load the starting non-whitespace token (assume that it is so) - if (fShouldLoadBuffered) { - context = fBufferedContext; - start = fBufferedStart; - textLength = length = fBufferedLength; - fShouldLoadBuffered = false; - } - else { - context = primGetNextToken(); - if (context == XML_TAG_NAME) { - if(containsTagName(yy_buffer, yy_startRead, yy_markedPos-yy_startRead)) - fCurrentTagName = yytext(); - else - fCurrentTagName = null; - } - else if (context == XML_TAG_OPEN) { - fIsBlockingEnabled = true; - } - else if (context == XML_END_TAG_OPEN) { - fIsBlockingEnabled = false; - } - start = yychar; - textLength = length = yylength(); - if (yy_atEOF) { - fTokenCount++; - return null; - } - } - // store the next token - f_context = primGetNextToken(); - if (f_context == XML_TAG_NAME) { - if(containsTagName(yy_buffer, yy_startRead, yy_markedPos-yy_startRead)) - fCurrentTagName = yytext(); - else - fCurrentTagName = null; - } - else if (f_context == XML_TAG_OPEN) { - fIsBlockingEnabled = true; - } - else if (f_context == XML_END_TAG_OPEN) { - fIsBlockingEnabled = false; - } - fBufferedContext = f_context; - fBufferedStart = yychar; - fBufferedLength = yylength(); - fShouldLoadBuffered = true; - if (fBufferedContext == WHITE_SPACE) { - fShouldLoadBuffered = false; - length += fBufferedLength; - } - if (context == null) { - // EOF - if (Debug.debugTokenizer) { - System.out.println(getClass().getName() + " discovered " + fTokenCount + " tokens."); //$NON-NLS-2$//$NON-NLS-1$ - } - return null; - } - fTokenCount++; - return fRegionFactory.createToken(context, start, textLength, length, null, fCurrentTagName); -} -/* user method */ -public XMLTokenizer(){ - super(); -} -/* user method */ -public XMLTokenizer(char[] charArray){ - this(new CharArrayReader(charArray)); -} -/* user method */ -public void reset(char[] charArray) { - reset(new CharArrayReader(charArray), 0); -} -/* user method */ -public void reset(char[] charArray, int newOffset) { - reset(new CharArrayReader(charArray), newOffset); -} -/* user method */ -public void reset(java.io.InputStream in) { - reset(new java.io.InputStreamReader(in), 0); -} -/* user method */ -public void reset(java.io.InputStream in, int newOffset) { - reset(new java.io.InputStreamReader(in), newOffset); -} -/* user method */ -public void reset(java.io.Reader in) { - reset(in, 0); -} -/** - * user method * - * - * Reset internal counters and vars to "newly created" values, in the hopes - * that resetting a pre-existing tokenizer is faster than creating a new one. - * - * This method contains code blocks that were essentially duplicated from the - * <em>generated</em> output of this specification before this method was - * added. Those code blocks were under the above copyright. - */ -public void reset(java.io.Reader in, int newOffset) { - if (Debug.debugTokenizer) { - System.out.println("resetting tokenizer");//$NON-NLS-1$ - } - fOffset = newOffset; - - /* the input device */ - yy_reader = in; - - /* the current state of the DFA */ - yy_state = 0; - - /* the current lexical state */ - yy_lexical_state = YYINITIAL; - - /* this buffer contains the current text to be matched and is - the source of the yytext() string */ - java.util.Arrays.fill(yy_buffer, (char)0); - - /* the textposition at the last accepting state */ - yy_markedPos = 0; - - /* the textposition at the last state to be included in yytext */ - yy_pushbackPos = 0; - - /* the current text position in the buffer */ - yy_currentPos = 0; - - /* startRead marks the beginning of the yytext() string in the buffer */ - yy_startRead = 0; - - /** - * endRead marks the last character in the buffer, that has been read - * from input - */ - yy_endRead = 0; - - /* number of newlines encountered up to the start of the matched text */ - yyline = 0; - - /* the number of characters up to the start of the matched text */ - yychar = 0; - - /* yy_atEOF == true <=> the scanner has returned a value for EOF */ - yy_atEOF = false; - - /* denotes if the user-EOF-code has already been executed */ - yy_eof_done = false; - - - /* user vars: */ - fTokenCount = 0; - - fShouldLoadBuffered = false; - fBufferedContext = null; - fBufferedStart = 1; - fBufferedLength = 0; - fStateStack = new IntStack(); - - context = null; - start = 0; - textLength = 0; - length = 0; -} - - /** - * user method - * - */ - public BlockTokenizer newInstance() { - XMLTokenizer newInstance = new XMLTokenizer(); - // global tagmarkers can be shared; they have no state and - // are never destroyed (e.g. 'release') - for(int i = 0; i < fBlockMarkers.size(); i++) { - BlockMarker blockMarker = (BlockMarker) fBlockMarkers.get(i); - if(blockMarker.isGlobal()) - newInstance.addBlockMarker(blockMarker); - } - return newInstance; - } -/* user method */ -private final String scanXMLCommentText() throws IOException { - // Scan for '-->' and return the text up to that point as - // XML_COMMENT_TEXT unless the string occurs IMMEDIATELY, in which - // case change to the ST_XML_COMMENT_END state and return the next - // context as usual. - return doScan("-->", false, XML_COMMENT_TEXT, ST_XML_COMMENT_END, ST_XML_COMMENT_END); -} - - - /** - * Creates a new scanner - * There is also a java.io.InputStream version of this constructor. - * - * @param in the java.io.Reader to read input from. - */ - public XMLTokenizer(java.io.Reader in) { - this.yy_reader = in; - } - - /** - * Creates a new scanner. - * There is also java.io.Reader version of this constructor. - * - * @param in the java.io.Inputstream to read input from. - */ - public XMLTokenizer(java.io.InputStream in) { - this(new java.io.InputStreamReader(in)); - } - - /** - * Unpacks the compressed DFA transition table. - * - * @param packed the packed transition table - * @return the unpacked transition table - */ - private static int [] yy_unpack(String packed) { - int [] trans = new int[11055]; - int i = 0; /* index in packed string */ - int j = 0; /* index in unpacked array */ - while (i < 3734) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - value--; - do trans[j++] = value; while (--count > 0); - } - return trans; - } - - /** - * Unpacks the compressed character translation table. - * - * @param packed the packed character translation table - * @return the unpacked character translation table - */ - private static char [] yy_unpack_cmap(String packed) { - char [] map = new char[0x10000]; - int i = 0; /* index in packed string */ - int j = 0; /* index in unpacked array */ - while (i < 1372) { - int count = packed.charAt(i++); - char value = packed.charAt(i++); - do map[j++] = value; while (--count > 0); - } - return map; - } - - - /** - * Gets the next input character. - * - * @return the next character of the input stream, EOF if the - * end of the stream is reached. - * @exception IOException if any I/O-Error occurs - */ - private int yy_advance() throws java.io.IOException { - - /* standard case */ - if (yy_currentPos < yy_endRead) return yy_buffer[yy_currentPos++]; - - /* if the eof is reached, we don't need to work hard */ - if (yy_atEOF) return YYEOF; - - /* otherwise: need to refill the buffer */ - - /* first: make room (if you can) */ - if (yy_startRead > 0) { - System.arraycopy(yy_buffer, yy_startRead, - yy_buffer, 0, - yy_endRead-yy_startRead); - - /* translate stored positions */ - yy_endRead-= yy_startRead; - yy_currentPos-= yy_startRead; - yy_markedPos-= yy_startRead; - yy_pushbackPos-= yy_startRead; - yy_startRead = 0; - } - - /* is the buffer big enough? */ - if (yy_currentPos >= yy_buffer.length) { - /* if not: blow it up */ - char newBuffer[] = new char[yy_currentPos*2]; - System.arraycopy(yy_buffer, 0, newBuffer, 0, yy_buffer.length); - yy_buffer = newBuffer; - } - - /* finally: fill the buffer with new input */ - int numRead = yy_reader.read(yy_buffer, yy_endRead, - yy_buffer.length-yy_endRead); - - if ( numRead == -1 ) return YYEOF; - - yy_endRead+= numRead; - - return yy_buffer[yy_currentPos++]; - } - - - /** - * Closes the input stream. - */ - final public void yyclose() throws java.io.IOException { - yy_atEOF = true; /* indicate end of file */ - yy_endRead = yy_startRead; /* invalidate buffer */ - yy_reader.close(); - } - - - /** - * Returns the current lexical state. - */ - final public int yystate() { - return yy_lexical_state; - } - - /** - * Enters a new lexical state - * - * @param newState the new lexical state - */ - final public void yybegin(int newState) { - yy_lexical_state = newState; - } - - - /** - * Returns the text matched by the current regular expression. - */ - final public String yytext() { - return new String( yy_buffer, yy_startRead, yy_markedPos-yy_startRead ); - } - - /** - * Returns the length of the matched text region. - */ - final public int yylength() { - return yy_markedPos-yy_startRead; - } - - - /** - * Reports an error that occured while scanning - from the SED JFlex skeleton - * - * @param errorCode the code of the errormessage to display - */ - private void yy_ScanError(int errorCode) { - try { - Logger.log(Logger.ERROR, YY_ERROR_MSG[errorCode]); - } - catch (ArrayIndexOutOfBoundsException e) { - Logger.log(Logger.ERROR, YY_ERROR_MSG[YY_UNKNOWN_ERROR]); - } - // DO NOT EXIT the VM on an error - // System.exit(1); - } - - - /** - * Pushes the specified amount of characters back into the input stream. - * - * They will be read again by then next call of the scanning method - * - * @param number the number of characters to be read again. - * This number must not be greater than yylength()! - */ - void yypushback(int number) { - if ( number > yylength() ) - yy_ScanError(YY_PUSHBACK_2BIG); - - yy_markedPos -= number; - } - - /** - * user method - skeleton.sed - */ - protected final boolean containsTagName(char[] markerTagName, int offset, int tagnameLength) { - for(int j = 0; j < fBlockMarkers.size(); j++) { - BlockMarker marker = (BlockMarker)fBlockMarkers.get(j); - if(marker.getTagName().length() == tagnameLength) { - boolean matchesSoFar = true; - for(int i = 0; i < tagnameLength && matchesSoFar; i++) { - if(marker.isCaseSensitive()) { - if(marker.getTagName().charAt(i) != markerTagName[i + offset]) - matchesSoFar = false; - } - else { - if(Character.toLowerCase(marker.getTagName().charAt(i)) != Character.toLowerCase(markerTagName[i + offset])) - matchesSoFar = false; - } - } - if(matchesSoFar) - return true; - } - } - return false; - } - - /** - * user method - skeleton.sed - * - * Return ALL of the regions scannable within the remaining text - * Note: for verification use - */ - public final List getRegions() { - List tokens = new ArrayList(); - ITextRegion region = null; - try { - region = getNextToken(); - while(region != null) { - if (region != null) { - tokens.add(region); - } - region = getNextToken(); - } - } - catch (StackOverflowError e) { - Logger.logException(getClass().getName()+": input could not be tokenized correctly at position " + getOffset(), e);//$NON-NLS-1$ - throw e; - } - catch (Exception e) { - // Since this is convenience method and NOT the recommended - // way of getting tokens, many errors are simply hidden - Logger.logException("Exception not handled retrieving regions: " + e.getLocalizedMessage(), e);//$NON-NLS-1$ - } - return tokens; - } - /** - * user method - skeleton.sed - */ - private final void dump(String s) { - if (Debug.debugTokenizer) { - System.out.println(s + " (" + yychar + "-" + //$NON-NLS-2$//$NON-NLS-1$ - (yylength() + yychar) + "):\'" +//$NON-NLS-1$ - StringUtils.escape(yytext()) + "\'");//$NON-NLS-1$ - } - } - /* user method - skeleton.sed */ - public final boolean isEOF() { - return yy_atEOF; - } -/* user method - skeleton.sed */ -protected final boolean containsTagName(String markerTagName) { - Iterator blocks = fBlockMarkers.iterator(); - while(blocks.hasNext()) { - BlockMarker marker = (BlockMarker)blocks.next(); - if(marker.isCaseSensitive()) { - if(marker.getTagName().equals(markerTagName)) - return true; - } - else { - if(marker.getTagName().equalsIgnoreCase(markerTagName)) - return true; - } - } - return false; -} - - /** - * Contains user EOF-code, which will be executed exactly once, - * when the end of file is reached - */ - private void yy_do_eof() { - if (!yy_eof_done) { - yy_eof_done = true; - // do nothing, this is the downstream parser's job - - } - } - - - /** - * Resumes scanning until the next regular expression is matched, - * the end of input is encountered or an I/O-Error occurs. - * - * @return the next token - * @exception IOException if any I/O-Error occurs - */ - public String primGetNextToken() throws java.io.IOException { - int yy_input; - int yy_action; - - - while (true) { - - yychar+= yylength(); - - boolean yy_counted = false; - for (yy_currentPos = yy_startRead; yy_currentPos < yy_markedPos; - yy_currentPos++) { - switch (yy_buffer[yy_currentPos]) { - case '\r': - yyline++; - yy_counted = true; - break; - case '\n': - if (yy_counted) - yy_counted = false; - else { - yyline++; - } - break; - default: - yy_counted = false; - } - } - - if (yy_counted) { - if ( yy_advance() == '\n' ) yyline--; - if ( !yy_atEOF ) yy_currentPos--; - } - - yy_action = -1; - - yy_currentPos = yy_startRead = yy_markedPos; - - yy_state = yy_lexical_state; - - - yy_forAction: { - while (true) { - - yy_input = yy_advance(); - - if ( yy_input == YYEOF ) break yy_forAction; - - int yy_next = yytrans[ yy_rowMap[yy_state] + yycmap[yy_input] ]; - if (yy_next == -1) break yy_forAction; - yy_state = yy_next; - - int yy_attributes = YY_ATTRIBUTE[yy_state]; - if ( (yy_attributes & 1) > 0 ) { - yy_action = yy_state; - yy_markedPos = yy_currentPos; - if ( (yy_attributes & 8) > 0 ) break yy_forAction; - } - - } - } - - - switch (yy_action) { - - case 291: - { - if(Debug.debugTokenizer) - dump("XSL processing instruction target");//$NON-NLS-1$ - yybegin(ST_XML_PI_ATTRIBUTE_NAME); - return XML_TAG_NAME; - } - case 293: break; - case 283: - case 285: - case 286: - { - if(Debug.debugTokenizer) - dump("\nCDATA start");//$NON-NLS-1$ - fStateStack.push(yystate()); - yybegin(ST_CDATA_TEXT); - return XML_CDATA_OPEN; - } - case 294: break; - case 276: - { - if(Debug.debugTokenizer) - dump("element");//$NON-NLS-1$ - yybegin(ST_XML_ELEMENT_DECLARATION); - return XML_ELEMENT_DECLARATION; - } - case 295: break; - case 275: - { - if(Debug.debugTokenizer) - dump("attlist");//$NON-NLS-1$ - yybegin(ST_XML_ATTLIST_DECLARATION); - return XML_ATTLIST_DECLARATION; - } - case 296: break; - case 274: - { - if(Debug.debugTokenizer) - dump("doctype");//$NON-NLS-1$ - yybegin(ST_XML_DOCTYPE_DECLARATION); - return XML_DOCTYPE_DECLARATION; - } - case 297: break; - case 268: - { - if(Debug.debugTokenizer) - dump("doctype external id");//$NON-NLS-1$ - yybegin(ST_XML_DOCTYPE_ID_PUBLIC); - return XML_DOCTYPE_EXTERNAL_ID_PUBLIC; - } - case 298: break; - case 267: - { - if(Debug.debugTokenizer) - dump("doctype external id");//$NON-NLS-1$ - yybegin(ST_XML_DOCTYPE_ID_SYSTEM); - return XML_DOCTYPE_EXTERNAL_ID_SYSTEM; - } - case 299: break; - case 263: - case 273: - { - if(Debug.debugTokenizer) - dump("DHTML processing instruction target");//$NON-NLS-1$ - yybegin(ST_DHTML_ATTRIBUTE_NAME); - return XML_TAG_NAME; - } - case 300: break; - case 237: - { - if(Debug.debugTokenizer) - dump("\nCharRef");//$NON-NLS-1$ - return XML_CHAR_REFERENCE; - } - case 301: break; - case 234: - { - if(Debug.debugTokenizer) - dump("\ncomment start");//$NON-NLS-1$ - yybegin(ST_XML_COMMENT); - return XML_COMMENT_OPEN; - } - case 302: break; - case 215: - case 216: - { - if(Debug.debugTokenizer) - dump("XML processing instruction target");//$NON-NLS-1$ - yybegin(ST_XML_PI_ATTRIBUTE_NAME); - return XML_TAG_NAME; - } - case 303: break; - case 214: - { - if(Debug.debugTokenizer) - dump("comment end");//$NON-NLS-1$ - yybegin(YYINITIAL); - return XML_COMMENT_CLOSE; - } - case 304: break; - case 213: - { - if(Debug.debugTokenizer) - dump("CDATA end");//$NON-NLS-1$ - yybegin(fStateStack.pop()); - return XML_CDATA_CLOSE; - } - case 305: break; - case 212: - { - if(Debug.debugTokenizer) - dump("\nPEReference");//$NON-NLS-1$ - return XML_PE_REFERENCE; - } - case 306: break; - case 209: - { - if(Debug.debugTokenizer) - dump("\nEntityRef");//$NON-NLS-1$ - return XML_ENTITY_REFERENCE; - } - case 307: break; - case 160: - case 174: - case 182: - { - return XML_DOCTYPE_INTERNAL_SUBSET; - } - case 308: break; - case 148: - { - yybegin(YYINITIAL); - if(Debug.debugTokenizer) - dump("empty tag close");//$NON-NLS-1$ - return XML_EMPTY_TAG_CLOSE; - } - case 309: break; - case 133: - { - if(Debug.debugTokenizer) - dump("XML processing instruction end");//$NON-NLS-1$ - yybegin(YYINITIAL); - return XML_PI_CLOSE; - } - case 310: break; - case 132: - { - // ended with nothing inside - yybegin(YYINITIAL); - return XML_PI_CLOSE; - } - case 311: break; - case 128: - { - if(Debug.debugTokenizer) - dump("processing instruction end");//$NON-NLS-1$ - yybegin(YYINITIAL); - return XML_PI_CLOSE; - } - case 312: break; - case 120: - { - fStateStack.push(yystate()); - if(Debug.debugTokenizer) - dump("\ndeclaration start");//$NON-NLS-1$ - yybegin(ST_XML_DECLARATION); - return XML_DECLARATION_OPEN; - } - case 313: break; - case 119: - { - if(Debug.debugTokenizer) - dump("\nprocessing instruction start");//$NON-NLS-1$ - yybegin(ST_PI); - return XML_PI_OPEN; - } - case 314: break; - case 63: - { - if(Debug.debugTokenizer) - dump("DHTML processing instruction end");//$NON-NLS-1$ - yybegin(YYINITIAL); - return XML_PI_CLOSE; - } - case 315: break; - case 57: - case 59: - case 60: - case 61: - case 137: - { - if(Debug.debugTokenizer) - dump("XML processing instruction attribute value");//$NON-NLS-1$ - yybegin(ST_XML_PI_ATTRIBUTE_NAME); - return XML_TAG_ATTRIBUTE_VALUE; - } - case 316: break; - case 56: - { - if(Debug.debugTokenizer) - dump("XML processing instruction '='");//$NON-NLS-1$ - yybegin(ST_XML_PI_ATTRIBUTE_VALUE); - return XML_TAG_ATTRIBUTE_EQUALS; - } - case 317: break; - case 55: - { - if(Debug.debugTokenizer) - dump("XML processing instruction attribute name");//$NON-NLS-1$ - yybegin(ST_XML_PI_EQUALS); - return XML_TAG_ATTRIBUTE_NAME; - } - case 318: break; - case 51: - case 52: - case 53: - { - // block scan until close is found - return doScan("?>", false, XML_PI_CONTENT, ST_XML_PI_TAG_CLOSE, ST_XML_PI_TAG_CLOSE); - } - case 319: break; - case 50: - { - yybegin(ST_PI_CONTENT); - return WHITE_SPACE; - } - case 320: break; - case 46: - case 47: - case 48: - case 49: - case 129: - case 130: - case 131: - case 217: - case 239: - case 240: - case 252: - case 253: - case 262: - case 272: - case 280: - case 284: - case 287: - case 288: - case 289: - case 290: - { - if(Debug.debugTokenizer) - dump("processing instruction target");//$NON-NLS-1$ - yybegin(ST_PI_WS); - return XML_TAG_NAME; - } - case 321: break; - case 41: - case 42: - { - if(Debug.debugTokenizer) - dump("comment content");//$NON-NLS-1$ - return scanXMLCommentText(); - } - case 322: break; - case 40: - { - if(Debug.debugTokenizer) - dump("LINE FEED");//$NON-NLS-1$ - return WHITE_SPACE; - } - case 323: break; - case 0: - case 31: - case 122: - case 124: - case 207: - case 208: - case 236: - { - if(Debug.debugTokenizer) - dump("\nXML content");//$NON-NLS-1$ - return XML_CONTENT; - } - case 324: break; - case 5: - case 8: - case 9: - case 10: - case 12: - case 13: - case 14: - case 15: - case 17: - case 18: - case 19: - case 20: - case 21: - case 22: - case 23: - case 24: - case 25: - case 26: - case 28: - case 45: - { - if(Debug.debugTokenizer) - dump("white space");//$NON-NLS-1$ - return WHITE_SPACE; - } - case 325: break; - case 16: - case 71: - { - if(Debug.debugTokenizer) - dump("inappropriate tag name");//$NON-NLS-1$ - yybegin(YYINITIAL); - return XML_CONTENT; - } - case 326: break; - case 27: - case 106: - case 107: - case 193: - case 229: - case 248: - case 259: - case 269: - case 277: - case 281: - { - if(Debug.debugTokenizer) - dump("elementdecl contentspec");//$NON-NLS-1$ - return XML_ELEMENT_DECL_CONTENT; - } - case 327: break; - case 29: - case 113: - case 114: - case 204: - case 233: - case 250: - case 260: - case 270: - case 278: - case 282: - { - if(Debug.debugTokenizer) - dump("attlist contentspec");//$NON-NLS-1$ - return XML_ATTLIST_DECL_CONTENT; - } - case 328: break; - case 32: - case 72: - case 83: - { - if(Debug.debugTokenizer) - dump("\nstart tag open");//$NON-NLS-1$ - yybegin(ST_XML_TAG_NAME); - return XML_TAG_OPEN; - } - case 329: break; - case 33: - case 34: - case 37: - case 38: - case 39: - case 43: - case 44: - case 54: - case 58: - case 62: - case 64: - case 68: - case 74: - case 80: - case 85: - case 86: - case 87: - case 88: - case 90: - case 91: - case 93: - case 98: - case 103: - case 110: - { - if (Debug.debugTokenizer) - System.out.println("!!!unexpected!!!: \"" + yytext() + "\":" + //$NON-NLS-2$//$NON-NLS-1$ - yychar + "-" + (yychar + yylength()));//$NON-NLS-1$ - return UNDEFINED; - } - case 330: break; - case 35: - case 36: - { - if(Debug.debugTokenizer) - dump("CDATA text");//$NON-NLS-1$ - String blockContext = doBlockScan("]]>", XML_CDATA_TEXT, ST_CDATA_END);//$NON-NLS-1$ - if(blockContext == XML_CDATA_TEXT) - yybegin(ST_CDATA_END); - return blockContext; - } - case 331: break; - case 65: - { - if(Debug.debugTokenizer) - dump("DHTML processing instruction attribute name");//$NON-NLS-1$ - yybegin(ST_DHTML_EQUALS); - return XML_TAG_ATTRIBUTE_NAME; - } - case 332: break; - case 66: - { - if(Debug.debugTokenizer) - dump("DHTML processing instruction '='");//$NON-NLS-1$ - yybegin(ST_DHTML_ATTRIBUTE_VALUE); - return XML_TAG_ATTRIBUTE_EQUALS; - } - case 333: break; - case 67: - case 69: - case 70: - case 145: - { - if(Debug.debugTokenizer) - dump("DHTML processing instruction attribute value");//$NON-NLS-1$ - yybegin(ST_DHTML_ATTRIBUTE_NAME); - return XML_TAG_ATTRIBUTE_VALUE; - } - case 334: break; - case 73: - { - if(Debug.debugTokenizer) - dump("tag close");//$NON-NLS-1$ - if(isBlockMarker()) { - yybegin(ST_BLOCK_TAG_SCAN); - } - else - yybegin(YYINITIAL); - return XML_TAG_CLOSE; - } - case 335: break; - case 75: - case 76: - { - if(Debug.debugTokenizer) - dump("tag name");//$NON-NLS-1$ - yybegin(ST_XML_ATTRIBUTE_NAME); - return XML_TAG_NAME; - } - case 336: break; - case 77: - { - if(Debug.debugTokenizer) - dump("attr name");//$NON-NLS-1$ - yybegin(ST_XML_EQUALS); - return XML_TAG_ATTRIBUTE_NAME; - } - case 337: break; - case 78: - { - if(Debug.debugTokenizer) - dump("equals");//$NON-NLS-1$ - yybegin(ST_XML_ATTRIBUTE_VALUE); - return XML_TAG_ATTRIBUTE_EQUALS; - } - case 338: break; - case 79: - case 81: - case 82: - case 152: - { - if(Debug.debugTokenizer) - dump("attr value");//$NON-NLS-1$ - yybegin(ST_XML_ATTRIBUTE_NAME); - return XML_TAG_ATTRIBUTE_VALUE; - } - case 339: break; - case 84: - { - if(Debug.debugTokenizer) - dump("declaration end");//$NON-NLS-1$ - if (Debug.debugTokenizer) { - if(fStateStack.peek()!=YYINITIAL) - System.out.println("end embedded region");//$NON-NLS-1$ - } - yybegin(fStateStack.pop()); - return XML_DECLARATION_CLOSE; - } - case 340: break; - case 89: - { - if(Debug.debugTokenizer) - dump("doctype type");//$NON-NLS-1$ - yybegin(ST_XML_DOCTYPE_EXTERNAL_ID); - return XML_DOCTYPE_NAME; - } - case 341: break; - case 92: - case 94: - case 95: - case 96: - case 166: - case 167: - case 170: - case 171: - case 224: - { - if(Debug.debugTokenizer) - dump("doctype public reference");//$NON-NLS-1$ - yybegin(ST_XML_DOCTYPE_ID_SYSTEM); - return XML_DOCTYPE_EXTERNAL_ID_PUBREF; - } - case 342: break; - case 97: - case 99: - case 100: - case 101: - case 178: - { - if(Debug.debugTokenizer) - dump("doctype system reference");//$NON-NLS-1$ - yybegin(ST_XML_DECLARATION_CLOSE); - return XML_DOCTYPE_EXTERNAL_ID_SYSREF; - } - case 343: break; - case 102: - case 104: - case 105: - case 186: - case 187: - case 190: - case 191: - case 227: - { - if(Debug.debugTokenizer) - dump("elementdecl name");//$NON-NLS-1$ - yybegin(ST_XML_ELEMENT_DECLARATION_CONTENT); - return XML_ELEMENT_DECL_NAME; - } - case 344: break; - case 108: - { - if(Debug.debugTokenizer) - dump("elementdecl close");//$NON-NLS-1$ - if (Debug.debugTokenizer) { - if(fStateStack.peek()!=YYINITIAL) - System.out.println("end embedded region");//$NON-NLS-1$ - } - yybegin(fStateStack.pop()); - return XML_DECLARATION_CLOSE; - } - case 345: break; - case 109: - case 111: - case 112: - case 197: - case 198: - case 201: - case 202: - case 231: - { - if(Debug.debugTokenizer) - dump("attlist name");//$NON-NLS-1$ - yybegin(ST_XML_ATTLIST_DECLARATION_CONTENT); - return XML_ATTLIST_DECL_NAME; - } - case 346: break; - case 115: - { - if(Debug.debugTokenizer) - dump("attlist close");//$NON-NLS-1$ - if (Debug.debugTokenizer) { - if(fStateStack.peek()!=YYINITIAL) - System.out.println("end embedded region");//$NON-NLS-1$ - } - yybegin(fStateStack.pop()); - return XML_DECLARATION_CLOSE; - } - case 347: break; - case 118: - { - if(Debug.debugTokenizer) - dump("\nend tag open");//$NON-NLS-1$ - yybegin(ST_XML_TAG_NAME); - return XML_END_TAG_OPEN; - } - case 348: break; - case 116: - case 117: - { - return doBlockTagScan(); - } - case 349: break; - default: - if (yy_input == YYEOF && yy_startRead == yy_currentPos) { - yy_atEOF = true; - yy_do_eof(); - return null; - } - else { - yy_ScanError(YY_NO_MATCH); - } - } - } - } - - -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/AttributeEqualsRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/AttributeEqualsRegion.java deleted file mode 100644 index 836dd41f5c..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/AttributeEqualsRegion.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.parser.regions; - -import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; - - - -public class AttributeEqualsRegion implements ITextRegion { - static private final byte fTextLength = 1; - static private final String fType = DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS; - private short fLength; - private int fStart; - - - public AttributeEqualsRegion() { - super(); - } - - public AttributeEqualsRegion(int start, int textLength, int length) { - this(); - fStart = start; - fLength = (short) length; - } - - - public void adjustLength(int i) { - fLength += i; - - } - - public void adjustStart(int i) { - fStart += i; - - } - - public void adjustTextLength(int i) { - // not supported - - } - - public void equatePositions(ITextRegion region) { - fStart = region.getStart(); - fLength = (short) region.getLength(); - } - - public int getEnd() { - return fStart + fLength; - } - - public int getLength() { - return fLength; - } - - public int getStart() { - return fStart; - } - - public int getTextEnd() { - return fStart + fTextLength; - } - - public int getTextLength() { - return fTextLength; - } - - public String getType() { - return fType; - } - - public String toString() { - return RegionToStringUtil.toString(this); - } - - public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) { - // can never be updated - return null; - } -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/AttributeNameRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/AttributeNameRegion.java deleted file mode 100644 index a2c4158f80..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/AttributeNameRegion.java +++ /dev/null @@ -1,165 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.parser.regions; - -import org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent; -import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.sse.core.internal.util.Debug; -import org.eclipse.wst.sse.core.internal.util.Utilities; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; - - -public class AttributeNameRegion implements ITextRegion { - // specify correct type - static private final String fType = DOMRegionContext.XML_TAG_ATTRIBUTE_NAME; - private int fLength; - private int fStart; - private int fTextLength; - - public AttributeNameRegion() { - super(); - } - - public AttributeNameRegion(int start, int textLength, int length) { - this(); - fStart = start; - fTextLength = textLength; - fLength = length; - } - - public void adjustLength(int i) { - fLength += i; - - } - - public void adjustStart(int i) { - fStart += i; - - } - - public void adjustTextLength(int i) { - fTextLength += 1; - - } - - public void equatePositions(ITextRegion region) { - fStart = region.getStart(); - fLength = region.getLength(); - fTextLength = region.getTextLength(); - } - - public int getEnd() { - return fStart + fLength; - } - - public int getLength() { - return fLength; - } - - public int getStart() { - return fStart; - } - - public int getTextEnd() { - return fStart + fTextLength; - } - - public int getTextLength() { - return fTextLength; - } - - public String getType() { - return fType; - } - - public String toString() { - return RegionToStringUtil.toString(this); - } - - public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) { - RegionChangedEvent result = null; - // if the region is an easy type (e.g. attribute value), - // and the requested changes are all - // alphanumeric, then make the change here locally. - // (This can obviously be made more sophisticated as the need arises, - // but should - // always follow this pattern.) - if (Debug.debugStructuredDocument) { - System.out.println("\t\tContextRegion::updateModel"); //$NON-NLS-1$ - System.out.println("\t\t\tregion type is " + fType); //$NON-NLS-1$ - } - boolean canHandle = false; - // note: we'll always handle deletes from these - // regions ... if its already that region, - // deleting something from it won't change its - // type. (remember, the calling program needs - // to insure we are not called, if not all contained - // on one region. - if ((changes == null) || (changes.length() == 0)) { - // delete case - // We can not do the quick delete, if - // if all the text in a region is to be deleted. - // Or, if the delete starts in the white space region. - // In these cases, a reparse is needed. - // Minor note, we use textEnd-start since it always - // less than or equal to end-start. This might - // cause us to miss a few cases we could have handled, - // but will prevent us from trying to handle funning cases - // involving whitespace. - if ((fStart >= getTextEnd()) || (Math.abs(lengthToReplace) >= getTextEnd() - getStart())) { - canHandle = false; - } else { - canHandle = true; - } - } else { - if ((RegionUpdateRule.canHandleAsWhiteSpace(this, parent, changes, requestStart, lengthToReplace)) || RegionUpdateRule.canHandleAsLetterOrDigit(this, parent, changes, requestStart, lengthToReplace)) { - canHandle = true; - } else { - canHandle = false; - } - - } - if (canHandle) { - // at this point, we still have the old region. We won't create a - // new instance, we'll just update the one we have, by changing - // its end postion, - // The parent flatnode, upon return, has responsibility - // for updating sibling regions. - // and in turn, the structuredDocument itself has responsibility - // for - // updating the text store and down stream flatnodes. - if (Debug.debugStructuredDocument) { - System.out.println("change handled by region"); //$NON-NLS-1$ - } - int lengthDifference = Utilities.calculateLengthDifference(changes, lengthToReplace); - // Note: we adjust both end and text end, because for any change - // that is in only the trailing whitespace region, we should not - // do a quick change, - // so 'canHandle' should have been false for those case. - // TO_DO_FUTURE: cache value of canHandleAsWhiteSpace from above - // If we are handling as whitespace, there is no need to increase - // the text length, only - // the total length is changing. - if (!RegionUpdateRule.canHandleAsWhiteSpace(this, parent, changes, requestStart, lengthToReplace)) { - fTextLength += lengthDifference; - } - fLength += lengthDifference; - result = new RegionChangedEvent(parent.getParentDocument(), requester, parent, this, changes, requestStart, lengthToReplace); - } - - return result; - } - -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/AttributeValueRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/AttributeValueRegion.java deleted file mode 100644 index 7fbbbbf353..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/AttributeValueRegion.java +++ /dev/null @@ -1,162 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.parser.regions; - -import org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent; -import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.sse.core.internal.util.Debug; -import org.eclipse.wst.sse.core.internal.util.Utilities; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; - - -public class AttributeValueRegion implements ITextRegion { - // specify correct type - static private final String fType = DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE; - private int fLength; - private int fStart; - private int fTextLength; - - public AttributeValueRegion() { - super(); - } - - public AttributeValueRegion(int start, int textLength, int length) { - this(); - fStart = start; - fTextLength = textLength; - fLength = length; - } - - public void adjustLength(int i) { - fLength += i; - } - - public void adjustStart(int i) { - fStart += i; - } - - public void adjustTextLength(int i) { - fTextLength += 1; - } - - public void equatePositions(ITextRegion region) { - fStart = region.getStart(); - fLength = region.getLength(); - fTextLength = region.getTextLength(); - } - - public int getEnd() { - return fStart + fLength; - } - - public int getLength() { - return fLength; - } - - public int getStart() { - return fStart; - } - - public int getTextEnd() { - return fStart + fTextLength; - } - - public int getTextLength() { - return fTextLength; - } - - public String getType() { - return fType; - } - - public String toString() { - return RegionToStringUtil.toString(this); - } - - public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) { - RegionChangedEvent result = null; - // if the region is an easy type (e.g. attribute value), - // and the requested changes are all - // alphanumeric, then make the change here locally. - // (This can obviously be made more sophisticated as the need arises, - // but should - // always follow this pattern.) - if (Debug.debugStructuredDocument) { - System.out.println("\t\tContextRegion::updateModel"); //$NON-NLS-1$ - System.out.println("\t\t\tregion type is " + fType); //$NON-NLS-1$ - } - boolean canHandle = false; - // note: we'll always handle deletes from these - // regions ... if its already that region, - // deleting something from it won't change its - // type. (remember, the calling program needs - // to insure we are not called, if not all contained - // on one region. - if ((changes == null) || (changes.length() == 0)) { - // delete case - // We can not do the quick delete, if - // if all the text in a region is to be deleted. - // Or, if the delete starts in the white space region. - // In these cases, a reparse is needed. - // Minor note, we use textEnd-start since it always - // less than or equal to end-start. This might - // cause us to miss a few cases we could have handled, - // but will prevent us from trying to handle funning cases - // involving whitespace. - if ((fStart >= getTextEnd()) || (Math.abs(lengthToReplace) >= getTextEnd() - getStart())) { - canHandle = false; - } else { - canHandle = true; - } - } else { - if ((RegionUpdateRule.canHandleAsWhiteSpace(this, parent, changes, requestStart, lengthToReplace)) || RegionUpdateRule.canHandleAsLetterOrDigit(this, parent, changes, requestStart, lengthToReplace)) { - canHandle = true; - } else { - canHandle = false; - } - } - if (canHandle) { - // at this point, we still have the old region. We won't create a - // new instance, we'll just update the one we have, by changing - // its end postion, - // The parent flatnode, upon return, has responsibility - // for updating sibling regions. - // and in turn, the structuredDocument itself has responsibility - // for - // updating the text store and down stream flatnodes. - if (Debug.debugStructuredDocument) { - System.out.println("change handled by region"); //$NON-NLS-1$ - } - int lengthDifference = Utilities.calculateLengthDifference(changes, lengthToReplace); - // Note: we adjust both end and text end, because for any change - // that is in only the trailing whitespace region, we should not - // do a quick change, - // so 'canHandle' should have been false for those case. - // TO_DO_FUTURE: cache value of canHandleAsWhiteSpace from above - // If we are handling as whitespace, there is no need to increase - // the text length, only - // the total length is changing. - if (!RegionUpdateRule.canHandleAsWhiteSpace(this, parent, changes, requestStart, lengthToReplace)) { - fTextLength += lengthDifference; - } - // update length (and end) after above check for white space, - // since - // it looks to determine if at end of region. - fLength += lengthDifference; - result = new RegionChangedEvent(parent.getParentDocument(), requester, parent, this, changes, requestStart, lengthToReplace); - } - return result; - } -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/EmptyTagCloseRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/EmptyTagCloseRegion.java deleted file mode 100644 index 339d692f4a..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/EmptyTagCloseRegion.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.parser.regions; - -import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; - - -public class EmptyTagCloseRegion implements ITextRegion { - private int fLength = 2; - static private final byte fTextLength = 2; - static private final String fType = DOMRegionContext.XML_EMPTY_TAG_CLOSE; - private int fStart; - - - public EmptyTagCloseRegion() { - super(); - } - - public EmptyTagCloseRegion(int start, int textLength, int length) { - super(); - fStart = start; - fLength = length; - if (fTextLength != textLength) - throw new RuntimeException("invalid for this region type"); //$NON-NLS-1$ - } - - public void adjustLength(int i) { - fLength += i; - } - - public void adjustStart(int i) { - fStart += i; - - } - - public void adjustTextLength(int i) { - throw new RuntimeException("invalid for this region type"); //$NON-NLS-1$ - } - - public void equatePositions(ITextRegion region) { - fStart = region.getStart(); - } - - public int getEnd() { - return fStart + fLength; - } - - public int getLength() { - return fLength; - } - - public int getStart() { - return fStart; - } - - public int getTextEnd() { - return fStart + fTextLength; - } - - public int getTextLength() { - return fTextLength; - } - - public String getType() { - return fType; - } - - public String toString() { - return RegionToStringUtil.toString(this); - } - - public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) { - // can never be updated - return null; - } - -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/EndTagOpenRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/EndTagOpenRegion.java deleted file mode 100644 index 1ad5549d0d..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/EndTagOpenRegion.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.parser.regions; - -import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; - - -public class EndTagOpenRegion implements ITextRegion { - static private final String fType = DOMRegionContext.XML_END_TAG_OPEN; - private int fLength; - private int fStart; - static private final byte fTextLength = 2; - - - public EndTagOpenRegion() { - super(); - } - - public EndTagOpenRegion(int start, int textLength, int length) { - this(); - fStart = start; - if (fTextLength != textLength) - throw new RuntimeException("invalid for this region type"); //$NON-NLS-1$ - fLength = length; - } - - public EndTagOpenRegion(int start, int length) { - this(); - fStart = start; - fLength = length; - } - - public void adjustLength(int i) { - fLength += i; - - } - - public void adjustStart(int i) { - fStart += i; - - } - - - public void adjustTextLength(int i) { -// fTextLength += 1; - throw new RuntimeException("invalid for this region type"); //$NON-NLS-1$ - } - - public void equatePositions(ITextRegion region) { - fStart = region.getStart(); - fLength = region.getLength(); -// fTextLength = region.getTextLength(); - } - - public int getEnd() { - return fStart + fLength; - } - - public int getLength() { - return fLength; - } - - public int getStart() { - return fStart; - } - - public int getTextEnd() { - return fStart + fTextLength; - } - - public int getTextLength() { - return fTextLength; - } - - public String getType() { - return fType; - } - - public String toString() { - return RegionToStringUtil.toString(this); - } - - public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) { - // can never be updated - return null; - } - -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/GenericTemplateRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/GenericTemplateRegion.java deleted file mode 100644 index e6064beb1d..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/GenericTemplateRegion.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.parser.regions; - -import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; - - -/** - * - * This class is not intended to be used, its just present to server as a - * generic starting point for adding new specific region types. - * - */ - -public class GenericTemplateRegion implements ITextRegion { - // specify correct type - static private final String fType = DOMRegionContext.UNDEFINED; - private int fLength; - private int fStart; - private int fTextLength; - - - public GenericTemplateRegion() { - super(); - } - - public GenericTemplateRegion(int start, int textLength, int length) { - this(); - fStart = start; - fTextLength = textLength; - fLength = length; - } - - public void adjustLength(int i) { - fLength += i; - - } - - public void adjustStart(int i) { - fStart += i; - - } - - - public void adjustTextLength(int i) { - fTextLength += i; - - } - - public void equatePositions(ITextRegion region) { - fStart = region.getStart(); - fLength = region.getLength(); - fTextLength = region.getTextLength(); - } - - public int getEnd() { - return fStart + fLength; - } - - public int getLength() { - return fLength; - } - - public int getStart() { - return fStart; - } - - public int getTextEnd() { - return fStart + fTextLength; - } - - public int getTextLength() { - return fTextLength; - } - - public String getType() { - return fType; - } - - public String toString() { - return RegionToStringUtil.toString(this); - } - - public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) { - // can never be updated - return null; - } - -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/RegionToStringUtil.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/RegionToStringUtil.java deleted file mode 100644 index af783f63b0..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/RegionToStringUtil.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.parser.regions; - -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; - - -public class RegionToStringUtil { - static public String toString(ITextRegion region) { - String className = region.getClass().getName(); - String shortClassName = className.substring(className.lastIndexOf(".") + 1); //$NON-NLS-1$ - String result = shortClassName + "--> " + region.getType() + ": " + region.getStart() + "-" + region.getTextEnd() + (region.getTextEnd() != region.getEnd() ? ("/" + region.getEnd()) : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - // NOTE: if the document held by any region has been updated and the - // region offsets have not - // yet been updated, the output from this method invalid. - return result; - } - -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/RegionUpdateRule.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/RegionUpdateRule.java deleted file mode 100644 index 567d0937bc..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/RegionUpdateRule.java +++ /dev/null @@ -1,209 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.parser.regions; - -import org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent; -import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.sse.core.internal.util.Debug; -import org.eclipse.wst.sse.core.internal.util.Utilities; - - -/** - * - * This is a utility class to centralize 'region' update. Note: care must be - * taken that is is not used for StructuredDocumentRegions, or container - * regions, its only for "token regions" - * - */ -public class RegionUpdateRule { - - static public boolean allLetterOrDigit(String changes) { - boolean result = true; - for (int i = 0; i < changes.length(); i++) { - // TO_DO_FUTURE: check that a Java Letter or Digit is - // the same thing as an XML letter or digit - if (!(Character.isLetterOrDigit(changes.charAt(i)))) { - result = false; - break; - } - } - return result; - } - - static public boolean allWhiteSpace(String changes) { - boolean result = true; - for (int i = 0; i < changes.length(); i++) { - if (!Character.isWhitespace(changes.charAt(i))) { - result = false; - break; - } - } - return result; - } - - static public boolean canHandleAsLetterOrDigit(ITextRegion region, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) { - if (parent == null) - return canHandleAsLetterOrDigit(region, changes, requestStart, lengthToReplace); - boolean result = false; - // Make sure we are in a non-white space area - if ((requestStart <= (parent.getTextEndOffset(region))) && (allLetterOrDigit(changes))) { - result = true; - } - return result; - } - - static public boolean canHandleAsLetterOrDigit(ITextRegion region, String changes, int requestStart, int lengthToReplace) { - boolean result = false; - // Make sure we are in a non-white space area - if ((requestStart <= (region.getTextEnd())) && (allLetterOrDigit(changes))) { - result = true; - } - return result; - } - - static public boolean canHandleAsWhiteSpace(ITextRegion region, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) { - // we don't explect a null parent, but just in case! - // (in which case, we must be dealing with regions that are - // structuredDocumentRegions). - if (parent == null) - return canHandleAsWhiteSpace(region, changes, requestStart, lengthToReplace); - boolean result = false; - // if we are in the "white space" area of a region, then - // we don't want to handle, a reparse is needed. - // the white space region is consider anywhere that would - // leave whitespace between this character and the text part. - // and of course, we can insert whitespace in whitespace region - // - // if there is no whitespace in this region, no need to look further - if (region.getEnd() > region.getTextEnd()) { - // no need to add one to end of text, as we used to, since we - // change definition of length to equate to offset plus one. - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=105866 - // watch out for whitespace at end of text - if (requestStart >= parent.getTextEndOffset(region)) { - // ok, we are in the whitespace region, so we can't handle, - // unless - // we are just inserting whitespace. - if (allWhiteSpace(changes)) { - result = true; - } else { - result = false; - } - } - } - return result; - } - - static public boolean canHandleAsWhiteSpace(ITextRegion region, String changes, int requestStart, int lengthToReplace) { - boolean result = false; - // if we are in the "white space" area of a region, then - // we don't want to handle, a reparse is needed. - // the white space region is consider anywhere that would - // leave whitespace between this character and the text part. - // and of course, we can insert whitespace in whitespace region - // - // if there is no whitespace in this region, no need to look further - if (region.getEnd() > region.getTextEnd()) { - // no need to add one to end of text, as we used to, since we - // change definition of length to equate to offset plus one. - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=105866 - // watch out for whitespace at end of text - if (requestStart >= region.getTextEnd()) { - // ok, we are in the whitespace region, so we can't handle, - // unless - // we are just inserting whitespace. - if (allWhiteSpace(changes)) { - result = true; - } else { - result = false; - } - } - } - return result; - } - - // need an adjust text length API before this can be used - static public StructuredDocumentEvent updateModel(ITextRegion region, Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) { - RegionChangedEvent result = null; - // if the region is an easy type (e.g. attribute value), - // and the requested changes are all - // alphanumeric, then make the change here locally. - // (This can obviously be made more sophisticated as the need arises, - // but should - // always follow this pattern.) - if (Debug.debugStructuredDocument) { - System.out.println("\t\tContextRegion::updateModel"); //$NON-NLS-1$ - System.out.println("\t\t\tregion type is " + region.getType()); //$NON-NLS-1$ - } - boolean canHandle = false; - // note: we'll always handle deletes from these - // regions ... if its already that region, - // deleting something from it won't change its - // type. (remember, the calling program needs - // to insure we are not called, if not all contained - // on one region. - if ((changes == null) || (changes.length() == 0)) { - // delete case - // We can not do the quick delete, if - // if all the text in a region is to be deleted. - // Or, if the delete starts in the white space region. - // In these cases, a reparse is needed. - // Minor note, we use textEnd-start since it always - // less than or equal to end-start. This might - // cause us to miss a few cases we could have handled, - // but will prevent us from trying to handle funning cases - // involving whitespace. - if ((region.getStart() >= region.getTextEnd()) || (Math.abs(lengthToReplace) >= region.getTextEnd() - region.getStart())) { - canHandle = false; - } else { - canHandle = true; - } - } else { - if ((RegionUpdateRule.canHandleAsWhiteSpace(region, parent, changes, requestStart, lengthToReplace)) || RegionUpdateRule.canHandleAsLetterOrDigit(region, parent, changes, requestStart, lengthToReplace)) { - canHandle = true; - } else { - canHandle = false; - } - } - if (canHandle) { - // at this point, we still have the old region. We won't create a - // new instance, we'll just update the one we have, by changing - // its end postion, - // The parent flatnode, upon return, has responsibility - // for updating sibling regions. - // and in turn, the structuredDocument itself has responsibility - // for - // updating the text store and down stream flatnodes. - if (Debug.debugStructuredDocument) { - System.out.println("change handled by region"); //$NON-NLS-1$ - } - int lengthDifference = Utilities.calculateLengthDifference(changes, lengthToReplace); - // Note: we adjust both end and text end, because for any change - // that is in only the trailing whitespace region, we should not - // do a quick change, - // so 'canHandle' should have been false for those case. - region.adjustLength(lengthDifference); - // TO_DO_FUTURE: cache value of canHandleAsWhiteSpace from above - // If we are handling as whitespace, there is no need to increase - // the text length, only - // the total length is changing. - if (!RegionUpdateRule.canHandleAsWhiteSpace(region, parent, changes, region.getStart(), lengthToReplace)) { - // region.adjustTextLength(lengthDifference); - } - result = new RegionChangedEvent(parent.getParentDocument(), requester, parent, region, changes, requestStart, lengthToReplace); - } - return result; - } -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/TagCloseRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/TagCloseRegion.java deleted file mode 100644 index 027ae4d992..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/TagCloseRegion.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.parser.regions; - -import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; - - -public class TagCloseRegion implements ITextRegion { - static private final byte fLength = 1; - static private final byte fTextLength = 1; - static private final String fType = DOMRegionContext.XML_TAG_CLOSE; - private int fStart; - - - public TagCloseRegion() { - super(); - } - - public TagCloseRegion(int start) { - this(); - fStart = start; - } - - public void adjustLength(int i) { - throw new RuntimeException("invalid for this region type"); //$NON-NLS-1$ - - } - - public void adjustStart(int i) { - fStart += i; - - } - - public void adjustTextLength(int i) { - // not supported - - } - - public void equatePositions(ITextRegion region) { - fStart = region.getStart(); - } - - public int getEnd() { - return fStart + fLength; - } - - public int getLength() { - return fLength; - } - - public int getStart() { - return fStart; - } - - public int getTextEnd() { - return fStart + fTextLength; - } - - public int getTextLength() { - return fTextLength; - } - - public String getType() { - return fType; - } - - public String toString() { - return RegionToStringUtil.toString(this); - } - - public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) { - // can never be updated - return null; - } - -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/TagNameRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/TagNameRegion.java deleted file mode 100644 index 38b59c4233..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/TagNameRegion.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.parser.regions; - -import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; - - -public class TagNameRegion implements ITextRegion { - static private final String fType = DOMRegionContext.XML_TAG_NAME; - private short fLength; - private int fStart; - private short fTextLength; - - - public TagNameRegion() { - super(); - } - - public TagNameRegion(int start, int textLength, int length) { - this(); - fStart = start; - fTextLength = (short) textLength; - fLength = (short) length; - } - - public void adjustLength(int i) { - fLength += i; - - } - - public void adjustStart(int i) { - fStart += i; - - } - - - public void adjustTextLength(int i) { - fTextLength += i; - } - - public void equatePositions(ITextRegion region) { - fStart = region.getStart(); - fLength = (short) region.getLength(); - fTextLength = (short) region.getTextLength(); - } - - public int getEnd() { - return fStart + fLength; - } - - public int getLength() { - return fLength; - } - - public int getStart() { - return fStart; - } - - public int getTextEnd() { - return fStart + fTextLength; - } - - public int getTextLength() { - return fTextLength; - } - - public String getType() { - return fType; - } - - public String toString() { - return RegionToStringUtil.toString(this); - } - - public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) { - // can never be updated - return null; - } - -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/TagOpenRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/TagOpenRegion.java deleted file mode 100644 index e8cb85e928..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/TagOpenRegion.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.parser.regions; - -import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; - - -public class TagOpenRegion implements ITextRegion { - static private final String fType = DOMRegionContext.XML_TAG_OPEN; - private int fLength; - private int fStart; - static private final byte fTextLength = 1; - - - public TagOpenRegion() { - super(); - } - - public TagOpenRegion(int start, int textLength, int length) { - this(start, length); - if (fTextLength != textLength) - throw new RuntimeException("invalid for this region type"); //$NON-NLS-1$ - } - - public TagOpenRegion(int start, int length) { - this(); - fStart = start; - fLength = length; - } - - public void adjustLength(int i) { - fLength += i; - - } - - public void adjustStart(int i) { - fStart += i; - - } - - - public void adjustTextLength(int i) { -// fTextLength += 1; - throw new RuntimeException("invalid for this region type"); //$NON-NLS-1$ - } - - public void equatePositions(ITextRegion region) { - fStart = region.getStart(); - fLength = region.getLength(); - } - - public int getEnd() { - return fStart + fLength; - } - - public int getLength() { - return fLength; - } - - public int getStart() { - return fStart; - } - - public int getTextEnd() { - return fStart + fTextLength; - } - - public int getTextLength() { - return fTextLength; - } - - public String getType() { - return fType; - } - - public String toString() { - return RegionToStringUtil.toString(this); - } - - public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) { - // can never be updated - return null; - } - -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/WhiteSpaceOnlyRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/WhiteSpaceOnlyRegion.java deleted file mode 100644 index bc0bcc197b..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/WhiteSpaceOnlyRegion.java +++ /dev/null @@ -1,188 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.parser.regions; - - - -import org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent; -import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.sse.core.internal.util.Debug; -import org.eclipse.wst.sse.core.internal.util.Utilities; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; - - -public class WhiteSpaceOnlyRegion implements ITextRegion { - static private final byte fTextLength = 0; - - static private final String fType = DOMRegionContext.WHITE_SPACE; - protected int fLength; - protected int fStart; - - public WhiteSpaceOnlyRegion(int start, int length) { - super(); - fStart = start; - fLength = length; - } - - public void adjust(int i) { - fStart += i; - } - - public void adjustLength(int i) { - fLength += i; - } - - public void adjustStart(int i) { - fStart += i; - } - - - public void adjustTextLength(int i) { - // not supported - - } - - public boolean contains(int position) { - - return fStart <= position && position < fStart + fLength; - } - - public void equatePositions(ITextRegion region) { - fStart = region.getStart(); - fLength = region.getLength(); - } - - public int getEnd() { - return fStart + fLength; - } - - public int getLength() { - return fLength; - } - - public int getStart() { - return fStart; - } - - public int getTextEnd() { - return fStart + fTextLength; - } - - public int getTextLength() { - return fTextLength; - } - - public String getType() { - return fType; - } - - public void setLength(int i) { - fLength = i; - } - - public void setStart(int i) { - fStart = i; - } - - public void setTextLength(short i) { - throw new RuntimeException("invalid call"); //$NON-NLS-1$ - } - - public void setType(String string) { - throw new RuntimeException("invalid call"); //$NON-NLS-1$ - } - - public String toString() { - return RegionToStringUtil.toString(this); - } - - /** - * For this ITextRegion type, the start must in terms of what the region - * expects ... that is, its not document offset, but start relative to - * what ever contains it. - */ - public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) { - // if the region is an easy type (e.g. attribute value), - // and the requested changes are all - // alphanumeric, then make the change here locally. - // (This can obviously be made more sophisticated as the need arises, - // but should - // always follow this pattern.) - if (Debug.debugStructuredDocument) { - System.out.println("\t\tContextRegion::updateModel"); //$NON-NLS-1$ - System.out.println("\t\t\tregion type is " + fType); //$NON-NLS-1$ - } - boolean canHandle = false; - // note: we'll always handle deletes from these - // regions ... if its already that region, - // deleting something from it won't change its - // type. (remember, the calling program needs - // to insure we are not called, if not all contained - // on one region. - if ((changes == null) || (changes.length() == 0)) { - // delete case - // We can not do the quick delete, if - // if all the text in a region is to be deleted. - // Or, if the delete starts in the white space region. - // In these cases, a reparse is needed. - // Minor note, we use textEnd-start since it always - // less than or equal to end-start. This might - // cause us to miss a few cases we could have handled, - // but will prevent us from trying to handle funning cases - // involving whitespace. - if ((fStart >= getTextEnd()) || (Math.abs(lengthToReplace) >= getTextEnd() - getStart())) { - canHandle = false; - } - else { - canHandle = true; - } - } - else { - if (RegionUpdateRule.canHandleAsWhiteSpace(this, parent, changes, requestStart, lengthToReplace)) { - canHandle = true; - } - else { - canHandle = false; - } - - } - RegionChangedEvent result = null; - - if (canHandle) { - // at this point, we still have the old region. We won't create a - // new instance, we'll just update the one we have, by changing - // its end postion, - // The parent flatnode, upon return, has responsibility - // for updating sibling regions. - // and in turn, the structuredDocument itself has responsibility - // for - // updating the text store and down stream flatnodes. - if (Debug.debugStructuredDocument) { - System.out.println("change handled by region"); //$NON-NLS-1$ - } - int lengthDifference = Utilities.calculateLengthDifference(changes, lengthToReplace); - // Note: we adjust both end and text end, because for any change - // that is in only the trailing whitespace region, we should not - // do a quick change, - // so 'canHandle' should have been false for those case. - fLength += lengthDifference; - - result = new RegionChangedEvent(parent.getParentDocument(), requester, parent, this, changes, requestStart, lengthToReplace); - } - - return result; - } - -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLCDataTextRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLCDataTextRegion.java deleted file mode 100644 index 23da980cde..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLCDataTextRegion.java +++ /dev/null @@ -1,175 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.parser.regions; - -import org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent; -import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.sse.core.internal.util.Debug; -import org.eclipse.wst.sse.core.internal.util.Utilities; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; - - -public class XMLCDataTextRegion implements ITextRegion { - static private final String fType = DOMRegionContext.XML_CDATA_TEXT; - private int fLength; - private int fStart; - private int fTextLength; - - - public XMLCDataTextRegion() { - super(); - } - - public XMLCDataTextRegion(int start, int textLength, int length) { - this(); - fStart = start; - fTextLength = textLength; - fLength = length; - } - - public void adjustLength(int i) { - fLength += i; - - } - - public void adjustStart(int i) { - fStart += i; - - } - - - public void adjustTextLength(int i) { - fTextLength += i; - - } - - public void equatePositions(ITextRegion region) { - fStart = region.getStart(); - fLength = region.getLength(); - fTextLength = region.getTextLength(); - } - - public int getEnd() { - return fStart + fLength; - } - - public int getLength() { - // TODO: shouldn't cdata be like XML Content ... length and text - // length - // always be the same, regardless of whitespace? - return fLength; - } - - public int getStart() { - return fStart; - } - - public int getTextEnd() { - return fStart + fTextLength; - } - - public int getTextLength() { - return fTextLength; - } - - public String getType() { - return fType; - } - - public String toString() { - return RegionToStringUtil.toString(this); - } - - - public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) { - // TODO: this is a pretty lame method, since XML CData region can have - // a much - // better rule for region update, but this is what previous - // (unfactored) - // version had, so I'll carry it over, of now. - RegionChangedEvent result = null; - // if the region is an easy type (e.g. attribute value), - // and the requested changes are all - // alphanumeric, then make the change here locally. - // (This can obviously be made more sophisticated as the need arises, - // but should - // always follow this pattern.) - if (Debug.debugStructuredDocument) { - System.out.println("\t\tContextRegion::updateModel"); //$NON-NLS-1$ - System.out.println("\t\t\tregion type is " + fType); //$NON-NLS-1$ - } - boolean canHandle = false; - // note: we'll always handle deletes from these - // regions ... if its already that region, - // deleting something from it won't change its - // type. (remember, the calling program needs - // to insure we are not called, if not all contained - // on one region. - if ((changes == null) || (changes.length() == 0)) { - // delete case - // We can not do the quick delete, if - // if all the text in a region is to be deleted. - // Or, if the delete starts in the white space region. - // In these cases, a reparse is needed. - // Minor note, we use textEnd-start since it always - // less than or equal to end-start. This might - // cause us to miss a few cases we could have handled, - // but will prevent us from trying to handle funning cases - // involving whitespace. - if ((fStart >= getTextEnd()) || (Math.abs(lengthToReplace) >= getTextEnd() - getStart())) { - canHandle = false; - } else { - canHandle = true; - } - } else { - if ((RegionUpdateRule.canHandleAsWhiteSpace(this, parent, changes, requestStart, lengthToReplace)) || RegionUpdateRule.canHandleAsLetterOrDigit(this, parent, changes, requestStart, lengthToReplace)) { - canHandle = true; - } else { - canHandle = false; - } - - } - if (canHandle) { - // at this point, we still have the old region. We won't create a - // new instance, we'll just update the one we have, by changing - // its end postion, - // The parent flatnode, upon return, has responsibility - // for updating sibling regions. - // and in turn, the structuredDocument itself has responsibility - // for - // updating the text store and down stream flatnodes. - if (Debug.debugStructuredDocument) { - System.out.println("change handled by region"); //$NON-NLS-1$ - } - int lengthDifference = Utilities.calculateLengthDifference(changes, lengthToReplace); - // Note: we adjust both end and text end, because for any change - // that is in only the trailing whitespace region, we should not - // do a quick change, - // so 'canHandle' should have been false for those case. - // TO_DO_FUTURE: cache value of canHandleAsWhiteSpace from above - // If we are handling as whitespace, there is no need to increase - // the text length, only - // the total length is changing. - if (!RegionUpdateRule.canHandleAsWhiteSpace(this, parent, changes, requestStart, lengthToReplace)) { - fTextLength += lengthDifference; - } - fLength += lengthDifference; - result = new RegionChangedEvent(parent.getParentDocument(), requester, parent, this, changes, requestStart, lengthToReplace); - } - - return result; - } - -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLContentRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLContentRegion.java deleted file mode 100644 index e9088dbb0c..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLContentRegion.java +++ /dev/null @@ -1,175 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.parser.regions; - -import org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent; -import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.sse.core.internal.util.Debug; -import org.eclipse.wst.sse.core.internal.util.Utilities; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; - - - -public class XMLContentRegion implements ITextRegion { - static private final String fType = DOMRegionContext.XML_CONTENT; - // length and textLength are always the same for content region - //private int fTextLength; - private int fLength; - private int fStart; - - - public XMLContentRegion() { - super(); - } - - public XMLContentRegion(int start, int length) { - this(); - fStart = start; - fLength = length; - } - - - public void adjustLength(int i) { - fLength += i; - - } - - public void adjustStart(int i) { - fStart += i; - - } - - - public void adjustTextLength(int i) { - // not supported - - } - - public void equatePositions(ITextRegion region) { - fStart = region.getStart(); - fLength = region.getLength(); - } - - public int getEnd() { - return fStart + fLength; - } - - public int getLength() { - return fLength; - } - - public int getStart() { - return fStart; - } - - public int getTextEnd() { - return fStart + fLength; - } - - public int getTextLength() { - return fLength; - } - - public String getType() { - return fType; - } - - public String toString() { - return RegionToStringUtil.toString(this); - } - - - public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) { - // TODO: this is a pretty lame method, since XML Content can have a - // much - // better rule for region update, but this is what previous - // (unfactored) - // version had, so I'll carry it over, of now. - RegionChangedEvent result = null; - // if the region is an easy type (e.g. attribute value), - // and the requested changes are all - // alphanumeric, then make the change here locally. - // (This can obviously be made more sophisticated as the need arises, - // but should - // always follow this pattern.) - if (Debug.debugStructuredDocument) { - System.out.println("\t\tContextRegion::updateModel"); //$NON-NLS-1$ - System.out.println("\t\t\tregion type is " + fType); //$NON-NLS-1$ - } - boolean canHandle = false; - // note: we'll always handle deletes from these - // regions ... if its already that region, - // deleting something from it won't change its - // type. (remember, the calling program needs - // to insure we are not called, if not all contained - // on one region. - if ((changes == null) || (changes.length() == 0)) { - // delete case - // We can not do the quick delete, if - // if all the text in a region is to be deleted. - // Or, if the delete starts in the white space region. - // In these cases, a reparse is needed. - // Minor note, we use textEnd-start since it always - // less than or equal to end-start. This might - // cause us to miss a few cases we could have handled, - // but will prevent us from trying to handle funning cases - // involving whitespace. - if ((fStart >= getTextEnd()) || (Math.abs(lengthToReplace) >= getTextEnd() - getStart())) { - canHandle = false; - } else { - canHandle = true; - } - } else { - if ((RegionUpdateRule.canHandleAsWhiteSpace(this, parent, changes, requestStart, lengthToReplace)) || RegionUpdateRule.canHandleAsLetterOrDigit(this, parent, changes, requestStart, lengthToReplace)) { - canHandle = true; - } else { - canHandle = false; - } - - } - if (canHandle) { - // at this point, we still have the old region. We won't create a - // new instance, we'll just update the one we have, by changing - // its end postion, - // The parent flatnode, upon return, has responsibility - // for updating sibling regions. - // and in turn, the structuredDocument itself has responsibility - // for - // updating the text store and down stream flatnodes. - if (Debug.debugStructuredDocument) { - System.out.println("change handled by region"); //$NON-NLS-1$ - } - int lengthDifference = Utilities.calculateLengthDifference(changes, lengthToReplace); - // Note: we adjust both end and text end, because for any change - // that is in only the trailing whitespace region, we should not - // do a quick change, - // so 'canHandle' should have been false for those case. - fLength += lengthDifference; - // TO_DO_FUTURE: cache value of canHandleAsWhiteSpace from above - // If we are handling as whitespace, there is no need to increase - // the text length, only - // the total length is changing. - // don't need for content region - // if (!RegionUpdateRule.canHandleAsWhiteSpace(this, changes, - // fStart, lengthToReplace)) { - // fTextLength += lengthDifference; - // } - result = new RegionChangedEvent(parent.getParentDocument(), requester, parent, this, changes, requestStart, lengthToReplace); - } - - return result; - } - -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLHeadParserFactory.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLHeadParserFactory.java deleted file mode 100644 index 38df3ea165..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLHeadParserFactory.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.parser.regions; - -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; - -public class XMLHeadParserFactory { - public ITextRegion createToken(String context, int start, int textLength, int length, String text) { - ITextRegion newRegion = null; - // if (context == XMLRegionContext.XML_CDATA_TEXT) { - newRegion = new XMLHeadParserRegion(context, start, textLength, length, text); - // } - return newRegion; - } -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLHeadParserRegion.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLHeadParserRegion.java deleted file mode 100644 index f3917b6338..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLHeadParserRegion.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.parser.regions; - -import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; - - -/** - * - * This class is not intended to be used, its just present to server as a - * generic starting point for adding new specific region types. - */ - -public class XMLHeadParserRegion implements ITextRegion { - private int fLength; - private int fStart; - private String fText; - private int fTextLength; - // specify correct type - private String fType = DOMRegionContext.UNDEFINED; - - public XMLHeadParserRegion() { - super(); - } - - public XMLHeadParserRegion(String context, int start, int textLength, int length, String text) { - this(); - fType = context; - fStart = start; - fTextLength = textLength; - fLength = length; - fText = text; - } - - public void adjustLength(int i) { - fLength += i; - - } - - public void adjustStart(int i) { - fStart += i; - - } - - - public void adjustTextLength(int i) { - fTextLength += 1; - - } - - public void equatePositions(ITextRegion region) { - fStart = region.getStart(); - fLength = region.getLength(); - fTextLength = region.getTextLength(); - } - - public int getEnd() { - return fStart + fLength; - } - - public int getLength() { - return fLength; - } - - public int getStart() { - return fStart; - } - - public String getText() { - return fText; - } - - public int getTextEnd() { - return fStart + fTextLength; - } - - public int getTextLength() { - return fTextLength; - } - - public String getType() { - return fType; - } - - public String toString() { - return RegionToStringUtil.toString(this); - } - - public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) { - // can never be updated - return null; - } - -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLParserRegionFactory.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLParserRegionFactory.java deleted file mode 100644 index 581f44780e..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/regions/XMLParserRegionFactory.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.parser.regions; - - - -import org.eclipse.wst.sse.core.internal.parser.ContextRegion; -import org.eclipse.wst.sse.core.internal.parser.ForeignRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; - - -/** - * - * This region factory is very specific to the parser output, and the specific - * implementation classes for various regions. - */ - -public class XMLParserRegionFactory { - - public XMLParserRegionFactory() { - super(); - } - - public ITextRegion createToken(ITextRegionContainer parent, String context, int start, int textLength, int length) { - return this.createToken(parent, context, start, textLength, length, null, null); - } - - public ITextRegion createToken(ITextRegionContainer parent, String context, int start, int textLength, int length, String lang, String surroundingTag) { - ITextRegion newRegion = createToken(context, start, textLength, length); - // DW, 4/16/2003 token regions no longer have parents - // newRegion.setParent(parent); - return newRegion; - } - - public ITextRegion createToken(String context, int start, int textLength, int length) { - return this.createToken(context, start, textLength, length, null, null); - } - - public ITextRegion createToken(String context, int start, int textLength, int length, String lang, String surroundingTag) { - ITextRegion newRegion = null; - if (context == DOMRegionContext.XML_CDATA_TEXT) { - newRegion = new XMLCDataTextRegion(start, textLength, length); - } - else if (context == DOMRegionContext.XML_CONTENT) { - newRegion = new XMLContentRegion(start, length); - } - else if (context == DOMRegionContext.XML_TAG_NAME) { - newRegion = new TagNameRegion(start, textLength, length); - } - else if (context == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) { - newRegion = new AttributeNameRegion(start, textLength, length); - } - else if (context == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) { - newRegion = new AttributeEqualsRegion(start, textLength, length); - } - else if (context == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) { - newRegion = new AttributeValueRegion(start, textLength, length); - } - else if (context == DOMRegionContext.XML_TAG_OPEN) { - newRegion = new TagOpenRegion(start, textLength, length); - } - else if (context == DOMRegionContext.XML_END_TAG_OPEN) { - newRegion = new EndTagOpenRegion(start, textLength, length); - } - else if (context == DOMRegionContext.XML_TAG_CLOSE) { - newRegion = new TagCloseRegion(start); - } - else if (context == DOMRegionContext.XML_EMPTY_TAG_CLOSE) { - newRegion = new EmptyTagCloseRegion(start, textLength, length); - } - else if (context == DOMRegionContext.WHITE_SPACE) { - newRegion = new WhiteSpaceOnlyRegion(start, length); - } - else - // removed this condition during transition, and implemented in - // subclass - // if (context == XMLJSPRegionContexts.JSP_CONTENT) { - // newRegion = new JSPCodeRegion(context, start, textLength, length); - // } else - if (context == DOMRegionContext.BLOCK_TEXT) { - newRegion = new ForeignRegion(context, start, textLength, length); - ((ForeignRegion) newRegion).setSurroundingTag(surroundingTag); - } - else { - newRegion = new ContextRegion(context, start, textLength, length); - } - return newRegion; - } - - -} |