I want to create an IntelliJ Idea plugin that
- detects that a specific Kotlin class appears in the source code file (e.g.
SomeGraph) and - if such a class executes code and displays the result in the sidebar.
Kotlin code as a minor DSL.

For example, let's say I have the following code snippet:
val vertex1 = GraphElement()
val vertex2 = GraphElement()
fun main(args : Array<String>) {
val myGraph = SomeGraph()
myGraph.addEdge(vertex1, vertex2)
}
myGraph.toDot()will return the Graphviz Dot graph ( digraph G {...) code .
My plugin should take this text, let Dot visualize the graph and display the graph.
Is it technically possible? If so, how can I execute part of the Kotlin code inside the IntelliJ plugin?
Notes:
- A DSL file does not require a function
main. If this simplifies the situation, I can change the place of creation SomeGraph.
. . DSL- :
class SpecialCaseGraph : SomeGraph() {
fun init() {
val vertex1 = GraphElement()
val vertex2 = GraphElement()
myGraph.addEdge(vertex1, vertex2)
}
fun toDot():String {
}
}
- PlantUML - . , , , ( PlantUML, Dot-).

1 (02.09.2017 19:53 MSK):
ScriptEngine Kotlin, , Kotlin.
ScriptEngineManager mgr = new ScriptEngineManager();
List<ScriptEngineFactory> factories = mgr.getEngineFactories();
for (ScriptEngineFactory factory : factories) {
System.out.println("ScriptEngineFactory Info");
String engName = factory.getEngineName();
String engVersion = factory.getEngineVersion();
String langName = factory.getLanguageName();
String langVersion = factory.getLanguageVersion();
System.out.printf("\tScript Engine: %s (%s)%n", engName, engVersion);
List<String> engNames = factory.getNames();
for(String name : engNames) {
System.out.printf("\tEngine Alias: %s%n", name);
}
System.out.printf("\tLanguage: %s (%s)%n", langName, langVersion);
}
, Kotlin, .
