• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java LookupItem类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.codeInsight.lookup.LookupItem的典型用法代码示例。如果您正苦于以下问题:Java LookupItem类的具体用法?Java LookupItem怎么用?Java LookupItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LookupItem类属于com.intellij.codeInsight.lookup包,在下文中一共展示了LookupItem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: insertParentheses

import com.intellij.codeInsight.lookup.LookupItem; //导入依赖的package包/类
public static boolean insertParentheses(InsertionContext context,
                                        LookupItem delegate,
                                        final PsiClass psiClass,
                                        final boolean forAnonymous) {
  if (context.getCompletionChar() == '[') {
    return false;
  }

  final PsiElement place = context.getFile().findElementAt(context.getStartOffset());
  assert place != null;
  boolean hasParams = hasConstructorParameters(psiClass, place);

  JavaCompletionUtil.insertParentheses(context, delegate, false, hasParams, forAnonymous);

  return true;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:ConstructorInsertHandler.java


示例2: isToStrikeout

import com.intellij.codeInsight.lookup.LookupItem; //导入依赖的package包/类
public static boolean isToStrikeout(LookupItem<?> item) {
  final List<PsiMethod> allMethods = item.getUserData(JavaCompletionUtil.ALL_METHODS_ATTRIBUTE);
  if (allMethods != null){
    for (PsiMethod method : allMethods) {
      if (!method.isValid()) { //?
        return false;
      }
      if (!isDeprecated(method)) {
        return false;
      }
    }
    return true;
  }
  else if (item.getObject() instanceof PsiElement) {
    final PsiElement element = (PsiElement)item.getObject();
    if (element.isValid()) {
      return isDeprecated(element);
    }
  }
  return false;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:JavaElementLookupRenderer.java


示例3: addLookupItem

import com.intellij.codeInsight.lookup.LookupItem; //导入依赖的package包/类
protected void addLookupItem(Set<LookupElement> set, TailType tailType, @Nonnull Object completion, final CompletionVariant variant) {
  LookupElement ret = objectToLookupItem(completion);
  if (ret == null) return;
  if (!(ret instanceof LookupItem)) {
    set.add(ret);
    return;
  }

  LookupItem item = (LookupItem)ret;

  final InsertHandler insertHandler = variant.getInsertHandler();
  if(insertHandler != null && item.getInsertHandler() == null) {
    item.setInsertHandler(insertHandler);
    item.setTailType(TailType.UNKNOWN);
  }
  else if (tailType != TailType.NONE) {
    item.setTailType(tailType);
  }
  final Map<Object, Object> itemProperties = variant.getItemProperties();
  for (final Object key : itemProperties.keySet()) {
    item.setAttribute(key, itemProperties.get(key));
  }

  set.add(ret);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:26,代码来源:CompletionData.java


示例4: handleInsert

import com.intellij.codeInsight.lookup.LookupItem; //导入依赖的package包/类
@Override
public void handleInsert(final InsertionContext context, LookupElement lookupElement)
{
	context.commitDocument();

	TailType tailType = getTailType(context.getCompletionChar(), (LookupItem) lookupElement);

	final Editor editor = context.getEditor();
	editor.getCaretModel().moveToOffset(context.getSelectionEndOffset());
	tailType.processTail(editor, context.getSelectionEndOffset());
	editor.getSelectionModel().removeSelection();

	if(tailType == TailType.DOT || context.getCompletionChar() == '.')
	{
		AutoPopupController.getInstance(context.getProject()).autoPopupMemberLookup(editor, null);
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:18,代码来源:DefaultInsertHandler.java


示例5: getTailType

import com.intellij.codeInsight.lookup.LookupItem; //导入依赖的package包/类
private static TailType getTailType(final char completionChar, LookupItem item)
{
	switch(completionChar)
	{
		case '.':
			return new CharTailType('.', false);
		case ',':
			return TailType.COMMA;
		case ';':
			return TailType.SEMICOLON;
		case '=':
			return TailType.EQ;
		case ' ':
			return TailType.SPACE;
		case ':':
			return TailType.CASE_COLON; //?
		case '<':
		case '>':
		case '\"':
	}
	final TailType attr = item.getTailType();
	return attr == TailType.UNKNOWN ? TailType.NONE : attr;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:24,代码来源:DefaultInsertHandler.java


示例6: withInsertHandler

import com.intellij.codeInsight.lookup.LookupItem; //导入依赖的package包/类
private static LookupElementDecorator<LookupElement> withInsertHandler(final SuggestedNameInfo callback, LookupElement element)
{
	return LookupElementDecorator.withInsertHandler(element, new InsertHandler<LookupElementDecorator<LookupElement>>()
	{
		@Override
		public void handleInsert(InsertionContext context, LookupElementDecorator<LookupElement> item)
		{
			TailType tailType = LookupItem.getDefaultTailType(context.getCompletionChar());
			if(tailType != null)
			{
				context.setAddCompletionChar(false);
				tailType.processTail(context.getEditor(), context.getTailOffset());
			}
			callback.nameChosen(item.getLookupString());
		}
	});
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:18,代码来源:JavaMemberNameCompletionContributor.java


示例7: handleInsert

import com.intellij.codeInsight.lookup.LookupItem; //导入依赖的package包/类
@Override
public void handleInsert(final InsertionContext context, LookupElement lookupElement) {
  context.commitDocument();

  TailType tailType = getTailType(context.getCompletionChar(), (LookupItem)lookupElement);

  final Editor editor = context.getEditor();
  editor.getCaretModel().moveToOffset(context.getSelectionEndOffset());
  tailType.processTail(editor, context.getSelectionEndOffset());
  editor.getSelectionModel().removeSelection();

  if (tailType == TailType.DOT || context.getCompletionChar() == '.') {
    AutoPopupController.getInstance(context.getProject()).autoPopupMemberLookup(editor, null);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:DefaultInsertHandler.java


示例8: getTailType

import com.intellij.codeInsight.lookup.LookupItem; //导入依赖的package包/类
private static TailType getTailType(final char completionChar, LookupItem item){
  switch(completionChar){
    case '.': return new CharTailType('.', false);
    case ',': return TailType.COMMA;
    case ';': return TailType.SEMICOLON;
    case '=': return TailType.EQ;
    case ' ': return TailType.SPACE;
    case ':': return TailType.CASE_COLON; //?
    case '<':
    case '>':
    case '\"':
  }
  final TailType attr = item.getTailType();
  return attr == TailType.UNKNOWN ? TailType.NONE : attr;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:DefaultInsertHandler.java


示例9: renderElement

import com.intellij.codeInsight.lookup.LookupItem; //导入依赖的package包/类
@Override
public void renderElement(final LookupItem item, final Object element, final LookupElementPresentation presentation) {
  presentation.setIcon(DefaultLookupItemRenderer.getRawIcon(item, presentation.isReal()));

  presentation.setItemText(PsiUtilCore.getName((PsiElement)element));
  presentation.setStrikeout(isToStrikeout(item));

  presentation.setTailText((String)item.getAttribute(LookupItem.TAIL_TEXT_ATTR), item.getAttribute(LookupItem.TAIL_TEXT_SMALL_ATTR) != null);

  PsiType type = ((BeanPropertyElement)element).getPropertyType();
  presentation.setTypeText(type == null ? null : type.getPresentableText());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:JavaElementLookupRenderer.java


示例10: weigh

import com.intellij.codeInsight.lookup.LookupItem; //导入依赖的package包/类
@Override
public Double weigh(@NotNull LookupElement element, @NotNull CompletionLocation location) {
  final PrioritizedLookupElement prioritized = element.as(PrioritizedLookupElement.CLASS_CONDITION_KEY);
  if (prioritized != null) {
    return prioritized.getPriority();
  }

  final LookupItem item = element.as(LookupItem.CLASS_CONDITION_KEY);
  if (item != null) {
    return item.getPriority();
  }
  return 0.0;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:PriorityWeigher.java


示例11: handleUserSelection

import com.intellij.codeInsight.lookup.LookupItem; //导入依赖的package包/类
@Override
public boolean handleUserSelection(LookupItem item, Project project) {
  if (!myIsStandard) {
    item.setLookupString(myValue);
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:ColorSampleLookupValue.java


示例12: addResult

import com.intellij.codeInsight.lookup.LookupItem; //导入依赖的package包/类
private static void addResult(CompletionResultSet result, Collection<Lookup> collection, PsiElement position, int offset) {
  result = result.withPrefixMatcher(findPrefixStatic(position, offset));

  for (Lookup lookup : collection) {
    final LookupItem<Lookup> item = new LookupItem<Lookup>(lookup, lookup.toString());
    item.setInsertHandler(INSERT_HANDLER);
    if (lookup.isKeyword()) {
      item.setBold();
    }
    result.addElement(item);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:XPathCompletionContributor.java


示例13: handleInsertInner

import com.intellij.codeInsight.lookup.LookupItem; //导入依赖的package包/类
private void handleInsertInner(InsertionContext context, LookupItem item, final char completionChar) {
  final Project project = context.getProject();
  final Editor editor = context.getEditor();
  final Document document = editor.getDocument();
  PsiDocumentManager.getInstance(project).commitDocument(document);

  TailType tailType = getTailType(completionChar, item);

  InsertHandlerState state = new InsertHandlerState(context.getSelectionEndOffset(), context.getSelectionEndOffset());

  if (completionChar == Lookup.REPLACE_SELECT_CHAR) {
    removeEndOfIdentifier(context);
  }
  else if(context.getOffsetMap().getOffset(CompletionInitializationContext.IDENTIFIER_END_OFFSET) != context.getSelectionEndOffset()) {
    JavaCompletionUtil.resetParensInfo(context.getOffsetMap());
  }

  handleParentheses(false, false, tailType, context, state);

  context.setTailOffset(state.tailOffset);
  state.caretOffset = processTail(tailType, state.caretOffset, state.tailOffset, editor);
  editor.getSelectionModel().removeSelection();

  if (tailType == TailType.DOT || context.getCompletionChar() == '.') {
    AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null);
  }

}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:29,代码来源:DefaultInsertHandler.java


示例14: getTailType

import com.intellij.codeInsight.lookup.LookupItem; //导入依赖的package包/类
protected TailType getTailType(final char completionChar, LookupItem item){
  switch(completionChar){
    case '.': return new CharTailType('.', false);
    case ',': return TailType.COMMA;
    case ';': return TailType.SEMICOLON;
    case '=': return TailType.EQ;
    case ' ': return TailType.SPACE;
    case ':': return TailType.CASE_COLON; //?
    case '<':
    case '>':
    case '\"':
  }
  final TailType attr = item.getTailType();
  return attr == TailType.UNKNOWN ? TailType.NONE : attr;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:16,代码来源:DefaultInsertHandler.java


示例15: renderClassItem

import com.intellij.codeInsight.lookup.LookupItem; //导入依赖的package包/类
public static void renderClassItem(LookupElementPresentation presentation, LookupItem item, PsiClass psiClass, boolean diamond) {
  if (!(psiClass instanceof PsiTypeParameter)) {
    presentation.setIcon(DefaultLookupItemRenderer.getRawIcon(item, presentation.isReal()));
  }

  final boolean bold = item.getAttribute(LookupItem.HIGHLIGHTED_ATTR) != null;
  boolean strikeout = JavaElementLookupRenderer.isToStrikeout(item);
  presentation.setItemText(getName(psiClass, item, diamond));
  presentation.setStrikeout(strikeout);
  presentation.setItemTextBold(bold);

  String tailText = getLocationString(item);
  PsiSubstitutor substitutor = (PsiSubstitutor)item.getAttribute(LookupItem.SUBSTITUTOR);

  if (item instanceof PsiTypeLookupItem) {
    if (((PsiTypeLookupItem)item).isIndicateAnonymous() &&
        (psiClass.isInterface() || psiClass.hasModifierProperty(PsiModifier.ABSTRACT)) ||
        ((PsiTypeLookupItem)item).isAddArrayInitializer()) {
      tailText = "{...}" + tailText;
    }
  }
  if (substitutor == null && !diamond && psiClass.getTypeParameters().length > 0) {
    tailText = "<" + StringUtil.join(psiClass.getTypeParameters(), new Function<PsiTypeParameter, String>() {
      @Override
      public String fun(PsiTypeParameter psiTypeParameter) {
        return psiTypeParameter.getName();
      }
    }, "," + (showSpaceAfterComma(psiClass) ? " " : "")) + ">" + tailText;
  }
  presentation.setTailText(tailText, true);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:32,代码来源:JavaPsiClassReferenceElement.java


示例16: getName

import com.intellij.codeInsight.lookup.LookupItem; //导入依赖的package包/类
private static String getName(final PsiClass psiClass, final LookupItem<?> item, boolean diamond) {
  if (item instanceof JavaPsiClassReferenceElement) {
    String forced = ((JavaPsiClassReferenceElement)item).getForcedPresentableName();
    if (forced != null) {
      return forced;
    }
  }

  String name = PsiUtilCore.getName(psiClass);

  if (item.getAttribute(LookupItem.FORCE_QUALIFY) != null) {
    if (psiClass.getContainingClass() != null) {
      name = psiClass.getContainingClass().getName() + "." + name;
    }
  }

  if (diamond) {
    return name + "<>";
  }

  PsiSubstitutor substitutor = (PsiSubstitutor)item.getAttribute(LookupItem.SUBSTITUTOR);
  if (substitutor != null) {
    final PsiTypeParameter[] params = psiClass.getTypeParameters();
    if (params.length > 0) {
      return name + formatTypeParameters(substitutor, params);
    }
  }

  return StringUtil.notNullize(name);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:31,代码来源:JavaPsiClassReferenceElement.java


示例17: NullSmartCompletionContributor

import com.intellij.codeInsight.lookup.LookupItem; //导入依赖的package包/类
public NullSmartCompletionContributor() {
  extend(CompletionType.SMART, and(JavaSmartCompletionContributor.INSIDE_EXPRESSION,
                                                    not(psiElement().afterLeaf("."))), new ExpectedTypeBasedCompletionProvider() {
    @Override
    protected void addCompletions(final CompletionParameters parameters,
                                  final CompletionResultSet result, final Collection<ExpectedTypeInfo> infos) {
      if (!StringUtil.startsWithChar(result.getPrefixMatcher().getPrefix(), 'n')) {
        return;
      }

      LinkedHashSet<CompletionResult> results = result.runRemainingContributors(parameters, true);
      for (CompletionResult completionResult : results) {
        if (completionResult.isStartMatch()) {
          return;
        }
      }

      for (final ExpectedTypeInfo info : infos) {
        if (!(info.getType() instanceof PsiPrimitiveType)) {
          final LookupItem item = (LookupItem)BasicExpressionCompletionContributor.createKeywordLookupItem(parameters.getPosition(), PsiKeyword.NULL);
          item.setAttribute(LookupItem.TYPE, PsiType.NULL);
          result.addElement(JavaSmartCompletionContributor.decorate(item, infos));
          return;
        }
      }
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:29,代码来源:NullSmartCompletionContributor.java


示例18: addLookupItem

import com.intellij.codeInsight.lookup.LookupItem; //导入依赖的package包/类
@Override
protected void addLookupItem(Set<LookupElement> set, final TailType tailType, @NotNull Object completion, final PsiFile file, final CompletionVariant variant) {
  if (completion instanceof LookupElement && !(completion instanceof LookupItem)) {
    set.add((LookupElement)completion);
    return;
  }

  LookupElement _ret = LookupItemUtil.objectToLookupItem(completion);
  if(_ret == null || !(_ret instanceof LookupItem)) return;

  LookupItem ret = (LookupItem)_ret;
  final InsertHandler insertHandler = variant.getInsertHandler();
  if(insertHandler != null && ret.getInsertHandler() == null) {
  }
  ret.setInsertHandler(new InsertHandler<LookupElement>() {
    @Override
    public void handleInsert(InsertionContext context, LookupElement item) {
      if (context.shouldAddCompletionChar()) {
        return;
      }
      if (tailType != TailType.NONE && tailType.isApplicable(context)) {
        tailType.processTail(context.getEditor(), context.getTailOffset());
      }
    }
  });

  final Map<Object, Object> itemProperties = variant.getItemProperties();
  for (final Object key : itemProperties.keySet()) {
    ret.setAttribute(key, itemProperties.get(key));
  }

  set.add(ret);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:34,代码来源:JavaAwareCompletionData.java


示例19: calculateLookupItems

import com.intellij.codeInsight.lookup.LookupItem; //导入依赖的package包/类
@Override
public LookupElement[] calculateLookupItems(@NotNull Expression[] params, final ExpressionContext context) {
  String[] names = getNames(context);
  if (names == null || names.length < 2) return null;
  LookupItem[] items = new LookupItem[names.length];
  for(int i = 0; i < names.length; i++) {
    String name = names[i];
    items[i] = LookupItem.fromString(name);
  }
  return items;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:12,代码来源:SuggestVariableNameMacro.java


示例20: addElementLookupItem

import com.intellij.codeInsight.lookup.LookupItem; //导入依赖的package包/类
public static LookupElement addElementLookupItem(Set<LookupElement> items, PsiElement element) {
  final LookupElement item = LookupItemUtil.addLookupItem(items, element);
  if (item instanceof LookupItem) {
    ((LookupItem)item).setAttribute(TemplateLookupSelectionHandler.KEY_IN_LOOKUP_ITEM, new JavaTemplateLookupSelectionHandler());
  }
  return item;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:8,代码来源:JavaTemplateUtil.java



注:本文中的com.intellij.codeInsight.lookup.LookupItem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java KnowledgeRuntimeLoggerFactory类代码示例发布时间:2022-05-22
下一篇:
Java RowData类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap