Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
273,000
void (@NotNull PsiFile file, ChangedLines... expected) { ChangedLines[] formatted = myMockCodeStyleManager.getFormattedLinesFor(file); Comparator<ChangedLines> cmp = Comparator.comparingInt(o -> o.from); Arrays.sort(expected, cmp); Arrays.sort(formatted, cmp); assertArrayEquals(getErrorMessage(expected, formatted), expected, formatted); }
assertFormattedRangesEqualsTo
273,001
boolean (@NotNull PsiFile file) { return myMockPlainTextImportOptimizer.getProcessedFiles().contains(file); }
isImportsOptimized
273,002
String (ChangedLines[] expected, ChangedLines[] actual) { return "Expected: " + Arrays.toString(expected) + " Actual: " + Arrays.toString(actual); }
getErrorMessage
273,003
void (@NotNull PsiDirectory dir) { ReformatCodeProcessor processor = new ReformatCodeProcessor(getProject(), dir, true, true); processor.run(); }
reformatDirectory
273,004
void () { myFileStructure.createDirectoryAndMakeItCurrent("inner"); }
createDirectoryAndMakeItCurrent
273,005
PsiFile (@NotNull String fileName, @NotNull String committedContent, @NotNull String actualContent) { PsiFile file = myFileStructure.addTestFile(fileName, actualContent); if (!committedContent.equals(actualContent)) { registerCommittedRevision(committedContent, file); } return file; }
createFile
273,006
void (@NotNull String committedContent, PsiFile @NotNull ... files) { List<Change> changes = createChanges(committedContent, files); injectChanges(changes); }
registerCommittedRevision
273,007
List<Change> (@NotNull String committed, PsiFile @NotNull ... files) { List<Change> changes = new ArrayList<>(); for (PsiFile file : files) { changes.add(createChange(committed, file)); } return changes; }
createChanges
273,008
void (@NotNull List<Change> changes) { Change[] arr = changes.toArray(Change.EMPTY_CHANGE_ARRAY); myMockChangeListManager.addChanges(arr); }
injectChanges
273,009
Change (@NotNull String committed, @NotNull PsiFile file) { FilePath filePath = VcsUtil.getFilePath(file.getVirtualFile()); ContentRevision before = new SimpleContentRevision(committed, filePath, ""); ContentRevision after = new SimpleContentRevision("", filePath, ""); return new Change(before, after); }
createChange
273,010
PsiDirectory () { return myFileStructure.getCurrentDirectory(); }
getCurrentDirectory
273,011
boolean (@NotNull PsiFile file) { return file.getLanguage() == PlainTextLanguage.INSTANCE; }
supports
273,012
Runnable (@NotNull PsiFile file) { myProcessedFiles.add(file); return EmptyRunnable.INSTANCE; }
processFile
273,013
Set<PsiFile> () { return myProcessedFiles; }
getProcessedFiles
273,014
String () { return "(" + from + ", " + to + ")"; }
toString
273,015
boolean (Object obj) { if (obj instanceof ChangedLines line) { return from == line.from && to == line.to; } return false; }
equals
273,016
String () { return PlatformTestUtil.getPlatformTestDataPath() + "codeStyle/formatter/"; }
getTestDataPath
273,017
void (int expectedLinesChanged) { myFixture.configureByFile(getTestName(true) + "_revision.java"); PsiFile file = myFixture.getFile(); CharSequence revisionContent = myFixture.getDocument(file).getCharsSequence(); myFixture.configureByFile(getTestName(true) + ".java"); file = myFixture.getFile(); Document document = myFixture.getDocument(file); int linesChanged = VcsFacade.getInstance().calculateChangedLinesNumber(document, revisionContent); Assert.assertTrue(linesChanged > 0); Assert.assertEquals(expectedLinesChanged, linesChanged); }
doTest
273,018
void () { doTest(17); }
testAddedLines
273,019
void () { doTest(6); }
testModifiedLines
273,020
void () { doTest(3); }
testDeletedLines
273,021
void () { doTest(1); }
testChangedSingleLine
273,022
void () { doTest(6); }
testChangedAndDeleted
273,023
void () { doTest(3); }
testModification
273,024
void () { doTest(2); }
testInsert
273,025
void () { doTest(19); }
testLotsWhiteSpaces
273,026
void (@NotNull CodeStyleManager manager) { ServiceContainerUtil.replaceService(getProject(), CodeStyleManager.class, manager, getTestRootDisposable()); }
registerCodeStyleManager
273,027
void () { TestFileStructure fileTree = new TestFileStructure(getModule(), myWorkingDirectory); PsiFile java1 = fileTree.addTestFile("Test.java", "empty content"); PsiFile java2 = fileTree.addTestFile("Pair.java", "empty content"); PsiFile java3 = fileTree.addTestFile("Pair2.java", "empty content"); PsiFile php = fileTree.addTestFile("Test.phpMask", "empty content"); PsiFile js = fileTree.addTestFile("Test.jsMask", "empty content"); reformatDirectoryWithFileMask(myWorkingDirectory, null); assertWasFormatted(java1, java2, java3, php, js); }
testReformatWithoutMask
273,028
void () { TestFileStructure fileTree = new TestFileStructure(getModule(), myWorkingDirectory); PsiFile java1 = fileTree.addTestFile("Test.java", "empty content"); PsiFile java2 = fileTree.addTestFile("Pair.java", "empty content"); PsiFile java3 = fileTree.addTestFile("Pair2.java", "empty content"); PsiFile php = fileTree.addTestFile("Test.phpMask", "empty content"); PsiFile js = fileTree.addTestFile("Test.jsMask", "empty content"); reformatDirectoryWithFileMask(myWorkingDirectory, "*.java"); assertWasFormatted(java1, java2, java3); assertWasNotFormatted(php, js); reformatDirectoryWithFileMask(myWorkingDirectory, "*.jsMask"); assertWasFormatted(js); assertWasNotFormatted(java1, java2, java3, php); }
testFormatByOnlyOneMask
273,029
void () { TestFileStructure fileTree = new TestFileStructure(getModule(), myWorkingDirectory); PsiFile java1 = fileTree.addTestFile("Test.java", "empty content"); PsiFile java2 = fileTree.addTestFile("Pair.java", "empty content"); PsiFile java3 = fileTree.addTestFile("Pair2.java", "empty content"); PsiFile php1 = fileTree.addTestFile("Test.phpMask", "empty content"); PsiFile php2 = fileTree.addTestFile("Test2.phpMask", "empty content"); PsiFile js1 = fileTree.addTestFile("Test1.jsMask", "empty content"); PsiFile js2 = fileTree.addTestFile("Test2.jsMask", "empty content"); PsiFile js3 = fileTree.addTestFile("Test3.jsMask", "empty content"); PsiFile py1 = fileTree.addTestFile("Test1.pyMask", "empty content"); PsiFile py2 = fileTree.addTestFile("Test2.pyMask", "empty content"); PsiFile py3 = fileTree.addTestFile("Test3.pyMask", "empty content"); reformatDirectoryWithFileMask(myWorkingDirectory, "*.jsMask, *.java"); assertWasFormatted(js1, js2, js3, java1, java2, java3); assertWasNotFormatted(php1, php2, py1, py2, py3); reformatDirectoryWithFileMask(myWorkingDirectory, "*.phpMask, *.jsMask"); assertWasFormatted(js1, js2, js3, php1, php2); assertWasNotFormatted(java1, java2, java3, py1, py2, py3); reformatDirectoryWithFileMask(myWorkingDirectory, "*.jsMask, *.phpMask, *.java"); assertWasFormatted(js1, js2, js3, php1, php2, java1, java2, java3); assertWasNotFormatted(py1, py2, py3); reformatDirectoryWithFileMask(myWorkingDirectory, "*.jsMask, *.phpMask, *.java, *.pyMask"); assertWasFormatted(js1, js2, js3, php1, php2, java1, java2, java3, py1, py2, py3); reformatDirectoryWithFileMask(myWorkingDirectory, "*.jsp, *.dartMask"); assertWasNotFormatted(js1, js2, js3, php1, php2, java1, java2, java3, py1, py2, py3); }
testFormatByMultiMask
273,030
void () { TestFileStructure fileTree = new TestFileStructure(getModule(), myWorkingDirectory); PsiFile java1 = fileTree.addTestFile("Test1.java", "empty content"); PsiFile php1 = fileTree.addTestFile("Pair1.phpMask", "empty content"); PsiFile js1 = fileTree.addTestFile("Pair1.jsMask", "empty content"); PsiDirectory outer = fileTree.createDirectoryAndMakeItCurrent("toFormat"); PsiFile java2 = fileTree.addTestFile("Test2.java", "empty content"); PsiFile php2 = fileTree.addTestFile("Pair2.phpMask", "empty content"); PsiFile js2 = fileTree.addTestFile("Pair2.jsMask", "empty content"); PsiDirectory inner = fileTree.createDirectoryAndMakeItCurrent("toFormat"); PsiFile java3 = fileTree.addTestFile("Test3.java", "empty content"); PsiFile php3 = fileTree.addTestFile("Pair3.phpMask", "empty content"); PsiFile js3 = fileTree.addTestFile("Pair3.jsMask", "empty content"); reformatDirectoryWithScopeFilter(myWorkingDirectory, directoryScope(outer, true)); assertWasFormatted(java2, php2, js2, java3, php3, js3); assertWasNotFormatted(java1, php1, js1); reformatDirectoryWithScopeFilter(myWorkingDirectory, directoryScope(outer, false)); assertWasFormatted(java2, php2, js2); assertWasNotFormatted(java1, php1, js1, java3, php3, js3); reformatDirectoryWithScopeFilter(myWorkingDirectory, directoryScope(inner, true)); assertWasFormatted(java3, php3, js3); assertWasNotFormatted(java1, php1, js1, java2, php2, js2); reformatDirectoryWithScopeFilter(myWorkingDirectory, directoryScope(myWorkingDirectory, false).union(directoryScope(inner, false))); assertWasFormatted(java3, php3, js3, java1, php1, js1); assertWasNotFormatted(java2, php2, js2); }
testDirectoryScope
273,031
void () { TestFileStructure fileTree = new TestFileStructure(getModule(), myWorkingDirectory); PsiFile java1 = fileTree.addTestFile("Test1.java", "empty content"); PsiFile php1 = fileTree.addTestFile("Pair1.phpMask", "empty content"); PsiFile js1 = fileTree.addTestFile("Pair1.jsMask", "empty content"); PsiDirectory outer = fileTree.createDirectoryAndMakeItCurrent("toFormat"); PsiFile java2 = fileTree.addTestFile("Test2.java", "empty content"); PsiFile php2 = fileTree.addTestFile("Pair2.phpMask", "empty content"); PsiFile js2 = fileTree.addTestFile("Pair2.jsMask", "empty content"); PsiDirectory inner = fileTree.createDirectoryAndMakeItCurrent("toFormat"); PsiFile java3 = fileTree.addTestFile("Test3.java", "empty content"); PsiFile php3 = fileTree.addTestFile("Pair3.phpMask", "empty content"); PsiFile js3 = fileTree.addTestFile("Pair3.jsMask", "empty content"); reformatDirectory(myWorkingDirectory, "*.jsMask", directoryScope(outer, true)); assertWasFormatted(js2, js3); assertWasNotFormatted(java1, php1, js1, java2, php2, java3, php3); reformatDirectory(myWorkingDirectory, "*.jsMask", directoryScope(myWorkingDirectory, false)); assertWasFormatted(js1); assertWasNotFormatted(js2, js3, java1, php1, java2, php2, java3, php3); reformatDirectory(myWorkingDirectory, "*.java, *.phpMask", directoryScope(myWorkingDirectory, false).union(directoryScope(inner, false))); assertWasFormatted(java1, php1, java3, php3); assertWasNotFormatted(java2, php2, js1, js2, js3); }
testDirectoryScopeWithMask
273,032
void () { TestFileStructure fileTree = new TestFileStructure(getModule(), myWorkingDirectory); fileTree.createDirectoryAndMakeItCurrent("src"); PsiFile java2 = fileTree.addTestFile("Test2.tj", "empty content"); PsiFile php2 = fileTree.addTestFile("Pair2.phpMask", "empty content"); PsiFile js2 = fileTree.addTestFile("Pair2.jsMask", "empty content"); PsiDirectory test = fileTree.createDirectoryAndMakeItCurrent("test"); PsiFile testJava1 = fileTree.addTestFile("testJava1.tj", "empty content"); PsiFile testPhp1 = fileTree.addTestFile("testPhp1.phpMask", "empty content"); PsiFile testJs1 = fileTree.addTestFile("testJs1.jsMask", "empty content"); GlobalSearchScope testScope = directoryScope(test, true); reformatAndOptimize(myWorkingDirectory, testScope); assertWasFormatted(testJava1, testPhp1, testJs1); assertWasNotFormatted(java2, php2, js2); }
testIDEA126830
273,033
void (PsiFile... files) { final Set<PsiFile> formattedFiles = myMockCodeStyleManager.getFormattedFiles(); for (PsiFile file : files) { assertTrue(file.getName() + " should be formatted", formattedFiles.contains(file)); } }
assertWasFormatted
273,034
void (PsiFile... files) { final Set<PsiFile> formattedFiles = myMockCodeStyleManager.getFormattedFiles(); for (PsiFile file : files) { assertTrue(file.getName() + " should not be formatted", !formattedFiles.contains(file)); } }
assertWasNotFormatted
273,035
void (@NotNull PsiDirectory directory, @Nullable String mask) { reformatDirectory(directory, mask, null); }
reformatDirectoryWithFileMask
273,036
void (@NotNull PsiDirectory directory, @Nullable SearchScope scope) { reformatDirectory(directory, null, scope); }
reformatDirectoryWithScopeFilter
273,037
void (@NotNull PsiDirectory directory, @Nullable SearchScope scope) { myMockCodeStyleManager.clearFormattedFiles(); AbstractLayoutCodeProcessor processor = new ReformatCodeProcessor(getProject(), directory, true, false); ReformatCodeAction.registerScopeFilter(processor, scope); processor = new RearrangeCodeProcessor(processor); processor.run(); }
reformatWithRearrange
273,038
void (@NotNull PsiDirectory workingDirectory, @NotNull GlobalSearchScope scope) { myMockCodeStyleManager.clearFormattedFiles(); AbstractLayoutCodeProcessor processor = new ReformatCodeProcessor(getProject(), workingDirectory, true, false); ReformatCodeAction.registerScopeFilter(processor, scope); processor = new OptimizeImportsProcessor(processor); processor.run(); }
reformatAndOptimize
273,039
void (@NotNull PsiDirectory directory, @Nullable String mask, @Nullable SearchScope scope) { myMockCodeStyleManager.clearFormattedFiles(); ReformatCodeProcessor processor = new ReformatCodeProcessor(getProject(), directory, true, false); ReformatCodeAction.registerFileMaskFilter(processor, mask); ReformatCodeAction.registerScopeFilter(processor, scope); processor.run(); }
reformatDirectory
273,040
Set<PsiFile> () { return myFormattedLinesForFile.keySet(); }
getFormattedFiles
273,041
void () { myFormattedLinesForFile = new HashMap<>(); }
clearFormattedFiles
273,042
Project () { throw new UnsupportedOperationException("com.intellij.codeInsight.actions.MockCodeStyleManager.getProject(...)"); }
getProject
273,043
int (@NotNull Document document, int offset) { throw new UnsupportedOperationException("com.intellij.codeInsight.actions.MockCodeStyleManager.adjustLineIndent(...)"); }
adjustLineIndent
273,044
boolean (@NotNull PsiFile file, int offset) { throw new UnsupportedOperationException("com.intellij.codeInsight.actions.MockCodeStyleManager.isLineToBeIndented(...)"); }
isLineToBeIndented
273,045
String (@NotNull PsiFile file, int offset) { throw new UnsupportedOperationException("com.intellij.codeInsight.actions.MockCodeStyleManager.getLineIndent(...)"); }
getLineIndent
273,046
String (@NotNull Document document, int offset) { throw new UnsupportedOperationException("com.intellij.codeInsight.actions.MockCodeStyleManager.getLineIndent(...)"); }
getLineIndent
273,047
Indent (String text, FileType fileType) { throw new UnsupportedOperationException("com.intellij.codeInsight.actions.MockCodeStyleManager.getIndent(...)"); }
getIndent
273,048
String (Indent indent, FileType fileType) { throw new UnsupportedOperationException("com.intellij.codeInsight.actions.MockCodeStyleManager.fillIndent(...)"); }
fillIndent
273,049
Indent () { throw new UnsupportedOperationException("com.intellij.codeInsight.actions.MockCodeStyleManager.zeroIndent(...)"); }
zeroIndent
273,050
boolean () { throw new UnsupportedOperationException("com.intellij.codeInsight.actions.MockCodeStyleManager.isSequentialProcessingAllowed(...)"); }
isSequentialProcessingAllowed
273,051
void (Runnable r) { throw new UnsupportedOperationException( "com.intellij.codeInsight.actions.MockCodeStyleManager.performActionWithFormatterDisabled(...)"); }
performActionWithFormatterDisabled
273,052
PsiFile (@NotNull String name, @NotNull String content) { PsiFile createdFile = null; try { createdFile = createFile(myModule, myCurrentLevelDirectory.getVirtualFile(), name, content); } catch (IOException e) { throw new RuntimeException(e); } getCurrentDirectoryFiles().add(createdFile); return createdFile; }
addTestFile
273,053
List<PsiFile> () { return myFilesForLevel.get(myLevel); }
getCurrentDirectoryFiles
273,054
PsiDirectory () { return myCurrentLevelDirectory; }
getCurrentDirectory
273,055
PsiDirectory (String name) { myLevel++; myFilesForLevel.add(new ArrayList<>()); myCurrentLevelDirectory = createDirectory(myProject, myCurrentLevelDirectory.getVirtualFile(), name); return myCurrentLevelDirectory; }
createDirectoryAndMakeItCurrent
273,056
List<PsiFile> (int level) { assert (myLevel >= level); return myFilesForLevel.get(level); }
getFilesAtLevel
273,057
PsiDirectory (@NotNull Project project, @NotNull final VirtualFile parent, @NotNull final String name) { final VirtualFile[] dir = new VirtualFile[1]; ApplicationManager.getApplication().runWriteAction(() -> { try { dir[0] = parent.createChildDirectory(null, name); } catch (IOException e) { e.printStackTrace(); } }); return PsiDirectoryFactory.getInstance(project).createDirectory(dir[0]); }
createDirectory
273,058
void (@NotNull final VirtualFile file) { ApplicationManager.getApplication().runWriteAction(() -> { try { file.delete(null); } catch (IOException e) { e.printStackTrace(); } }); }
delete
273,059
void () { final FoldingBuilder first = createDummyFoldingBuilder("plain", "mountain", false); final FoldingBuilder second = createDummyFoldingBuilder("plain", "tree", false); LanguageFolding.INSTANCE.addExplicitExtension(PlainTextLanguage.INSTANCE, first); LanguageFolding.INSTANCE.addExplicitExtension(PlainTextLanguage.INSTANCE, second); try { PsiFile file = getFile(); List<FoldingUpdate.RegionInfo> regionInfos = FoldingUpdate.getFoldingsFor(file, false); int regionCount = ContainerUtil.count(regionInfos, i -> file.equals(i.element)); assert regionCount == 1: "Only one descriptor allowed for the same text range. Descriptors: " + regionInfos; } finally { LanguageFolding.INSTANCE.removeExplicitExtension(PlainTextLanguage.INSTANCE, first); LanguageFolding.INSTANCE.removeExplicitExtension(PlainTextLanguage.INSTANCE, second); } }
testAllowOnlyOneDescriptorPerTextRange
273,060
void () { final FoldingBuilder first = createDummyFoldingBuilder("plain", "mountain", true); LanguageFolding.INSTANCE.addExplicitExtension(PlainTextLanguage.INSTANCE, first); try { PsiFile file = getFile(); List<FoldingUpdate.RegionInfo> regionInfos = FoldingUpdate.getFoldingsFor(file, false); int regionCount = ContainerUtil.count(regionInfos, i -> file.equals(i.element)); assertEquals("mountain", regionInfos.get(0).descriptor.getPlaceholderText()); assert regionCount == 1: "Only one descriptor allowed for the same text range. Descriptors: " + regionInfos; } finally { LanguageFolding.INSTANCE.removeExplicitExtension(PlainTextLanguage.INSTANCE, first); } }
testOverrideGetText
273,061
FoldingBuilder (final String textToFold, final String placeholderText, final boolean overrideGetText) { return new CustomFoldingBuilder() { @Override protected void buildLanguageFoldRegions( @NotNull List<FoldingDescriptor> descriptors, @NotNull PsiElement root, @NotNull Document document, boolean quick) { final int index = root.getText().indexOf(textToFold); TextRange textRange = new TextRange(index, index + textToFold.length()); if (overrideGetText) { descriptors.add(new FoldingDescriptor(root.getNode(), textRange) { @Nullable @Override public String getPlaceholderText() { return placeholderText; } }); } else { descriptors.add(new FoldingDescriptor(root.getNode(), textRange, null, placeholderText, true, Collections.emptySet())); } } @Override protected String getLanguagePlaceholderText(@NotNull ASTNode node, @NotNull TextRange range) { return ""; } @Override protected boolean isRegionCollapsedByDefault(@NotNull ASTNode node) { return true; } }; }
createDummyFoldingBuilder
273,062
void ( @NotNull List<FoldingDescriptor> descriptors, @NotNull PsiElement root, @NotNull Document document, boolean quick) { final int index = root.getText().indexOf(textToFold); TextRange textRange = new TextRange(index, index + textToFold.length()); if (overrideGetText) { descriptors.add(new FoldingDescriptor(root.getNode(), textRange) { @Nullable @Override public String getPlaceholderText() { return placeholderText; } }); } else { descriptors.add(new FoldingDescriptor(root.getNode(), textRange, null, placeholderText, true, Collections.emptySet())); } }
buildLanguageFoldRegions
273,063
String () { return placeholderText; }
getPlaceholderText
273,064
String (@NotNull ASTNode node, @NotNull TextRange range) { return ""; }
getLanguagePlaceholderText
273,065
boolean (@NotNull ASTNode node) { return true; }
isRegionCollapsedByDefault
273,066
void (String leftMostPosition, String... rightPositions) { doTest(true, leftMostPosition); doTest(false, leftMostPosition, rightPositions); }
doTestFromLeftToRight
273,067
void (String rightMostPosition, String... leftPositions) { doTest(false, rightMostPosition); doTest(true, rightMostPosition, leftPositions); }
doTestFromRightToLeft
273,068
void (boolean moveLeft, String before, String... after) { String current = before; for (String next : after) { doTestSingle(moveLeft, current, next); current = next; } doTestSingle(moveLeft, current, current); if (after.length == 0) return; for (int i = after.length - 2; i >= 0; i--) { String prev = after[i]; doTestSingle(!moveLeft, current, prev); current = prev; } doTestSingle(!moveLeft, current, before); }
doTest
273,069
void (boolean moveLeft, String before, String after) { configureEditor(before); executeAction(moveLeft ? IdeActions.MOVE_ELEMENT_LEFT : IdeActions.MOVE_ELEMENT_RIGHT); checkResultByText(after); }
doTestSingle
273,070
String () { return "platform/platform-tests/testData/editor/actionsInCustomFileType"; }
getBasePath
273,071
boolean () { return true; }
isCommunity
273,072
void (String test, String ext) { myFixture.configureByFile(test + "." + ext); performEndBlockAction(); myFixture.checkResultByFile(test + "_after." + ext); myFixture.configureByFile(test + "_after." + ext); performStartBlockAction(); myFixture.checkResultByFile(test + "." + ext); }
_testBlockNavigation
273,073
void () { EditorActionHandler actionHandler = new CodeBlockStartAction().getHandler(); actionHandler.execute(myFixture.getEditor(), myFixture.getEditor().getCaretModel().getPrimaryCaret(), ((EditorEx)myFixture.getEditor()).getDataContext()); }
performStartBlockAction
273,074
void () { EditorActionHandler actionHandler = new CodeBlockEndAction().getHandler(); actionHandler.execute(myFixture.getEditor(), myFixture.getEditor().getCaretModel().getPrimaryCaret(), ((EditorEx)myFixture.getEditor()).getDataContext()); }
performEndBlockAction
273,075
void () { _testBlockNavigation("blockNavigation","cs"); }
testBlockNavigation
273,076
void () { myFixture.configureByFile("InsertDeleteQuote.cs"); EditorTestUtil.performTypingAction(myFixture.getEditor(), '"'); myFixture.checkResultByFile("InsertDeleteQuote_after.cs"); myFixture.configureByFile("InsertDeleteQuote_after.cs"); EditorTestUtil.performTypingAction(myFixture.getEditor(), BACKSPACE_FAKE_CHAR); myFixture.checkResultByFile("InsertDeleteQuote.cs"); FileType extension = FileTypeManager.getInstance().getFileTypeByExtension("pl"); TestCase.assertTrue("Test is not set up correctly:" + extension, extension instanceof AbstractFileType); myFixture.configureByFile("InsertDeleteQuote.pl"); EditorTestUtil.performTypingAction(myFixture.getEditor(), '"'); myFixture.checkResultByFile("InsertDeleteQuote_after.pl"); myFixture.configureByFile("InsertDeleteQuote_after.pl"); EditorTestUtil.performTypingAction(myFixture.getEditor(), BACKSPACE_FAKE_CHAR); myFixture.checkResultByFile("InsertDeleteQuote.pl"); myFixture.configureByFile("InsertDeleteQuote.aj"); EditorTestUtil.performTypingAction(myFixture.getEditor(), '"'); myFixture.checkResultByFile("InsertDeleteQuote_after.aj"); myFixture.configureByFile("InsertDeleteQuote_after.aj"); EditorTestUtil.performTypingAction(myFixture.getEditor(), BACKSPACE_FAKE_CHAR); myFixture.checkResultByFile("InsertDeleteQuote.aj"); }
testInsertDeleteQuotes
273,077
void () { myFixture.configureByFile("InsertDeleteBracket.cs"); EditorTestUtil.performTypingAction(myFixture.getEditor(), '['); myFixture.checkResultByFile("InsertDeleteBracket_after.cs"); myFixture.configureByFile("InsertDeleteBracket_after.cs"); EditorTestUtil.performTypingAction(myFixture.getEditor(), BACKSPACE_FAKE_CHAR); myFixture.checkResultByFile("InsertDeleteBracket.cs"); myFixture.configureByFile("InsertDeleteBracket_after.cs"); EditorTestUtil.performTypingAction(myFixture.getEditor(), ']'); myFixture.checkResultByFile("InsertDeleteBracket_after2.cs"); }
testInsertDeleteBracket
273,078
void () { myFixture.configureByFile("InsertDeleteParenth.cs"); EditorTestUtil.performTypingAction(myFixture.getEditor(), '('); myFixture.checkResultByFile("InsertDeleteParenth_after.cs"); myFixture.configureByFile("InsertDeleteParenth_after.cs"); EditorTestUtil.performTypingAction(myFixture.getEditor(), BACKSPACE_FAKE_CHAR); myFixture.checkResultByFile("InsertDeleteParenth.cs"); myFixture.configureByFile("InsertDeleteParenth_after.cs"); EditorTestUtil.performTypingAction(myFixture.getEditor(), ')'); myFixture.checkResultByFile("InsertDeleteParenth_after2.cs"); myFixture.configureByFile("InsertDeleteParenth2_2.cs"); EditorTestUtil.performTypingAction(myFixture.getEditor(), '('); myFixture.checkResultByFile("InsertDeleteParenth2_2_after.cs"); myFixture.configureByFile("InsertDeleteParenth2.cs"); EditorTestUtil.performTypingAction(myFixture.getEditor(), '('); myFixture.checkResultByFile("InsertDeleteParenth2_after.cs"); }
testInsertDeleteParenth
273,079
void (String fileName, String before, char typed, String after) { myFixture.configureByText(fileName, before); EditorTestUtil.performTypingAction(myFixture.getEditor(), typed); myFixture.checkResult(after); }
checkTyping
273,080
void () { checkTyping("a.cs", "<caret>a", '(', "(<caret>a"); checkTyping("a.cs", "<caret>@a", '(', "(<caret>@a"); checkTyping("a.cs", "<caret>(a", '(', "(<caret>(a"); checkTyping("a.cs", "<caret>[a", '(', "(<caret>[a"); checkTyping("a.cs", "<caret> (a", '(', "(<caret>) (a"); checkTyping("a.cs", "(<caret>)", '(', "((<caret>))"); checkTyping("a.cs", "(<caret>,)", '(', "((<caret>),)"); checkTyping("a.cs", "<caret>a", '[', "[<caret>a"); checkTyping("a.cs", "<caret>@a", '[', "[<caret>@a"); checkTyping("a.cs", "<caret>(a", '[', "[<caret>(a"); checkTyping("a.cs", "<caret>[a", '[', "[<caret>[a"); checkTyping("a.cs", "<caret> (a", '[', "[<caret>] (a"); }
testParenthesesBeforeNonWs
273,081
void () { checkTyping("a.cs", "<caret>a", '"', "\"<caret>a"); checkTyping("a.cs", "<caret> ", '"', "\"<caret>\" "); checkTyping("a.cs", "<caret>a", '\'', "'<caret>a"); checkTyping("a.cs", "<caret> ", '\'', "'<caret>' "); }
testQuoteBeforeNonWs
273,082
void () { CodeInsightSettings settings = CodeInsightSettings.getInstance(); boolean oldValue = settings.SURROUND_SELECTION_ON_QUOTE_TYPED; settings.SURROUND_SELECTION_ON_QUOTE_TYPED = false; boolean oldValuePairQuote = settings.AUTOINSERT_PAIR_QUOTE; settings.AUTOINSERT_PAIR_QUOTE = false; try { checkTyping("a.cs", "<caret><selection>\"</selection>a\"", '\'', "'<caret>a\""); checkTyping("a.cs", "<caret><selection>\"</selection>a'", '\'', "'<caret>a'"); checkTyping("a.cs", "\"a<caret><selection>\"</selection>", '\'', "\"a'<caret>"); checkTyping("a.cs", "'a<caret><selection>\"</selection>", '\'', "'a'<caret>"); checkTyping("a.cs", "<caret><selection>'</selection>a\"", '\"', "\"<caret>a\""); checkTyping("a.cs", "<caret><selection>'</selection>a'", '\"', "\"<caret>a'"); checkTyping("a.cs", "\"a<caret><selection>'</selection>", '\"', "\"a\"<caret>"); checkTyping("a.cs", "'a<caret><selection>'</selection>", '\"', "'a\"<caret>"); } finally { settings.SURROUND_SELECTION_ON_QUOTE_TYPED = oldValue; settings.AUTOINSERT_PAIR_QUOTE = oldValuePairQuote; } }
testReplaceQuoteDontSurroundSelection
273,083
void () { CodeInsightSettings settings = CodeInsightSettings.getInstance(); boolean oldValue = settings.AUTOINSERT_PAIR_QUOTE; settings.AUTOINSERT_PAIR_QUOTE = false; try { checkTyping("a.cs", "<caret><selection>\"</selection>a\"", '\'', "'<selection><caret>\"</selection>'a\""); checkTyping("a.cs", "<caret><selection>\"</selection>a'", '\'', "'<selection><caret>\"</selection>'a'"); checkTyping("a.cs", "\"a<caret><selection>\"</selection>", '\'', "\"a'<selection><caret>\"</selection>'"); checkTyping("a.cs", "'a<caret><selection>\"</selection>", '\'', "'a'<selection><caret>\"</selection>'"); checkTyping("a.cs", "<caret><selection>'</selection>a\"", '\"', "\"<selection><caret>'</selection>\"a\""); checkTyping("a.cs", "<caret><selection>'</selection>a'", '\"', "\"<selection><caret>'</selection>\"a'"); checkTyping("a.cs", "\"a<caret><selection>'</selection>", '\"', "\"a\"<selection><caret>'</selection>\""); checkTyping("a.cs", "'a<caret><selection>'</selection>", '\"', "'a\"<selection><caret>'</selection>\""); } finally { settings.AUTOINSERT_PAIR_QUOTE = oldValue; } }
testReplaceQuoteDontInsertPair
273,084
void () { checkTyping("a.cs", "<caret><selection>\"</selection>a\"", '\'', "'<caret>a'"); checkTyping("a.cs", "<caret><selection>\"</selection>a'", '\'', "'<selection><caret>\"</selection>'a'"); checkTyping("a.cs", "\"a<caret><selection>\"</selection>", '\'', "'a'<caret>"); checkTyping("a.cs", "'a<caret><selection>\"</selection>", '\'', "'a'<selection><caret>\"</selection>'"); checkTyping("a.cs", "<caret><selection>'</selection>a\"", '\"', "\"<selection><caret>'</selection>\"a\""); checkTyping("a.cs", "<caret><selection>'</selection>a'", '\"', "\"<caret>a\""); checkTyping("a.cs", "\"a<caret><selection>'</selection>", '\"', "\"a\"<selection><caret>'</selection>\""); checkTyping("a.cs", "'a<caret><selection>'</selection>", '\"', "\"a\"<caret>"); }
testReplaceQuote
273,085
void () { checkTyping("a.txt", "<caret>", '(', "(<caret>"); checkTyping("a.txt", "{<caret>}", '}
testNoPairedBracesInPlainText
273,086
void () { myFixture.configureByText("a.txt", "<caret>"); EditorTestUtil.performTypingAction(myFixture.getEditor(), '('); EditorTestUtil.performTypingAction(myFixture.getEditor(), ')'); myFixture.checkResult("()<caret>"); }
testClosingBraceInPlainText
273,087
void () { myFixture.configureByFile("InsertBraceOnEnter.cs"); EditorTestUtil.performTypingAction(myFixture.getEditor(), '\n'); myFixture.checkResultByFile("InsertBraceOnEnter_after.cs"); }
testInsertBraceOnEnter
273,088
void () { String testName = getTestName(false); myFixture.configureByFile(testName + ".fx"); EditorTestUtil.performTypingAction(myFixture.getEditor(), '\n'); myFixture.checkResultByFile(testName + "_after.fx"); }
testInsertBraceOnEnterJavaFx
273,089
void () { EditorHighlighter highlighter = HighlighterFactory.createHighlighter(getProject(), "A.cpp"); // 0123456789012345678 9 0123 45 6 7 highlighter.setText("#include try enum \"\\xff\\z\\\"xxx\""); HighlighterIterator iterator = highlighter.createIterator(2); TestCase.assertEquals(CustomHighlighterTokenType.KEYWORD_1, iterator.getTokenType()); iterator = highlighter.createIterator(9); TestCase.assertEquals(CustomHighlighterTokenType.KEYWORD_2, iterator.getTokenType()); iterator = highlighter.createIterator(15); TestCase.assertEquals(CustomHighlighterTokenType.KEYWORD_1, iterator.getTokenType()); iterator = highlighter.createIterator(19); TestCase.assertEquals(StringEscapesTokenTypes.VALID_STRING_ESCAPE_TOKEN, iterator.getTokenType()); iterator = highlighter.createIterator(23); TestCase.assertEquals(StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN, iterator.getTokenType()); iterator = highlighter.createIterator(25); TestCase.assertEquals(StringEscapesTokenTypes.VALID_STRING_ESCAPE_TOKEN, iterator.getTokenType()); iterator = highlighter.createIterator(27); TestCase.assertEquals(CustomHighlighterTokenType.STRING, iterator.getTokenType()); }
testCpp
273,090
void () { EditorHighlighter highlighter = HighlighterFactory.createHighlighter(getProject(), "A.hs"); // 0123456789012345678 9 0123 45 6 7 highlighter.setText("{-# #-} module"); HighlighterIterator iterator = highlighter.createIterator(2); TestCase.assertEquals(CustomHighlighterTokenType.MULTI_LINE_COMMENT, iterator.getTokenType()); iterator = highlighter.createIterator(12); TestCase.assertEquals(CustomHighlighterTokenType.KEYWORD_1, iterator.getTokenType()); }
testHaskel
273,091
void () { String text = " <start>"; EnterAfterJavadocTagHandler.Context context = parse(text); assertEmpty(context); }
textWithoutAsterisk
273,092
void () { String text = "/**\n * <p><"; EnterAfterJavadocTagHandler.Context context = parse(text, text.length() - 1); assertEquals(9, context.startTagEndOffset); assertEquals(-1, context.endTagStartOffset); String text2 = "/**\n * <p></"; context = parse(text2, text2.length() - 2); assertEquals(9, context.startTagEndOffset); assertEquals(-1, context.endTagStartOffset); }
unterminatedTagAtTheEnd
273,093
void () { String text = " * <start>"; // Cursor after single tag EnterAfterJavadocTagHandler.Context context = parse(text); assertEquals(text.indexOf(">"), context.startTagEndOffset); assertTrue(context.endTagStartOffset < 0); // Cursor before context = parse(text, text.length() - 1); assertEmpty(context); }
startTagOnly
273,094
void () { String text = " * <outer><inner> sdf </inner></outer>"; // Cursor before <outer>. EnterAfterJavadocTagHandler.Context context = parse(text, 0); assertEmpty(context); // Cursor at <outer>. int offset = text.indexOf("<outer>") + 2; context = parse(text, offset); assertEmpty(context); // Cursor between <outer> and <inner>. offset = text.indexOf("<inner>"); context = parse(text, offset); assertEquals(offset - 1, context.startTagEndOffset); assertEquals(text.indexOf("</outer>"), context.endTagStartOffset); // Cursor at <inner>. offset += 2; context = parse(text, offset); assertEmpty(context); // Cursor inside <inner>. offset = text.indexOf("sdf"); context = parse(text, offset); assertEquals(text.indexOf("<inner>") + "<inner>".length() - 1, context.startTagEndOffset); assertEquals(text.indexOf("</inner>"), context.endTagStartOffset); // Cursor at </inner>. offset = text.indexOf("</inner>") + 2; context = parse(text, offset); assertEmpty(context); // Cursor between </inner> and </outer>. offset = text.indexOf("</outer>"); context = parse(text, offset); assertEquals(text.indexOf("<inner>") - 1, context.startTagEndOffset); assertEquals(offset, context.endTagStartOffset); // Cursor at </outer>. offset += 2; context = parse(text, offset); assertEmpty(context); // Cursor at end. context = parse(text); assertEmpty(context); }
nestedTags
273,095
void () { EnterAfterJavadocTagHandler.Context context = parse("* <p/>"); assertEmpty(context); }
emptyTag
273,096
void (EnterAfterJavadocTagHandler.Context context) { assertTrue(context.startTagEndOffset < 0); assertTrue(context.endTagStartOffset < 0); }
assertEmpty
273,097
void () { DocumentationComponent component = createDocumentationComponent(); String actionText = CodeInsightBundle.message("javadoc.show.popup.automatically"); ToggleAction showPopupAction = ObjectUtils.tryCast(findAction(component, actionText), ToggleAction.class); assertNotNull(showPopupAction); CodeInsightSettings settings = CodeInsightSettings.getInstance(); boolean info = settings.AUTO_POPUP_JAVADOC_INFO; try { AnActionEvent event = createEvent(); assertEquals(info, showPopupAction.isSelected(event)); showPopupAction.setSelected(event, true); assertTrue(showPopupAction.isSelected(event)); assertTrue(settings.AUTO_POPUP_JAVADOC_INFO); showPopupAction.setSelected(event, false); assertFalse(settings.AUTO_POPUP_JAVADOC_INFO); assertFalse(showPopupAction.isSelected(event)); } finally { settings.AUTO_POPUP_JAVADOC_INFO = info; } }
testShowPopupAutomaticallyAction
273,098
DocumentationComponent () { DocumentationManager manager = DocumentationManager.getInstance(getProject()); DocumentationComponent component = new DocumentationComponent(manager); Disposer.register(getTestRootDisposable(), component); return component; }
createDocumentationComponent
273,099
AnActionEvent () { DataContext context = SimpleDataContext.builder() .add(CommonDataKeys.PROJECT, getProject()) .build(); return AnActionEvent.createFromDataContext("", null, context); }
createEvent