use of org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent in project webtools.sourceediting by eclipse.
the class JSPReParser method checkForJSP.
/**
* A change to a JSP tag can result in all being reparsed.
*/
private StructuredDocumentEvent checkForJSP() {
StructuredDocumentEvent result = null;
// $NON-NLS-1$
result = checkForCriticalKey("<%");
if (result == null)
// $NON-NLS-1$
result = checkForCriticalKey("<%=");
if (result == null)
// $NON-NLS-1$
result = checkForCriticalKey("<%!");
if (result == null)
// $NON-NLS-1$
result = checkForCriticalKey("%>");
return result;
}
use of org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent in project webtools.sourceediting by eclipse.
the class AbstractNodeCleanupHandler method replaceSource.
protected static StructuredDocumentEvent replaceSource(IDOMModel model, Object requester, int offset, int length, String source) {
StructuredDocumentEvent result = null;
if (model == null)
return result;
IStructuredDocument structuredDocument = model.getStructuredDocument();
if (structuredDocument == null)
return result;
if (source == null)
source = new String();
if (structuredDocument.containsReadOnly(offset, length))
return result;
if (requester == null) {
requester = structuredDocument;
}
return structuredDocument.replaceText(requester, offset, length, source);
}
use of org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent in project webtools.sourceediting by eclipse.
the class JSONStructuredDocumentReParser method checkInsideBrace.
private StructuredDocumentEvent checkInsideBrace(int start, int end) {
StructuredDocumentEvent result = null;
IStructuredDocumentRegion region = fStructuredDocument.getRegionAtCharacterOffset(start);
if (region == null) {
return null;
}
boolean bDeclaration = false;
String type = region.getType();
// if (JSONRegionUtil.isDeclarationType(type) || type ==
// JSONRegionContexts.JSON_LBRACE || type ==
// JSONRegionContexts.JSON_RBRACE) {
// bDeclaration = true;
// }
// if (!bDeclaration) {
// IStructuredDocumentRegion prevRegion =
// JSONUtil.findPreviousSignificantNode(region);
// if (prevRegion != null) {
// type = prevRegion.getType();
// if (JSONRegionUtil.isDeclarationType(type) || type ==
// JSONRegionContexts.JSON_LBRACE) {
// bDeclaration = true;
// }
// }
// }
// if (!bDeclaration) {
// IStructuredDocumentRegion nextRegion =
// JSONUtil.findNextSignificantNode(region);
// if (nextRegion != null) {
// type = nextRegion.getType();
// if (JSONRegionUtil.isDeclarationType(type) || type ==
// JSONRegionContexts.JSON_RBRACE) {
// bDeclaration = true;
// }
// }
// }
bDeclaration = true;
if (bDeclaration) {
IStructuredDocumentRegion startRegion = findRuleStart(region);
if (startRegion != null) {
IStructuredDocumentRegion endRegion = fStructuredDocument.getRegionAtCharacterOffset(end);
if (endRegion != null) {
result = reparse(startRegion, endRegion);
}
}
}
return result;
}
use of org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent in project webtools.sourceediting by eclipse.
the class JSONStructuredDocumentReParser method checkForCrossStructuredDocumentRegionSyntax.
/**
*/
// public StructuredDocumentEvent
// checkForCrossStructuredDocumentRegionBoundryCases2() {
// StructuredDocumentEvent result = specialPositionUpdate(fStart, fStart +
// fLengthToReplace - 1);
// if (result == null) {
// result = checkInsideBrace();
// }
// return result;
// }
@Override
protected StructuredDocumentEvent checkForCrossStructuredDocumentRegionSyntax() {
int checkStart = fStart;
int checkEnd = fStart + fLengthToReplace - 1;
IStructuredDocumentRegion endRegion = fStructuredDocument.getRegionAtCharacterOffset(checkEnd);
if (endRegion != null) {
checkEnd = endRegion.getEndOffset();
}
ReparseRange range = new ReparseRange(checkStart, checkEnd);
range.expand(getUpdateRangeForDelimiter(range.getStart(), range.getEnd()));
range.expand(getUpdateRangeForUnknownRegion(range.getStart(), range.getEnd()));
// range.expand(getUpdateRangeForQuotes(range.getStart(),
// range.getEnd()));
// range.expand(getUpdateRangeForComments(range.getStart(),
// range.getEnd()));
range.expand(getUpdateRangeForBraces(range.getStart(), range.getEnd()));
StructuredDocumentEvent result;
result = checkInsideBrace(range.getStart(), range.getEnd());
if (result == null) {
result = reparse(range.getStart(), range.getEnd());
}
return result;
}
use of org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent in project webtools.sourceediting by eclipse.
the class RegionChangedAdapterNotificationTests method testReplaceTrailingSpaceofEqualSignWithTwoSpaces.
public void testReplaceTrailingSpaceofEqualSignWithTwoSpaces() throws IOException {
IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(getName() + ".xml", new NullInputStream(), null);
try {
Document document = model.getDocument();
IStructuredDocument structuredDocument = model.getStructuredDocument();
structuredDocument.setText(this, "<a b= c></a>");
Node before = document.getFirstChild();
final int[] changed = new int[] { -1 };
INodeAdapter adapter = new INodeAdapter() {
public boolean isAdapterForType(Object type) {
return type.equals(RegionChangedAdapterNotificationTests.class);
}
public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
changed[0] = eventType;
}
};
((INodeNotifier) before).addAdapter(adapter);
Object[] originalRegions = structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray();
StructuredDocumentEvent fmEvent = structuredDocument.replaceText(null, 5, 0, " ");
assertTrue("Region instances changed", Arrays.equals(originalRegions, structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray()));
assertTrue(fmEvent instanceof RegionChangedEvent);
Node after = document.getFirstChild();
assertEquals("Node replaced", before, after);
assertEquals("unexpected adapter notification event sent " + structuredDocument.get(), -1, changed[0]);
assertEquals("unexpected document content", "<a b= c></a>", structuredDocument.get());
} finally {
model.releaseFromEdit();
}
}
Aggregations