Make implementation link between different languages
Hello.
Please help me with understanding how to implement PSI "implementation link" between interface in one language and implementation in another.
I'm developing ICE framework support plugin. The framework have own language (Slice) for own files. The Slice scripts are translated into java code. To hide generated code from user, I'd like to have navigation from Slice file to Java implementation.
For example:
Slice file:
{code}
// **********************************************************************
//
// Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
#ifndef HELLO_ICE
#define HELLO_ICE
module Demo
{
interface Hello
{
idempotent void sayHello(int delay);
void shutdown();
};
};
#endif
{code}
ICE generates a java files which could be used like
{code}
// **********************************************************************
//
// Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
import Demo.*;
public class HelloI extends _HelloDisp
{
public void
sayHello(int delay, Ice.Current current)
{
if(delay > 0)
{
try
{
Thread.currentThread().sleep(delay);
}
catch(InterruptedException ex1)
{
}
}
System.out.println("Hello World!");
}
public void
shutdown(Ice.Current current)
{
System.out.println("Shutting down...");
current.adapter.getCommunicator().shutdown();
}
}
{code}
_HelloDisp - is class generated by ICE.
So, I want to have 'implemented' icon on 'void shutdown();' line in ice file and go to 'public void shutdown(Ice.Current current)' method in java file after click on the icon.
Thanks.
请先登录再写评论。
You need to implement LineMarkerProvider and register it as a codeInsight.lineMarkerProvider extension point for your language.
Is there a good example exists to learn?
Any open-source plugin to see?
Any language plugin. And lots of implementations in IDEA itself.
As far as I understand, this is is one-way method for showing icons only in my files.
I need something else:
ICE generated a Java class based on Slice declarations. The class is used in code.
I want to have 'implemented' icon in java code without real generating IDE Java file.
How to register a fake(?) method/class to allow it to be resolved?
Not sure I got what do you want.
You have a Slice file with some declarations. And you have a Java file which has implementations (not yet) generated from those declarations. Where do you want to put the icon?
Slice2java compiler generates java files based on a slice file.
Then the generated files could be used in own project.
Example:
hello.ice produces Hello.java. All public methods in generated Hello class which are declared in hello.ice are abstract.
Class Hello is extended by HelloImpl class and the HelloImlp class implements the abstract methods.
This is normal process.
I want next:
Allow to show 'implemented' link from hello.ice to HelloImpl class (and vise versa) _without_ invoking slice2java compiler and allows to search usages of methods, declared in hello.ice.
Also allow to user to write
class HelloImpl extends Hello {
}
with resolved class Hello (also - without slice2java compilation)
Then I could safely gengerate Java files before real compilation and include them into source path.
Take a look on a Groovy plugin sources starting from a GroovyLineMarkerProvider class.