@Override
  protected CodeInsightTestFixture createTestFixture(IdeaProjectTestFixture fixture)
      throws Exception {

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

    codeInsightFixture.setTestDataPath(getTestRootPath());

    return codeInsightFixture;
  }
Ejemplo n.º 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);
    }
  }
Ejemplo n.º 3
0
 public static void checkCompletionContains(
     JavaCodeInsightTestFixture fixture, PsiFile file, String... expectedVariants) {
   fixture.configureFromExistingVirtualFile(file.getVirtualFile());
   checkCompletionContains(fixture, expectedVariants);
 }
 public static PsiStatementExtractor createStatementExtractor(JavaCodeInsightTestFixture fixture) {
   Caret currentCaret = getCaret(fixture);
   return ExtractorFactory.createStatementExtractor(
       fixture.getFile(), currentCaret.getSelectionStart(), currentCaret.getSelectionEnd());
 }