コード例 #1
0
  @Override
  protected void setUp() throws Exception {
    myMainOutput = new TempDirTestFixtureImpl();
    myMainOutput.setUp();
    super.setUp();
    getProject().getComponent(GroovyCompilerLoader.class).projectOpened();
    CompilerManagerImpl.testSetup();

    new WriteCommandAction(getProject()) {
      @Override
      protected void run(Result result) throws Throwable {
        //noinspection ConstantConditions
        CompilerProjectExtension.getInstance(getProject())
            .setCompilerOutputUrl(myMainOutput.findOrCreateDir("out").getUrl());
        if (useJps()) {
          ApplicationManagerEx.getApplicationEx().doNotSave(false);
          CompilerWorkspaceConfiguration.getInstance(getProject()).USE_COMPILE_SERVER = true;

          JavaAwareProjectJdkTableImpl jdkTable = JavaAwareProjectJdkTableImpl.getInstanceEx();
          Sdk internalJdk = jdkTable.getInternalJdk();
          jdkTable.addJdk(internalJdk);
          ModuleRootModificationUtil.setModuleSdk(myModule, internalJdk);
        }
      }
    }.execute();
  }
コード例 #2
0
  @Before
  public void setUp() throws Exception {
    Runner.initLogger();
    myTempDirFixture = IdeaTestFixtureFactory.getFixtureFactory().createTempDirTestFixture();
    myTempDirFixture.setUp();

    FileUtil.copyDir(PathManagerEx.findFileUnderCommunityHome("updater/testData"), getDataDir());

    boolean windowsLineEnds = new File(getDataDir(), "Readme.txt").length() == 7132;
    CHECKSUMS = new CheckSums(windowsLineEnds);
  }
コード例 #3
0
  public void testNonCodeClassUsages() throws Exception {
    final TempDirTestFixture tdf =
        IdeaTestFixtureFactory.getFixtureFactory().createTempDirTestFixture();
    tdf.setUp();

    try {
      new WriteCommandAction(getProject()) {
        @Override
        protected void run(Result result) throws Throwable {
          final ModifiableModuleModel moduleModel =
              ModuleManager.getInstance(getProject()).getModifiableModel();
          moduleModel.newModule("independent/independent.iml", StdModuleTypes.JAVA.getId());
          moduleModel.commit();

          tdf.createFile(
              "plugin.xml",
              "<document>\n"
                  + "  <action class=\"com.Foo\" />\n"
                  + "  <action class=\"com.Foo.Bar\" />\n"
                  + "  <action class=\"com.Foo$Bar\" />\n"
                  + "</document>");

          PsiTestUtil.addContentRoot(
              ModuleManager.getInstance(getProject()).findModuleByName("independent"),
              tdf.getFile(""));
        }
      }.execute();

      GlobalSearchScope scope = GlobalSearchScope.allScope(getProject());
      PsiClass foo = myJavaFacade.findClass("com.Foo", scope);
      PsiClass bar = myJavaFacade.findClass("com.Foo.Bar", scope);

      final int[] count = {0};
      Processor<UsageInfo> processor =
          new Processor<UsageInfo>() {
            @Override
            public boolean process(UsageInfo usageInfo) {
              int navigationOffset = usageInfo.getNavigationOffset();
              assertTrue(navigationOffset > 0);
              String textAfter = usageInfo.getFile().getText().substring(navigationOffset);
              assertTrue(
                  textAfter,
                  textAfter.startsWith("Foo")
                      || textAfter.startsWith("Bar")
                      || textAfter.startsWith(
                          "com.Foo.Bar") // sorry, can't get references with dollar-dot mismatch to
                  // work now
                  );
              count[0]++;
              return true;
            }
          };
      JavaFindUsagesHandler handler =
          new JavaFindUsagesHandler(bar, JavaFindUsagesHandlerFactory.getInstance(getProject()));

      count[0] = 0;
      handler.processUsagesInText(foo, processor, scope);
      assertEquals(3, count[0]);

      count[0] = 0;
      handler.processUsagesInText(bar, processor, scope);
      assertEquals(2, count[0]);
    } finally {
      tdf.tearDown();
    }
  }
コード例 #4
0
 public File getTempFile(String fileName) {
   return new File(myTempDirFixture.getTempDirPath(), fileName);
 }
コード例 #5
0
 @After
 public void tearDown() throws Exception {
   myTempDirFixture.tearDown();
   Utils.cleanup();
 }