mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git@git.labs.intellij.net:idea/community
This commit is contained in:
@@ -225,7 +225,7 @@ public class PositionHighlighter {
|
||||
}
|
||||
|
||||
if (breakpoint instanceof BreakpointWithHighlighter) {
|
||||
if (((BreakpointWithHighlighter)breakpoint).isVisible()) {
|
||||
if (((BreakpointWithHighlighter)breakpoint).isVisible() && breakpoint.isValid()) {
|
||||
breakpoint.reload();
|
||||
final SourcePosition sourcePosition = ((BreakpointWithHighlighter)breakpoint).getSourcePosition();
|
||||
if (sourcePosition == null || sourcePosition.getLine() != lineIndex) {
|
||||
|
||||
+2
-2
@@ -42,7 +42,7 @@ class CollectionsUtilityMethodsProvider {
|
||||
final PsiType type = parameters.getExpectedType();
|
||||
final PsiType defaultType = parameters.getDefaultType();
|
||||
final PsiElement pparent = parent.getParent();
|
||||
if (parameters.getInvocationCount() > 1 ||
|
||||
if (parameters.getParameters().getInvocationCount() > 1 ||
|
||||
pparent instanceof PsiReturnStatement ||
|
||||
pparent instanceof PsiConditionalExpression && pparent.getParent() instanceof PsiReturnStatement) {
|
||||
addCollectionMethod(result, type, defaultType, JAVA_UTIL_LIST, "emptyList", collectionsClass);
|
||||
@@ -50,7 +50,7 @@ class CollectionsUtilityMethodsProvider {
|
||||
addCollectionMethod(result, type, defaultType, JAVA_UTIL_MAP, "emptyMap", collectionsClass);
|
||||
}
|
||||
|
||||
if (parameters.getInvocationCount() > 1) {
|
||||
if (parameters.getParameters().getInvocationCount() > 1) {
|
||||
addCollectionMethod(result, type, defaultType, JAVA_UTIL_LIST, "singletonList", collectionsClass);
|
||||
addCollectionMethod(result, type, defaultType, JAVA_UTIL_SET, "singleton", collectionsClass);
|
||||
addCollectionMethod(result, type, defaultType, JAVA_UTIL_MAP, "singletonMap", collectionsClass);
|
||||
|
||||
+5
-5
@@ -220,15 +220,14 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
|
||||
addKeywords(parameters, result);
|
||||
|
||||
addAllClasses(parameters, result, position, inheritors);
|
||||
addAllClasses(parameters, result, inheritors);
|
||||
result.stopHere();
|
||||
}
|
||||
|
||||
public static void addAllClasses(CompletionParameters parameters,
|
||||
final CompletionResultSet result,
|
||||
PsiElement position,
|
||||
final InheritorsHolder inheritors) {
|
||||
if (shouldRunClassNameCompletion(result, position)) {
|
||||
if (shouldRunClassNameCompletion(result, parameters)) {
|
||||
JavaClassNameCompletionContributor.addAllClasses(parameters, result, new Consumer<LookupElement>() {
|
||||
@Override
|
||||
public void consume(LookupElement element) {
|
||||
@@ -314,7 +313,8 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean shouldRunClassNameCompletion(CompletionResultSet result, PsiElement position) {
|
||||
private static boolean shouldRunClassNameCompletion(CompletionResultSet result, CompletionParameters parameters) {
|
||||
PsiElement position = parameters.getPosition();
|
||||
final PsiElement parent = position.getParent();
|
||||
if (!(parent instanceof PsiJavaCodeReferenceElement)) return false;
|
||||
if (((PsiJavaCodeReferenceElement)parent).getQualifier() != null) return false;
|
||||
@@ -331,7 +331,7 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
return false;
|
||||
}
|
||||
|
||||
return StringUtil.isNotEmpty(result.getPrefixMatcher().getPrefix());
|
||||
return StringUtil.isCapitalized(result.getPrefixMatcher().getPrefix()) || parameters.relaxMatching();
|
||||
}
|
||||
|
||||
private static void completeAnnotationAttributeName(CompletionResultSet result, PsiElement insertedElement,
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ public class JavaDocCompletionContributor extends CompletionContributor {
|
||||
result.addElement(item);
|
||||
}
|
||||
|
||||
JavaCompletionContributor.addAllClasses(parameters, result, position, new InheritorsHolder(position, result));
|
||||
JavaCompletionContributor.addAllClasses(parameters, result, new InheritorsHolder(position, result));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+12
-2
@@ -15,17 +15,19 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.codeInsight.ExpectedTypeInfo;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class JavaSmartCompletionParameters extends CompletionParameters{
|
||||
public class JavaSmartCompletionParameters {
|
||||
private final CompletionParameters myParameters;
|
||||
private final ExpectedTypeInfo myExpectedType;
|
||||
|
||||
public JavaSmartCompletionParameters(CompletionParameters parameters, final ExpectedTypeInfo expectedType) {
|
||||
super(parameters.getPosition(), parameters.getOriginalFile(), parameters.getCompletionType(), parameters.getOffset(), parameters.getInvocationCount());
|
||||
myParameters = parameters;
|
||||
myExpectedType = expectedType;
|
||||
}
|
||||
|
||||
@@ -36,4 +38,12 @@ public class JavaSmartCompletionParameters extends CompletionParameters{
|
||||
public PsiType getDefaultType() {
|
||||
return myExpectedType.getDefaultType();
|
||||
}
|
||||
|
||||
public PsiElement getPosition() {
|
||||
return myParameters.getPosition();
|
||||
}
|
||||
|
||||
public CompletionParameters getParameters() {
|
||||
return myParameters;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -110,7 +110,7 @@ public class ReferenceExpressionCompletionContributor {
|
||||
final PsiElement element = parameters.getPosition();
|
||||
if (JavaSmartCompletionContributor.INSIDE_TYPECAST_EXPRESSION.accepts(element)) return;
|
||||
|
||||
final int offset = parameters.getOffset();
|
||||
final int offset = parameters.getParameters().getOffset();
|
||||
final PsiReference reference = element.getContainingFile().findReferenceAt(offset);
|
||||
if (reference != null) {
|
||||
final ElementFilter filter = getReferenceFilter(element, false);
|
||||
@@ -118,9 +118,9 @@ public class ReferenceExpressionCompletionContributor {
|
||||
result.consume(item);
|
||||
}
|
||||
|
||||
final boolean secondTime = parameters.getInvocationCount() >= 2;
|
||||
final boolean secondTime = parameters.getParameters().getInvocationCount() >= 2;
|
||||
|
||||
for (final LookupElement item : JavaSmartCompletionContributor.completeReference(element, reference, filter, false, parameters)) {
|
||||
for (final LookupElement item : JavaSmartCompletionContributor.completeReference(element, reference, filter, false, parameters.getParameters())) {
|
||||
addSingleArrayElementAccess(element, item, parameters, result);
|
||||
|
||||
if (secondTime) {
|
||||
@@ -164,7 +164,7 @@ public class ReferenceExpressionCompletionContributor {
|
||||
public boolean isClassAcceptable(Class hintClass) {
|
||||
return true;
|
||||
}
|
||||
}), false, parameters);
|
||||
}), false, parameters.getParameters());
|
||||
for (LookupElement lookupElement : elements) {
|
||||
if (lookupElement.getObject() instanceof PsiMethod) {
|
||||
final JavaMethodCallElement item = lookupElement.as(JavaMethodCallElement.CLASS_CONDITION_KEY);
|
||||
|
||||
@@ -218,6 +218,7 @@ public class GlobalJavaInspectionContextImpl extends GlobalJavaInspectionContext
|
||||
));
|
||||
|
||||
final List<DerivedClassesProcessor> processors = myDerivedClassesRequests.get(sortedID);
|
||||
LOG.assertTrue(processors != null, psiClass.getClass().getName());
|
||||
ClassInheritorsSearch.search(psiClass, searchScope, false)
|
||||
.forEach(createMembersProcessor(processors, scope));
|
||||
}
|
||||
@@ -229,12 +230,14 @@ public class GlobalJavaInspectionContextImpl extends GlobalJavaInspectionContext
|
||||
final List<SmartPsiElementPointer> sortedIDs = getSortedIDs(myDerivedMethodsRequests);
|
||||
for (SmartPsiElementPointer sortedID : sortedIDs) {
|
||||
final PsiMethod psiMethod = (PsiMethod)sortedID.getElement();
|
||||
if (psiMethod == null) continue;
|
||||
final RefMethod refMethod = (RefMethod)refManager.getReference(psiMethod);
|
||||
|
||||
context
|
||||
.incrementJobDoneAmount(GlobalInspectionContextImpl.FIND_EXTERNAL_USAGES, refManager.getQualifiedName(refMethod));
|
||||
|
||||
final List<DerivedMethodsProcessor> processors = myDerivedMethodsRequests.get(sortedID);
|
||||
LOG.assertTrue(processors != null, psiMethod.getClass().getName());
|
||||
OverridingMethodsSearch.search(psiMethod, searchScope, true)
|
||||
.forEach(createMembersProcessor(processors, scope));
|
||||
}
|
||||
@@ -249,6 +252,7 @@ public class GlobalJavaInspectionContextImpl extends GlobalJavaInspectionContext
|
||||
if (psiField == null) continue;
|
||||
final List<UsagesProcessor> processors = myFieldUsagesRequests.get(sortedID);
|
||||
|
||||
LOG.assertTrue(processors != null, psiField.getClass().getName());
|
||||
context
|
||||
.incrementJobDoneAmount(GlobalInspectionContextImpl.FIND_EXTERNAL_USAGES,
|
||||
refManager.getQualifiedName(refManager.getReference(psiField)));
|
||||
@@ -267,6 +271,7 @@ public class GlobalJavaInspectionContextImpl extends GlobalJavaInspectionContext
|
||||
if (psiClass == null) continue;
|
||||
final List<UsagesProcessor> processors = myClassUsagesRequests.get(sortedID);
|
||||
|
||||
LOG.assertTrue(processors != null, psiClass.getClass().getName());
|
||||
context.incrementJobDoneAmount(GlobalInspectionContextImpl.FIND_EXTERNAL_USAGES, ApplicationManager.getApplication().runReadAction(
|
||||
new Computable<String>() {
|
||||
public String compute() {
|
||||
@@ -289,6 +294,7 @@ public class GlobalJavaInspectionContextImpl extends GlobalJavaInspectionContext
|
||||
if (psiMethod == null) continue;
|
||||
final List<UsagesProcessor> processors = myMethodUsagesRequests.get(sortedID);
|
||||
|
||||
LOG.assertTrue(processors != null, psiMethod.getClass().getName());
|
||||
context
|
||||
.incrementJobDoneAmount(GlobalInspectionContextImpl.FIND_EXTERNAL_USAGES,
|
||||
refManager.getQualifiedName(refManager.getReference(psiMethod)));
|
||||
|
||||
+3
-1
@@ -187,7 +187,9 @@ class InplaceIntroduceParameterPopup extends IntroduceParameterSettingsUI {
|
||||
|
||||
final JPanel wrapper = new JPanel(new BorderLayout());
|
||||
wrapper.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||
wrapper.add(myCanBeFinal, BorderLayout.NORTH);
|
||||
if (myCanBeFinal != null) {
|
||||
wrapper.add(myCanBeFinal, BorderLayout.NORTH);
|
||||
}
|
||||
panel.add(wrapper, BorderLayout.SOUTH);
|
||||
|
||||
return panel;
|
||||
|
||||
+5
-4
@@ -164,8 +164,9 @@ public class IntroduceParameterHandler extends IntroduceHandlerBase implements R
|
||||
final Introducer introducer = new Introducer(project, expr, localVar, editor);
|
||||
final boolean unitTestMode = ApplicationManager.getApplication().isUnitTestMode();
|
||||
if (validEnclosingMethods.size() == 1 || unitTestMode) {
|
||||
if (validEnclosingMethods.get(0).findDeepestSuperMethod() == null || unitTestMode) {
|
||||
introducer.introduceParameter(method, method);
|
||||
final PsiMethod methodToIntroduceParameterTo = validEnclosingMethods.get(0);
|
||||
if (methodToIntroduceParameterTo.findDeepestSuperMethod() == null || unitTestMode) {
|
||||
introducer.introduceParameter(methodToIntroduceParameterTo, methodToIntroduceParameterTo);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -176,8 +177,8 @@ public class IntroduceParameterHandler extends IntroduceHandlerBase implements R
|
||||
}
|
||||
|
||||
private void chooseMethodToIntroduceParameter(final Editor editor,
|
||||
final List<PsiMethod> validEnclosingMethods,
|
||||
final Introducer introducer) {
|
||||
final List<PsiMethod> validEnclosingMethods,
|
||||
final Introducer introducer) {
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
final JCheckBox superMethod = new JCheckBox("Use super method of", true);
|
||||
superMethod.setMnemonic('U');
|
||||
|
||||
+1
@@ -478,6 +478,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme
|
||||
final VariableInplaceRenamer renamer =
|
||||
new VariableInplaceIntroducer(project, expression, editor, elementToRename, cantChangeFinalModifier,
|
||||
typeSelectorManager.getTypesForAll().length > 1, exprMarker, occurrenceMarkers);
|
||||
PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(editor.getDocument());
|
||||
renamer.performInplaceRename(false, new LinkedHashSet<String>(Arrays.asList(suggestedName.names)));
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -235,7 +235,9 @@ public class VariableInplaceIntroducer extends VariableInplaceRenamer {
|
||||
titlePanel.setText(IntroduceVariableBase.REFACTORING_NAME);
|
||||
panel.add(titlePanel, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
|
||||
|
||||
panel.add(myCanBeFinal, new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
|
||||
if (myCanBeFinal != null) {
|
||||
panel.add(myCanBeFinal, new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
|
||||
}
|
||||
|
||||
panel.add(Box.createVerticalBox(), new GridBagConstraints(0, 2, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0,0,0,0), 0,0));
|
||||
|
||||
|
||||
+13
-3
@@ -29,9 +29,10 @@ public class CompletionParameters {
|
||||
private final CompletionType myCompletionType;
|
||||
private final int myOffset;
|
||||
private final int myInvocationCount;
|
||||
private final boolean myRelaxedMatching;
|
||||
|
||||
protected CompletionParameters(@NotNull final PsiElement position, @NotNull final PsiFile originalFile,
|
||||
final CompletionType completionType, int offset, final int invocationCount) {
|
||||
final CompletionType completionType, int offset, final int invocationCount, final boolean relaxedMatching) {
|
||||
assert offset >= position.getTextRange().getStartOffset();
|
||||
myPosition = position;
|
||||
assert position.isValid();
|
||||
@@ -39,14 +40,19 @@ public class CompletionParameters {
|
||||
myCompletionType = completionType;
|
||||
myOffset = offset;
|
||||
myInvocationCount = invocationCount;
|
||||
myRelaxedMatching = relaxedMatching;
|
||||
}
|
||||
|
||||
public CompletionParameters withType(CompletionType type) {
|
||||
return new CompletionParameters(myPosition, myOriginalFile, type, myOffset, myInvocationCount);
|
||||
return new CompletionParameters(myPosition, myOriginalFile, type, myOffset, myInvocationCount, myRelaxedMatching);
|
||||
}
|
||||
|
||||
public CompletionParameters withInvocationCount(int newCount) {
|
||||
return new CompletionParameters(myPosition, myOriginalFile, myCompletionType, myOffset, newCount);
|
||||
return new CompletionParameters(myPosition, myOriginalFile, myCompletionType, myOffset, newCount, myRelaxedMatching);
|
||||
}
|
||||
|
||||
public CompletionParameters withRelaxedMatching() {
|
||||
return new CompletionParameters(myPosition, myOriginalFile, myCompletionType, myOffset, myInvocationCount, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -82,4 +88,8 @@ public class CompletionParameters {
|
||||
public int getInvocationCount() {
|
||||
return myInvocationCount;
|
||||
}
|
||||
|
||||
public boolean relaxMatching() {
|
||||
return myRelaxedMatching;
|
||||
}
|
||||
}
|
||||
|
||||
+13
-3
@@ -53,6 +53,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.codeStyle.NameUtil;
|
||||
import com.intellij.psi.impl.PsiFileEx;
|
||||
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
|
||||
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
|
||||
@@ -291,11 +292,20 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
indicator.duringCompletion(initContext);
|
||||
ProgressManager.checkCanceled();
|
||||
|
||||
data.set(CompletionService.getCompletionService().performCompletion(parameters, new Consumer<LookupElement>() {
|
||||
Consumer<LookupElement> consumer = new Consumer<LookupElement>() {
|
||||
public void consume(final LookupElement lookupElement) {
|
||||
indicator.addItem(lookupElement);
|
||||
}
|
||||
}));
|
||||
};
|
||||
LookupElement[] result = CompletionService.getCompletionService().performCompletion(parameters, consumer);
|
||||
if (NameUtil.isUseMinusculeHumpMatcher() && parameters.getInvocationCount() == 0) {
|
||||
if (result.length == 0) {
|
||||
result = CompletionService.getCompletionService().performCompletion(parameters.withRelaxedMatching(), consumer);
|
||||
} else {
|
||||
indicator.restartOnEmpty = true;
|
||||
}
|
||||
}
|
||||
data.set(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -347,7 +357,7 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
LOG.error("wrong text: copy='" + fileCopy.getText() + "'; element='" + insertedElement.getText() + "'; range=" + range);
|
||||
}
|
||||
|
||||
return new CompletionParameters(insertedElement, fileCopy.getOriginalFile(), myCompletionType, offset, invocationCount);
|
||||
return new CompletionParameters(insertedElement, fileCopy.getOriginalFile(), myCompletionType, offset, invocationCount, invocationCount >= 2);
|
||||
}
|
||||
|
||||
private AutoCompletionDecision shouldAutoComplete(
|
||||
|
||||
+7
-2
@@ -18,6 +18,7 @@ package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightSettings;
|
||||
import com.intellij.codeInsight.completion.impl.CompletionServiceImpl;
|
||||
import com.intellij.codeInsight.editorActions.CompletionAutoPopupHandler;
|
||||
import com.intellij.codeInsight.hint.EditorHintListener;
|
||||
import com.intellij.codeInsight.hint.HintManager;
|
||||
import com.intellij.codeInsight.lookup.*;
|
||||
@@ -399,7 +400,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
Disposer.dispose(myQueue);
|
||||
|
||||
CompletionProgressIndicator currentCompletion = CompletionServiceImpl.getCompletionService().getCurrentCompletion();
|
||||
assert currentCompletion == this : currentCompletion + "!=" + this;
|
||||
LOG.assertTrue(currentCompletion == this, currentCompletion + "!=" + this);
|
||||
CompletionServiceImpl.getCompletionService().setCurrentCompletion(null);
|
||||
|
||||
CompletionServiceImpl.assertPhase(CompletionPhase.BgCalculation.class, CompletionPhase.ItemsCalculated.class, CompletionPhase.Synchronous.class, CompletionPhase.Restarted.class);
|
||||
@@ -573,6 +574,8 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
}
|
||||
}
|
||||
|
||||
public boolean restartOnEmpty = false;
|
||||
|
||||
public void prefixUpdated() {
|
||||
final CharSequence text = myEditor.getDocument().getCharsSequence();
|
||||
final int caretOffset = myEditor.getCaretModel().getOffset();
|
||||
@@ -585,7 +588,9 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
}
|
||||
}
|
||||
|
||||
hideAutopopupIfMeaningless();
|
||||
if (hideAutopopupIfMeaningless() && restartOnEmpty) {
|
||||
CompletionAutoPopupHandler.scheduleAutoPopup(getProject(), myEditor, getParameters().getOriginalFile());
|
||||
}
|
||||
updateFocus();
|
||||
}
|
||||
|
||||
|
||||
+16
-5
@@ -28,13 +28,15 @@ public class CamelHumpMatcher extends PrefixMatcher {
|
||||
private NameUtil.Matcher myMatcher;
|
||||
private final boolean myCaseSensitive;
|
||||
private final int currentSetting;
|
||||
private final boolean myRelaxedMatching;
|
||||
|
||||
public CamelHumpMatcher(@NotNull final String prefix) {
|
||||
this(prefix, true);
|
||||
this(prefix, true, false);
|
||||
}
|
||||
|
||||
public CamelHumpMatcher(String prefix, boolean caseSensitive) {
|
||||
public CamelHumpMatcher(String prefix, boolean caseSensitive, boolean relaxedMatching) {
|
||||
super(prefix);
|
||||
myRelaxedMatching = relaxedMatching;
|
||||
currentSetting = CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE;
|
||||
myCaseSensitive = caseSensitive;
|
||||
}
|
||||
@@ -47,10 +49,11 @@ public class CamelHumpMatcher extends PrefixMatcher {
|
||||
ourLastCompletionCaseSetting = currentSetting;
|
||||
}
|
||||
|
||||
NameUtil.Matcher pattern = ourPatternCache.get(myPrefix);
|
||||
String key = myRelaxedMatching + myPrefix;
|
||||
NameUtil.Matcher pattern = ourPatternCache.get(key);
|
||||
if (pattern == null) {
|
||||
pattern = createCamelHumpsMatcher();
|
||||
ourPatternCache.put(myPrefix, pattern);
|
||||
ourPatternCache.put(key, pattern);
|
||||
}
|
||||
myMatcher = pattern;
|
||||
}
|
||||
@@ -81,7 +84,7 @@ public class CamelHumpMatcher extends PrefixMatcher {
|
||||
|
||||
@NotNull
|
||||
public PrefixMatcher cloneWithPrefix(@NotNull final String prefix) {
|
||||
return new CamelHumpMatcher(prefix);
|
||||
return new CamelHumpMatcher(prefix, myCaseSensitive, myRelaxedMatching);
|
||||
}
|
||||
|
||||
private NameUtil.Matcher createCamelHumpsMatcher() {
|
||||
@@ -89,6 +92,10 @@ public class CamelHumpMatcher extends PrefixMatcher {
|
||||
return NameUtil.buildCompletionMatcher(myPrefix, 0, true, true);
|
||||
}
|
||||
|
||||
if (myRelaxedMatching) {
|
||||
return NameUtil.buildCompletionMatcher(myPrefix, 0, true, true);
|
||||
}
|
||||
|
||||
switch (CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE) {
|
||||
case CodeInsightSettings.NONE:
|
||||
return NameUtil.buildCompletionMatcher(myPrefix, 0, true, true);
|
||||
@@ -106,4 +113,8 @@ public class CamelHumpMatcher extends PrefixMatcher {
|
||||
public String toString() {
|
||||
return myPrefix;
|
||||
}
|
||||
|
||||
public boolean isRelaxedMatching() {
|
||||
return myRelaxedMatching;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-3
@@ -82,7 +82,7 @@ public class CompletionServiceImpl extends CompletionService{
|
||||
final PsiElement position = parameters.getPosition();
|
||||
final String prefix = CompletionData.findPrefixStatic(position, parameters.getOffset());
|
||||
final String textBeforePosition = parameters.getPosition().getContainingFile().getText().substring(0, parameters.getOffset());
|
||||
return new CompletionResultSetImpl(consumer, textBeforePosition, new CamelHumpMatcher(prefix), contributor, defaultSorter(parameters), null);
|
||||
return new CompletionResultSetImpl(consumer, textBeforePosition, new CamelHumpMatcher(prefix, true, parameters.relaxMatching()), contributor, defaultSorter(parameters), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,7 +148,8 @@ public class CompletionServiceImpl extends CompletionService{
|
||||
|
||||
@NotNull
|
||||
public CompletionResultSet withPrefixMatcher(@NotNull final String prefix) {
|
||||
return withPrefixMatcher(new CamelHumpMatcher(prefix));
|
||||
boolean relaxed = getPrefixMatcher() instanceof CamelHumpMatcher && ((CamelHumpMatcher)getPrefixMatcher()).isRelaxedMatching();
|
||||
return withPrefixMatcher(new CamelHumpMatcher(prefix, true, relaxed));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -160,7 +161,8 @@ public class CompletionServiceImpl extends CompletionService{
|
||||
@NotNull
|
||||
@Override
|
||||
public CompletionResultSet caseInsensitive() {
|
||||
return withPrefixMatcher(new CamelHumpMatcher(getPrefixMatcher().getPrefix(), false));
|
||||
boolean relaxed = getPrefixMatcher() instanceof CamelHumpMatcher && ((CamelHumpMatcher)getPrefixMatcher()).isRelaxedMatching();
|
||||
return withPrefixMatcher(new CamelHumpMatcher(getPrefixMatcher().getPrefix(), false, relaxed));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-1
@@ -76,6 +76,11 @@ public class CompletionAutoPopupHandler extends TypedHandlerDelegate {
|
||||
return Result.CONTINUE;
|
||||
}
|
||||
|
||||
scheduleAutoPopup(project, editor, file);
|
||||
return Result.STOP;
|
||||
}
|
||||
|
||||
public static void scheduleAutoPopup(final Project project, final Editor editor, final PsiFile file) {
|
||||
final boolean isMainEditor = FileEditorManager.getInstance(project).getSelectedTextEditor() == editor;
|
||||
|
||||
final CompletionPhase.AutoPopupAlarm phase = new CompletionPhase.AutoPopupAlarm();
|
||||
@@ -95,7 +100,6 @@ public class CompletionAutoPopupHandler extends TypedHandlerDelegate {
|
||||
}
|
||||
};
|
||||
AutoPopupController.getInstance(project).invokeAutoPopupRunnable(request, CodeInsightSettings.getInstance().AUTO_LOOKUP_DELAY);
|
||||
return Result.STOP;
|
||||
}
|
||||
|
||||
public static void invokeAutoPopupCompletion(Project project, final Editor editor) {
|
||||
|
||||
@@ -87,12 +87,12 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable {
|
||||
private final Project myProject;
|
||||
private final Editor myEditor;
|
||||
|
||||
private int myMinPrefixLength;
|
||||
private int myPreferredItemsCount;
|
||||
private String myInitialPrefix;
|
||||
private LookupArranger myCustomArranger;
|
||||
|
||||
private RangeMarker myLookupStartMarker;
|
||||
private boolean myStableStart;
|
||||
@NotNull private RangeMarker myLookupStartMarker;
|
||||
private final JList myList = new JBList(new DefaultListModel());
|
||||
private final LookupCellRenderer myCellRenderer;
|
||||
private Boolean myPositionedAbove = null;
|
||||
@@ -154,6 +154,8 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable {
|
||||
myIconPanel.setBackground(Color.LIGHT_GRAY);
|
||||
myIconPanel.add(myProcessIcon);
|
||||
|
||||
updateLookupStart(0);
|
||||
|
||||
final ListModel model = myList.getModel();
|
||||
addEmptyItem((DefaultListModel)model);
|
||||
updateListHeight(model);
|
||||
@@ -270,10 +272,6 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable {
|
||||
return myModel.getActionsFor(element);
|
||||
}
|
||||
|
||||
public int getMinPrefixLength() {
|
||||
return myMinPrefixLength;
|
||||
}
|
||||
|
||||
public JList getList() {
|
||||
return myList;
|
||||
}
|
||||
@@ -421,15 +419,17 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable {
|
||||
}
|
||||
|
||||
private void checkMinPrefixLengthChanges(Collection<LookupElement> items) {
|
||||
if (myStableStart) return;
|
||||
if (!myCalculating && !items.isEmpty()) {
|
||||
myStableStart = true;
|
||||
}
|
||||
|
||||
int minPrefixLength = items.isEmpty() ? 0 : Integer.MAX_VALUE;
|
||||
for (final LookupElement item : items) {
|
||||
minPrefixLength = Math.min(item.getPrefixMatcher().getPrefix().length(), minPrefixLength);
|
||||
}
|
||||
|
||||
if (myMinPrefixLength != minPrefixLength) {
|
||||
myLookupStartMarker = null;
|
||||
}
|
||||
myMinPrefixLength = minPrefixLength;
|
||||
updateLookupStart(minPrefixLength);
|
||||
}
|
||||
|
||||
private void restoreSelection(@Nullable LookupElement oldSelected, boolean choosePreselectedItem, @Nullable String oldInvariant) {
|
||||
@@ -568,7 +568,7 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable {
|
||||
Dimension dim = component.getPreferredSize();
|
||||
int lookupStart = getLookupStart();
|
||||
if (lookupStart < 0) {
|
||||
LOG.error(lookupStart + "; minprefix=" + myMinPrefixLength + "; offset=" + myEditor.getCaretModel().getOffset() + "; element=" +
|
||||
LOG.error(lookupStart + "; offset=" + myEditor.getCaretModel().getOffset() + "; element=" +
|
||||
getPsiElement());
|
||||
}
|
||||
|
||||
@@ -656,12 +656,6 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable {
|
||||
}
|
||||
|
||||
public int getLookupStart() {
|
||||
if (myLookupStartMarker == null) {
|
||||
final int start = calcLookupStart();
|
||||
myLookupStartMarker = myEditor.getDocument().createRangeMarker(start, start);
|
||||
myLookupStartMarker.setGreedyToLeft(true);
|
||||
}
|
||||
|
||||
return myLookupStartMarker.getStartOffset();
|
||||
}
|
||||
|
||||
@@ -816,11 +810,14 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
private int calcLookupStart() {
|
||||
private int updateLookupStart(int myMinPrefixLength) {
|
||||
int offset = myEditor.getSelectionModel().hasSelection()
|
||||
? myEditor.getSelectionModel().getSelectionStart()
|
||||
: myEditor.getCaretModel().getOffset();
|
||||
return Math.max(offset - myMinPrefixLength - myAdditionalPrefix.length(), 0);
|
||||
int start = Math.max(offset - myMinPrefixLength - myAdditionalPrefix.length(), 0);
|
||||
myLookupStartMarker = myEditor.getDocument().createRangeMarker(start, start);
|
||||
myLookupStartMarker.setGreedyToLeft(true);
|
||||
return start;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -126,8 +126,11 @@ public class TypedHandler implements TypedActionHandler {
|
||||
|
||||
@Nullable
|
||||
private static CharFilter.Result getFiltersDecision(char charTyped, LookupImpl lookup) {
|
||||
LookupElement item = lookup.getCurrentItem();
|
||||
int prefixLength = (item == null ? 0 : item.getPrefixMatcher().getPrefix().length()) + lookup.getAdditionalPrefix().length();
|
||||
|
||||
for (final CharFilter extension : getFilters()) {
|
||||
final CharFilter.Result result = extension.acceptChar(charTyped, lookup.getMinPrefixLength() + lookup.getAdditionalPrefix().length(), lookup);
|
||||
final CharFilter.Result result = extension.acceptChar(charTyped, prefixLength, lookup);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1568,14 +1568,14 @@ private final class MyVirtualFileListener extends VirtualFileAdapter {
|
||||
// already open
|
||||
if (eachWindow.findFileIndex(newFile) != -1) continue;
|
||||
|
||||
closeFile(eachFile, eachWindow);
|
||||
try {
|
||||
newFile.putUserData(EditorWindow.INITIAL_INDEX_KEY, i);
|
||||
openFile(newFile, eachFile == selected);
|
||||
openFileImpl2(eachWindow, newFile, eachFile == selected);
|
||||
}
|
||||
finally {
|
||||
newFile.putUserData(EditorWindow.INITIAL_INDEX_KEY, null);
|
||||
}
|
||||
closeFile(eachFile, eachWindow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.util.containers;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class IntArrayList implements Cloneable {
|
||||
private int[] myData;
|
||||
private int mySize;
|
||||
@@ -163,4 +165,9 @@ public class IntArrayList implements Cloneable {
|
||||
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + mySize);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Arrays.toString(toArray());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -453,7 +453,7 @@ public class GroovyCompletionContributor extends CompletionContributor {
|
||||
}
|
||||
});
|
||||
|
||||
if (StringUtil.isNotEmpty(result.getPrefixMatcher().getPrefix())) {
|
||||
if (StringUtil.isCapitalized(result.getPrefixMatcher().getPrefix()) || parameters.relaxMatching()) {
|
||||
addAllClasses(parameters, result, inheritors);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,15 +25,15 @@ import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.xml.XmlChildRole;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.util.SmartList;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class XmlUnwrapDescriptor implements UnwrapDescriptor {
|
||||
public List<Pair<PsiElement, Unwrapper>> collectUnwrappers(Project project, Editor editor, PsiFile file) {
|
||||
List<Pair<PsiElement, Unwrapper>> result = new SmartList<Pair<PsiElement, Unwrapper>>();
|
||||
List<Pair<PsiElement, Unwrapper>> result = new ArrayList<Pair<PsiElement, Unwrapper>>();
|
||||
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
PsiElement e1 = file.findElementAt(offset);
|
||||
@@ -49,7 +49,9 @@ public class XmlUnwrapDescriptor implements UnwrapDescriptor {
|
||||
|
||||
PsiElement tag = PsiTreeUtil.getParentOfType(e1, XmlTag.class);
|
||||
while (tag != null) {
|
||||
result.add(new Pair<PsiElement, Unwrapper>(tag, new XmlEnclosingTagUnwrapper()));
|
||||
if (XmlChildRole.START_TAG_END_FINDER.findChild(tag.getNode()) != null) { // Exclude implicit tags suck as 'jsp:root'
|
||||
result.add(new Pair<PsiElement, Unwrapper>(tag, new XmlEnclosingTagUnwrapper()));
|
||||
}
|
||||
tag = PsiTreeUtil.getParentOfType(tag, XmlTag.class);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user