use of org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue in project webtools.sourceediting by eclipse.
the class CSSDeclarationItemParser method setupValues.
/**
* nodeRegions must be broken. If you need after, make copy of them.
*/
private void setupValues(ICSSStyleDeclItem item, ITextRegionList nodeRegions, List propertyValueList) {
if (item == null) {
return;
}
ICSSPrimitiveValue value;
ITextRegionList regionBuf = new TextRegionListImpl();
String propertyName = item.getPropertyName().toLowerCase();
boolean bFont = (propertyName.equals(PropCMProperty.P_FONT));
// (short-hand) font
String propertyValue = null;
int status = (propertyName.equals(PropCMProperty.P_VOICE_FAMILY) || propertyName.equals(PropCMProperty.P_FONT_FAMILY)) ? S_COMMA_SEPARATION : S_NORMAL;
while (!nodeRegions.isEmpty()) {
value = null;
ITextRegion region = nodeRegions.remove(0);
if (region == null) {
continue;
}
if (propertyValueList != null && !propertyValueList.isEmpty()) {
propertyValue = (String) propertyValueList.remove(0);
}
String type = region.getType();
// }
switch(status) {
case S_NORMAL:
if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION) {
regionBuf.add(region);
regionValues.put(region, propertyValue);
status = S_FUNCTION;
} else if (bFont && type == CSSRegionContexts.CSS_DECLARATION_VALUE_OPERATOR && isValueRegionEqual(region, propertyValue, "/")) {
// $NON-NLS-1$
value = createPrimitiveValue(region, propertyValue);
status = S_FONT_SLASH;
} else if (!isBlank(type)) {
value = createPrimitiveValue(region, propertyValue);
}
break;
case S_FUNCTION:
if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE) {
regionBuf.add(region);
regionValues.put(region, propertyValue);
value = createPrimitiveValue(regionBuf);
regionBuf.clear();
regionValues.clear();
status = S_NORMAL;
} else if (!isBlank(type)) {
regionBuf.add(region);
regionValues.put(region, propertyValue);
}
break;
case S_FONT_SLASH:
if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_DIMENSION) {
value = createPrimitiveValue(region, propertyValue);
status = S_COMMA_SEPARATION;
} else if (!isBlank(type)) {
value = createPrimitiveValue(region, propertyValue);
}
break;
case S_COMMA_SEPARATION:
if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_OPERATOR && isValueRegionEqual(region, propertyValue, ",")) {
// $NON-NLS-1$
value = createPrimitiveValue(regionBuf);
regionBuf.clear();
regionValues.clear();
if (value != null) {
if (fUpdateContext == null || !fUpdateContext.isActive()) {
item.appendValue(value);
}
}
value = createPrimitiveValue(region, propertyValue);
} else {
regionBuf.add(region);
regionValues.put(region, propertyValue);
}
break;
default:
break;
}
if (value != null) {
if (fUpdateContext == null || !fUpdateContext.isActive()) {
item.appendValue(value);
}
}
}
if (!regionBuf.isEmpty()) {
value = createPrimitiveValue(regionBuf);
if (fUpdateContext == null || !fUpdateContext.isActive()) {
item.appendValue(value);
}
regionBuf.clear();
regionValues.clear();
}
}
Aggregations