private String[] getContentLines(Problem problem) { try { LessSource source = problem.getSource(); if (source==null) return new String[0]; String content = source.getContent(); if (content == null) return new String[0]; return content.split("\n"); } catch (FileNotFound e) { } catch (CannotReadFile e) { } return new String[0]; }
private String toSourceContent(HiddenTokenAwareTree underlyingStructure, String sourceName, LessSource source) { if (configuration.isIncludeSourcesContent() || sourceName==null || includeContentOf.contains(source)) { if (cachedContent.containsKey(source)) { return cachedContent.get(source); } String content; try { content = source.getContent(); } catch (FileNotFound e) { throw new BugHappened("How did we compiled something we did not read?", underlyingStructure); } catch (CannotReadFile e) { throw new BugHappened("How did we compiled something we did not read?", underlyingStructure); } cachedContent.put(source, content); return content; } else { return null; } }
private StyleSheet getImportedAst(Import node, LessSource source) throws FileNotFound, CannotReadFile { StyleSheet importedAst = (StyleSheet) astCache.getAst(source); if (importedAst == null) { importedAst = parseContent(node, source.getContent(), source); astCache.setAst(source, importedAst); } return importedAst.clone(); }
private ParseResult toAntlrTree(LessSource source) throws Less4jException { ParseResult result; try { result = parser.parseStyleSheet(source.getContent(), source); } catch (FileNotFound ex) { throw new Less4jException(new GeneralProblem("The file " + source + " does not exists."), new CompilationResult(null)); } catch (CannotReadFile ex) { throw new Less4jException(new GeneralProblem("Cannot read the file " + source + "."), new CompilationResult(null)); } if (result.hasErrors()) { CompilationResult compilationResult = new CompilationResult("Errors during parsing phase, partial result is not available."); throw new Less4jException(result.getErrors(), compilationResult); } return result; }
try { if (importNode.isInline()) { ASTCssNode importedNode = replaceByInlineValue(importNode, importedSource.getContent()); alreadyImportedSources.add(importedSource); configureVisibilityBlocks(importNode, Arrays.asList(importedNode));