Search in sources :

Example 1 with JpsIntelliLangConfiguration

use of org.jetbrains.jps.intellilang.model.JpsIntelliLangConfiguration in project intellij-community by JetBrains.

the class PatternValidatorBuilder method instrument.

@Nullable
@Override
protected BinaryContent instrument(CompileContext context, CompiledClass compiled, ClassReader reader, ClassWriter writer, InstrumentationClassFinder finder) {
    final JpsIntelliLangConfiguration config = JpsIntelliLangExtensionService.getInstance().getConfiguration(context.getProjectDescriptor().getModel().getGlobal());
    final PatternInstrumenter instrumenter = new PatternInstrumenter(config.getPatternAnnotationClass(), writer, config.getInstrumentationType(), finder);
    try {
        reader.accept(instrumenter, 0);
        if (instrumenter.instrumented()) {
            return new BinaryContent(writer.toByteArray());
        }
    } catch (InstrumentationException e) {
        context.processMessage(new CompilerMessage(getPresentableName(), BuildMessage.Kind.ERROR, e.getMessage()));
    }
    return null;
}
Also used : CompilerMessage(org.jetbrains.jps.incremental.messages.CompilerMessage) BinaryContent(org.jetbrains.jps.incremental.BinaryContent) JpsIntelliLangConfiguration(org.jetbrains.jps.intellilang.model.JpsIntelliLangConfiguration) InstrumentationException(org.jetbrains.jps.intellilang.model.InstrumentationException) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Nullable (org.jetbrains.annotations.Nullable)1 BinaryContent (org.jetbrains.jps.incremental.BinaryContent)1 CompilerMessage (org.jetbrains.jps.incremental.messages.CompilerMessage)1 InstrumentationException (org.jetbrains.jps.intellilang.model.InstrumentationException)1 JpsIntelliLangConfiguration (org.jetbrains.jps.intellilang.model.JpsIntelliLangConfiguration)1