use of org.eclipse.wst.css.core.internal.parser.CSSSourceParser in project webtools.sourceediting by eclipse.
the class TestCSSDecl method testCSSStyleDeclItemMODE_DECLARATION.
public void testCSSStyleDeclItemMODE_DECLARATION() {
String value = "color: blue;";
IDocumentLoader loader = new CSSDocumentLoader();
IStructuredDocument sharedStructuredDocument = (IStructuredDocument) loader.createNewStructuredDocument();
((CSSSourceParser) sharedStructuredDocument.getParser()).setParserMode(CSSSourceParser.MODE_DECLARATION);
sharedStructuredDocument.set(value);
IStructuredDocumentRegion region = sharedStructuredDocument.getFirstStructuredDocumentRegion();
assertNotNull(region);
}
use of org.eclipse.wst.css.core.internal.parser.CSSSourceParser in project webtools.sourceediting by eclipse.
the class TestCSSDecl method testCSSStyleDeclItem.
public void testCSSStyleDeclItem() {
String value = "color: blue;";
IDocumentLoader loader = new CSSDocumentLoader();
IStructuredDocument sharedStructuredDocument = (IStructuredDocument) loader.createNewStructuredDocument();
((CSSSourceParser) sharedStructuredDocument.getParser()).setParserMode(CSSSourceParser.MODE_DECLARATION_VALUE);
sharedStructuredDocument.set(value);
IStructuredDocumentRegion region = sharedStructuredDocument.getFirstStructuredDocumentRegion();
assertNotNull(region);
}
use of org.eclipse.wst.css.core.internal.parser.CSSSourceParser in project webtools.sourceediting by eclipse.
the class CSSUrlTest method testDeclaration4.
/**
* Declaration: with double quote
*/
public void testDeclaration4() {
ICSSModel model = FileUtil.createModel();
IStructuredDocument document = model.getStructuredDocument();
((CSSSourceParser) document.getParser()).setParserMode(CSSSourceParser.MODE_DECLARATION_VALUE);
// $NON-NLS-1$
document.set("background-image: url(\"white space.gif\");");
UrlInfo[] urls = pickupUrl(document);
assertEquals(1, urls.length);
assertEquals(CSSRegionContexts.CSS_DECLARATION_VALUE_URI, urls[0].getType());
// $NON-NLS-1$
assertEquals("white space.gif", urls[0].getUrl());
}
use of org.eclipse.wst.css.core.internal.parser.CSSSourceParser in project webtools.sourceediting by eclipse.
the class CSSUrlTest method testDeclaration5.
/**
* Declaration: two urls
*/
public void testDeclaration5() {
ICSSModel model = FileUtil.createModel();
IStructuredDocument document = model.getStructuredDocument();
((CSSSourceParser) document.getParser()).setParserMode(CSSSourceParser.MODE_DECLARATION_VALUE);
// $NON-NLS-1$
document.set("background-image: url(white space.gif); list-style-image: url(style image.gif);");
UrlInfo[] urls = pickupUrl(document);
assertEquals(2, urls.length);
assertEquals(CSSRegionContexts.CSS_DECLARATION_VALUE_URI, urls[0].getType());
// $NON-NLS-1$
assertEquals("white space.gif", urls[0].getUrl());
assertEquals(CSSRegionContexts.CSS_DECLARATION_VALUE_URI, urls[1].getType());
// $NON-NLS-1$
assertEquals("style image.gif", urls[1].getUrl());
}
use of org.eclipse.wst.css.core.internal.parser.CSSSourceParser in project webtools.sourceediting by eclipse.
the class CSSUrlTest method testFixError1.
/**
* Declaration: Two urls but parenthesis are missed, so concatenated url
* is identified. By adding parenthesis, urls are corrected.
*/
public void testFixError1() {
ICSSModel model = FileUtil.createModel();
IStructuredDocument document = model.getStructuredDocument();
((CSSSourceParser) document.getParser()).setParserMode(CSSSourceParser.MODE_DECLARATION_VALUE);
// ____________01234567890123456789012345678901234567890123456789012345678901234567890123456789
// $NON-NLS-1$
document.set("background-image: url(white space.gif; list-style-image: urlstyle image.gif);");
UrlInfo[] urls = pickupUrl(document);
assertEquals(1, urls.length);
assertEquals(CSSRegionContexts.CSS_DECLARATION_VALUE_URI, urls[0].getType());
// $NON-NLS-1$
assertEquals("white space.gif; list-style-image: urlstyle image.gif", urls[0].getUrl());
// correct first url
// $NON-NLS-1$
document.replaceText(null, 37, 0, ")");
urls = pickupUrl(document);
assertEquals(1, urls.length);
assertEquals(CSSRegionContexts.CSS_DECLARATION_VALUE_URI, urls[0].getType());
// $NON-NLS-1$
assertEquals("white space.gif", urls[0].getUrl());
// correct second url
// $NON-NLS-1$
document.replaceText(null, 61, 0, "(");
urls = pickupUrl(document);
assertEquals(2, urls.length);
assertEquals(CSSRegionContexts.CSS_DECLARATION_VALUE_URI, urls[0].getType());
// $NON-NLS-1$
assertEquals("white space.gif", urls[0].getUrl());
assertEquals(CSSRegionContexts.CSS_DECLARATION_VALUE_URI, urls[1].getType());
// $NON-NLS-1$
assertEquals("style image.gif", urls[1].getUrl());
}
Aggregations