コード例 #1
0
  @Override
  protected CodeInsightTestFixture createTestFixture(IdeaProjectTestFixture fixture)
      throws Exception {

    JavaCodeInsightTestFixture codeInsightFixture =
        JavaTestFixtureFactory.getFixtureFactory()
            .createCodeInsightFixture(fixture, new LightTempDirTestFixtureImpl(true));

    codeInsightFixture.setTestDataPath(getTestRootPath());

    return codeInsightFixture;
  }
コード例 #2
0
  public static void checkCompletionContains(
      JavaCodeInsightTestFixture fixture, String... expectedVariants) {
    LookupElement[] lookupElements = fixture.completeBasic();

    Assert.assertNotNull(lookupElements);

    Set<String> missedVariants = CollectionFactory.hashSet(expectedVariants);

    for (LookupElement lookupElement : lookupElements) {
      String lookupString = lookupElement.getLookupString();
      missedVariants.remove(lookupString);

      Object object = lookupElement.getObject();
      if (object instanceof ResolveResult) {
        object = ((ResolveResult) object).getElement();
      }

      if (object instanceof PsiMethod) {
        missedVariants.remove(lookupString + "()");
      } else if (object instanceof PsiVariable) {
        missedVariants.remove('@' + lookupString);
      } else if (object instanceof NamedArgumentDescriptor) {
        missedVariants.remove(lookupString + ':');
      }
    }

    if (missedVariants.size() > 0) {
      Assert.assertTrue("Some completion variants are missed " + missedVariants, false);
    }
  }
コード例 #3
0
 public static void checkCompletionContains(
     JavaCodeInsightTestFixture fixture, PsiFile file, String... expectedVariants) {
   fixture.configureFromExistingVirtualFile(file.getVirtualFile());
   checkCompletionContains(fixture, expectedVariants);
 }
コード例 #4
0
 public static PsiStatementExtractor createStatementExtractor(JavaCodeInsightTestFixture fixture) {
   Caret currentCaret = getCaret(fixture);
   return ExtractorFactory.createStatementExtractor(
       fixture.getFile(), currentCaret.getSelectionStart(), currentCaret.getSelectionEnd());
 }