mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Reduce test's memory footprint; cleanup
This commit is contained in:
+18
-2
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.daemon;
|
||||
|
||||
import com.intellij.ExtensionPoints;
|
||||
@@ -266,10 +281,11 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
|
||||
public void testNamesHighlighting() throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
testFile(BASE_PATH + "/" + getTestName(false) + ".java").checkSymbolNames().test();
|
||||
doTestFile(BASE_PATH + "/" + getTestName(false) + ".java").checkSymbolNames().test();
|
||||
}
|
||||
|
||||
public void testMultiFieldDeclNames() throws Exception {
|
||||
testFile(BASE_PATH + "/" + getTestName(false) + ".java").checkSymbolNames().test();
|
||||
doTestFile(BASE_PATH + "/" + getTestName(false) + ".java").checkSymbolNames().test();
|
||||
}
|
||||
|
||||
public static class MyAnnotator implements Annotator {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,12 +18,23 @@ package com.intellij.psi;
|
||||
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
|
||||
|
||||
public class JavaSOEOnReparseTest extends LightDaemonAnalyzerTestCase {
|
||||
private static final StringBuilder HUGE_EXPR;
|
||||
static {
|
||||
HUGE_EXPR = new StringBuilder("\"-\"");
|
||||
for (int i = 0; i < 100000; i++) HUGE_EXPR.append("+\"b\"");
|
||||
private StringBuilder myHugeExpr;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myHugeExpr = new StringBuilder("\"-\"");
|
||||
for (int i = 0; i < 100000; i++) myHugeExpr.append("+\"b\"");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
if (myHugeExpr != null) {
|
||||
myHugeExpr.setLength(0);
|
||||
myHugeExpr = null;
|
||||
}
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testOnHugeBinaryExprInFile() throws Exception {
|
||||
@@ -42,7 +53,7 @@ public class JavaSOEOnReparseTest extends LightDaemonAnalyzerTestCase {
|
||||
// replace small expression with huge binary one
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override
|
||||
public void run() {
|
||||
getEditor().getDocument().replaceString(pos, pos + 2, HUGE_EXPR);
|
||||
getEditor().getDocument().replaceString(pos, pos + 2, myHugeExpr);
|
||||
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
|
||||
}});
|
||||
doTestConfiguredFile(false, false, null);
|
||||
@@ -66,7 +77,7 @@ public class JavaSOEOnReparseTest extends LightDaemonAnalyzerTestCase {
|
||||
// replace huge binary expression with small one
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override
|
||||
public void run() {
|
||||
getEditor().getDocument().replaceString(pos, pos + HUGE_EXPR.length(), "\".\"");
|
||||
getEditor().getDocument().replaceString(pos, pos + myHugeExpr.length(), "\".\"");
|
||||
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
|
||||
}});
|
||||
doTestConfiguredFile(false, false, null);
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -79,7 +79,7 @@ public abstract class LightDaemonAnalyzerTestCase extends LightCodeInsightTestCa
|
||||
doTestConfiguredFile(checkWarnings, checkInfos, filePath);
|
||||
}
|
||||
|
||||
protected void doTestConfiguredFile(boolean checkWarnings, boolean checkInfos, String filePath) {
|
||||
protected void doTestConfiguredFile(boolean checkWarnings, boolean checkInfos, @Nullable String filePath) {
|
||||
getJavaFacade().setAssertOnFileLoadingFilter(VirtualFileFilter.NONE);
|
||||
|
||||
ExpectedHighlightingData data = new ExpectedHighlightingData(getEditor().getDocument(),checkWarnings, checkInfos);
|
||||
@@ -87,7 +87,7 @@ public abstract class LightDaemonAnalyzerTestCase extends LightCodeInsightTestCa
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String composeLocalPath(String filePath) {
|
||||
private String composeLocalPath(@Nullable String filePath) {
|
||||
return filePath != null ? getTestDataPath() + "/" + filePath : null;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public abstract class LightDaemonAnalyzerTestCase extends LightCodeInsightTestCa
|
||||
data.checkResult(infos, getEditor().getDocument().getText(), filePath);
|
||||
}
|
||||
|
||||
protected HighlightTestInfo testFile(@NonNls @NotNull String filePath) {
|
||||
protected HighlightTestInfo doTestFile(@NonNls @NotNull String filePath) {
|
||||
return new HighlightTestInfo(getTestRootDisposable(), filePath){
|
||||
@Override
|
||||
public HighlightTestInfo doTest() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user