本文整理汇总了Java中com.intellij.codeInsight.lookup.AutoCompletionPolicy类的典型用法代码示例。如果您正苦于以下问题:Java AutoCompletionPolicy类的具体用法?Java AutoCompletionPolicy怎么用?Java AutoCompletionPolicy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AutoCompletionPolicy类属于com.intellij.codeInsight.lookup包,在下文中一共展示了AutoCompletionPolicy类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addEnumSuggestions
import com.intellij.codeInsight.lookup.AutoCompletionPolicy; //导入依赖的package包/类
private static void addEnumSuggestions(Editor editor, String val, String suffix, List<LookupElement> answer,
String deprecated, String enums, String defaultValue, boolean xmlMode) {
String[] parts = enums.split(",");
for (String part : parts) {
String lookup = val + part;
LookupElementBuilder builder = LookupElementBuilder.create(lookup);
builder = addInsertHandler(editor, suffix, builder, xmlMode);
// only show the option in the UI
builder = builder.withPresentableText(part);
builder = builder.withBoldness(true);
if ("true".equals(deprecated)) {
// mark as deprecated
builder = builder.withStrikeoutness(true);
}
boolean isDefaultValue = defaultValue != null && part.equals(defaultValue);
if (isDefaultValue) {
builder = builder.withTailText(" (default value)");
// add default value first in the list
answer.add(0, builder.withAutoCompletionPolicy(AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE));
} else {
answer.add(builder.withAutoCompletionPolicy(AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE));
}
}
}
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:26,代码来源:CamelSmartCompletionEndpointValue.java
示例2: addSmartCompletionSuggestionsContextPath
import com.intellij.codeInsight.lookup.AutoCompletionPolicy; //导入依赖的package包/类
public static List<LookupElement> addSmartCompletionSuggestionsContextPath(String val, ComponentModel component,
Map<String, String> existing, boolean xmlMode, PsiElement psiElement) {
List<LookupElement> answer = new ArrayList<>();
// show the syntax as the only choice for now
LookupElementBuilder builder = LookupElementBuilder.create(val);
builder = builder.withIcon(getCamelPreferenceService().getCamelIcon());
builder = builder.withBoldness(true);
builder = builder.withPresentableText(component.getSyntax());
LookupElement element = builder.withAutoCompletionPolicy(AutoCompletionPolicy.NEVER_AUTOCOMPLETE);
answer.add(element);
val = removeUnknownEnum(val, psiElement);
List<LookupElement> old = addSmartCompletionContextPathEnumSuggestions(val, component, existing);
if (!old.isEmpty()) {
answer.addAll(old);
}
return answer;
}
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:21,代码来源:CamelSmartCompletionEndpointOptions.java
示例3: suggestNonImportedClasses
import com.intellij.codeInsight.lookup.AutoCompletionPolicy; //导入依赖的package包/类
private static void suggestNonImportedClasses(final CompletionParameters parameters, final CompletionResultSet result, @Nullable final InheritorsHolder inheritorsHolder) {
JavaClassNameCompletionContributor.addAllClasses(parameters,
true, result.getPrefixMatcher(), new Consumer<LookupElement>() {
@Override
public void consume(LookupElement element) {
if (inheritorsHolder != null && inheritorsHolder.alreadyProcessed(element)) {
return;
}
JavaPsiClassReferenceElement classElement = element.as(JavaPsiClassReferenceElement.CLASS_CONDITION_KEY);
if (classElement != null) {
classElement.setAutoCompletionPolicy(AutoCompletionPolicy.NEVER_AUTOCOMPLETE);
element = JavaClassNameCompletionContributor.highlightIfNeeded(classElement, parameters);
}
result.addElement(element);
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:JavaNoVariantsDelegator.java
示例4: createLookupElement
import com.intellij.codeInsight.lookup.AutoCompletionPolicy; //导入依赖的package包/类
@NotNull
@Override
protected LookupElement createLookupElement(@NotNull PsiMember member, @NotNull final PsiClass containingClass, boolean shouldImport) {
shouldImport |= myOriginalPosition != null && PsiTreeUtil.isAncestor(containingClass, myOriginalPosition, false);
if (member instanceof PsiMethod) {
return AutoCompletionPolicy.NEVER_AUTOCOMPLETE.applyPolicy(new GlobalMethodCallElement((PsiMethod)member, shouldImport, false));
}
return AutoCompletionPolicy.NEVER_AUTOCOMPLETE.applyPolicy(new VariableLookupItem((PsiField)member, shouldImport) {
@Override
public void handleInsert(InsertionContext context) {
FeatureUsageTracker.getInstance().triggerFeatureUsed(JavaCompletionFeatures.GLOBAL_MEMBER_NAME);
super.handleInsert(context);
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:JavaStaticMemberProcessor.java
示例5: doProcessMembers
import com.intellij.codeInsight.lookup.AutoCompletionPolicy; //导入依赖的package包/类
private void doProcessMembers(boolean acceptMethods,
Consumer<LookupElement> results,
boolean isExpectedTypeMember, Collection<? extends PsiElement> declarations) {
for (final PsiElement result : declarations) {
if (result instanceof PsiMember && !(result instanceof PsiClass)) {
final PsiMember member = (PsiMember)result;
if (!member.hasModifierProperty(PsiModifier.STATIC)) continue;
if (result instanceof PsiField && !member.hasModifierProperty(PsiModifier.FINAL)) continue;
if (result instanceof PsiMethod && (!acceptMethods || myPlaceMethods.contains(result))) continue;
if (JavaCompletionUtil.isInExcludedPackage(member, false) || myImportedStatically.contains(member)) continue;
if (!JavaPsiFacade.getInstance(myPlace.getProject()).getResolveHelper().isAccessible(member, myPlace, null)) {
continue;
}
final LookupElement item = result instanceof PsiMethod ? createMethodElement((PsiMethod)result) : createFieldElement((PsiField)result);
if (item != null) {
item.putUserData(EXPECTED_TYPE_MEMBER, isExpectedTypeMember);
results.consume(AutoCompletionPolicy.NEVER_AUTOCOMPLETE.applyPolicy(item));
}
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:MembersGetter.java
示例6: addCompletionElements
import com.intellij.codeInsight.lookup.AutoCompletionPolicy; //导入依赖的package包/类
private static <T> void addCompletionElements(final CompletionResultSet result,
final TextFieldWithAutoCompletionListProvider<T> listProvider,
final Collection<T> items,
final int index) {
final AutoCompletionPolicy completionPolicy = ApplicationManager.getApplication().isUnitTestMode()
? AutoCompletionPolicy.ALWAYS_AUTOCOMPLETE
: AutoCompletionPolicy.NEVER_AUTOCOMPLETE;
int grouping = index;
for (final T item : items) {
if (item == null) {
LOG.error("Null item from " + listProvider);
continue;
}
LookupElementBuilder builder = listProvider.createLookupBuilder(item);
result.addElement(PrioritizedLookupElement.withGrouping(builder.withAutoCompletionPolicy(completionPolicy), grouping--));
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:TextFieldWithAutoCompletionContributor.java
示例7: getVariants
import com.intellij.codeInsight.lookup.AutoCompletionPolicy; //导入依赖的package包/类
@NotNull
public Object[] getVariants() {
final TargetResolver.Result result = doResolve(getCanonicalText());
if (result == null) {
return EMPTY_ARRAY;
}
final Map<String, AntDomTarget> variants = result.getVariants();
final List resVariants = new ArrayList();
final Set<String> existing = getExistingNames();
for (String s : variants.keySet()) {
if (existing.contains(s)){
continue;
}
final LookupElementBuilder builder = LookupElementBuilder.create(s).withCaseSensitivity(false);
final LookupElement element = AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE.applyPolicy(builder);
resVariants.add(element);
}
return ContainerUtil.toArray(resVariants, new Object[resVariants.size()]);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:AntDomTargetReference.java
示例8: getVariants
import com.intellij.codeInsight.lookup.AutoCompletionPolicy; //导入依赖的package包/类
@NotNull
@Override
public Object[] getVariants() {
final AntDomProject project = myInvocationContextElement.getParentOfType(AntDomProject.class, true);
if (project != null) {
final Collection<String> variants = PropertyResolver.resolve(project.getContextAntProject(), getCanonicalText(), myInvocationContextElement).getSecond();
Object[] result = new Object[variants.size()];
int idx = 0;
for (String variant : variants) {
final LookupElementBuilder builder = LookupElementBuilder.create(variant).withCaseSensitivity(false);
final LookupElement element = AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE.applyPolicy(builder);
result[idx++] = element;
}
return result;
}
return EMPTY_ARRAY;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:AntDomPropertyReference.java
示例9: getVariants
import com.intellij.codeInsight.lookup.AutoCompletionPolicy; //导入依赖的package包/类
@NotNull
public Object[] getVariants() {
final AntDomMacroDef parentMacrodef = getParentMacrodef();
if (parentMacrodef != null) {
final List variants = new ArrayList();
for (AntDomMacrodefAttribute attribute : parentMacrodef.getMacroAttributes()) {
final String attribName = attribute.getName().getStringValue();
if (attribName != null && attribName.length() > 0) {
final LookupElementBuilder builder = LookupElementBuilder.create(attribName);
final LookupElement element = AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE.applyPolicy(builder);
variants.add(element);
}
}
return ContainerUtil.toArray(variants, new Object[variants.size()]);
}
return EMPTY_ARRAY;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:AntDomMacrodefAttributeReference.java
示例10: doProcessMembers
import com.intellij.codeInsight.lookup.AutoCompletionPolicy; //导入依赖的package包/类
private void doProcessMembers(boolean acceptMethods,
Consumer<LookupElement> results,
boolean isInheritor, Collection<? extends PsiElement> declarations) {
for (final PsiElement result : declarations) {
if (result instanceof PsiMember && !(result instanceof PsiClass)) {
final PsiMember member = (PsiMember)result;
if (!member.hasModifierProperty(PsiModifier.STATIC)) continue;
if (result instanceof PsiField && !member.hasModifierProperty(PsiModifier.FINAL)) continue;
if (result instanceof PsiMethod && (!acceptMethods || myPlaceMethods.contains(result))) continue;
if (JavaCompletionUtil.isInExcludedPackage(member, false) || myImportedStatically.contains(member)) continue;
if (!JavaPsiFacade.getInstance(myPlace.getProject()).getResolveHelper().isAccessible(member, myPlace, null)) {
continue;
}
final LookupElement item = result instanceof PsiMethod ? createMethodElement((PsiMethod)result) : createFieldElement((PsiField)result);
if (item != null) {
item.putUserData(EXPECTED_TYPE_INHERITOR_MEMBER, isInheritor);
results.consume(AutoCompletionPolicy.NEVER_AUTOCOMPLETE.applyPolicy(item));
}
}
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:MembersGetter.java
示例11: suggestNonImportedClasses
import com.intellij.codeInsight.lookup.AutoCompletionPolicy; //导入依赖的package包/类
private static void suggestNonImportedClasses(CompletionParameters parameters, CompletionResultSet result, @Nullable JavaCompletionSession session)
{
JavaClassNameCompletionContributor.addAllClasses(parameters, true, result.getPrefixMatcher(), element ->
{
if(session != null && session.alreadyProcessed(element))
{
return;
}
JavaPsiClassReferenceElement classElement = element.as(JavaPsiClassReferenceElement.CLASS_CONDITION_KEY);
if(classElement != null)
{
classElement.setAutoCompletionPolicy(AutoCompletionPolicy.NEVER_AUTOCOMPLETE);
element = JavaClassNameCompletionContributor.highlightIfNeeded(classElement, parameters);
}
result.addElement(element);
});
}
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:JavaNoVariantsDelegator.java
示例12: addBooleanSuggestions
import com.intellij.codeInsight.lookup.AutoCompletionPolicy; //导入依赖的package包/类
private static void addBooleanSuggestions(Editor editor, String val, String suffix, List<LookupElement> answer,
String deprecated, String defaultValue, boolean xmlMode) {
// for boolean types then give a choice between true|false
String lookup = val + "true";
LookupElementBuilder builder = LookupElementBuilder.create(lookup);
builder = addInsertHandler(editor, suffix, builder, xmlMode);
// only show the option in the UI
builder = builder.withPresentableText("true");
if ("true".equals(deprecated)) {
// mark as deprecated
builder = builder.withStrikeoutness(true);
}
boolean isDefaultValue = defaultValue != null && "true".equals(defaultValue);
if (isDefaultValue) {
builder = builder.withTailText(" (default value)");
// add default value first in the list
answer.add(0, builder.withAutoCompletionPolicy(AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE));
} else {
answer.add(builder.withAutoCompletionPolicy(AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE));
}
lookup = val + "false";
builder = LookupElementBuilder.create(lookup);
builder = addInsertHandler(editor, suffix, builder, xmlMode);
// only show the option in the UI
builder = builder.withPresentableText("false");
if ("true".equals(deprecated)) {
// mark as deprecated
builder = builder.withStrikeoutness(true);
}
isDefaultValue = defaultValue != null && "false".equals(defaultValue);
if (isDefaultValue) {
builder = builder.withTailText(" (default value)");
// add default value first in the list
answer.add(0, builder.withAutoCompletionPolicy(AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE));
} else {
answer.add(builder.withAutoCompletionPolicy(AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE));
}
}
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:40,代码来源:CamelSmartCompletionEndpointValue.java
示例13: addDefaultValueSuggestions
import com.intellij.codeInsight.lookup.AutoCompletionPolicy; //导入依赖的package包/类
private static void addDefaultValueSuggestions(Editor editor, String val, String suffix, List<LookupElement> answer,
String deprecated, String defaultValue, boolean xmlMode) {
String lookup = val + defaultValue;
LookupElementBuilder builder = LookupElementBuilder.create(lookup);
builder = addInsertHandler(editor, suffix, builder, xmlMode);
// only show the option in the UI
builder = builder.withPresentableText(defaultValue);
if ("true".equals(deprecated)) {
// mark as deprecated
builder = builder.withStrikeoutness(true);
}
builder = builder.withTailText(" (default value)");
// there is only one value in the list and its the default value, so never auto complete it but show as suggestion
answer.add(0, builder.withAutoCompletionPolicy(AutoCompletionPolicy.NEVER_AUTOCOMPLETE));
}
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:16,代码来源:CamelSmartCompletionEndpointValue.java
示例14: fillCompletionVariants
import com.intellij.codeInsight.lookup.AutoCompletionPolicy; //导入依赖的package包/类
@Override
public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull final CompletionResultSet result) {
PsiElement position = parameters.getPosition();
PsiFile file = position.getContainingFile();
if (parameters.getCompletionType() != CompletionType.BASIC ||
!JavaCompletionContributor.mayStartClassName(result) ||
!file.getLanguage().isKindOf(StdLanguages.XML)) {
return;
}
final boolean empty = result.runRemainingContributors(parameters, true).isEmpty();
if (!empty && parameters.getInvocationCount() == 0) {
result.restartCompletionWhenNothingMatches();
}
if (empty && JavaClassReferenceCompletionContributor.findJavaClassReference(file, parameters.getOffset()) != null ||
parameters.isExtendedCompletion()) {
CompletionService.getCompletionService().getVariantsFromContributors(parameters.delegateToClassName(), null, new Consumer<CompletionResult>() {
@Override
public void consume(final CompletionResult completionResult) {
LookupElement lookupElement = completionResult.getLookupElement();
JavaPsiClassReferenceElement classElement = lookupElement.as(JavaPsiClassReferenceElement.CLASS_CONDITION_KEY);
if (classElement != null) {
classElement.setAutoCompletionPolicy(AutoCompletionPolicy.NEVER_AUTOCOMPLETE);
}
lookupElement.putUserData(XmlCompletionContributor.WORD_COMPLETION_COMPATIBLE, Boolean.TRUE); //todo think of a less dirty interaction
result.passResult(completionResult);
}
});
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:XmlBasicToClassNameDelegator.java
示例15: createConstructorReferenceLookup
import com.intellij.codeInsight.lookup.AutoCompletionPolicy; //导入依赖的package包/类
private static LookupElement createConstructorReferenceLookup(PsiType functionalInterfaceType, PsiType expectedReturnType) {
return LookupElementBuilder
.create(expectedReturnType.getPresentableText() + "::new")
.withTypeText(functionalInterfaceType.getPresentableText())
.withIcon(AllIcons.Nodes.MethodReference)
.withAutoCompletionPolicy(AutoCompletionPolicy.NEVER_AUTOCOMPLETE);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:FunctionalExpressionCompletionProvider.java
示例16: collectThisVariants
import com.intellij.codeInsight.lookup.AutoCompletionPolicy; //导入依赖的package包/类
private static void collectThisVariants(PsiType functionalInterfaceType,
PsiParameter[] params,
PsiElement originalPosition,
PsiSubstitutor substitutor, PsiType expectedReturnType, List<LookupElement> result) {
final PsiClass psiClass = PsiTreeUtil.getParentOfType(originalPosition, PsiClass.class);
if (psiClass != null) {
for (PsiMethod psiMethod : psiClass.getMethods()) {
final PsiType returnType = psiMethod.getReturnType();
if (isInstanceMethodWithAppropriateReturnType(expectedReturnType, psiMethod, returnType) &&
areParameterTypesAppropriate(psiMethod, params, substitutor, 0)) {
LookupElement methodRefLookupElement = LookupElementBuilder
.create(psiMethod)
.withPresentableText("this::" + psiMethod.getName())
.withInsertHandler(new InsertHandler<LookupElement>() {
@Override
public void handleInsert(InsertionContext context, LookupElement item) {
final int startOffset = context.getStartOffset();
final Document document = context.getDocument();
document.insertString(startOffset, "this::");
}
})
.withTypeText(functionalInterfaceType.getPresentableText())
.withIcon(AllIcons.Nodes.MethodReference)
.withAutoCompletionPolicy(AutoCompletionPolicy.NEVER_AUTOCOMPLETE);
result.add(methodRefLookupElement);
}
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:FunctionalExpressionCompletionProvider.java
示例17: consume
import com.intellij.codeInsight.lookup.AutoCompletionPolicy; //导入依赖的package包/类
@Override
public void consume(LookupElement lookupElement) {
final Object object = lookupElement.getObject();
if (object instanceof PsiClass) {
registerClass((PsiClass)object);
}
myResult.addElement(AutoCompletionPolicy.NEVER_AUTOCOMPLETE.applyPolicy(lookupElement));
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:InheritorsHolder.java
示例18: addMethodItem
import com.intellij.codeInsight.lookup.AutoCompletionPolicy; //导入依赖的package包/类
private void addMethodItem(PsiType expectedType, String methodName, PsiClass containingClass) {
final PsiMethod[] methods = containingClass.findMethodsByName(methodName, false);
if (methods.length == 0) {
return;
}
final PsiMethod method = methods[0];
final JavaMethodCallElement item = new JavaMethodCallElement(method, false, false);
item.setAutoCompletionPolicy(AutoCompletionPolicy.NEVER_AUTOCOMPLETE);
item.setInferenceSubstitutor(SmartCompletionDecorator.calculateMethodReturnTypeSubstitutor(method, expectedType), myElement);
myResult.consume(item);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:CollectionsUtilityMethodsProvider.java
示例19: createSmartCastElement
import com.intellij.codeInsight.lookup.AutoCompletionPolicy; //导入依赖的package包/类
private static LookupElement createSmartCastElement(final CompletionParameters parameters, final boolean overwrite, final PsiType type) {
return AutoCompletionPolicy.ALWAYS_AUTOCOMPLETE.applyPolicy(new LookupElementDecorator<PsiTypeLookupItem>(
PsiTypeLookupItem.createLookupItem(type, parameters.getPosition())) {
@Override
public void handleInsert(InsertionContext context) {
FeatureUsageTracker.getInstance().triggerFeatureUsed("editing.completion.smarttype.casting");
final Editor editor = context.getEditor();
final Document document = editor.getDocument();
if (overwrite) {
document.deleteString(context.getSelectionEndOffset(),
context.getOffsetMap().getOffset(CompletionInitializationContext.IDENTIFIER_END_OFFSET));
}
final CommonCodeStyleSettings csSettings = context.getCodeStyleSettings();
final int oldTail = context.getTailOffset();
context.setTailOffset(RParenthTailType.addRParenth(editor, oldTail, csSettings.SPACE_WITHIN_CAST_PARENTHESES));
getDelegate().handleInsert(CompletionUtil.newContext(context, getDelegate(), context.getStartOffset(), oldTail));
PostprocessReformattingAspect.getInstance(context.getProject()).doPostponedFormatting();
if (csSettings.SPACE_AFTER_TYPE_CAST) {
context.setTailOffset(TailType.insertChar(editor, context.getTailOffset(), ' '));
}
if (parameters.getCompletionType() == CompletionType.SMART) {
editor.getCaretModel().moveToOffset(context.getTailOffset());
}
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:SmartCastProvider.java
示例20: addClassLiteralLookupElement
import com.intellij.codeInsight.lookup.AutoCompletionPolicy; //导入依赖的package包/类
private static void addClassLiteralLookupElement(@Nullable final PsiType type, final Consumer<LookupElement> resultSet, final PsiFile context) {
if (type instanceof PsiClassType &&
PsiUtil.resolveClassInType(type) != null &&
!((PsiClassType)type).hasParameters() &&
!(((PsiClassType)type).resolve() instanceof PsiTypeParameter)) {
try {
resultSet.consume(AutoCompletionPolicy.NEVER_AUTOCOMPLETE.applyPolicy(new ClassLiteralLookupElement((PsiClassType)type, context)));
}
catch (IncorrectOperationException ignored) {
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ClassLiteralGetter.java
注:本文中的com.intellij.codeInsight.lookup.AutoCompletionPolicy类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论