public void testIsVariable() { myFixture.configureByFiles("is_variable.ex"); PsiElement callable = myFixture .getFile() .findElementAt(myFixture.getCaretOffset()) .getPrevSibling(); assertInstanceOf(callable, Call.class); assertFalse("order_by is incorrectly marked as a variable", isVariable(callable)); }
public void testNoSpaceAfterAtOperator() { myFixture.configureByFile("space_after_at_operator.ex"); reformatFixture(); myFixture.checkResultByFile("no_space_after_at_operator.ex"); }
public void testSingleNestedKeywordValue() { myFixture.configureByFiles("SingleNestedKeywordValue.ex"); myFixture.enableInspections(NoParenthesesManyStrict.class); myFixture.checkHighlighting(); }
public void testQualifierDotQuoteParentheses() { myFixture.configureByFile("QualifierDotQuoteParentheses.ex"); myFixture.enableInspections(NoParenthesesStrict.class); myFixture.checkHighlighting(); }
public void testRenameExternalDefinitionDeclarationWhereDefinitionsAreInRoot() { final VirtualFile definitionsFile = myFixture.copyFileToProject( FILES_PATH + "definitions_in_root_with_caret.yaml", "definitions.yaml"); myFixture.copyFileToProject( FILES_PATH + "external_definition_definitions_in_root.yaml", "swagger.yaml"); myFixture.configureFromExistingVirtualFile(definitionsFile); myFixture.renameElementAtCaret("newName"); myFixture.checkResultByFile( "swagger.yaml", FILES_PATH + "external_definition_definitions_in_root_after.yaml", true); myFixture.checkResultByFile( "definitions.yaml", FILES_PATH + "definitions_in_root_with_caret_after.yaml", true); }
private void testRename( final String newName, final String beforeFileName, final String afterFileName) { myFixture.configureByFile(FILES_PATH + beforeFileName); myFixture.renameElementAtCaret(newName); myFixture.checkResultByFile(FILES_PATH + afterFileName); }
public void assertNavigationContains(LanguageFileType languageFileType, String configureByText, String targetShortcut) { myFixture.configureByText(languageFileType, configureByText); PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); assertNavigationContains(psiElement, targetShortcut); }
private void assertNavigationIsEmpty() { PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) { PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, 0, myFixture.getEditor()); if(gotoDeclarationTargets != null && gotoDeclarationTargets.length > 0) { fail(String.format("failed that PsiElement (%s) navigate is empty; found target in '%s'", psiElement.toString(), gotoDeclarationHandler.getClass())); } } }
public void assertNavigationContainsFile(LanguageFileType languageFileType, String configureByText, String targetShortcut) { myFixture.configureByText(languageFileType, configureByText); PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); Set<String> targets = new HashSet<String>(); for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) { PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, 0, myFixture.getEditor()); if (gotoDeclarationTargets != null && gotoDeclarationTargets.length > 0) { for (PsiElement gotoDeclarationTarget : gotoDeclarationTargets) { if(gotoDeclarationTarget instanceof PsiFile) { targets.add(((PsiFile) gotoDeclarationTarget).getVirtualFile().getUrl()); } } } } // its possible to have memory fields, // so simple check for ending conditions // temp:///src/interchange.en.xlf for (String target : targets) { if(target.endsWith(targetShortcut)) { return; } } fail(String.format("failed that PsiElement (%s) navigate to file %s", psiElement.toString(), targetShortcut)); }
private void rename(final String file, final String newName) { final VirtualFile specFile = myFixture.copyFileToProject(getSourceFile(file), "openapi.json"); myFixture.configureFromExistingVirtualFile(specFile); myFixture.renameElementAtCaret(newName); }
private void assertReferenceAndResolvedNameArityRange(@NotNull String name, int arity) { PsiElement elementAtCaret = myFixture .getFile() .findElementAt(myFixture.getCaretOffset()); assertNotNull(elementAtCaret); PsiElement grandParent = elementAtCaret.getParent().getParent(); assertNotNull(grandParent); assertInstanceOf(grandParent, Call.class); Call grandParentCall = (Call) grandParent; assertEquals(name, grandParentCall.functionName()); assertEquals(arity, grandParentCall.resolvedFinalArity()); assertResolvedNameArityRange(grandParentCall, name, arity); }
private void initVersion(@NotNull String version) { myFixture.configureByText(PhpFileType.INSTANCE, "<?php\n" + "namespace Symfony\\Component\\HttpKernel {\n" + " class Kernel {\n" + " const VERSION = '" + version + "';" + " }" + "}" ); } }
public void setUp() throws Exception { super.setUp(); myFixture.copyFileToProject("BundleScopeLineMarkerProvider.php"); myFixture.copyFileToProject("XmlLineMarkerProvider.php"); myFixture.configureByText( XmlFileType.INSTANCE, "<routes><import resource=\"@FooBundle/foo.xml\" /></routes>" ); }
public void assertCompletionNotContains(String filename, String configureByText, String... lookupStrings) { myFixture.configureByText(filename, configureByText); myFixture.completeBasic(); assertFalse(myFixture.getLookupElementStrings().containsAll(Arrays.asList(lookupStrings))); }
public void assertCompletionResultEquals(LanguageFileType languageFileType, String complete, String result) { myFixture.configureByText(languageFileType, complete); myFixture.completeBasic(); myFixture.checkResult(result); }
protected void testQuickDocumentation(final String fileName, final String expectedDocumentation) { final PsiFile psiFile = myFixture.configureByFile(filesPath + fileName); final PsiElement originalElement = psiFile.findElementAt(myFixture.getEditor().getCaretModel().getOffset()); final PsiElement targetElement = DocumentationManager.getInstance(getProject()) .findTargetElement(myFixture.getEditor(), psiFile, originalElement); final DocumentationProvider documentationProvider = DocumentationManager.getProviderFromElement(targetElement); final String quickNavigateInfo = documentationProvider.getQuickNavigateInfo(targetElement, originalElement); assertEquals(expectedDocumentation, quickNavigateInfo); } }
public void assertAtTextCompletionContains(String findByText, String... lookupStrings) { final PsiElement element = myFixture.findElementByText(findByText, PsiElement.class); assert element != null : "No element found by text: " + findByText; myFixture.getEditor().getCaretModel().moveToOffset(element.getTextOffset() + 1); myFixture.completeBasic(); checkContainsCompletion(lookupStrings); }
public void assertCompletionContains(String filename, String configureByText, String... lookupStrings) { myFixture.configureByText(filename, configureByText); myFixture.completeBasic(); completionContainsAssert(lookupStrings); }
public void testActionAvailableForFileScope() { myFixture.configureByText(PhpFileType.INSTANCE, "" + "<?php\n" + "class Foo implements \\Symfony\\Component\\Form\\FormTypeInterface\n" + "{" + " \n private $foo = 'te<caret>st';\n" + "} " ); assertTrue(myFixture.testAction(new FormTypeConstantMigrationAction()).isEnabledAndVisible()); } }