use of org.eclipse.wst.css.core.internal.metamodel.CSSMMNode in project webtools.sourceediting by eclipse.
the class CSSMetaModelTest method testDisplayPropertyValues2r1.
public void testDisplayPropertyValues2r1() {
CSSMetaModel model = CSSProfileRegistry.getInstance().getDefaultProfile().getMetaModel();
if (model != null) {
CSSMetaModelUtil util = new CSSMetaModelUtil(model);
CSSMMProperty property = util.getProperty(PropCMProperty.P_DISPLAY);
Iterator it = property.getValues();
Set set = new HashSet(1);
set.add(IValID.V_INLINE_BLOCK);
while (it.hasNext()) {
CSSMMNode node = (CSSMMNode) it.next();
if (set.contains(node.getName())) {
assertEquals("Property should be a keyword", CSSMMNode.TYPE_KEYWORD, node.getType());
set.remove(node.getName());
}
}
assertTrue("The content property is missing values added for CSS 2 revision 1.", set.isEmpty());
}
}
use of org.eclipse.wst.css.core.internal.metamodel.CSSMMNode in project webtools.sourceediting by eclipse.
the class CSSMetaModelTest method testWhitespacePropertyValues2r1.
public void testWhitespacePropertyValues2r1() {
CSSMetaModel model = CSSProfileRegistry.getInstance().getDefaultProfile().getMetaModel();
if (model != null) {
CSSMetaModelUtil util = new CSSMetaModelUtil(model);
CSSMMProperty property = util.getProperty(PropCMProperty.P_WHITE_SPACE);
Iterator it = property.getValues();
Set set = new HashSet(1);
set.add(IValID.V_PRE_LINE);
set.add(IValID.V_PRE_WRAP);
while (it.hasNext()) {
CSSMMNode node = (CSSMMNode) it.next();
if (set.contains(node.getName())) {
assertEquals("Property should be a keyword", CSSMMNode.TYPE_KEYWORD, node.getType());
set.remove(node.getName());
}
}
assertTrue("The content property is missing values added for CSS 2 revision 1.", set.isEmpty());
}
}
use of org.eclipse.wst.css.core.internal.metamodel.CSSMMNode in project webtools.sourceediting by eclipse.
the class CSSProposalGeneratorForDeclarationValue method getCandidates.
/**
* getCandidates method comment.
*/
protected Iterator getCandidates() {
List candidates = new ArrayList();
// check should add semi-colon or not
checkSemiColon();
String name = getPropertyName();
if (name != null) {
CSSMetaModelUtil util = new CSSMetaModelUtil(fContext.getMetaModel());
Iterator i = Collections.EMPTY_LIST.iterator();
if (isFontFaceRule()) {
CSSMMDescriptor desc = util.getDescriptor(name);
if (desc != null) {
i = desc.getValues();
}
} else {
CSSMMProperty prop = util.getProperty(name);
if (prop != null) {
i = prop.getValues();
}
}
while (i.hasNext()) {
CSSMMNode val = (CSSMMNode) i.next();
String valueType = val.getType();
if (valueType == CSSMMNode.TYPE_KEYWORD) {
addString(candidates, val.toString());
} else if (valueType == CSSMMNode.TYPE_NUMBER) {
addNumber(candidates, (CSSMMNumber) val);
} else if (valueType == CSSMMNode.TYPE_FUNCTION) {
addFunction(candidates, (CSSMMFunction) val);
}
}
}
addImportant(candidates);
addSemiColon(candidates);
return candidates.iterator();
}
use of org.eclipse.wst.css.core.internal.metamodel.CSSMMNode in project webtools.sourceediting by eclipse.
the class CSSProposalGeneratorForDeclarationName method getCandidates.
/**
* getCandidates method comment.
*/
protected Iterator getCandidates() {
List candidates = new ArrayList();
Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
// $NON-NLS-1$
String preDelim = "";
for (int i = 0; i < preferences.getInt(CSSCorePreferenceNames.FORMAT_PROP_PRE_DELIM); i++) {
// $NON-NLS-1$
preDelim += ' ';
}
// $NON-NLS-1$
String postDelim = "";
for (int i = 0; i < preferences.getInt(CSSCorePreferenceNames.FORMAT_PROP_POST_DELIM); i++) {
// $NON-NLS-1$
postDelim += ' ';
}
ICSSNode targetNode = fContext.getTargetNode();
boolean bFontRule = false;
for (ICSSNode node = targetNode; node != null; node = node.getParentNode()) {
if (node instanceof org.w3c.dom.css.CSSFontFaceRule) {
bFontRule = true;
break;
}
}
List names = new ArrayList();
CSSMetaModelUtil util = new CSSMetaModelUtil(fContext.getMetaModel());
Iterator iNames = util.collectNodesByType((bFontRule) ? CSSMMNode.TYPE_DESCRIPTOR : CSSMMNode.TYPE_PROPERTY);
while (iNames.hasNext()) {
CSSMMNode node = (CSSMMNode) iNames.next();
names.add(node);
}
sortNames(names);
// Collections.sort(names);
boolean bAddColon = true;
if ((targetNode instanceof ICSSStyleRule || targetNode instanceof ICSSStyleDeclItem || targetNode instanceof ICSSStyleDeclaration) && fContext.targetHas(CSSRegionContexts.CSS_DECLARATION_SEPARATOR)) {
bAddColon = false;
}
Iterator i = names.iterator();
while (i.hasNext()) {
CSSMMNode node = (CSSMMNode) i.next();
String text = node.getName();
text = (preferences.getInt(CSSCorePreferenceNames.CASE_PROPERTY_NAME) == CSSCorePreferenceNames.UPPER) ? text.toUpperCase() : text.toLowerCase();
if (!isMatch(text)) {
continue;
}
int cursorPos = 0;
StringBuffer buf = new StringBuffer();
buf.append(text);
buf.append(preDelim);
cursorPos = buf.length();
if (bAddColon) {
// $NON-NLS-1$
buf.append(':');
buf.append(postDelim);
cursorPos += 1 + postDelim.length();
}
// if (! (targetNode instanceof ICSSStyleDeclItem)) {
// buf.append(';');//$NON-NLS-1$
// }
CSSCACandidate item = new CSSCACandidate();
item.setReplacementString(buf.toString());
item.setCursorPosition(cursorPos);
item.setDisplayString(text);
item.setMMNode(node);
item.setImageType(getCategoryImageType(node));
candidates.add(item);
}
return candidates.iterator();
}
use of org.eclipse.wst.css.core.internal.metamodel.CSSMMNode in project webtools.sourceediting by eclipse.
the class ProfileHandler method endDocument.
public void endDocument() throws SAXException {
new ErrorCorrector().doCorrect(fMetaModel);
if (fLogging) {
Iterator i = fNodePool.getStrayNodes();
while (i.hasNext()) {
CSSMMNode node = (CSSMMNode) i.next();
// $NON-NLS-1$
String str = "[CSSProfile Warning] " + node.getName();
// $NON-NLS-1$ //$NON-NLS-2$
str += "(" + node.getType() + ") is not referred by any node.";
Logger.log(Logger.WARNING, str);
// System.out.println(str);
}
}
}
Aggregations