mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 10:20:15 +07:00
IDEA-42378 Live template expansion: existing identifier is converted to lower case
This commit is contained in:
@@ -44,10 +44,10 @@ public class JavaCharFilter extends CharFilter {
|
||||
}
|
||||
|
||||
public static boolean isNonImportedClassEntered(LookupImpl lookup, boolean orPackage) {
|
||||
if (lookup.isSelectionTouched() || !lookup.isCompletion()) return false;
|
||||
if (lookup.isSelectionTouched()) return false;
|
||||
|
||||
CompletionProcess process = CompletionService.getCompletionService().getCurrentCompletion();
|
||||
if (process == null || !process.isAutopopupCompletion()) return false;
|
||||
if (process != null && !process.isAutopopupCompletion()) return false;
|
||||
|
||||
LookupElement item = lookup.getCurrentItem();
|
||||
if (item == null) return false;
|
||||
@@ -56,11 +56,6 @@ public class JavaCharFilter extends CharFilter {
|
||||
if (file == null) return false;
|
||||
|
||||
final String prefix = lookup.itemPattern(item);
|
||||
for (String s : item.getAllLookupStrings()) {
|
||||
if (s.equalsIgnoreCase(prefix)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (PsiClass aClass : PsiShortNamesCache.getInstance(file.getProject()).getClassesByName(prefix, file.getResolveScope())) {
|
||||
if (!isObfuscated(aClass) && PsiUtil.isAccessible(aClass, file, null)) {
|
||||
return true;
|
||||
@@ -88,8 +83,6 @@ public class JavaCharFilter extends CharFilter {
|
||||
}
|
||||
|
||||
public Result acceptChar(char c, final int prefixLength, final Lookup lookup) {
|
||||
if (!lookup.isCompletion()) return null;
|
||||
|
||||
if (!lookup.getPsiFile().getLanguage().isKindOf(JavaLanguage.INSTANCE)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import java.io.File;
|
||||
|
||||
class Foo {
|
||||
{
|
||||
File file = new File("some.txt");
|
||||
System.out.println("file = " + File.<caret>);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import java.io.File;
|
||||
|
||||
class Foo {
|
||||
{
|
||||
File file = new File("some.txt");
|
||||
<caret>
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ package com.intellij.codeInsight.template;
|
||||
|
||||
|
||||
import com.intellij.JavaTestUtil
|
||||
import com.intellij.codeInsight.CodeInsightSettings
|
||||
import com.intellij.codeInsight.lookup.LookupManager
|
||||
import com.intellij.codeInsight.lookup.impl.LookupImpl
|
||||
import com.intellij.codeInsight.lookup.impl.LookupManagerImpl
|
||||
@@ -39,6 +40,7 @@ public class LiveTemplateTest extends LightCodeInsightFixtureTestCase {
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
CodeInsightSettings.instance.COMPLETION_CASE_SENSITIVE = CodeInsightSettings.FIRST_LETTER
|
||||
((TemplateManagerImpl)TemplateManager.getInstance(getProject())).setTemplateTesting(false);
|
||||
if (state != null) {
|
||||
state.gotoEnd();
|
||||
@@ -177,6 +179,17 @@ public class LiveTemplateTest extends LightCodeInsightFixtureTestCase {
|
||||
assert LookupManager.getActiveLookup(editor).currentItem.lookupString == 'entry'
|
||||
}
|
||||
|
||||
public void testClassNameDotInTemplate() {
|
||||
CodeInsightSettings.instance.COMPLETION_CASE_SENSITIVE = CodeInsightSettings.NONE
|
||||
configure();
|
||||
startTemplate("soutv", "output")
|
||||
myFixture.type('File')
|
||||
assert myFixture.lookupElementStrings == ['file']
|
||||
myFixture.type('.')
|
||||
checkResult()
|
||||
assert !state.finished
|
||||
}
|
||||
|
||||
private TemplateState getState() {
|
||||
TemplateManagerImpl.getTemplateState(getEditor())
|
||||
}
|
||||
|
||||
@@ -17,14 +17,13 @@ package com.intellij.refactoring;
|
||||
|
||||
import com.intellij.codeInsight.lookup.CharFilter;
|
||||
import com.intellij.codeInsight.lookup.Lookup;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class IdentifierCharFilter extends CharFilter {
|
||||
|
||||
public Result acceptChar(char c, @NotNull final int prefixLength, final Lookup lookup) {
|
||||
public Result acceptChar(char c, final int prefixLength, final Lookup lookup) {
|
||||
if (lookup.isCompletion()) return null;
|
||||
|
||||
if (Character.isJavaIdentifierPart(c)) return Result.ADD_TO_PREFIX;
|
||||
|
||||
@@ -490,7 +490,7 @@
|
||||
|
||||
<lookup.charFilter implementation="com.intellij.codeInsight.template.impl.LiveTemplateCharFilter" order="first" id="liveTemplate"/>
|
||||
<lookup.charFilter implementation="com.intellij.codeInsight.completion.CompletionCharFilter" order="last" id="completion"/>
|
||||
<lookup.charFilter implementation="com.intellij.refactoring.IdentifierCharFilter" id="identifier"/>
|
||||
<lookup.charFilter implementation="com.intellij.refactoring.IdentifierCharFilter" id="identifier" order="last"/>
|
||||
<lookup.charFilter implementation="com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceCharFilter" id="fileRef"
|
||||
order="before completion"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user