use of org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent in project webtools.sourceediting by eclipse.
the class AttributeNameRegion method updateRegion.
public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {
RegionChangedEvent result = null;
// always follow this pattern.)
if (Debug.debugStructuredDocument) {
// $NON-NLS-1$
System.out.println("\t\tContextRegion::updateModel");
// $NON-NLS-1$
System.out.println("\t\t\tregion type is " + fType);
}
boolean canHandle = false;
// on one region.
if ((changes == null) || (changes.length() == 0)) {
// 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) {
// updating the text store and down stream flatnodes.
if (Debug.debugStructuredDocument) {
// $NON-NLS-1$
System.out.println("change handled by region");
}
int lengthDifference = Utilities.calculateLengthDifference(changes, lengthToReplace);
// 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;
}
use of org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent in project webtools.sourceediting by eclipse.
the class WhiteSpaceOnlyRegion method updateRegion.
/**
* 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) {
// always follow this pattern.)
if (Debug.debugStructuredDocument) {
// $NON-NLS-1$
System.out.println("\t\tContextRegion::updateModel");
// $NON-NLS-1$
System.out.println("\t\t\tregion type is " + fType);
}
boolean canHandle = false;
// on one region.
if ((changes == null) || (changes.length() == 0)) {
// 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) {
// updating the text store and down stream flatnodes.
if (Debug.debugStructuredDocument) {
// $NON-NLS-1$
System.out.println("change handled by region");
}
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;
}
use of org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent in project webtools.sourceediting by eclipse.
the class XMLContentRegion method updateRegion.
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;
// always follow this pattern.)
if (Debug.debugStructuredDocument) {
// $NON-NLS-1$
System.out.println("\t\tContextRegion::updateModel");
// $NON-NLS-1$
System.out.println("\t\t\tregion type is " + fType);
}
boolean canHandle = false;
// on one region.
if ((changes == null) || (changes.length() == 0)) {
// involving whitespace.
if ((fStart >= getTextEnd()) || (Math.abs(lengthToReplace) >= getTextEnd() - getStart()) || ((parent.getText().startsWith("&")) && (parent.getText().endsWith(";")))) {
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) {
// updating the text store and down stream flatnodes.
if (Debug.debugStructuredDocument) {
// $NON-NLS-1$
System.out.println("change handled by region");
}
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;
}
use of org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent in project webtools.sourceediting by eclipse.
the class XMLCDataTextRegion method updateRegion.
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;
// always follow this pattern.)
if (Debug.debugStructuredDocument) {
// $NON-NLS-1$
System.out.println("\t\tContextRegion::updateModel");
// $NON-NLS-1$
System.out.println("\t\t\tregion type is " + fType);
}
boolean canHandle = false;
// on one region.
if ((changes == null) || (changes.length() == 0)) {
// 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) {
// updating the text store and down stream flatnodes.
if (Debug.debugStructuredDocument) {
// $NON-NLS-1$
System.out.println("change handled by region");
}
int lengthDifference = Utilities.calculateLengthDifference(changes, lengthToReplace);
// 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;
}
use of org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent in project webtools.sourceediting by eclipse.
the class UnitTests method handleEvent.
protected void handleEvent(StructuredDocumentEvent structuredDocumentEvent) {
eventResult = false;
switch(eventCase) {
case 1:
{
if (structuredDocumentEvent instanceof NoChangeEvent) {
// ok
eventResult = true;
}
break;
}
case 2:
{
if (structuredDocumentEvent instanceof NoChangeEvent) {
// ok
eventResult = true;
}
break;
}
case 3:
{
if (structuredDocumentEvent instanceof StructuredDocumentRegionsReplacedEvent) {
// ok
eventResult = true;
}
break;
}
case 4:
{
if (structuredDocumentEvent instanceof StructuredDocumentRegionsReplacedEvent) {
// ok
eventResult = true;
}
break;
}
case 5:
{
if (structuredDocumentEvent instanceof StructuredDocumentRegionsReplacedEvent) {
if (3 == ((StructuredDocumentRegionsReplacedEvent) structuredDocumentEvent).getOldStructuredDocumentRegions().getLength())
if (3 == ((StructuredDocumentRegionsReplacedEvent) structuredDocumentEvent).getNewStructuredDocumentRegions().getLength())
// ok
eventResult = true;
}
break;
}
case 6:
{
if (structuredDocumentEvent instanceof StructuredDocumentRegionsReplacedEvent) {
if (0 == ((StructuredDocumentRegionsReplacedEvent) structuredDocumentEvent).getOldStructuredDocumentRegions().getLength())
if (2 == ((StructuredDocumentRegionsReplacedEvent) structuredDocumentEvent).getNewStructuredDocumentRegions().getLength())
if ("<B>".equals(((StructuredDocumentRegionsReplacedEvent) structuredDocumentEvent).getNewStructuredDocumentRegions().item(0).getText()))
if ("</B>".equals(((StructuredDocumentRegionsReplacedEvent) structuredDocumentEvent).getNewStructuredDocumentRegions().item(1).getText())) {
// ok
eventResult = true;
}
}
break;
}
case 7:
{
if (structuredDocumentEvent instanceof StructuredDocumentRegionsReplacedEvent) {
if (0 == ((StructuredDocumentRegionsReplacedEvent) structuredDocumentEvent).getOldStructuredDocumentRegions().getLength())
if (1 == ((StructuredDocumentRegionsReplacedEvent) structuredDocumentEvent).getNewStructuredDocumentRegions().getLength())
// ok
eventResult = true;
}
break;
}
case 8:
{
if (structuredDocumentEvent instanceof StructuredDocumentRegionsReplacedEvent) {
if (0 == ((StructuredDocumentRegionsReplacedEvent) structuredDocumentEvent).getOldStructuredDocumentRegions().getLength())
if (2 == ((StructuredDocumentRegionsReplacedEvent) structuredDocumentEvent).getNewStructuredDocumentRegions().getLength())
// if ("<B>".equals(((StructuredDocumentRegionsReplacedEvent) structuredDocumentEvent).getNewStructuredDocumentRegions().item(0).getText()))
// if ("</B>".equals(((StructuredDocumentRegionsReplacedEvent) structuredDocumentEvent).getNewStructuredDocumentRegions().item(1).getText())) {
// ok
eventResult = true;
}
break;
}
case 9:
case 10:
{
if (structuredDocumentEvent instanceof StructuredDocumentRegionsReplacedEvent) {
if (2 == ((StructuredDocumentRegionsReplacedEvent) structuredDocumentEvent).getOldStructuredDocumentRegions().getLength())
if (0 == ((StructuredDocumentRegionsReplacedEvent) structuredDocumentEvent).getNewStructuredDocumentRegions().getLength())
if ("<TD>".equals(((StructuredDocumentRegionsReplacedEvent) structuredDocumentEvent).getOldStructuredDocumentRegions().item(0).getText()))
if ("</TD>".equals(((StructuredDocumentRegionsReplacedEvent) structuredDocumentEvent).getOldStructuredDocumentRegions().item(1).getText()))
// ok
eventResult = true;
}
break;
}
case 11:
case 12:
{
if (structuredDocumentEvent instanceof StructuredDocumentRegionsReplacedEvent) {
if (2 == ((StructuredDocumentRegionsReplacedEvent) structuredDocumentEvent).getOldStructuredDocumentRegions().getLength())
if (0 == ((StructuredDocumentRegionsReplacedEvent) structuredDocumentEvent).getNewStructuredDocumentRegions().getLength())
if ("<TD>".equals(((StructuredDocumentRegionsReplacedEvent) structuredDocumentEvent).getOldStructuredDocumentRegions().item(0).getText()))
if ("</TD>".equals(((StructuredDocumentRegionsReplacedEvent) structuredDocumentEvent).getOldStructuredDocumentRegions().item(1).getText()))
// ok
eventResult = true;
}
break;
}
case 13:
{
if (structuredDocumentEvent instanceof RegionsReplacedEvent) {
if (3 == ((RegionsReplacedEvent) structuredDocumentEvent).getNewRegions().size())
if (3 == ((RegionsReplacedEvent) structuredDocumentEvent).getOldRegions().size())
// ok
eventResult = true;
}
break;
}
case 14:
{
if (structuredDocumentEvent instanceof StructuredDocumentRegionsReplacedEvent) {
if (3 == ((StructuredDocumentRegionsReplacedEvent) structuredDocumentEvent).getOldStructuredDocumentRegions().getLength())
if (1 == ((StructuredDocumentRegionsReplacedEvent) structuredDocumentEvent).getNewStructuredDocumentRegions().getLength())
// ok
eventResult = true;
}
break;
}
case 15:
{
if (structuredDocumentEvent instanceof RegionChangedEvent) {
RegionChangedEvent regionChangedEvent = (RegionChangedEvent) structuredDocumentEvent;
IStructuredDocumentRegion documentRegion = ((RegionChangedEvent) structuredDocumentEvent).getStructuredDocumentRegion();
if ("b ".equals(documentRegion.getFullText(regionChangedEvent.getRegion()))) {
// ok
eventResult = true;
}
}
break;
}
case 16:
{
if (structuredDocumentEvent instanceof RegionsReplacedEvent) {
if (0 == ((RegionsReplacedEvent) structuredDocumentEvent).getOldRegions().size()) {
if (1 == ((RegionsReplacedEvent) structuredDocumentEvent).getNewRegions().size()) {
// ok
eventResult = true;
}
}
}
break;
}
case 17:
{
if (structuredDocumentEvent instanceof RegionsReplacedEvent) {
if (1 == ((RegionsReplacedEvent) structuredDocumentEvent).getOldRegions().size()) {
if (3 == ((RegionsReplacedEvent) structuredDocumentEvent).getNewRegions().size()) {
// ok
eventResult = true;
}
}
}
break;
}
case 18:
{
if (structuredDocumentEvent instanceof RegionsReplacedEvent) {
if (2 == ((RegionsReplacedEvent) structuredDocumentEvent).getOldRegions().size()) {
if (2 == ((RegionsReplacedEvent) structuredDocumentEvent).getNewRegions().size()) {
// ok
eventResult = true;
}
}
}
break;
}
case 19:
{
if (structuredDocumentEvent instanceof RegionChangedEvent) {
// ok
eventResult = true;
}
break;
}
case 20:
case 21:
{
if (structuredDocumentEvent instanceof RegionChangedEvent) {
// ok
eventResult = true;
}
break;
}
case 22:
{
if (structuredDocumentEvent instanceof RegionChangedEvent) {
// ok
eventResult = true;
}
break;
}
case 23:
{
if (structuredDocumentEvent instanceof StructuredDocumentRegionsReplacedEvent) {
// ok
eventResult = true;
}
break;
}
case 24:
{
if (structuredDocumentEvent instanceof StructuredDocumentRegionsReplacedEvent) {
// ok
eventResult = true;
}
break;
}
case 25:
{
if (structuredDocumentEvent instanceof StructuredDocumentRegionsReplacedEvent) {
// ok
eventResult = true;
}
break;
}
case 26:
{
if (structuredDocumentEvent instanceof StructuredDocumentRegionsReplacedEvent) {
// ok
eventResult = true;
}
break;
}
// JSP5
case 27:
{
// changed 2002, 9/12 to fit
if (structuredDocumentEvent instanceof RegionsReplacedEvent) {
// ok
eventResult = true;
}
break;
}
case 28:
{
// changed 2002, 9/12 to fit
if (structuredDocumentEvent instanceof StructuredDocumentRegionsReplacedEvent) {
// ok
eventResult = true;
}
break;
}
case 29:
{
// changed 2002, 9/12 to fit
if (structuredDocumentEvent instanceof StructuredDocumentRegionsReplacedEvent) {
// ok
eventResult = true;
}
break;
}
case 30:
{
if (structuredDocumentEvent instanceof StructuredDocumentRegionsReplacedEvent) {
// ok
eventResult = true;
}
break;
}
// JSP6
case 31:
{
// changed 2002, 9/12 to fit
if (structuredDocumentEvent instanceof RegionsReplacedEvent) {
// ok
eventResult = true;
}
break;
}
case 32:
{
// changed 2002, 9/12 to fit -- this is definitely a change
if (structuredDocumentEvent instanceof RegionsReplacedEvent) {
RegionsReplacedEvent regionsReplacedEvent = (RegionsReplacedEvent) structuredDocumentEvent;
if (1 == regionsReplacedEvent.getOldRegions().size()) {
ITextRegion region = regionsReplacedEvent.getOldRegions().get(0);
IStructuredDocumentRegion documentRegion = regionsReplacedEvent.getStructuredDocumentRegion();
String text = documentRegion.getText(region);
if ("<% aaa %>".equals(text)) {
// ok
eventResult = true;
}
}
} else if (structuredDocumentEvent instanceof StructuredDocumentRegionsReplacedEvent) {
StructuredDocumentRegionsReplacedEvent nodesReplacedEvent = (StructuredDocumentRegionsReplacedEvent) structuredDocumentEvent;
IStructuredDocumentRegionList regions = nodesReplacedEvent.getNewStructuredDocumentRegions();
if (1 == regions.getLength()) {
IStructuredDocumentRegion region = regions.item(0);
String text = region.getText();
// System.out.println(text);
if ("<c<% aaa ".equals(text)) {
eventResult = true;
}
}
}
break;
}
case 33:
{
// changed 2002, 9/12 to fit
if (structuredDocumentEvent instanceof StructuredDocumentRegionsReplacedEvent) {
// if (structuredDocumentEvent instanceof RegionChangedEvent) {
// ok
eventResult = true;
}
break;
}
case 34:
{
if (structuredDocumentEvent instanceof StructuredDocumentRegionsReplacedEvent) {
// ok
eventResult = true;
}
break;
}
case 35:
{
// if (structuredDocumentEvent instanceof StructuredDocumentRegionsReplacedEvent) {
if (structuredDocumentEvent instanceof RegionsReplacedEvent) {
// ok
eventResult = true;
}
break;
}
case 36:
{
if (structuredDocumentEvent instanceof RegionsReplacedEvent) {
// ok
eventResult = true;
}
break;
}
case 37:
{
if (structuredDocumentEvent instanceof StructuredDocumentRegionsReplacedEvent) {
// ok
eventResult = true;
}
break;
}
case 38:
{
if (structuredDocumentEvent instanceof RegionChangedEvent) {
// ok
eventResult = true;
}
break;
}
case 39:
{
if (structuredDocumentEvent instanceof RegionChangedEvent) {
// ok
eventResult = true;
}
break;
}
case 40:
{
if (structuredDocumentEvent instanceof StructuredDocumentRegionsReplacedEvent) {
// ok
eventResult = true;
}
break;
}
case GENERIC_NODES_REPLACED_EVENT_CASE:
{
if (structuredDocumentEvent instanceof StructuredDocumentRegionsReplacedEvent) {
// ok
eventResult = true;
}
break;
}
case GENERIC_REGIONS_REPLACED_EVENT_CASE:
{
if (structuredDocumentEvent instanceof RegionsReplacedEvent) {
// ok
eventResult = true;
}
break;
}
case GENERIC_REGION_CHANGED_EVENT_CASE:
{
if (structuredDocumentEvent instanceof RegionChangedEvent) {
// ok
eventResult = true;
}
break;
}
case GENERIC_NEW_MODEL_EVENT_CASE:
{
if (structuredDocumentEvent instanceof NewDocumentEvent) {
// ok
eventResult = true;
}
break;
}
case GENERIC_NO_CHANGE_EVENT_CASE:
{
if (structuredDocumentEvent instanceof NoChangeEvent) {
// ok
eventResult = true;
}
break;
}
default:
{
if (structuredDocumentEvent instanceof NewDocumentEvent) {
// ok
eventResult = true;
}
}
}
}
Aggregations