当前位置: 首页>>代码示例>>Java>>正文


Java LookupItem类代码示例

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


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


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