GithubHelp home page GithubHelp logo

Support warning/error messages about mpapt HOT 3 CLOSED

foso avatar foso commented on July 2, 2024
Support warning/error messages

from mpapt.

Comments (3)

Foso avatar Foso commented on July 2, 2024

Hi, i haven't documented it yet. But i wrote an extension method MessageCollector.printMessage(diagnosticKind: DiagnosticKind, message: String)
(in https://github.com/Foso/MpApt/blob/master/mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/utils/KaptUtils.kt)
to try to provide a similar api to the java annotation processor.

You can get the MessageCollector from the configuration like this:

val messager = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY,MessageCollector.NONE)
messager.printMessage(DiagnosticKind.ERROR,"My error message")

I will add it to the documentation

from mpapt.

evant avatar evant commented on July 2, 2024

👍 any plan to add an argument to pass the element the warning/error happened on?

from mpapt.

Foso avatar Foso commented on July 2, 2024

I hadn't considered this before, but i took a quick look how can be done with compiler api. I changed the printMessage() and added the CompilerMessageLocation as a parameter.

Inside your processor, you can use it like that:

configuration.messager().printMessage(DiagnosticKind.ERROR,"My error message", CompilerMessageLocation.Companion.create("/home/jens/Code/2019/MpApt/kotlin-plugin-shared/src/main/java/de/jensklingenberg/MpAptTestProcessor.kt",42,106))

This will print the message to the log and stop the compiler:

e: /home/jens/Code/2019/MpApt/kotlin-plugin-shared/src/main/java/de/jensklingenberg/MpAptTestProcessor.kt: (42, 106): My error message

I can't add an element parameter yet, because my element type doesn't have the (line,column)-Information. But i think it could be possible to get information out of a "descriptor"

from mpapt.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.