Unnamed: 0 int64 0 305k | body stringlengths 7 52.9k | name stringlengths 1 185 |
|---|---|---|
273,200 | void () { @NonNls final String longName = "ThisIsAQuiteLongNameWithParentheses().Dots.-Minuses-_UNDERSCORES_digits239:colons:/slashes\\AndOfCourseManyLetters"; final List<MinusculeMatcher> matching = new ArrayList<>(); final List<MinusculeMatcher> nonMatching = new ArrayList<>(); for (String s : ContainerUtil.ar("*", "*i", "*a", "*u", "T", "ti", longName, longName.substring(0, 20))) { matching.add(NameUtil.buildMatcher(s, NameUtil.MatchingCaseSensitivity.NONE)); } for (String s : ContainerUtil.ar("A", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "tag")) { nonMatching.add(NameUtil.buildMatcher(s, NameUtil.MatchingCaseSensitivity.NONE)); } PlatformTestUtil.startPerformanceTest("Matching", 4_000, () -> { for (int i = 0; i < 100_000; i++) { for (MinusculeMatcher matcher : matching) { Assert.assertTrue(matcher.matches(longName)); matcher.matchingDegree(longName); } for (MinusculeMatcher matcher : nonMatching) { Assert.assertFalse(matcher.matches(longName)); } } }).assertTiming(); } | testPerformance |
273,201 | void () { PlatformTestUtil.startPerformanceTest(getName(), 120, () -> { String small = StringUtil.repeat("_", 50000); String big = StringUtil.repeat("_", small.length() + 1); assertMatches("*" + small, big); assertDoesntMatch("*" + big, small); }).assertTiming(); } | testOnlyUnderscoresPerformance |
273,202 | void () { PlatformTestUtil.startPerformanceTest(getName(), 30, () -> { String big = StringUtil.repeat("Aaaaaa", 50000); assertMatches("aaaaaaaaaaaaaaaaaaaaaaaa", big); assertDoesntMatch("aaaaaaaaaaaaaaaaaaaaaaaab", big); }).assertTiming(); } | testRepeatedLetterPerformance |
273,203 | void () { PlatformTestUtil.startPerformanceTest(getName(), 30, () -> { String pattern = "*<p> aaa <div id=\"a"; String html = "<html> <body> <H2> <FONT SIZE=\"-1\"> com.sshtools.cipher</FONT> <BR> Class AES128Cbc</H2> <PRE> java.lang.Object <IMG SRC=\"../../../resources/inherit.gif\" ALT=\"extended by\">com.maverick.ssh.cipher.SshCipher <IMG SRC=\"../../../resources/inherit.gif\" ALT=\"extended by\">com.maverick.ssh.crypto.engines.CbcBlockCipher <IMG SRC=\"../../../resources/inherit.gif\" ALT=\"extended by\"><B>com.sshtools.cipher.AES128Cbc</B> </PRE> <HR> <DL> <DT>public class <B>AES128Cbc</B><DT>extends com.maverick.ssh.crypto.engines.CbcBlockCipher</DL> <P> This cipher can optionally be added to the J2SSH Maverick API. To add the ciphers from this package simply add them to the <A HREF=\"../../../com/maverick/ssh2/Ssh2Context.html\" title=\"class in com.maverick.ssh2\"><CODE>Ssh2Context</CODE></A> <blockquote><pre> import com.sshtools.cipher.*; </pre></blockquote> <P> <P> <DL> <DT><B>Version:</B></DT> <DD>Revision: 1.20</DD> </DL> <HR> </body> </html>"; assertDoesntMatch(pattern, html); }).assertTiming(); } | testMatchingLongHtmlWithShortHtml |
273,204 | void () { String pattern = "*Then the large string is '{asdbsfafds adsfadasdfasdfasdfasdfasdfasdfsfasf adsfasdf sfasdfasdfasdfasdfasdfasdfd adsfadsfsafd adsfafdadsfsdfasdf sdf asdfasdfasfadsfasdfasfd asdfafd fasdfasdfasdfdsfas dadsfasfadsfafdsafddf dsf dsasdfasdfsdafsdfsdfsdfasdffafdadfafafasdfasdf asdfasdfasdfasdfasdfasdfasdfasdfaasdfsdfasdfds adfafddfas aa afds}' is sent into the abyss\nThen"; String name = "Then the large string is '{asdbsfafds adsfadasdfasdfasdfasdfasdfasdfsfasf adsfasdf sfasdfasdfasdfasdfasdfasdfd adsfadsfsafd adsfafdadsfsdfasdf sdf asdfasdfasfadsfasdfasfd asdfafd fasdfasdfasdfdsfas dadsfasfadsfafdsafddf dsf dsasdfasdfsdafsdfsdfsdfasdffafdadfafafasdfasdf asdfasdfasdfasdfasdfasdfasdfasdfaasdfsdfasdfds adfafddfas aa afds}' is sent into the abyss\nTh' is sent into the abyss"; assertDoesntMatchFast(pattern, name); pattern = "findFirstAdjLoanPlanTemplateByAdjLoanPlan_AdjLoanProgram_AdjLoanProgramCodeAndTemplateVersions"; name = "findFirstAdjLoanPlanTemplateByAdjLoanPlan_AdjLoanProgram_AdjLoanProgramCodeAndTemplateVersion_TemplateVersionCode"; assertDoesntMatchFast(pattern, name); pattern = "tip.how.to.select.a.thing.and.that.selected.things.are.shown.as.bold"; name = "tip.how.to.select.a.thing.and.that.selected.things.are.shown.as.bolid"; assertDoesntMatchFast(pattern, name); } | testMatchingLongStringWithAnotherLongStringWhereOnlyEndsDiffer |
273,205 | void (String pattern, String name) { PlatformTestUtil.startPerformanceTest(getName(), 30, () -> assertDoesntMatch(pattern, name)).assertTiming(); } | assertDoesntMatchFast |
273,206 | void () { PlatformTestUtil.startPerformanceTest(getName(), 30, () -> { String pattern = "*# -*- coding: utf-8 -*-$:. unshift(\"/Library/RubyMotion/lib\")require 'motion/project'Motion::Project::App. setup do |app| # Use `rake config' to see complete project settings. app. sdk_version = '4. 3'end"; String name = "# -*- coding: utf-8 -*-$:.unshift(\"/Library/RubyMotion/lib\")require 'motion/project'Motion::Project::App.setup do |app| # Use `rake config' to see complete project settings. app.sdk_version = '4.3' app.frameworks -= ['UIKit']end"; assertDoesntMatch(pattern, name); }).assertTiming(); } | testMatchingLongRuby |
273,207 | void () { String s = "the class with its attributes mapped to fields of records parsed by an {@link AbstractParser} or written by an {@link AbstractWriter}."; PlatformTestUtil.startPerformanceTest(getName(), 30, () -> { assertMatches(s, s); assertMatches("*" + s, s); assertPreference(s, s.substring(0, 10), s); assertPreference("*" + s, s.substring(0, 10), s); }).assertTiming(); } | testLongStringMatchingWithItself |
273,208 | void () { DefaultLogger.disableStderrDumping(getTestRootDisposable()); SimpleModificationTracker dependency = new SimpleModificationTracker(); Function<String, String> getCached = arg -> CachedValuesManager.getManager(getProject()).getCachedValue(holder, () -> CachedValueProvider.Result.create("result " + arg, dependency)); assertEquals("result foo", getCached.apply("foo")); dependency.incModificationCount(); assertEquals("result foo", getCached.apply("foo")); dependency.incModificationCount(); try { getCached.apply("bar"); TestCase.fail(); } catch (AssertionError e) { String message = e.getMessage(); assertTrue(message, message.contains("Incorrect CachedValue use")); assertTrue(message, message.contains("foo")); assertTrue(message, message.contains("bar")); } } | testCachedValueCapturingInvalidStuff |
273,209 | Long () { return getPsiManager().getModificationTracker().getModificationCount(); } | getPsiModCount |
273,210 | void () { IdempotenceChecker.disableRandomChecksUntil(getTestRootDisposable()); PsiFile file = myFixture.addFileToProject("a.txt", ""); AtomicInteger recomputations = new AtomicInteger(); CachedValue<String> cv = CachedValuesManager.getManager(getProject()).createCachedValue(() -> { recomputations.incrementAndGet(); return CachedValueProvider.Result.create("x", file); }); assertEquals("x", cv.getValue()); assertEquals(1, recomputations.get()); myFixture.addFileToProject("b.txt", ""); assertEquals("x", cv.getValue()); assertEquals(1, recomputations.get()); } | testExternalChangesDoNotLeadToRecomputationOfPsiFileDependentCache |
273,211 | void () { VirtualFile moduleRoot = getTempDir().createVirtualDir(); ModuleRootModificationUtil.addContentRoot(getModule(), moduleRoot.getPath()); GlobalSearchScope projectScope = GlobalSearchScope.projectScope(getProject()); assertFalse(projectScope.isSearchInLibraries()); assertTrue(projectScope.isSearchInModuleContent(getModule())); assertTrue(projectScope.contains(moduleRoot)); GlobalSearchScope notProjectScope = GlobalSearchScope.notScope(projectScope); assertTrue(notProjectScope.isSearchInLibraries()); assertFalse(notProjectScope.contains(moduleRoot)); GlobalSearchScope allScope = GlobalSearchScope.allScope(getProject()); assertTrue(allScope.isSearchInLibraries()); assertTrue(allScope.contains(moduleRoot)); GlobalSearchScope notAllScope = GlobalSearchScope.notScope(allScope); assertFalse(notAllScope.contains(moduleRoot)); } | testNotScope |
273,212 | void () { AtomicInteger targetCalled = new AtomicInteger(); GlobalSearchScope alwaysTrue = new DelegatingGlobalSearchScope(new EverythingGlobalScope()) { @Override public boolean contains(@NotNull VirtualFile file) { return true; } }; GlobalSearchScope target = new DelegatingGlobalSearchScope(new EverythingGlobalScope()) { @Override public boolean contains(@NotNull VirtualFile file) { targetCalled.incrementAndGet(); return true; } }; GlobalSearchScope trueIntersection = target.intersectWith(alwaysTrue); VirtualFile file1 = getTempDir().createVirtualFile("file1"); VirtualFile file2 = getTempDir().createVirtualFile("file2"); assertTrue(trueIntersection.contains(file2)); assertEquals(1, targetCalled.get()); assertFalse(GlobalSearchScope.fileScope(myProject, file1).intersectWith(trueIntersection).contains(file2)); assertEquals(1, targetCalled.get()); } | testIntersectionPreservesOrderInCaseClientsWantToPutCheaperChecksFirst |
273,213 | boolean (@NotNull VirtualFile file) { return true; } | contains |
273,214 | boolean (@NotNull VirtualFile file) { targetCalled.incrementAndGet(); return true; } | contains |
273,215 | void () { VirtualFile moduleRoot = getTempDir().createVirtualDir(); assertNotNull(moduleRoot); PsiTestUtil.addSourceRoot(getModule(), moduleRoot); VirtualFile moduleRoot2 = getTempDir().createVirtualDir(); assertNotNull(moduleRoot2); PsiTestUtil.addSourceRoot(getModule(), moduleRoot2); GlobalSearchScope modScope = getModule().getModuleScope(); int compare = modScope.compare(moduleRoot, moduleRoot2); assertTrue(compare != 0); GlobalSearchScope union = modScope.uniteWith(GlobalSearchScope.EMPTY_SCOPE); int compare2 = union.compare(moduleRoot, moduleRoot2); assertEquals(compare, compare2); assertEquals(modScope.compare(moduleRoot2, moduleRoot), union.compare(moduleRoot2, moduleRoot)); } | testUnionWithEmptyScopeMustNotAffectCompare |
273,216 | void () { PsiFile file = PsiFileFactory.getInstance(myProject).createFileFromText(PlainTextLanguage.INSTANCE, ""); VirtualFile vFile = file.getViewProvider().getVirtualFile(); assertFalse(GlobalSearchScope.allScope(myProject).contains(vFile)); assertFalse(PsiSearchScopeUtil.isInScope(GlobalSearchScope.allScope(myProject), file)); assertTrue(file.getResolveScope().contains(vFile)); assertTrue(PsiSearchScopeUtil.isInScope(file.getResolveScope(), file)); } | testIsInScopeDoesNotAcceptRandomNonPhysicalFilesByDefault |
273,217 | void () { GlobalSearchScope scope = GlobalSearchScope.EMPTY_SCOPE.uniteWith(GlobalSearchScope.EMPTY_SCOPE); assertEquals(GlobalSearchScope.EMPTY_SCOPE, scope); GlobalSearchScope scope2 = GlobalSearchScope.union(new GlobalSearchScope[]{GlobalSearchScope.EMPTY_SCOPE, GlobalSearchScope.EMPTY_SCOPE}); assertEquals(GlobalSearchScope.EMPTY_SCOPE, scope2); GlobalSearchScope p = GlobalSearchScope.projectScope(getProject()); GlobalSearchScope scope3 = GlobalSearchScope.union(new GlobalSearchScope[]{GlobalSearchScope.EMPTY_SCOPE, p, GlobalSearchScope.EMPTY_SCOPE}); assertEquals(p, scope3); GlobalSearchScope m = GlobalSearchScope.moduleScope(getModule()); GlobalSearchScope pm = m.uniteWith(p); Assert.assertNotEquals(m, pm); GlobalSearchScope scope4 = GlobalSearchScope.union(new GlobalSearchScope[]{GlobalSearchScope.EMPTY_SCOPE, p, GlobalSearchScope.EMPTY_SCOPE, pm, m}); assertEquals(pm, scope4); } | testUnionWithEmptyAndUnion |
273,218 | void () { assertEquals("a\\.[^\\.]*", FilePatternPackageSet.convertToRegexp("a.*", '.')); assertEquals("a\\.(.*\\.)?[^\\.]*", FilePatternPackageSet.convertToRegexp("a..*", '.')); assertEquals("a\\/[^\\/]*", FilePatternPackageSet.convertToRegexp("a/*", '/')); assertEquals("a\\/.*\\.css", FilePatternPackageSet.convertToRegexp("a/*.css", '/')); assertEquals("a\\/(.*\\/)?[^\\/]*", FilePatternPackageSet.convertToRegexp("a//*", '/')); assertEquals("[^\\.]*", FilePatternPackageSet.convertToRegexp("*", '.')); } | testConvertToRegexp |
273,219 | void () { myStrategy = new StaticTextWhiteSpaceDefinitionStrategy("abc"); } | setUp |
273,220 | void () { assertSame(0, myStrategy.check(" abc", 0, 4)); assertSame(1, myStrategy.check(" abc", 1, 3)); } | notAtFirstPosition |
273,221 | void () { assertSame(3, myStrategy.check("abc", 0, 3)); assertSame(4, myStrategy.check(" abcde", 1, 5)); } | match |
273,222 | void () { assertSame(0, myStrategy.check("abc", 0, 2)); assertSame(1, myStrategy.check(" abc", 1, 3)); } | withoutEnd |
273,223 | void () { myStrategy = new StaticSymbolWhiteSpaceDefinitionStrategy('a', 'b', 'c'); } | setUp |
273,224 | void () { assertSame(0, myStrategy.check("def", 0, 2)); assertSame(1, myStrategy.check("defghi", 1, 2)); } | failOnTheFirstSymbol |
273,225 | void () { assertSame(1, myStrategy.check("adef", 0, 3)); assertSame(2, myStrategy.check("daefghi", 1, 3)); } | failInTheMiddle |
273,226 | void () { assertSame(2, myStrategy.check("abe", 0, 3)); assertSame(3, myStrategy.check("dabefghi", 1, 4)); } | failOnTheLastSymbol |
273,227 | void () { assertSame(3, myStrategy.check("abc", 0, 3)); assertSame(4, myStrategy.check("dabcefg", 1, 4)); } | successfulMatch |
273,228 | void (int indentExpected, int timesUsedExpected) { IndentUsageInfo maxIndentExpected = new IndentUsageInfo(indentExpected, timesUsedExpected); IndentUsageInfo indentInfo = getMaxUsedIndentInfo(); Assert.assertEquals("Indent size mismatch", maxIndentExpected.getIndentSize(), indentInfo.getIndentSize()); Assert.assertEquals("Indent size usage number mismatch", maxIndentExpected.getTimesUsed(), indentInfo.getTimesUsed()); } | doTestMaxUsedIndent |
273,229 | void (int indentExpected) { IndentUsageInfo indentInfo = getMaxUsedIndentInfo(); Assert.assertEquals("Indent size mismatch", indentExpected, indentInfo.getIndentSize()); } | doTestMaxUsedIndent |
273,230 | void () { doTestTabsUsed(null); } | doTestTabsUsed |
273,231 | void (int expectedIndent) { configureByFile(getFileNameWithExtension()); doTestIndentSize(null, expectedIndent); } | doTestIndentSize |
273,232 | void (String text, @Nullable CommonCodeStyleSettings.IndentOptions options, int expectedIndent) { configureFromFileText(getFileNameWithExtension(), text); doTestIndentSize(options, expectedIndent); } | doTestIndentSizeFromText |
273,233 | void (@Nullable CommonCodeStyleSettings.IndentOptions defaultIndentOptions) { configureByFile(getFileNameWithExtension()); if (defaultIndentOptions != null) { setIndentOptions(defaultIndentOptions); } CommonCodeStyleSettings.IndentOptions options = detectIndentOptions(getVFile(), getEditor().getDocument()); Assert.assertTrue("Tab usage not detected", options.USE_TAB_CHARACTER); } | doTestTabsUsed |
273,234 | void (@Nullable CommonCodeStyleSettings.IndentOptions defaultIndentOptions, int expectedIndent) { if (defaultIndentOptions != null) { setIndentOptions(defaultIndentOptions); } CommonCodeStyleSettings.IndentOptions options = detectIndentOptions(getVFile(), getEditor().getDocument()); Assert.assertFalse("Tab usage detected: ", options.USE_TAB_CHARACTER); Assert.assertEquals("Indent mismatch", expectedIndent, options.INDENT_SIZE); } | doTestIndentSize |
273,235 | void (@NotNull CommonCodeStyleSettings.IndentOptions defaultIndentOptions) { CodeStyleSettings settings = CodeStyle.getSettings(getProject()); CommonCodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptions(getFile().getFileType()); indentOptions.copyFrom(defaultIndentOptions); } | setIndentOptions |
273,236 | IndentUsageInfo () { configureByFile(getFileNameWithExtension()); Document document = getDocument(getFile()); FormattingModelBuilder builder = LanguageFormatting.INSTANCE.forContext(getFile()); Assert.assertNotNull(builder); FormattingModel model = builder.createModel(FormattingContext.create(getFile(), CodeStyle.getSettings(getProject()))); List<LineIndentInfo> lines = new FormatterBasedLineIndentInfoBuilder(document, model.getRootBlock(), null).build(); IndentUsageStatistics statistics = new IndentUsageStatisticsImpl(lines); return statistics.getKMostUsedIndentInfo(0); } | getMaxUsedIndentInfo |
273,237 | PsiDocumentManagerImpl () { return (PsiDocumentManagerImpl)PsiDocumentManager.getInstance(getProject()); } | getPsiDocumentManager |
273,238 | void () { final PsiFile file = getPsiDocumentManager().getCachedPsiFile(new MockDocument()); assertNull(file); } | testGetCachedPsiFile_NoFile |
273,239 | void () { final PsiFile file = getPsiDocumentManager().getPsiFile(new MockDocument()); assertNull(file); } | testGetPsiFile_NotRegisteredDocument |
273,240 | void () { VirtualFile vFile = createFile(); final PsiFile file = new MockPsiFile(vFile, getPsiManager()); final Document document = getDocument(file); assertNotNull(document); assertSame(document, FileDocumentManager.getInstance().getDocument(vFile)); } | testGetDocument_FirstGet |
273,241 | LightVirtualFile () { return new LightVirtualFile("foo.txt"); } | createFile |
273,242 | PsiFile (@NotNull VirtualFile vFile) { return getPsiManager().findFile(vFile); } | findFile |
273,243 | void () { assertEquals(0, getPsiDocumentManager().getUncommittedDocuments().length); } | testGetUncommittedDocuments_noDocuments |
273,244 | void () { final PsiFile file = findFile(createFile()); final Document document = getDocument(file); WriteCommandAction.runWriteCommandAction(null, () -> PsiToDocumentSynchronizer .performAtomically(file, () -> changeDocument(document, getPsiDocumentManager()))); assertEquals(0, getPsiDocumentManager().getUncommittedDocuments().length); } | testGetUncommittedDocuments_documentChanged_DontProcessEvents |
273,245 | void () { final Document document = new MockDocument(); WriteCommandAction.runWriteCommandAction(null, () -> changeDocument(document, getPsiDocumentManager())); assertEquals(0, getPsiDocumentManager().getUncommittedDocuments().length); } | testGetUncommittedDocuments_documentNotRegistered |
273,246 | void () { PsiFile file = findFile(createFile()); final Document document = getDocument(file); WriteCommandAction.runWriteCommandAction(null, () -> changeDocument(document, getPsiDocumentManager())); getPsiDocumentManager().commitDocument(document); assertEquals(0, getPsiDocumentManager().getUncommittedDocuments().length); } | testCommitDocument_RemovesFromUncommittedList |
273,247 | Document (PsiFile file) { return getPsiDocumentManager().getDocument(file); } | getDocument |
273,248 | void (Document document, PsiDocumentManagerImpl manager) { DocumentEventImpl event = new DocumentEventImpl(document, 0, "", "", document.getModificationStamp(), false, 0, 0, 0); manager.beforeDocumentChange(event); manager.documentChanged(event); } | changeDocument |
273,249 | void () { PsiFile file = findFile(createFile()); final Document document = getDocument(file); WriteCommandAction.runWriteCommandAction(null, () -> changeDocument(document, getPsiDocumentManager())); getPsiDocumentManager().commitAllDocuments(); assertEquals(0, getPsiDocumentManager().getUncommittedDocuments().length); } | testCommitAllDocument_RemovesFromUncommittedList |
273,250 | void () { PsiFile file = findFile(createFile()); assertNotNull(file); assertTrue(file.isPhysical()); final Document document = getDocument(file); assertNotNull(document); final Semaphore semaphore = new Semaphore(); semaphore.down(); getPsiDocumentManager().performWhenAllCommitted(() -> { assertTrue(getPsiDocumentManager().isCommitted(document)); semaphore.up(); }); waitAndPump(semaphore); assertTrue(getPsiDocumentManager().isCommitted(document)); WriteCommandAction.runWriteCommandAction(null, () -> document.insertString(0, "class X {}")); semaphore.down(); getPsiDocumentManager().performWhenAllCommitted(() -> { assertTrue(getPsiDocumentManager().isCommitted(document)); semaphore.up(); }); waitAndPump(semaphore); assertTrue(getPsiDocumentManager().isCommitted(document)); final AtomicInteger count = new AtomicInteger(); WriteCommandAction.runWriteCommandAction(null, () -> { document.insertString(0, "/**/"); boolean executed = getPsiDocumentManager().cancelAndRunWhenAllCommitted("xxx", count::incrementAndGet); assertFalse(executed); executed = getPsiDocumentManager().cancelAndRunWhenAllCommitted("xxx", count::incrementAndGet); assertFalse(executed); assertEquals(0, count.get()); }); while (!getPsiDocumentManager().isCommitted(document)) { UIUtil.dispatchAllInvocationEvents(); } assertTrue(getPsiDocumentManager().isCommitted(document)); assertEquals(1, count.get()); count.set(0); WriteCommandAction.runWriteCommandAction(null, () -> { document.insertString(0, "/**/"); boolean executed = getPsiDocumentManager().performWhenAllCommitted(count::incrementAndGet); assertFalse(executed); executed = getPsiDocumentManager().performWhenAllCommitted(count::incrementAndGet); assertFalse(executed); assertEquals(0, count.get()); }); while (!getPsiDocumentManager().isCommitted(document)) { UIUtil.dispatchAllInvocationEvents(); } assertTrue(getPsiDocumentManager().isCommitted(document)); assertEquals(2, count.get()); } | testCommitInBackground |
273,251 | void (Semaphore semaphore) { TestTimeOut t = TestTimeOut.setTimeout(TIMEOUT_MS, TimeUnit.MILLISECONDS); while (!t.timedOut()) { if (semaphore.waitFor(1)) return; UIUtil.dispatchAllInvocationEvents(); } fail("Timeout"); } | waitAndPump |
273,252 | void (VirtualFile vFile, PsiFile psiFile, Document document) { assertNull(FileDocumentManager.getInstance().getDocument(vFile)); assertNull(FileDocumentManager.getInstance().getFile(document)); assertNull(getPsiDocumentManager().getPsiFile(document)); assertNull(getDocument(psiFile)); } | assertNoFileDocumentMapping |
273,253 | JComponent () { return null; } | createCenterPanel |
273,254 | JComponent () { return null; } | createCenterPanel |
273,255 | void () { try { DocumentCommitThread.getInstance().waitForAllCommits(100, TimeUnit.SECONDS); } catch (ExecutionException | InterruptedException | TimeoutException e) { throw new RuntimeException(e); } } | waitForCommits |
273,256 | void () { PsiFile file = findFile(createFile()); assertNotNull(file); assertTrue(file.isPhysical()); final Document document = getDocument(file); assertNotNull(document); WriteCommandAction.runWriteCommandAction(null, () -> document.insertString(0, "class X {}")); getPsiDocumentManager().performWhenAllCommitted(() -> { try { getPsiDocumentManager().performWhenAllCommitted(() -> { }); fail("Must fail"); } catch (IncorrectOperationException ignored) { } }); getPsiDocumentManager().commitAllDocuments(); assertTrue(getPsiDocumentManager().isCommitted(document)); } | testPerformWhenAllCommittedMustNotNest |
273,257 | void () { Document document = createFreeThreadedDocument(); document.addDocumentListener(new PrioritizedDocumentListener() { @Override public int getPriority() { return 0; } @Override public void beforeDocumentChange(@NotNull DocumentEvent event) { throw new ProcessCanceledException(); } }); try { document.insertString(0, "a"); fail("PCE expected"); } catch (ProcessCanceledException ignored) { } getPsiDocumentManager().commitAllDocuments(); LeakHunter.checkLeak(getPsiDocumentManager(), Document.class, d -> d == document); } | testNoLeaksAfterPCEInListener |
273,258 | int () { return 0; } | getPriority |
273,259 | void (@NotNull DocumentEvent event) { throw new ProcessCanceledException(); } | beforeDocumentChange |
273,260 | Document () { PsiFile file = PsiFileFactory.getInstance(myProject).createFileFromText("a.txt", PlainTextFileType.INSTANCE, ""); return file.getViewProvider().getDocument(); } | createFreeThreadedDocument |
273,261 | void (@NotNull String content, @NotNull VirtualFile vFile, @NotNull Document document) { Charset charset = EncodingProjectManager.getInstance(getProject()).getEncoding(vFile, false); float bytesPerChar = charset == null ? 2 : charset.newEncoder().averageBytesPerChar(); int contentSize = (int)(FileUtilRt.LARGE_FILE_PREVIEW_SIZE / bytesPerChar); String substring = content.substring(0, contentSize); assertEquals(substring, document.getText()); } | assertLargeFileContentLimited |
273,262 | String () { return StringUtil.repeat("a", FileUtilRt.LARGE_FOR_CONTENT_LOADING + 1); } | getTooLargeContent |
273,263 | void () { Assume.assumeTrue("This test must have JavaFileType in its classpath", FileTypeManager.getInstance().findFileTypeByName("JAVA") != null); } | assumeJavaInClassPath |
273,264 | void () { NonBlockingReadActionImpl.waitForAsyncTaskCompletion(); PsiFileFactory factory = PsiFileFactory.getInstance(getProject()); List<PsiFile> files = new ArrayList<>(); for (int i = 0; i < 90; i++) { files.add(factory.createFileFromText("a.xml", XMLLanguage.INSTANCE, "<a><b><c/></b></a>", false, false)); } AtomicInteger attempts = new AtomicInteger(); CancellablePromise<Void> future = ReadAction.nonBlocking(() -> { attempts.incrementAndGet(); for (PsiFile file : files) { TimeoutUtil.sleep(1); Document document = FileDocumentManager.getInstance().getDocument(file.getViewProvider().getVirtualFile()); document.insertString(0, " "); for (PsiElement element : SyntaxTraverser.psiTraverser(file)) { ProgressManager.checkCanceled(); assertNotNull(element.getTextRange()); } } }).submit(AppExecutorUtil.getAppExecutorService()); PlatformTestUtil.waitForFuture(future, 10_000); assertTrue(String.valueOf(attempts), attempts.get() < 10); } | testNonPhysicalDocumentCommitsDoNotInterruptBackgroundTasks |
273,265 | void () { ExecutorService executor = AppExecutorUtil.createBoundedApplicationPoolExecutor(getTestName(false), 10); PsiFile mainFile = findFile(createFile()); Document mainDoc = getDocument(mainFile); PsiFileFactory factory = PsiFileFactory.getInstance(getProject()); List<Future<?>> futures = new ArrayList<>(); for (int i = 0; i < 5; i++) { for (int j = 0; j < 20; j++) { PsiFile tempFile = factory.createFileFromText(i + ".xml", XMLLanguage.INSTANCE, "<a><b><c/></b></a>", false, false); Document document = FileDocumentManager.getInstance().getDocument(tempFile.getViewProvider().getVirtualFile()); document.insertString(0, " "); futures.add(ReadAction.nonBlocking(() -> { getPsiDocumentManager().commitDocument(document); assertEquals(tempFile.getText(), document.getText()); }).submit(executor)); } Semaphore semaphore = new Semaphore(1); WriteCommandAction.runWriteCommandAction(myProject, () -> { mainDoc.insertString(0, " "); getPsiDocumentManager().performWhenAllCommitted(semaphore::up); }); waitAndPump(semaphore); assertTrue(getPsiDocumentManager().isCommitted(mainDoc)); assertEquals(mainFile.getText(), mainDoc.getText()); } for (Future<?> future : futures) { PlatformTestUtil.waitForFuture(future, 10_000); } } | testPerformWhenAllCommittedDoesNotRaceWithBackgroundLightCommitsResultingInExceptions |
273,266 | void () { PsiFile file = findFile(createFile()); Document document = getDocument(file); AtomicBoolean called = new AtomicBoolean(true); getProject().getMessageBus().connect(getTestRootDisposable()).subscribe(PsiManagerImpl.ANY_PSI_CHANGE_TOPIC, new AnyPsiChangeListener() { @Override public void afterPsiChanged(boolean isPhysical) { called.set(true); assertFalse(getPsiDocumentManager().isCommitted(document)); assertTrue(getPsiDocumentManager().isUncommited(document)); assertSameElements(getPsiDocumentManager().getUncommittedDocuments(), document); } }); WriteCommandAction.runWriteCommandAction(myProject, () -> { document.insertString(0, "a"); getPsiDocumentManager().commitDocument(document); }); assertTrue(called.get()); } | testDocumentIsUncommittedInsidePsiListener |
273,267 | void (boolean isPhysical) { called.set(true); assertFalse(getPsiDocumentManager().isCommitted(document)); assertTrue(getPsiDocumentManager().isUncommited(document)); assertSameElements(getPsiDocumentManager().getUncommittedDocuments(), document); } | afterPsiChanged |
273,268 | void () { Document ftDocument = createFreeThreadedDocument(); CompletableFuture<Boolean> called = new CompletableFuture<>(); WriteCommandAction.runWriteCommandAction(myProject, () -> { ftDocument.insertString(0, " "); getPsiDocumentManager().performWhenAllCommitted(() -> called.complete(true)); }); assertTrue(PlatformTestUtil.waitForFuture(called, 10_000)); } | test_performWhenAllCommitted_works_eventually_despite_nonPhysical_uncommitted |
273,269 | void () { Document ftDocument = createFreeThreadedDocument(); CompletableFuture<Boolean> called = new CompletableFuture<>(); WriteCommandAction.runWriteCommandAction(myProject, () -> { ftDocument.insertString(0, " "); getPsiDocumentManager().performLaterWhenAllCommitted(() -> called.complete(true)); }); assertTrue(PlatformTestUtil.waitForFuture(called, 10_000)); } | test_performLaterWhenAllCommitted_works_eventually_despite_nonPhysical_uncommitted |
273,270 | void () { Document ftDocument = createFreeThreadedDocument(); CompletableFuture<Boolean> called = new CompletableFuture<>(); WriteCommandAction.runWriteCommandAction(myProject, () -> { ftDocument.insertString(0, " "); AppUIExecutor.onUiThread().withDocumentsCommitted(myProject).submit(() -> called.complete(true)); }); assertTrue(PlatformTestUtil.waitForFuture(called, 10_000)); } | test_AppUIExecutor_withDocumentsCommitted_works_eventually_despite_nonPhysical_uncommitted |
273,271 | void () { Document document = getDocument(findFile(createFile())); CompletableFuture<Boolean> called = new CompletableFuture<>(); WriteCommandAction.runWriteCommandAction(myProject, () -> { document.insertString(0, " "); ApplicationManager.getApplication().invokeLater(() -> { LaterInvocator.enterModal(this); assertFalse(TransactionGuard.getInstance().isWriteSafeModality(ModalityState.defaultModalityState())); getPsiDocumentManager().performWhenAllCommitted(() -> called.complete(true)); waitForCommits(); assertFalse(called.isDone()); }, ModalityState.any()); }); UIUtil.dispatchAllInvocationEvents(); LaterInvocator.leaveModal(this); assertTrue(PlatformTestUtil.waitForFuture(called, 10_000)); } | test_performWhenAllCommitted_may_be_invoked_from_writeUnsafe_modality |
273,272 | void () { Document document = getDocument(findFile(createFile())); WriteCommandAction.runWriteCommandAction(myProject, () -> document.insertString(0, " ")); ProgressManager.getInstance().run(new Task.Modal(myProject, "", true) { @Override public void run(@NotNull ProgressIndicator indicator) { assertFalse(getPsiDocumentManager().isCommitted(document)); getPsiDocumentManager().commitAndRunReadAction(() -> assertTrue(getPsiDocumentManager().isCommitted(document))); } }); } | test_commitAndRunReadAction_commits_documents_in_needed_modality |
273,273 | void (@NotNull ProgressIndicator indicator) { assertFalse(getPsiDocumentManager().isCommitted(document)); getPsiDocumentManager().commitAndRunReadAction(() -> assertTrue(getPsiDocumentManager().isCommitted(document))); } | run |
273,274 | void () { assertEquals(-1, doTest("n", "\\n")); } | testBackslashBeforeSequence |
273,275 | void () { assertEquals(2, doTest("n", "\\\\n")); } | testEscapedBackslashBeforeSequence |
273,276 | void () { assertEquals(-1, doTest("n", "\\\\\\n")); } | testTwoBackslashesBeforeSequence |
273,277 | void () { assertEquals(2, doTest("n", "\\nn")); } | testBackslashNBeforeSequence |
273,278 | void () { assertEquals(-1, doTest("n", "%d\\n")); } | testBackslashBeforeSequenceNotBeginning |
273,279 | int (String pattern, String text) { StringSearcher searcher = new StringSearcher(pattern, true, true, true); final int[] index = {-1}; LowLevelSearchUtil.processTexts(text, 0, text.length(), searcher, value -> { index[0] = value; return false; }); return index[0]; } | doTest |
273,280 | void () { StringSearcher searcher = new StringSearcher("xxx", true, true); IntList found = new IntArrayList(new int[]{-1}); CharSequence text = StringUtil.repeat("xxx z ", 1000000); PlatformTestUtil.startPerformanceTest("processTextOccurrences", 100, ()-> { for (int i=0; i<10000; i++) { found.removeInt(0); int startOffset = text.length() / 2 + i % 20; int endOffset = startOffset + 8; boolean success = LowLevelSearchUtil.processTexts(text, startOffset, endOffset, searcher, offset -> { found.add(offset); return true; }); assertTrue(success); assertEquals(startOffset+","+endOffset, 1, found.size()); } }).assertTiming(); } | testProcessTextOccurrencesNeverScansBeyondStartEndOffsetIfNeverAskedTo |
273,281 | void () { T1 = new IElementType("T1", Language.ANY); T2 = new IElementType("T2", Language.ANY); fakeElements(1, 128); T3 = new IElementType("T3", Language.ANY); T4 = new IElementType("T4", Language.ANY); fakeElements(201, 204); T5 = new IElementType("T5", Language.ANY); T6 = new IElementType("T6", Language.ANY); } | setUp |
273,282 | void () { S1 = TokenSet.create(T1); S12 = TokenSet.create(T1, T2); S3 = TokenSet.create(T3); S34 = TokenSet.create(T3, T4); S5 = TokenSet.create(T5); } | isetup |
273,283 | void () { check(S1, T1); check(S12, T1, T2); check(S3, T3); check(S34, T3, T4); } | create |
273,284 | void () { assertArrayEquals(IElementType.EMPTY_ARRAY, TokenSet.EMPTY.getTypes()); assertArrayEquals(new IElementType[]{T1, T2}, S12.getTypes()); assertArrayEquals(new IElementType[]{T3, T4}, S34.getTypes()); assertEquals("[]", TokenSet.EMPTY.toString()); assertEquals("[T1, T2]", S12.toString()); assertEquals("[T3, T4]", S34.toString()); } | getTypes |
273,285 | void () { check(TokenSet.orSet(S1, S12, S3), T1, T2, T3); check(TokenSet.orSet(S1, S3), T1, T3); } | orSet |
273,286 | void () { check(TokenSet.andSet(S1, S12), T1); check(TokenSet.andSet(S12, S34)); } | andSet |
273,287 | void () { final TokenSet S123 = TokenSet.orSet(S12, S3); check(TokenSet.andNot(S123, S12), T3); check(TokenSet.andNot(S123, S5), T1, T2, T3); } | andNot |
273,288 | void (int from, int to) { for (int i = from; i <= to; i++) { new IElementType("Test element #" + i, Language.ANY); } } | fakeElements |
273,289 | void (@NotNull TokenSet set, IElementType @NotNull ... elements) { final Set<IElementType> expected = ContainerUtil.newHashSet(elements); for (IElementType t : Arrays.asList(T1, T2, T3, T4, T5, T6)) { if (expected.contains(t)) { assertTrue("missed: " + t, set.contains(t)); } else { assertFalse("unexpected: " + t, set.contains(t)); } } } | check |
273,290 | void () { final IElementType[] elementTypes = IElementType.enumerate(IElementType.TRUE); final TokenSet set = TokenSet.create(); final int shift = new Random().nextInt(500000); PlatformTestUtil.startPerformanceTest("TokenSet.contains()", 25, () -> { for (int i = 0; i < 1000000; i++) { final IElementType next = elementTypes[(i + shift) % elementTypes.length]; assertFalse(set.contains(next)); } }).useLegacyScaling().assertTiming(); } | performance |
273,291 | void () { SplittableRandom random = new SplittableRandom(1); String[] data = Stream.generate(() -> { StringBuilder sb = new StringBuilder(); random.ints(random.nextInt(5, 25), 'a', 'z') .map(ch -> random.nextInt(100) == 0 ? "0123456789$_@%вгдежзиклмно".charAt(ch - 'a') : random.nextInt(6) == 0 ? Character.toUpperCase(ch) : ch) .forEach(sb::appendCodePoint); return sb.toString(); }).limit(20000).toArray(String[]::new); TypoTolerantMatcher matcher = new TypoTolerantMatcher("asd", NameUtil.MatchingCaseSensitivity.FIRST_LETTER, ""); List<String> matched = ContainerUtil.filter(data, matcher::matches); List<String> expected = List.of("aqvQpSfmT", "arvIeSdS", "agofjgjwovuUiSmdalto", "jasridvantDr", "asvioqecqrkujxuLoiDo", "ssHDdcogvKq", "asQDqhkej", "gastDtHdqgG", "ahSDaks", "abKluwAdwxJoUyibvgeoh", "aDbsnmlGlJuBJsDi", "aamaoRrghlcD", "aadnjwforytcqwa", "adovoaqvSximVAdD", "adyqfdmDaryuakWicnjcj", "ahNbcEcpIsD", "aLompgtlMkDdypdxwmvvUG", "ajxoADelNmdbmvutbidrde", "nasbcDhbfXx", "aDhbEtoublcDryyh", "pAeloeorWqXslbSDbv", "asnnWshffqbujmcOd", "adXovaMuDYjyrlexj"); assertEquals(expected, matched); } | testStability |
273,292 | void () { TypoTolerantMatcher matcher = new TypoTolerantMatcher("*", NameUtil.MatchingCaseSensitivity.NONE, ""); String[] data = new String[]{"foo", "bar", "buzz"}; List<String> matched = ContainerUtil.filter(data, matcher::matches); List<String> expected = List.of("foo", "bar", "buzz"); assertEquals(expected, matched); } | testEmptyPattern |
273,293 | String (String varName, String input) { StringBuilder result = new StringBuilder(varName + " =\n\""); int curLineLength = 0; for (int i = 0; i < input.length(); i++) { char ch = input.charAt(i); String charRepresentation; if (ch == '"' || ch == '\\') { charRepresentation = "\\" + ch; } else if (ch < 127) { charRepresentation = Character.toString(ch); } else { charRepresentation = String.format("\\u%04X", (int)ch); } result.append(charRepresentation); curLineLength += charRepresentation.length(); if (curLineLength > LINE_LENGTH && i < input.length() - 1) { curLineLength = 0; result.append("\" +\n\""); } } return result.append("\";").toString(); } | toJavaStringLiteral |
273,294 | String (List<Mapping> mappings, List<String> initials) { Map<String, Character> encoding = initials.stream() .collect(Collectors.toMap(s -> s, s -> (char)(PinyinMatcher.BASE_CHAR + initials.indexOf(s)))); Map<Integer, Character> map = mappings.stream() .collect(Collectors.toMap(mapping -> mapping.codePoint, m -> encoding.get(m.charString()))); int lastCodePoint = mappings.stream().mapToInt(m -> m.codePoint).max().orElseThrow(NoSuchElementException::new); return IntStream.rangeClosed(PinyinMatcher.BASE_CODE_POINT, lastCodePoint) .mapToObj(i -> map.getOrDefault(i, ' ').toString()).collect(Collectors.joining()); } | getDataString |
273,295 | List<String> (List<Mapping> mappings) { return mappings.stream().map(Mapping::charString).distinct() .sorted(Comparator.comparing(String::length).thenComparing(Comparator.naturalOrder())) .collect(Collectors.toList()); } | generateInitials |
273,296 | record (int codePoint, long chars) { String charString() { return BitSet.valueOf(new long[]{chars}).stream().mapToObj(bit -> Character.toString((char)(bit + 'a'))) .collect(Collectors.joining()); } static Mapping merge(Mapping m1, Mapping m2) { if (m1.codePoint != m2.codePoint) throw new IllegalArgumentException(); return new Mapping(m1.codePoint, m1.chars | m2.chars); } static Mapping parseUniHan(String line) { if (line.startsWith("#")) return null; String[] parts = line.split("\\s+"); if (parts.length != 3) return null; if (!parts[0].startsWith("U+")) return null; int codePoint = Integer.parseInt(parts[0].substring(2), 16); if (codePoint < PinyinMatcher.BASE_CODE_POINT) return null; // Codepoints outside BMP are not supported for now if (codePoint > 0xA000) return null; String[] readings; switch (parts[1]) { case "kMandarin" -> readings = new String[]{parts[2]}; case "kHanyuPinyin" -> { int colonPos = parts[2].indexOf(':'); if (colonPos == -1) return null; readings = parts[2].substring(colonPos + 1).split(","); } default -> { return null; } } long encoded = 0; for (String reading : readings) { char initial = Normalizer.normalize(reading, Normalizer.Form.NFKD).charAt(0); encoded |= 1L << (initial - 'a'); } return new Mapping(codePoint, encoded); } @Override public String toString() { return String.format("%04X: %s", codePoint, charString()); } } | Mapping |
273,297 | Mapping (Mapping m1, Mapping m2) { if (m1.codePoint != m2.codePoint) throw new IllegalArgumentException(); return new Mapping(m1.codePoint, m1.chars | m2.chars); } | merge |
273,298 | Mapping (String line) { if (line.startsWith("#")) return null; String[] parts = line.split("\\s+"); if (parts.length != 3) return null; if (!parts[0].startsWith("U+")) return null; int codePoint = Integer.parseInt(parts[0].substring(2), 16); if (codePoint < PinyinMatcher.BASE_CODE_POINT) return null; // Codepoints outside BMP are not supported for now if (codePoint > 0xA000) return null; String[] readings; switch (parts[1]) { case "kMandarin" -> readings = new String[]{parts[2]}; case "kHanyuPinyin" -> { int colonPos = parts[2].indexOf(':'); if (colonPos == -1) return null; readings = parts[2].substring(colonPos + 1).split(","); } default -> { return null; } } long encoded = 0; for (String reading : readings) { char initial = Normalizer.normalize(reading, Normalizer.Form.NFKD).charAt(0); encoded |= 1L << (initial - 'a'); } return new Mapping(codePoint, encoded); } | parseUniHan |
273,299 | String () { return String.format("%04X: %s", codePoint, charString()); } | toString |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.