List of usage examples for com.intellij.openapi.actionSystem IdeActions ACTION_SMART_TYPE_COMPLETION
String ACTION_SMART_TYPE_COMPLETION
To view the source code for com.intellij.openapi.actionSystem IdeActions ACTION_SMART_TYPE_COMPLETION.
Click Source Link
From source file:com.intellij.application.options.CodeCompletionPanel.java
License:Apache License
public CodeCompletionPanel() { //noinspection unchecked myCaseSensitiveCombo.setModel(new DefaultComboBoxModel(CASE_VARIANTS)); ActionManager actionManager = ActionManager.getInstance(); String basicShortcut = KeymapUtil .getFirstKeyboardShortcutText(actionManager.getAction(IdeActions.ACTION_CODE_COMPLETION)); String smartShortcut = KeymapUtil .getFirstKeyboardShortcutText(actionManager.getAction(IdeActions.ACTION_SMART_TYPE_COMPLETION)); if (StringUtil.isNotEmpty(basicShortcut)) { myCbOnCodeCompletion.setText(myCbOnCodeCompletion.getText() + " ( " + basicShortcut + " )"); }/*from w w w .j ava2 s .c om*/ if (StringUtil.isNotEmpty(smartShortcut)) { myCbOnSmartTypeCompletion.setText(myCbOnSmartTypeCompletion.getText() + " ( " + smartShortcut + " )"); } myCbAutocompletion.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { boolean selected = myCbAutocompletion.isSelected(); myCbSelectByChars.setEnabled(selected); } }); myCbAutopopupJavaDoc.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { myAutopopupJavaDocField.setEnabled(myCbAutopopupJavaDoc.isSelected()); } }); myCbParameterInfoPopup.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { myParameterInfoDelayField.setEnabled(myCbParameterInfoPopup.isSelected()); } }); reset(); }
From source file:com.intellij.codeInsight.completion.JavaClassReferenceCompletionContributor.java
License:Apache License
@Override public void fillCompletionVariants(CompletionParameters parameters, CompletionResultSet result) { PsiElement position = parameters.getPosition(); JavaClassReference reference = findJavaClassReference(position.getContainingFile(), parameters.getOffset()); if (reference == null) { return;/* w w w . j a v a 2s . c o m*/ } String[] extendClassNames = reference.getExtendClassNames(); PsiElement context = reference.getCompletionContext(); if (extendClassNames != null && context instanceof PsiJavaPackage) { if (parameters.getCompletionType() == CompletionType.SMART) { JavaClassReferenceSet set = reference.getJavaClassReferenceSet(); int setStart = set.getRangeInElement().getStartOffset() + set.getElement().getTextRange().getStartOffset(); String fullPrefix = parameters.getPosition().getContainingFile().getText().substring(setStart, parameters.getOffset()); reference.processSubclassVariants((PsiJavaPackage) context, extendClassNames, result.withPrefixMatcher(fullPrefix)); return; } result.addLookupAdvertisement("Press " + getActionShortcut(IdeActions.ACTION_SMART_TYPE_COMPLETION) + " to see inheritors of " + StringUtil.join(extendClassNames, ", ")); } if (parameters.getCompletionType() == CompletionType.SMART) { return; } if (parameters.isExtendedCompletion() || parameters.getCompletionType() == CompletionType.CLASS_NAME) { JavaClassNameCompletionContributor.addAllClasses(parameters, result); } else { LegacyCompletionContributor.completeReference(parameters, result); } result.stopHere(); }
From source file:com.intellij.codeInsight.completion.JavaCompletionContributor.java
License:Apache License
@Override public String advertise(@NotNull final CompletionParameters parameters) { if (!(parameters.getOriginalFile() instanceof PsiJavaFile)) { return null; }/* w ww . j a v a 2 s. c o m*/ if (parameters.getCompletionType() == CompletionType.BASIC && parameters.getInvocationCount() > 0) { PsiElement position = parameters.getPosition(); if (psiElement().withParent( psiReferenceExpression().withFirstChild(psiReferenceExpression().referencing(psiClass()))) .accepts(position)) { if (CompletionUtil.shouldShowFeature(parameters, JavaCompletionFeatures.GLOBAL_MEMBER_NAME)) { final String shortcut = getActionShortcut(IdeActions.ACTION_CODE_COMPLETION); if (shortcut != null) { return "Pressing " + shortcut + " twice without a class qualifier would show all accessible static methods"; } } } } if (parameters.getCompletionType() != CompletionType.SMART && shouldSuggestSmartCompletion(parameters.getPosition())) { if (CompletionUtil.shouldShowFeature(parameters, CodeCompletionFeatures.EDITING_COMPLETION_SMARTTYPE_GENERAL)) { final String shortcut = getActionShortcut(IdeActions.ACTION_SMART_TYPE_COMPLETION); if (shortcut != null) { return CompletionBundle.message("completion.smart.hint", shortcut); } } } if (parameters.getCompletionType() == CompletionType.SMART && parameters.getInvocationCount() == 1) { final PsiType[] psiTypes = ExpectedTypesGetter.getExpectedTypes(parameters.getPosition(), true); if (psiTypes.length > 0) { if (CompletionUtil.shouldShowFeature(parameters, JavaCompletionFeatures.SECOND_SMART_COMPLETION_TOAR)) { final String shortcut = getActionShortcut(IdeActions.ACTION_SMART_TYPE_COMPLETION); if (shortcut != null) { for (final PsiType psiType : psiTypes) { final PsiType type = PsiUtil.extractIterableTypeParameter(psiType, false); if (type != null) { return CompletionBundle.message("completion.smart.aslist.hint", shortcut, type.getPresentableText()); } } } } if (CompletionUtil.shouldShowFeature(parameters, JavaCompletionFeatures.SECOND_SMART_COMPLETION_ASLIST)) { final String shortcut = getActionShortcut(IdeActions.ACTION_SMART_TYPE_COMPLETION); if (shortcut != null) { for (final PsiType psiType : psiTypes) { if (psiType instanceof PsiArrayType) { final PsiType componentType = ((PsiArrayType) psiType).getComponentType(); if (!(componentType instanceof PsiPrimitiveType)) { return CompletionBundle.message("completion.smart.toar.hint", shortcut, componentType.getPresentableText()); } } } } } if (CompletionUtil.shouldShowFeature(parameters, JavaCompletionFeatures.SECOND_SMART_COMPLETION_CHAIN)) { final String shortcut = getActionShortcut(IdeActions.ACTION_SMART_TYPE_COMPLETION); if (shortcut != null) { return CompletionBundle.message("completion.smart.chain.hint", shortcut); } } } } return null; }
From source file:com.intellij.spring.model.converters.SpringCompletionContributor.java
License:Apache License
@Override public String advertise(@Nonnull CompletionParameters parameters) { if (parameters.getCompletionType() == CompletionType.BASIC && getReference(parameters) != null) { final String shortcut = getActionShortcut(IdeActions.ACTION_SMART_TYPE_COMPLETION); if (shortcut != null) { return CompletionBundle.message("completion.smart.hint", shortcut); }//from w ww . j av a 2 s . c o m } return null; }