mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 06:05:01 +07:00
less CLASS_NAME mentions
This commit is contained in:
-62
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.completion;
|
||||
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.Consumer;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class AbstractBasicToClassNameDelegator extends CompletionContributor {
|
||||
protected abstract boolean isClassNameCompletionSupported(CompletionResultSet result, PsiFile file, PsiElement position);
|
||||
|
||||
protected void updateProperties(LookupElement lookupElement) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillCompletionVariants(final CompletionParameters parameters, final CompletionResultSet result) {
|
||||
if (parameters.getCompletionType() != CompletionType.BASIC || parameters.getInvocationCount() == 0) return;
|
||||
|
||||
final PsiFile file = parameters.getOriginalFile();
|
||||
final PsiElement position = parameters.getPosition();
|
||||
if (!isClassNameCompletionSupported(result, file, position)) return;
|
||||
|
||||
final boolean empty = result.runRemainingContributors(parameters, true).isEmpty();
|
||||
|
||||
final CompletionParameters classParams;
|
||||
|
||||
final int invocationCount = parameters.getInvocationCount();
|
||||
if (empty) {
|
||||
classParams = parameters.withType(CompletionType.CLASS_NAME);
|
||||
}
|
||||
else if (invocationCount > 1) {
|
||||
classParams = parameters.withType(CompletionType.CLASS_NAME).withInvocationCount(invocationCount - 1);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
CompletionService.getCompletionService().getVariantsFromContributors(classParams, null, new Consumer<CompletionResult>() {
|
||||
public void consume(final CompletionResult lookupElement) {
|
||||
updateProperties(lookupElement.getLookupElement());
|
||||
result.passResult(lookupElement);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -179,8 +179,8 @@ public class JavaClassNameCompletionContributor extends CompletionContributor {
|
||||
}
|
||||
|
||||
private static boolean shouldShowSecondSmartCompletionHint(final CompletionParameters parameters) {
|
||||
return parameters.getCompletionType() == CompletionType.CLASS_NAME &&
|
||||
parameters.getInvocationCount() == 1 &&
|
||||
return parameters.getCompletionType() == CompletionType.BASIC &&
|
||||
parameters.getInvocationCount() == 2 &&
|
||||
parameters.getOriginalFile().getLanguage().isKindOf(JavaLanguage.INSTANCE);
|
||||
}
|
||||
}
|
||||
|
||||
+37
-12
@@ -19,27 +19,52 @@ import com.intellij.codeInsight.lookup.AutoCompletionPolicy;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.lang.StdLanguages;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.Consumer;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class XmlBasicToClassNameDelegator extends AbstractBasicToClassNameDelegator {
|
||||
public class XmlBasicToClassNameDelegator extends CompletionContributor {
|
||||
|
||||
@Override
|
||||
protected boolean isClassNameCompletionSupported(CompletionResultSet result, PsiFile file, PsiElement position) {
|
||||
if (!JavaCompletionContributor.mayStartClassName(result)) return false;
|
||||
public void fillCompletionVariants(CompletionParameters parameters, final CompletionResultSet result) {
|
||||
PsiElement position = parameters.getPosition();
|
||||
if (parameters.getCompletionType() != CompletionType.BASIC ||
|
||||
!JavaCompletionContributor.mayStartClassName(result) ||
|
||||
!position.getContainingFile().getLanguage().isKindOf(StdLanguages.XML)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return file.getLanguage().isKindOf(StdLanguages.XML);
|
||||
}
|
||||
final boolean empty = result.runRemainingContributors(parameters, true).isEmpty();
|
||||
|
||||
@Override
|
||||
protected void updateProperties(LookupElement lookupElement) {
|
||||
JavaPsiClassReferenceElement classElement = lookupElement.as(JavaPsiClassReferenceElement.CLASS_CONDITION_KEY);
|
||||
if (classElement != null) {
|
||||
classElement.setAutoCompletionPolicy(AutoCompletionPolicy.NEVER_AUTOCOMPLETE);
|
||||
if (!empty && parameters.getInvocationCount() == 0) {
|
||||
result.restartCompletionWhenNothingMatches();
|
||||
}
|
||||
|
||||
if (empty || parameters.isExtendedCompletion()) {
|
||||
final int invocationCount = parameters.getInvocationCount();
|
||||
CompletionParameters classParams;
|
||||
if (empty) {
|
||||
classParams = parameters.withType(CompletionType.CLASS_NAME);
|
||||
}
|
||||
else if (invocationCount > 1) {
|
||||
classParams = parameters.withType(CompletionType.CLASS_NAME).withInvocationCount(invocationCount - 1);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
CompletionService.getCompletionService().getVariantsFromContributors(classParams, null, new Consumer<CompletionResult>() {
|
||||
public void consume(final CompletionResult completionResult) {
|
||||
LookupElement lookupElement = completionResult.getLookupElement();
|
||||
JavaPsiClassReferenceElement classElement = lookupElement.as(JavaPsiClassReferenceElement.CLASS_CONDITION_KEY);
|
||||
if (classElement != null) {
|
||||
classElement.setAutoCompletionPolicy(AutoCompletionPolicy.NEVER_AUTOCOMPLETE);
|
||||
}
|
||||
lookupElement.putUserData(XmlCompletionContributor.WORD_COMPLETION_COMPATIBLE, Boolean.TRUE); //todo think of a less dirty interaction
|
||||
result.passResult(completionResult);
|
||||
}
|
||||
});
|
||||
}
|
||||
lookupElement.putUserData(XmlCompletionContributor.WORD_COMPLETION_COMPATIBLE, Boolean.TRUE); //todo think of a less dirty interaction
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user