Comparision with IntelliJ code completion engine?

Answered

Hello all,

I'm a Masters student and working on a code-suggestion engine. For reporting my results, I would like to compare my results with IntelliJ's code suggestion engine.

Is there a way I can trigger IntelliJ's code-suggestion from the command line for an input source file?

Any comments would be very useful. Thank you for your help.

Best wishes,

Yichen

5 comments

IntelliJ IDEA Community edition has a lot of code completion unit tests, they can be run on the CI server or manually: https://github.com/JetBrains/intellij-community/tree/master/java/java-tests/testSrc/com/intellij/codeInsight/completion.

0

Hi Serge,

Thank you for your reply.

I have spent some time to look at the build file of the IntelliJ-community project, and I am able to run the test defined in the build file. But I couldn't find a way to run those unit tests specifically for code completion. 

I have seen that in the build file the "test" is defined as:

<target name="test" depends="init">
<call_gant script="${project.home}/build/scripts/tests_in_community.gant"/>
</target>

Then I went to /tests_in_community.gant file and I can see that there is a piece of code for triggering the test:

target("default": "Run tests") {
String home = IdeaProjectLoader.guessHome(this)
String outputDir = "$home/out/tests"
def context = CompilationContextImpl.create(home, home, outputDir, this)
TestingTasks.create(context).runTests([], "community-main", null)
}

I'm not an expert of unit testing, after spend a few hours I couldn't find a way to run the unit tests just for code completion module. Do I need to change the argument of "community-main" in runTests() to something else in order to run the unite tests for code completion? May I ask what do I need to change? Many thanks.

Yichen

0

Do you run this from inside IDE? Then you can select the module java-tests in the project view and run all tests there.

Anna

0

Hi Anna,

Thanks for your reply! I was building the project from command line using ant. I have tried your suggestion, it works! I didn't know IntelliJ can do this so easily, awesome!

Yichen

0

Hello All,

Sorry to bring up this question again. With Anna's answer I can run it inside the IDE but because of the requirement of my project, I still have to run the code completion unit tests outside IntelliJ IDEA (in command line locally on my computer).

I'm not familiar with unit testing frameworks, could anyone tell me how to do that? I can use ant to run all the tests by calling "ant test" which is a target defined in the build.xml file, but I couldn't figure out the way to run just a subset of test cases.

Is there any documentation about test frameworks used by IntelliJ IDEA project I can read about, to help me understand and get on to the right track? 

Many thanks!

Yichen

0

Please sign in to leave a comment.