use of com.intellij.codeInsight.template.SmartCompletionContextType in project intellij-community by JetBrains.
the class BasicExpressionCompletionContributor method fillCompletionVariants.
public static void fillCompletionVariants(JavaSmartCompletionParameters parameters, final Consumer<LookupElement> result, PrefixMatcher matcher) {
final PsiElement element = parameters.getPosition();
if (JavaKeywordCompletion.isAfterTypeDot(element)) {
addKeyword(result, element, PsiKeyword.CLASS);
addKeyword(result, element, PsiKeyword.THIS);
}
if (!JavaKeywordCompletion.AFTER_DOT.accepts(element)) {
if (parameters.getParameters().getInvocationCount() <= 1) {
new CollectionsUtilityMethodsProvider(parameters.getPosition(), parameters.getExpectedType(), parameters.getDefaultType(), result).addCompletions(StringUtil.isNotEmpty(matcher.getPrefix()));
}
ClassLiteralGetter.addCompletions(parameters, result, matcher);
final PsiElement position = parameters.getPosition();
final PsiType expectedType = parameters.getExpectedType();
for (final TemplateImpl template : TemplateSettings.getInstance().getTemplates()) {
if (!template.isDeactivated() && template.getTemplateContext().isEnabled(new SmartCompletionContextType())) {
result.consume(new SmartCompletionTemplateItem(template, position));
}
}
addKeyword(result, position, PsiKeyword.TRUE);
addKeyword(result, position, PsiKeyword.FALSE);
final PsiElement parent = position.getParent();
if (parent != null && !(parent.getParent() instanceof PsiSwitchLabelStatement)) {
for (final PsiExpression expression : ThisGetter.getThisExpressionVariants(position)) {
result.consume(new ExpressionLookupItem(expression));
}
}
processDataflowExpressionTypes(position, expectedType, matcher, result);
}
}
use of com.intellij.codeInsight.template.SmartCompletionContextType in project intellij-community by JetBrains.
the class SmartTypeCompletionTest method testLiveTemplate.
public void testLiveTemplate() throws Throwable {
final Template template = TemplateManager.getInstance(getProject()).createTemplate("foo", "zzz");
template.addTextSegment("FooFactory.createFoo()");
final SmartCompletionContextType completionContextType = ContainerUtil.findInstance(TemplateContextType.EP_NAME.getExtensions(), SmartCompletionContextType.class);
((TemplateImpl) template).getTemplateContext().setEnabled(completionContextType, true);
CodeInsightTestUtil.addTemplate(template, myFixture.getTestRootDisposable());
doTest();
}
Aggregations