use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.
the class JSONObjectFormatter method formatPre.
@Override
protected void formatPre(IJSONNode node, IRegion region, StringBuilder source) {
IJSONCleanupStrategy stgy = getCleanupStrategy(node);
if (region.getOffset() >= 0 && region.getLength() >= 0) {
IStructuredDocument document = node.getOwnerDocument().getModel().getStructuredDocument();
CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(document, region, stgy);
if (regions.length > 0 && regions[0] != null && regions[0].getType() == JSONRegionContexts.JSON_OBJECT_OPEN) {
source.append(decoratedRegion(regions[0], 0, stgy));
}
}
source.append(getLineDelimiter(node));
source.append(getIndent(node));
source.append(getIndentString());
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.
the class UnknownRuleFormatter method formatPre.
@Override
protected void formatPre(IJSONNode node, IRegion region, StringBuilder source) {
IJSONCleanupStrategy stgy = getCleanupStrategy(node);
IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
for (int i = 0; i < regions.length; i++) {
if (i != 0 || needS(outside[0]))
appendSpaceBefore(node, regions[i], source);
source.append(decoratedPropValueRegion(regions[i], stgy));
}
if (needS(outside[1]) && !isIncludesPreEnd(node, region))
appendSpaceBefore(node, outside[1], source);
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.
the class UnknownRuleFormatter method formatPre.
@Override
protected void formatPre(IJSONNode node, StringBuilder source) {
IJSONCleanupStrategy stgy = getCleanupStrategy(node);
int start = ((IndexedRegion) node).getStartOffset();
int end = ((IndexedRegion) node).getEndOffset();
if (end > 0) {
// format source
IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
for (int i = 0; i < regions.length; i++) {
if (i != 0)
appendSpaceBefore(node, regions[i], source);
source.append(decoratedPropValueRegion(regions[i], stgy));
}
}
// else { // generate source
// JSONUnknownRule rule = (JSONUnknownRule) node;
// source.append(rule.getCssText());
// }
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.
the class JSPModelLoader method newStructuredDocument.
/**
* This method must return a new instance of IStructuredDocument, that has
* been initialized with appropriate parser. For many loaders, the
* (default) parser used is known for any input. For others, the correct
* parser (and its initialization) is normall dependent on the content of
* the file. This no-argument method should assume "empty input" and would
* therefore return the default parser for the default contentType.
*
* If the parser is to handle tag libraries, it must have a TaglibSupport
* object with a valid URIResolver and this IStructuredDocument attached
* to it before the contents are set on the IStructuredDocument.
*/
public IStructuredDocument newStructuredDocument() {
IStructuredDocument structuredDocument = StructuredDocumentFactory.getNewStructuredDocumentInstance(getParser());
((BasicStructuredDocument) structuredDocument).setReParser(new JSPReParser());
// structuredDocument.setDocumentPartitioner(new
// JSPJavaDocumentPartioner());
// even though this is an "empty model" ... we want it to have at
// least the
// default embeddeded content type handler
EmbeddedTypeHandler embeddedType = getJSPDefaultEmbeddedType(null);
embeddedType.initializeParser(structuredDocument.getParser());
return structuredDocument;
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.
the class AbstractJSONSourceFormatter method formatValue.
protected void formatValue(IJSONNode node, StringBuilder source, IJSONNode value) {
IJSONCleanupStrategy stgy = getCleanupStrategy(node);
IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
int start = node.getStartOffset();
int end = node.getEndOffset();
CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
if (regions.length > 2) {
for (int i = 2; i < regions.length; i++) {
source.append(decoratedRegion(regions[i], 0, stgy));
}
}
}
Aggregations