use of org.eclipse.wst.css.core.internal.parser.CSSSourceParser in project webtools.sourceediting by eclipse.
the class CSSStyleDeclItemImpl method setCssValueTextCore.
private void setCssValueTextCore(String value) throws DOMException {
CSSSourceParser parser = new CSSSourceParser();
parser.setParserMode(CSSSourceParser.MODE_DECLARATION_VALUE);
parser.reset(value);
IStructuredDocumentRegion node = parser.getDocumentRegions();
if (node == null) {
return;
}
if (node.getNext() != null) {
// $NON-NLS-1$
throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");
}
CSSDeclarationItemParser itemParser = new CSSDeclarationItemParser(getOwnerDocument());
itemParser.setStructuredDocumentTemporary(true);
// make a copy of nodelist because setupValues will destroy list
ITextRegionList nodeList = new TextRegionListImpl(node.getRegions());
List nodeValuesList = new ArrayList();
;
for (int i = 0; i < nodeList.size(); i++) {
ITextRegion textRegion = nodeList.get(i);
nodeValuesList.add(value.substring(textRegion.getStart(), textRegion.getTextEnd()));
}
itemParser.setupValues(this, node, nodeList, nodeValuesList);
}
use of org.eclipse.wst.css.core.internal.parser.CSSSourceParser in project webtools.sourceediting by eclipse.
the class StyleAttrAdapter method getModel.
/**
*/
public ICSSModel getModel() {
ICSSModel model = getExistingModel();
if (model == null && isModelNecessary()) {
model = createModel();
if (model == null)
return null;
IStructuredDocument structuredDocument = model.getStructuredDocument();
if (structuredDocument == null)
return null;
RegionParser parser = structuredDocument.getParser();
if (parser instanceof CSSSourceParser) {
((CSSSourceParser) parser).setParserMode(CSSSourceParser.MODE_DECLARATION);
} else {
return null;
}
structuredDocument.addDocumentChangedListener(this);
// need to set before valueChanged()
setModel(model);
valueChanged();
}
if (model != null && !isModelNecessary()) {
model = null;
valueChanged();
}
return model;
}
Aggregations