Browse Source

Prevent NPE when a SCSS file is not found #11099

Change-Id: Id0e0fd6a31f4089228b02bf8b66086d3f3a1727b
tags/7.0.2
John Ahlroos 11 years ago
parent
commit
b056c43954

+ 7
- 0
theme-compiler/src/com/vaadin/sass/SassCompiler.java View File

package com.vaadin.sass; package com.vaadin.sass;


import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;


// ScssStylesheet.setStylesheetResolvers(new VaadinResolver()); // ScssStylesheet.setStylesheetResolvers(new VaadinResolver());


ScssStylesheet scss = ScssStylesheet.get(input); ScssStylesheet scss = ScssStylesheet.get(input);
if(scss == null){
System.err.println("The scss file " + input
+ " could not be found.");
return;
}
scss.compile(); scss.compile();
if (output == null) { if (output == null) {
System.out.println(scss.toString()); System.out.println(scss.toString());

+ 10
- 2
theme-compiler/src/com/vaadin/sass/internal/ScssStylesheet.java View File

* ScssStylesheet tree out of it. Calling compile() on it will transform * ScssStylesheet tree out of it. Calling compile() on it will transform
* SASS into CSS. Calling toString() will print out the SCSS/CSS. * SASS into CSS. Calling toString() will print out the SCSS/CSS.
* *
* @param file
* @param identifier
* The file path. If null then null is returned.
* @return * @return
* @throws CSSException * @throws CSSException
* @throws IOException * @throws IOException
* builds up a ScssStylesheet tree out of it. Calling compile() on it will * builds up a ScssStylesheet tree out of it. Calling compile() on it will
* transform SASS into CSS. Calling toString() will print out the SCSS/CSS. * transform SASS into CSS. Calling toString() will print out the SCSS/CSS.
* *
* @param file
* @param identifier
* The file path. If null then null is returned.
* @param encoding * @param encoding
* @return * @return
* @throws CSSException * @throws CSSException
* *
* @charset declaration, the default one is ASCII. * @charset declaration, the default one is ASCII.
*/ */

if (identifier == null) {
return null;
}

// FIXME Is this actually intended? /John 1.3.2013
File file = new File(identifier); File file = new File(identifier);
file = file.getCanonicalFile(); file = file.getCanonicalFile();



Loading…
Cancel
Save