diff options
author | ndai | 2004-10-13 15:56:56 +0000 |
---|---|---|
committer | ndai | 2004-10-13 15:56:56 +0000 |
commit | 87d3387644150821cade15c0f6f8ff20c0499ff2 (patch) | |
tree | 7aa179138beb8d95184f0e03bf5b621dd8a70c4c /bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal | |
download | webtools.sourceediting-87d3387644150821cade15c0f6f8ff20c0499ff2.tar.gz webtools.sourceediting-87d3387644150821cade15c0f6f8ff20c0499ff2.tar.xz webtools.sourceediting-87d3387644150821cade15c0f6f8ff20c0499ff2.zip |
CVS structure renamed. org.eclipse.wtp.* has been moved to org.eclipse.*
Diffstat (limited to 'bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal')
3 files changed, 144 insertions, 0 deletions
diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/text/DTDStructuredDocumentReParser.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/text/DTDStructuredDocumentReParser.java new file mode 100644 index 0000000000..29431d0b55 --- /dev/null +++ b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/text/DTDStructuredDocumentReParser.java @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2002 IBM Corporation and others. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Common Public License v1.0 +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/cpl-v10.html +* +* Contributors: +* IBM - Initial API and implementation +* Jens Lukowski/Innoopract - initial renaming/restructuring +* +*/ +package org.eclipse.wst.dtd.core.internal.text; + +import org.eclipse.wst.sse.core.events.StructuredDocumentEvent; +import org.eclipse.wst.sse.core.internal.text.StructuredDocumentReParser; +import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion; + +public class DTDStructuredDocumentReParser extends StructuredDocumentReParser { + protected StructuredDocumentEvent reparse(IStructuredDocumentRegion dirtyStart, IStructuredDocumentRegion dirtyEnd) { + return super.reparse(dirtyStart, dirtyEnd); + } + + public StructuredDocumentEvent checkForCrossStructuredDocumentRegionBoundryCases() { + IStructuredDocumentRegion startNode = fStructuredDocument.getRegionAtCharacterOffset(fStart); + IStructuredDocumentRegion endNode = fStructuredDocument.getRegionAtCharacterOffset(fStart + fLengthToReplace - 1); + return reparse(startNode.getStart(), endNode.getEnd()); + } + +} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/text/DTDStructuredDocumentRegionFactory.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/text/DTDStructuredDocumentRegionFactory.java new file mode 100644 index 0000000000..aacdf9176f --- /dev/null +++ b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/text/DTDStructuredDocumentRegionFactory.java @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2002 IBM Corporation and others. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Common Public License v1.0 +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/cpl-v10.html +* +* Contributors: +* IBM - Initial API and implementation +* Jens Lukowski/Innoopract - initial renaming/restructuring +* +*/ +package org.eclipse.wst.dtd.core.internal.text; + +import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocumentRegion; +import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion; + +public class DTDStructuredDocumentRegionFactory { + public static final int DTD_GENERIC = 5; + + public static IStructuredDocumentRegion createStructuredDocumentRegion(int type) { + IStructuredDocumentRegion instance = null; + switch (type) { + case DTD_GENERIC : + instance = new BasicStructuredDocumentRegion(); + break; + default : + break; + } + return instance; + } +} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/text/RegionIterator.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/text/RegionIterator.java new file mode 100644 index 0000000000..1f7b906c95 --- /dev/null +++ b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/text/RegionIterator.java @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2002 IBM Corporation and others. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Common Public License v1.0 +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/cpl-v10.html +* +* Contributors: +* IBM - Initial API and implementation +* Jens Lukowski/Innoopract - initial renaming/restructuring +* +*/ +package org.eclipse.wst.dtd.core.internal.text; + +import java.util.NoSuchElementException; + +import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion; +import org.eclipse.wst.sse.core.text.ITextRegion; +import org.eclipse.wst.sse.core.text.ITextRegionList; + +public class RegionIterator { + public RegionIterator(IStructuredDocumentRegion node) { + this(node, node.getStart(), node.getEnd()); + } + + public RegionIterator(ITextRegionList regions) { + this.regions = regions; + startRegion = regions.get(0); + endRegion = regions.get(regions.size() - 1); + currentIndex = 0; + // this(node, node.getStart(), node.getEnd()); + } + + public RegionIterator(IStructuredDocumentRegion node, int startOffset, int endOffset) { + regions = node.getRegions(); + startRegion = node.getRegionAtCharacterOffset(startOffset); + endRegion = node.getRegionAtCharacterOffset(endOffset - 1); + + for (int i = 0; i < regions.size(); i++) { + ITextRegion region = regions.get(i); + if (startRegion == region) { + currentIndex = i; + break; + } + } + } + + private IStructuredDocumentRegion flatNode; + private ITextRegionList regions; + private ITextRegion startRegion, endRegion; + private int startOffset, endOffset; + + private int currentIndex; + + public ITextRegion next() { + if (hasNext()) { + return regions.get(currentIndex++); + } + throw new NoSuchElementException(); + } + + public ITextRegion previous() { + if (hasPrevious()) { + return regions.get(--currentIndex); + } + throw new NoSuchElementException(); + } + + public boolean hasNext() { + if (currentIndex < regions.size()) { + return currentIndex <= regions.indexOf(endRegion); + } + return false; + } + + public boolean hasPrevious() { + if (currentIndex >= 0) { + return currentIndex >= regions.indexOf(startRegion); + } + return false; + } +} |