mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
override, do not create LookupManager if not needed
This commit is contained in:
+2
-16
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.java.codeInsight.completion;
|
||||
|
||||
import com.intellij.codeInsight.completion.CompletionType;
|
||||
@@ -48,7 +34,7 @@ public abstract class CompletionSortingTestCase extends LightFixtureCompletionTe
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
try {
|
||||
LookupManager.getInstance(getProject()).hideActiveLookup();
|
||||
LookupManager.hideActiveLookup(getProject());
|
||||
UISettings.getInstance().setSortLookupElementsLexicographically(false);
|
||||
}
|
||||
finally {
|
||||
|
||||
+15
-26
@@ -1,21 +1,8 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.java.codeInsight.completion;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.application.options.CodeStyle;
|
||||
import com.intellij.codeInsight.completion.CodeCompletionHandlerBase;
|
||||
import com.intellij.codeInsight.completion.CompletionType;
|
||||
import com.intellij.codeInsight.lookup.Lookup;
|
||||
@@ -25,7 +12,6 @@ import com.intellij.codeInsight.lookup.impl.LookupManagerImpl;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
@@ -123,9 +109,8 @@ public class CompletionStyleTest extends LightCodeInsightTestCase{
|
||||
}
|
||||
|
||||
public void testLocalVariablePreselect() {
|
||||
final String path = BASE_PATH;
|
||||
|
||||
configureByFile(path + "/before5.java");
|
||||
configureByFile(BASE_PATH + "/before5.java");
|
||||
performSmartCompletion();
|
||||
assertEquals("xxxx", getSelected().getLookupString());
|
||||
}
|
||||
@@ -260,7 +245,7 @@ public class CompletionStyleTest extends LightCodeInsightTestCase{
|
||||
}
|
||||
|
||||
private static CommonCodeStyleSettings getCodeStyleSettings() {
|
||||
return CodeStyleSettingsManager.getSettings(getProject()).getCommonSettings(JavaLanguage.INSTANCE);
|
||||
return CodeStyle.getSettings(getProject()).getCommonSettings(JavaLanguage.INSTANCE);
|
||||
}
|
||||
|
||||
|
||||
@@ -319,30 +304,34 @@ public class CompletionStyleTest extends LightCodeInsightTestCase{
|
||||
checkResultByFile(path + "/after38.java");
|
||||
}
|
||||
|
||||
private void performSmartCompletion(){
|
||||
private static void performSmartCompletion(){
|
||||
new CodeCompletionHandlerBase(CompletionType.SMART).invokeCompletion(getProject(), getEditor());
|
||||
}
|
||||
|
||||
private void performNormalCompletion(){
|
||||
private static void performNormalCompletion(){
|
||||
new CodeCompletionHandlerBase(CompletionType.BASIC).invokeCompletion(getProject(), getEditor());
|
||||
}
|
||||
|
||||
private void select(char completionChar, int index){
|
||||
private static void select(char completionChar, int index){
|
||||
((LookupManagerImpl)LookupManager.getInstance(getProject())).forceSelection(completionChar, index);
|
||||
}
|
||||
|
||||
private void select(char completionChar, LookupElement item){
|
||||
private static void select(char completionChar, LookupElement item){
|
||||
((LookupManagerImpl)LookupManager.getInstance(getProject())).forceSelection(completionChar, item);
|
||||
}
|
||||
|
||||
private LookupElement getSelected(){
|
||||
private static LookupElement getSelected(){
|
||||
return LookupManager.getInstance(getProject()).getActiveLookup().getCurrentItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
LookupManager.getInstance(getProject()).hideActiveLookup();
|
||||
super.tearDown();
|
||||
try {
|
||||
LookupManager.hideActiveLookup(getProject());
|
||||
}
|
||||
finally {
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
||||
|
||||
public void testAfterNew15() {
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.codeInsight.daemon.DaemonAnalyzerTestCase;
|
||||
@@ -41,7 +27,7 @@ public abstract class CompletionTestCase extends DaemonAnalyzerTestCase {
|
||||
protected void tearDown() throws Exception {
|
||||
myItems = null;
|
||||
try {
|
||||
LookupManager.getInstance(myProject).hideActiveLookup();
|
||||
LookupManager.hideActiveLookup(myProject);
|
||||
}
|
||||
finally {
|
||||
super.tearDown();
|
||||
|
||||
+3
-3
@@ -306,7 +306,7 @@ public class CodeCompletionHandlerBase {
|
||||
}
|
||||
|
||||
private AutoCompletionDecision shouldAutoComplete(CompletionProgressIndicator indicator,
|
||||
List<LookupElement> items,
|
||||
List<LookupElement> items,
|
||||
CompletionParameters parameters) {
|
||||
if (!invokedExplicitly) {
|
||||
return AutoCompletionDecision.SHOW_LOOKUP;
|
||||
@@ -352,7 +352,7 @@ public class CodeCompletionHandlerBase {
|
||||
final List<LookupElement> items = indicator.getLookup().getItems();
|
||||
CompletionParameters parameters = Objects.requireNonNull(indicator.getParameters());
|
||||
if (items.isEmpty()) {
|
||||
LookupManager.getInstance(indicator.getProject()).hideActiveLookup();
|
||||
LookupManager.hideActiveLookup(indicator.getProject());
|
||||
|
||||
Caret nextCaret = getNextCaretToProcess(indicator.getEditor());
|
||||
if (nextCaret != null) {
|
||||
@@ -391,7 +391,7 @@ public class CodeCompletionHandlerBase {
|
||||
CompletionServiceImpl.setCompletionPhase(hasModifiers? new CompletionPhase.InsertedSingleItem(indicator, restorePrefix) : CompletionPhase.NoCompletion);
|
||||
}
|
||||
} else if (decision == AutoCompletionDecision.CLOSE_LOOKUP) {
|
||||
LookupManager.getInstance(indicator.getProject()).hideActiveLookup();
|
||||
LookupManager.hideActiveLookup(indicator.getProject());
|
||||
}
|
||||
}
|
||||
catch (Throwable e) {
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package com.intellij.codeInsight.lookup;
|
||||
|
||||
@@ -63,6 +49,13 @@ public abstract class LookupManager {
|
||||
|
||||
public abstract void hideActiveLookup();
|
||||
|
||||
public static void hideActiveLookup(@NotNull Project project) {
|
||||
LookupManager lookupManager = ServiceManager.getServiceIfCreated(project, LookupManager.class);
|
||||
if (lookupManager != null) {
|
||||
lookupManager.hideActiveLookup();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract LookupEx getActiveLookup();
|
||||
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.ui.content.impl;
|
||||
|
||||
import com.intellij.ide.DataManager;
|
||||
@@ -52,7 +38,7 @@ import static com.intellij.openapi.wm.IdeFocusManager.getGlobalInstance;
|
||||
* @author Vladimir Kondratyev
|
||||
*/
|
||||
public class ContentManagerImpl implements ContentManager, PropertyChangeListener, Disposable.Parent {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ui.content.impl.ContentManagerImpl");
|
||||
private static final Logger LOG = Logger.getInstance(ContentManagerImpl.class);
|
||||
|
||||
private ContentUI myUI;
|
||||
private final List<Content> myContents = new ArrayList<>();
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.testFramework;
|
||||
|
||||
import com.intellij.ProjectTopics;
|
||||
@@ -402,9 +388,9 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
|
||||
new RunAll().
|
||||
append(() -> ((FileTypeManagerImpl)FileTypeManager.getInstance()).drainReDetectQueue()).
|
||||
append(() -> CodeStyle.dropTemporarySettings(project)).
|
||||
append(LightPlatformTestCase::checkJavaSwingTimersAreDisposed).
|
||||
append(() -> checkJavaSwingTimersAreDisposed()).
|
||||
append(() -> UsefulTestCase.doPostponedFormatting(project)).
|
||||
append(() -> LookupManager.getInstance(project).hideActiveLookup()).
|
||||
append(() -> LookupManager.hideActiveLookup(project)).
|
||||
append(() -> ((StartupManagerImpl)StartupManager.getInstance(project)).prepareForNextTest()).
|
||||
append(() -> { if (ProjectManager.getInstance() == null) throw new AssertionError("Application components damaged"); }).
|
||||
append(() -> WriteCommandAction.runWriteCommandAction(project, () -> {
|
||||
@@ -458,7 +444,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
|
||||
}).
|
||||
run();
|
||||
}
|
||||
|
||||
|
||||
private static int ourTestCount;
|
||||
|
||||
@ReviseWhenPortedToJDK("9")
|
||||
@@ -707,7 +693,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
|
||||
return myModuleType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Nullable
|
||||
@Override
|
||||
public Sdk getSdk() {
|
||||
return mySdk;
|
||||
|
||||
+1
-1
@@ -1112,7 +1112,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
return;
|
||||
}
|
||||
|
||||
LookupManager.getInstance(project).hideActiveLookup();
|
||||
LookupManager.hideActiveLookup(project);
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
FileEditorManagerEx.getInstanceEx(project).closeAllFiles();
|
||||
EditorHistoryManager.getInstance(project).removeAllFiles();
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.lang.ant;
|
||||
|
||||
import com.intellij.codeInsight.completion.CodeCompletionHandlerBase;
|
||||
@@ -215,7 +201,7 @@ public class AntCompletionTest extends LightCodeInsightTestCase {
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
try {
|
||||
LookupManager.getInstance(getProject()).hideActiveLookup();
|
||||
LookupManager.hideActiveLookup(getProject());
|
||||
}
|
||||
finally {
|
||||
super.tearDown();
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
|
||||
import org.jetbrains.plugins.groovy.util.TestUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -23,7 +24,6 @@ import java.util.List;
|
||||
* author ven
|
||||
*/
|
||||
public abstract class CompletionTestBase extends JavaCodeInsightFixtureTestCase {
|
||||
|
||||
protected void doTest() {
|
||||
doTest("");
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public abstract class CompletionTestBase extends JavaCodeInsightFixtureTestCase
|
||||
CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION = false;
|
||||
|
||||
|
||||
String result = "";
|
||||
StringBuilder result = new StringBuilder();
|
||||
try {
|
||||
myFixture.completeBasic();
|
||||
|
||||
@@ -51,20 +51,20 @@ public abstract class CompletionTestBase extends JavaCodeInsightFixtureTestCase
|
||||
return !(o instanceof PsiMember) && !(o instanceof GrVariable) && !(o instanceof GroovyResolveResult) && !(o instanceof PsiPackage);
|
||||
});
|
||||
}
|
||||
Collections.sort(items, (o1, o2) -> o1.getLookupString().compareTo(o2.getLookupString()));
|
||||
result = "";
|
||||
Collections.sort(items, Comparator.comparing(LookupElement::getLookupString));
|
||||
result = new StringBuilder();
|
||||
for (LookupElement item : items) {
|
||||
result = result + "\n" + item.getLookupString();
|
||||
result.append("\n").append(item.getLookupString());
|
||||
}
|
||||
result = result.trim();
|
||||
LookupManager.getInstance(myFixture.getProject()).hideActiveLookup();
|
||||
result = new StringBuilder(result.toString().trim());
|
||||
LookupManager.hideActiveLookup(myFixture.getProject());
|
||||
}
|
||||
|
||||
}
|
||||
finally {
|
||||
CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION = true;
|
||||
}
|
||||
assertEquals(StringUtil.trimEnd(stringList.get(1), "\n"), result);
|
||||
assertEquals(StringUtil.trimEnd(stringList.get(1), "\n"), result.toString());
|
||||
}
|
||||
|
||||
protected String getExtension() {
|
||||
|
||||
Reference in New Issue
Block a user