public ProcessingException(Element element, AnnotationMirror annotation, MessageCode code, Object... arguments) { this(element, annotation, Collections.singletonList(new Message(code, arguments))); }
public ProcessingException(Element element, AnnotationMirror annotation, MessageCode code, Object... arguments) { this(element, annotation, Collections.singletonList(new Message(code, arguments))); }
public static Message parse(String s) { List<String> arguments = Collections.emptyList(); Matcher matcher = PATTERN.matcher(s); if (matcher.find()) { String codeKey = matcher.group(1); MessageCode code = MessageCode.decode(codeKey); if (matcher.group(2).length() > 0) { arguments = new ArrayList<String>(); for (String argument : SPLIT_PATTERN.split(matcher.group(2), 0)) { int prev = 0; while (true) { int pos = argument.indexOf('\\', prev); if (pos == -1) { break; } else { argument = argument.substring(0, pos) + argument.charAt(pos + 1) + argument.substring(pos + 2); prev = pos + 2; } } arguments.add(argument); } } return new Message(code, arguments.toArray()); } else { return null; } }
public static Message parse(String s) { List<String> arguments = Collections.emptyList(); Matcher matcher = PATTERN.matcher(s); if (matcher.find()) { String codeKey = matcher.group(1); MessageCode code = MessageCode.decode(codeKey); if (matcher.group(2).length() > 0) { arguments = new ArrayList<String>(); for (String argument : SPLIT_PATTERN.split(matcher.group(2), 0)) { int prev = 0; while (true) { int pos = argument.indexOf('\\', prev); if (pos == -1) { break; } else { argument = argument.substring(0, pos) + argument.charAt(pos + 1) + argument.substring(pos + 2); prev = pos + 2; } } arguments.add(argument); } } return new Message(code, arguments.toArray()); } else { return null; } }
@Override public InputStream open(String s, URLConnection resource) throws IOException { LessCompiler compiler = new ThreadUnsafeLessCompiler(); try { LessCompiler.CompilationResult result = compiler.compile(resource.getURL()); return new ByteArrayInputStream(result.getCss().getBytes()); } catch (Less4jException e) { List<LessCompiler.Problem> errors = e.getErrors(); ArrayList<Message> messages = new ArrayList<Message>(errors.size()); for (LessCompiler.Problem error : errors) { String text = error.getMessage() != null ? error.getMessage() : "There is an error in your .less file"; String errorName = error.getType().name(); LessSource source = error.getSource(); Message msg; if (source != null) { msg = new Message(MetaModelPluginImpl.COMPILATION_ERROR, errorName, source.getName(), error.getLine(), text); } else { msg = new Message(MetaModelPluginImpl.GENERAL_PROBLEM, errorName, text); } MetaModelPluginImpl.log.info(msg.toDisplayString()); messages.add(msg); } throw new ProcessingException(messages); } } }
@Override public InputStream open(String s, URLConnection resource) throws IOException { LessCompiler compiler = new ThreadUnsafeLessCompiler(); try { LessCompiler.CompilationResult result = compiler.compile(resource.getURL()); return new ByteArrayInputStream(result.getCss().getBytes()); } catch (Less4jException e) { List<LessCompiler.Problem> errors = e.getErrors(); ArrayList<Message> messages = new ArrayList<Message>(errors.size()); for (LessCompiler.Problem error : errors) { String text = error.getMessage() != null ? error.getMessage() : "There is an error in your .less file"; String errorName = error.getType().name(); LessSource source = error.getSource(); Message msg; if (source != null) { msg = new Message(MetaModelPluginImpl.COMPILATION_ERROR, errorName, source.getName(), error.getLine(), text); } else { msg = new Message(MetaModelPluginImpl.GENERAL_PROBLEM, errorName, text); } MetaModelPluginImpl.log.info(msg.toDisplayString()); messages.add(msg); } throw new ProcessingException(messages); } } }
@Test public void testLineTerminator() { Message msg = new Message(TemplateMetaModel.CANNOT_WRITE_APPLICATION, "a\nb"); String s = msg.format(); msg = Message.parse(s); assertNotNull(msg); } }
index++; Message msg = new Message(COMPILATION_ERROR, text, error.src,
index++; Message msg = new Message(COMPILATION_ERROR, text, error.src,
@Test public void testLineTerminator() { Message msg = new Message(TemplateMetaModel.CANNOT_WRITE_APPLICATION, "a\nb"); String s = msg.format(); msg = Message.parse(s); assertNotNull(msg); } }