mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
let's enable completion autopopup when typing digits and see if anyone complains (IDEA-123325)
This commit is contained in:
+34
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package com.intellij.codeInsight.completion
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
class CustomFileTypeAutopopupTest extends CompletionAutoPopupTestCase {
|
||||
void "test no autopopup when typing just digit in a custom file type"() {
|
||||
myFixture.configureByText 'a.hs', 'a42 = 42\n<caret> }}'
|
||||
type '4'
|
||||
assert !lookup
|
||||
}
|
||||
|
||||
void "test show autopopup when typing digit after letter"() {
|
||||
myFixture.configureByText 'a.hs', 'a42 = 42\na<caret> }}'
|
||||
type '4'
|
||||
assert lookup
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1833,4 +1833,11 @@ ita<caret>
|
||||
|
||||
myFixture.assertPreferredCompletionItems 0, 'KimeFamilyRange'
|
||||
}
|
||||
|
||||
void "test show autopopup when typing digit after letter"() {
|
||||
myFixture.configureByText 'a.java', 'class Foo {{ int a42; a<caret> }}'
|
||||
type '4'
|
||||
assert lookup
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
-13
@@ -23,7 +23,6 @@ import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.psi.CustomHighlighterTokenType;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.ProcessingContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -56,7 +55,11 @@ public class CustomFileTypeCompletionContributor extends CompletionContributor i
|
||||
}
|
||||
|
||||
SyntaxTable syntaxTable = ((CustomSyntaxTableFileType)fileType).getSyntaxTable();
|
||||
String prefix = findPrefix(parameters.getPosition(), parameters.getOffset());
|
||||
String prefix = CompletionUtil.findJavaIdentifierPrefix(parameters);
|
||||
if (prefix.isEmpty() && parameters.isAutoPopup()) {
|
||||
return;
|
||||
}
|
||||
|
||||
CompletionResultSet resultSetWithPrefix = result.withPrefixMatcher(prefix);
|
||||
|
||||
addVariants(resultSetWithPrefix, syntaxTable.getKeywords1());
|
||||
@@ -90,15 +93,4 @@ public class CustomFileTypeCompletionContributor extends CompletionContributor i
|
||||
}
|
||||
}
|
||||
|
||||
private static String findPrefix(PsiElement insertedElement, int offset) {
|
||||
String text = insertedElement.getText();
|
||||
int offsetInElement = offset - insertedElement.getTextOffset();
|
||||
int start = offsetInElement - 1;
|
||||
while(start >=0 ) {
|
||||
if(!Character.isJavaIdentifierStart(text.charAt(start))) break;
|
||||
--start;
|
||||
}
|
||||
return text.substring(start+1, offsetInElement).trim();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ public class CompletionAutoPopupHandler extends TypedHandlerDelegate {
|
||||
return Result.STOP;
|
||||
}
|
||||
|
||||
if (Character.isLetter(charTyped) || charTyped == '_') {
|
||||
if (Character.isLetterOrDigit(charTyped) || charTyped == '_') {
|
||||
AutoPopupController.getInstance(project).scheduleAutoPopup(editor);
|
||||
return Result.STOP;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user