Fixed 'Completion suggests live tempates in name position'
#KT-1374 fixed
This commit is contained in:
@@ -36,6 +36,7 @@ import com.intellij.util.ProcessingContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lexer.JetToken;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.plugin.completion.handlers.JetFunctionInsertHandler;
|
||||
import org.jetbrains.jet.plugin.completion.handlers.JetKeywordInsertHandler;
|
||||
import org.jetbrains.jet.plugin.completion.handlers.JetTemplateInsertHandler;
|
||||
@@ -61,7 +62,9 @@ public class JetKeywordCompletionContributor extends CompletionContributor {
|
||||
new CommentFilter(), // or
|
||||
new ParentFilter(new ClassFilter(JetLiteralStringTemplateEntry.class)), // or
|
||||
new ParentFilter(new ClassFilter(JetConstantExpression.class)), // or
|
||||
new LeftNeighbour(new TextFilter("."))
|
||||
new LeftNeighbour(new TextFilter(".")), // or
|
||||
new AndFilter(new LeafElementFilter(JetTokens.IDENTIFIER),
|
||||
new NotFilter(new ParentFilter(new ClassFilter(JetReferenceExpression.class))))
|
||||
));
|
||||
|
||||
private final static List<String> FUNCTION_KEYWORDS = Lists.newArrayList(GET_KEYWORD.toString(), SET_KEYWORD.toString());
|
||||
@@ -309,4 +312,5 @@ public class JetKeywordCompletionContributor extends CompletionContributor {
|
||||
new FilterPattern(new AndFilter(GENERAL_FILTER, placeFilter)));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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 org.jetbrains.jet.plugin.completion;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.filters.ClassFilter;
|
||||
import com.intellij.psi.filters.ElementFilter;
|
||||
import com.intellij.psi.impl.source.tree.LeafPsiElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
|
||||
/**
|
||||
* @author Evgeny Gerashchenko
|
||||
* @since 2/23/12
|
||||
*/
|
||||
public class LeafElementFilter implements ElementFilter {
|
||||
private static final ClassFilter LEAF_CLASS_FILTER = new ClassFilter(LeafPsiElement.class);
|
||||
|
||||
private IElementType myElementType;
|
||||
|
||||
LeafElementFilter(IElementType elementType) {
|
||||
myElementType = elementType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptable(Object element, PsiElement context) {
|
||||
return element instanceof LeafPsiElement && ((LeafPsiElement) element).getElementType() == myElementType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClassAcceptable(Class hintClass) {
|
||||
return LEAF_CLASS_FILTER.isClassAcceptable(hintClass);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
fun <caret>() {
|
||||
|
||||
}
|
||||
|
||||
// ABSENT: abstract
|
||||
// ABSENT: annotation
|
||||
// ABSENT: as
|
||||
// ABSENT: break
|
||||
// ABSENT: by
|
||||
// ABSENT: catch
|
||||
// ABSENT: class
|
||||
// ABSENT: continue
|
||||
// ABSENT: do
|
||||
// ABSENT: else
|
||||
// ABSENT: enum
|
||||
// ABSENT: false
|
||||
// ABSENT: final
|
||||
// ABSENT: finally
|
||||
// ABSENT: for
|
||||
// ABSENT: fun
|
||||
// ABSENT: get
|
||||
// ABSENT: if
|
||||
// ABSENT: import
|
||||
// ABSENT: in
|
||||
// ABSENT: inline
|
||||
// ABSENT: internal
|
||||
// ABSENT: is
|
||||
// ABSENT: null
|
||||
// ABSENT: object
|
||||
// ABSENT: open
|
||||
// ABSENT: out
|
||||
// ABSENT: override
|
||||
// ABSENT: package
|
||||
// ABSENT: private
|
||||
// ABSENT: protected
|
||||
// ABSENT: public
|
||||
// ABSENT: return
|
||||
// ABSENT: set
|
||||
// ABSENT: super
|
||||
// ABSENT: This
|
||||
// ABSENT: this
|
||||
// ABSENT: throw
|
||||
// ABSENT: trait
|
||||
// ABSENT: true
|
||||
// ABSENT: try
|
||||
// ABSENT: type
|
||||
// ABSENT: val
|
||||
// ABSENT: var
|
||||
// ABSENT: vararg
|
||||
// ABSENT: when
|
||||
// ABSENT: where
|
||||
// ABSENT: while
|
||||
@@ -31,7 +31,7 @@ class TestSample() {
|
||||
// ABSENT: null
|
||||
// ABSENT: object
|
||||
// ABSENT: open
|
||||
// EXIST: out
|
||||
// ABSENT: out
|
||||
// ABSENT: override
|
||||
// ABSENT: package
|
||||
// ABSENT: private
|
||||
|
||||
@@ -28,7 +28,7 @@ fun test(<caret>) {
|
||||
// ABSENT: null
|
||||
// ABSENT: object
|
||||
// ABSENT: open
|
||||
// EXIST: out
|
||||
// ABSENT: out
|
||||
// ABSENT: override
|
||||
// ABSENT: package
|
||||
// ABSENT: private
|
||||
|
||||
@@ -63,6 +63,10 @@ public class KeywordsCompletionTest extends JetCompletionTestBase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testInFunctionName() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testInFunctionScope() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user