Problem "Access to psi files shoud be performed only after startup activity"

Great!


I have next code:

public class Test extends LightCodeInsightFixtureTestCase {
    public void testMethod(){
        myFixture.addClass("package com.A; public class A {}");
        JavaPsiFacade.getInstance(getProject()).findClass("com.A", GlobalSearchScope.allScope(getProject()));
    }
}

After start, it throws next exception:

java.lang.AssertionError: Access to psi files should be performed only after startup activity

                at com.intellij.testFramework.LoggedErrorProcessor$1.processError(LoggedErrorProcessor.java:35)

                at com.intellij.testFramework.TestLogger.error(TestLogger.java:52)

                at com.intellij.openapi.diagnostic.Logger.error(Logger.java:54)

                at com.intellij.psi.impl.file.impl.JavaFileManagerBase.findClass(JavaFileManagerBase.java:169)

                at com.intellij.psi.impl.JavaPsiFacadeImpl$PsiElementFinderImpl.findClass(JavaPsiFacadeImpl.java:281)

                at com.intellij.psi.impl.JavaPsiFacadeImpl.findClass(JavaPsiFacadeImpl.java:109)

Intellij IDEA Version: 12.1.4

Thanks!

3 comments

com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture#addClass returns the just created class, no need for manual findClass() calls.

0

This is simplifed sample, i must use findClass in my work code.

Why findClass doesn' t work?

0

Please post full sources of your test or preferrably link to plugin sources repository.


0

Please sign in to leave a comment.