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

Java LookupElementDecorator类代码示例

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

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



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

示例1: fillCompletionVariants

import com.intellij.codeInsight.lookup.LookupElementDecorator; //导入依赖的package包/类
@Override
public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull final CompletionResultSet resultSet) {
  if (parameters.getOriginalFile().getUserData(ClassNameReferenceEditor.CLASS_NAME_REFERENCE_FRAGMENT) == null) {
    return;
  }
  
  resultSet.runRemainingContributors(parameters, new Consumer<CompletionResult>() {
    @Override
    public void consume(CompletionResult result) {
      LookupElement element = result.getLookupElement();
      Object object = element.getObject();
      if (object instanceof PsiClass) {
        Module module = ModuleUtil.findModuleForPsiElement((PsiClass)object);
        if (module != null) {
          resultSet.consume(LookupElementDecorator.withRenderer(element, new AppendModuleName(module)));
          return;
        }
      }
      resultSet.passResult(result);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:RefactoringCompletionContributor.java


示例2: handleInsert

import com.intellij.codeInsight.lookup.LookupElementDecorator; //导入依赖的package包/类
@Override
public void handleInsert(InsertionContext context, LookupElementDecorator<LookupElement> item) {
  final char completionChar = context.getCompletionChar();
  if (completionChar == '\'' || completionChar == '\"') {
    context.setAddCompletionChar(false);
    item.getDelegate().handleInsert(context);

    final Editor editor = context.getEditor();
    final Document document = editor.getDocument();
    int tailOffset = editor.getCaretModel().getOffset();
    if (document.getTextLength() > tailOffset) {
      final char c = document.getCharsSequence().charAt(tailOffset);
      if (c == completionChar || completionChar == '\'') {
        editor.getCaretModel().moveToOffset(tailOffset + 1);
      }
    }
  } else {
    item.getDelegate().handleInsert(context);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:XmlCompletionContributor.java


示例3: customizeLayoutAttributeLookupElement

import com.intellij.codeInsight.lookup.LookupElementDecorator; //导入依赖的package包/类
private static CompletionResult customizeLayoutAttributeLookupElement(String localName,
                                                                      LookupElement lookupElement,
                                                                      CompletionResult result) {
  final String layoutPrefix = "layout_";

  if (!localName.startsWith(layoutPrefix)) {
    return result;
  }
  final String localSuffix = localName.substring(layoutPrefix.length());

  if (localSuffix.length() > 0) {
    final HashSet<String> lookupStrings = new HashSet<String>(lookupElement.getAllLookupStrings());
    lookupStrings.add(localSuffix);

    lookupElement = new LookupElementDecorator<LookupElement>(lookupElement) {
      @Override
      public Set<String> getAllLookupStrings() {
        return lookupStrings;
      }
    };
  }
  return result.withLookupElement(PrioritizedLookupElement.withPriority(lookupElement, 100.0));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:AndroidCompletionContributor.java


示例4: fillCompletionVariants

import com.intellij.codeInsight.lookup.LookupElementDecorator; //导入依赖的package包/类
@Override
public void fillCompletionVariants(CompletionParameters parameters, final CompletionResultSet resultSet) {
  if (parameters.getOriginalFile().getUserData(ClassNameReferenceEditor.CLASS_NAME_REFERENCE_FRAGMENT) == null) {
    return;
  }
  
  resultSet.runRemainingContributors(parameters, new Consumer<CompletionResult>() {
    @Override
    public void consume(CompletionResult result) {
      LookupElement element = result.getLookupElement();
      Object object = element.getObject();
      if (object instanceof PsiClass) {
        Module module = ModuleUtil.findModuleForPsiElement((PsiClass)object);
        if (module != null) {
          resultSet.consume(LookupElementDecorator.withRenderer(element, new AppendModuleName(module)));
          return;
        }
      }
      resultSet.passResult(result);
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:RefactoringCompletionContributor.java


示例5: handleInsert

import com.intellij.codeInsight.lookup.LookupElementDecorator; //导入依赖的package包/类
public void handleInsert(InsertionContext context, LookupElementDecorator<LookupElement> item) {
  final char completionChar = context.getCompletionChar();
  if (completionChar == '\'' || completionChar == '\"') {
    context.setAddCompletionChar(false);
    item.getDelegate().handleInsert(context);

    final Editor editor = context.getEditor();
    final Document document = editor.getDocument();
    int tailOffset = editor.getCaretModel().getOffset();
    if (document.getTextLength() > tailOffset) {
      final char c = document.getCharsSequence().charAt(tailOffset);
      if (c == completionChar || completionChar == '\'') {
        editor.getCaretModel().moveToOffset(tailOffset + 1);
      }
    }
  } else {
    item.getDelegate().handleInsert(context);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:XmlCompletionContributor.java


示例6: handleInsert

import com.intellij.codeInsight.lookup.LookupElementDecorator; //导入依赖的package包/类
@Override
public void handleInsert(InsertionContext context, LookupElementDecorator<LookupElement> item)
{
	final char completionChar = context.getCompletionChar();
	if(completionChar == '\'' || completionChar == '\"')
	{
		context.setAddCompletionChar(false);
		item.getDelegate().handleInsert(context);

		final Editor editor = context.getEditor();
		final Document document = editor.getDocument();
		int tailOffset = editor.getCaretModel().getOffset();
		if(document.getTextLength() > tailOffset)
		{
			final char c = document.getCharsSequence().charAt(tailOffset);
			if(c == completionChar || completionChar == '\'')
			{
				editor.getCaretModel().moveToOffset(tailOffset + 1);
			}
		}
	}
	else
	{
		item.getDelegate().handleInsert(context);
	}
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:27,代码来源:XmlCompletionContributor.java


示例7: withInsertHandler

import com.intellij.codeInsight.lookup.LookupElementDecorator; //导入依赖的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


示例8: createSmartCastElement

import com.intellij.codeInsight.lookup.LookupElementDecorator; //导入依赖的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


示例9: XmlCompletionContributor

import com.intellij.codeInsight.lookup.LookupElementDecorator; //导入依赖的package包/类
public XmlCompletionContributor() {
  extend(CompletionType.BASIC, psiElement().inside(XmlPatterns.xmlFile()), new EmmetAbbreviationCompletionProvider());
  extend(CompletionType.BASIC,
         psiElement().inside(XmlPatterns.xmlAttributeValue()),
         new CompletionProvider<CompletionParameters>() {
           @Override
           protected void addCompletions(@NotNull CompletionParameters parameters,
                                         ProcessingContext context,
                                         @NotNull final CompletionResultSet result) {
             final XmlAttributeValue attributeValue = PsiTreeUtil.getParentOfType(parameters.getPosition(), XmlAttributeValue.class, false);
             if (attributeValue == null) {
               // we are injected, only getContext() returns attribute value
               return;
             }

             final Set<String> usedWords = new THashSet<String>();
             final Ref<Boolean> addWordVariants = Ref.create(true);
             result.runRemainingContributors(parameters, new Consumer<CompletionResult>() {
               @Override
               public void consume(CompletionResult r) {
                 if (r.getLookupElement().getUserData(WORD_COMPLETION_COMPATIBLE) == null) {
                   addWordVariants.set(false);
                 }
                 usedWords.add(r.getLookupElement().getLookupString());
                 result.passResult(r.withLookupElement(LookupElementDecorator.withInsertHandler(r.getLookupElement(), QUOTE_EATER)));
               }
             });
             if (addWordVariants.get().booleanValue()) {
               addWordVariants.set(attributeValue.getReferences().length == 0);
             }

             if (addWordVariants.get().booleanValue() && parameters.getInvocationCount() > 0) {
               WordCompletionContributor.addWordCompletionVariants(result, parameters, usedWords);
             }
           }
         });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:XmlCompletionContributor.java


示例10: createSmartCastElement

import com.intellij.codeInsight.lookup.LookupElementDecorator; //导入依赖的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(), ' '));
      }

      editor.getCaretModel().moveToOffset(context.getTailOffset());
      editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:32,代码来源:SmartCastProvider.java


示例11: testNoArraysAsListCommonPrefix

import com.intellij.codeInsight.lookup.LookupElementDecorator; //导入依赖的package包/类
public void testNoArraysAsListCommonPrefix() throws Throwable {
  configure();
  checkResultByFile(getTestName(false) + ".java");
  assertStringItems("bar()", "foo()");
  assertEquals("Arrays.asList(f.bar())", ((LookupItem)((LookupElementDecorator)myItems[0]).getDelegate()).getPresentableText());
  assertEquals("Arrays.asList(f.foo())", ((LookupItem)((LookupElementDecorator)myItems[1]).getDelegate()).getPresentableText());
  selectItem(myItems[1]);
  checkResult();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:10,代码来源:SecondSmartTypeCompletionTest.java


示例12: serialize

import com.intellij.codeInsight.lookup.LookupElementDecorator; //导入依赖的package包/类
@Override
public StatisticsInfo serialize(final LookupElement element, final CompletionLocation location) {
  if (element instanceof LookupElementDecorator) {
    return StatisticsManager.serialize(CompletionService.STATISTICS_KEY, ((LookupElementDecorator)element).getDelegate(), location);
  }
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:8,代码来源:DecoratorCompletionStatistician.java


示例13: XmlCompletionContributor

import com.intellij.codeInsight.lookup.LookupElementDecorator; //导入依赖的package包/类
public XmlCompletionContributor() {
  extend(CompletionType.BASIC,
         psiElement().inside(XmlPatterns.xmlAttributeValue()),
         new CompletionProvider<CompletionParameters>() {
           @Override
           protected void addCompletions(@NotNull CompletionParameters parameters,
                                         ProcessingContext context,
                                         @NotNull final CompletionResultSet result) {
             final XmlAttributeValue attributeValue = PsiTreeUtil.getParentOfType(parameters.getPosition(), XmlAttributeValue.class, false);
             if (attributeValue == null) {
               // we are injected, only getContext() returns attribute value
               return;
             }

             final Set<String> usedWords = new THashSet<String>();
             final Ref<Boolean> addWordVariants = Ref.create(true);
             result.runRemainingContributors(parameters, new Consumer<CompletionResult>() {
               public void consume(CompletionResult r) {
                 if (r.getLookupElement().getUserData(WORD_COMPLETION_COMPATIBLE) == null) {
                   addWordVariants.set(false);
                 }
                 usedWords.add(r.getLookupElement().getLookupString());
                 result.passResult(r.withLookupElement(LookupElementDecorator.withInsertHandler(r.getLookupElement(), QUOTE_EATER)));
               }
             });
             if (addWordVariants.get().booleanValue()) {
               addWordVariants.set(attributeValue.getReferences().length == 0);
             }

             if (addWordVariants.get().booleanValue() && parameters.getInvocationCount() > 0) {
               WordCompletionContributor.addWordCompletionVariants(result, parameters, usedWords);
             }
           }
         });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:36,代码来源:XmlCompletionContributor.java


示例14: handleInsert

import com.intellij.codeInsight.lookup.LookupElementDecorator; //导入依赖的package包/类
@Override
public void handleInsert(InsertionContext context, LookupElement item)
{
	Editor editor = context.getEditor();
	Document document = editor.getDocument();
	Project project = context.getProject();
	if(item instanceof LookupElementDecorator)
	{
		((LookupElementDecorator) item).getDelegate().handleInsert(context);
	}
	PsiDocumentManager.getInstance(project).commitDocument(document);
	int lineOffset = document.getLineStartOffset(document.getLineNumber(editor.getCaretModel().getOffset()));
	CodeStyleManager.getInstance(project).adjustLineIndent(document, lineOffset);
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:15,代码来源:XmlClosingTagInsertHandler.java


示例15: withQualifiedSuper

import com.intellij.codeInsight.lookup.LookupElementDecorator; //导入依赖的package包/类
@NotNull
private static LookupElement withQualifiedSuper(final String className, LookupElement item)
{
	return PrioritizedLookupElement.withExplicitProximity(new LookupElementDecorator<LookupElement>(item)
	{

		@Override
		public void renderElement(LookupElementPresentation presentation)
		{
			super.renderElement(presentation);
			presentation.setItemText(className + ".super." + presentation.getItemText());
		}

		@Override
		public void handleInsert(InsertionContext context)
		{
			context.commitDocument();
			PsiJavaCodeReferenceElement ref = PsiTreeUtil.findElementOfClassAtOffset(context.getFile(), context.getStartOffset(), PsiJavaCodeReferenceElement.class, false);
			if(ref != null)
			{
				context.getDocument().insertString(ref.getTextRange().getStartOffset(), className + ".");
			}

			super.handleInsert(context);
		}
	}, -1);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:28,代码来源:SuperCalls.java


示例16: markClassItemWrapped

import com.intellij.codeInsight.lookup.LookupElementDecorator; //导入依赖的package包/类
private void markClassItemWrapped(@NotNull LookupElement classItem)
{
	LookupElement delegate = classItem;
	while(true)
	{
		delegate.putUserData(WRAPPING_CONSTRUCTOR_CALL, this);
		if(!(delegate instanceof LookupElementDecorator))
		{
			break;
		}
		delegate = ((LookupElementDecorator) delegate).getDelegate();
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:14,代码来源:JavaConstructorCallElement.java


示例17: addInstanceof

import com.intellij.codeInsight.lookup.LookupElementDecorator; //导入依赖的package包/类
private void addInstanceof()
{
	if(isInstanceofPlace(myPosition))
	{
		addKeyword(LookupElementDecorator.withInsertHandler(createKeyword(PsiKeyword.INSTANCEOF), new InsertHandler<LookupElementDecorator<LookupElement>>()
		{
			@Override
			public void handleInsert(InsertionContext context, LookupElementDecorator<LookupElement> item)
			{
				TailType tailType = TailType.HUMBLE_SPACE_BEFORE_WORD;
				if(tailType.isApplicable(context))
				{
					tailType.processTail(context.getEditor(), context.getTailOffset());
				}

				if('!' == context.getCompletionChar())
				{
					context.setAddCompletionChar(false);
					context.commitDocument();
					PsiInstanceOfExpression expr = PsiTreeUtil.findElementOfClassAtOffset(context.getFile(), context.getStartOffset(), PsiInstanceOfExpression.class, false);
					if(expr != null)
					{
						String space = context.getCodeStyleSettings().SPACE_WITHIN_PARENTHESES ? " " : "";
						context.getDocument().insertString(expr.getTextRange().getStartOffset(), "!(" + space);
						context.getDocument().insertString(context.getTailOffset(), space + ")");
					}
				}
			}
		}));
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:32,代码来源:JavaKeywordCompletion.java


示例18: createSmartCastElement

import com.intellij.codeInsight.lookup.LookupElementDecorator; //导入依赖的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:consulo,项目名称:consulo-java,代码行数:38,代码来源:SmartCastProvider.java


示例19: addExpectedType

import com.intellij.codeInsight.lookup.LookupElementDecorator; //导入依赖的package包/类
@Nullable
private LookupElement addExpectedType(final PsiType type,
                                      final CompletionParameters parameters) {
  if (!JavaCompletionUtil.hasAccessibleConstructor(type)) return null;

  final PsiClass psiClass = PsiUtil.resolveClassInType(type);
  if (psiClass == null || psiClass.getName() == null) return null;

  PsiElement position = parameters.getPosition();
  if ((parameters.getInvocationCount() < 2 || psiClass instanceof PsiCompiledElement) &&
      HighlightClassUtil.checkCreateInnerClassFromStaticContext(position, null, psiClass) != null &&
      !psiElement().afterLeaf(psiElement().withText(PsiKeyword.NEW).afterLeaf(".")).accepts(position)) {
    return null;
  }

  PsiType psiType = GenericsUtil.eliminateWildcards(type);
  if (JavaSmartCompletionContributor.AFTER_NEW.accepts(parameters.getOriginalPosition()) &&
      PsiUtil.getLanguageLevel(parameters.getOriginalFile()).isAtLeast(LanguageLevel.JDK_1_7)) {
    final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(psiClass.getProject());
    if (psiClass.hasTypeParameters() && !((PsiClassType)type).isRaw()) {
      final String erasedText = TypeConversionUtil.erasure(psiType).getCanonicalText();
      String canonicalText = psiType.getCanonicalText();
      if (canonicalText.contains("?extends") || canonicalText.contains("?super")) {
        LOG.error("Malformed canonical text: " + canonicalText + "; presentable text: " + psiType + " of " + psiType.getClass() + "; " +
                  (psiType instanceof PsiClassReferenceType ? ((PsiClassReferenceType)psiType).getReference().getClass() : ""));
        return null;
      }
      try {
        final PsiStatement statement = elementFactory
          .createStatementFromText(canonicalText + " v = new " + erasedText + "<>()", parameters.getOriginalFile());
        final PsiVariable declaredVar = (PsiVariable)((PsiDeclarationStatement)statement).getDeclaredElements()[0];
        final PsiNewExpression initializer = (PsiNewExpression)declaredVar.getInitializer();
        final boolean hasDefaultConstructorOrNoGenericsOne = PsiDiamondTypeImpl.hasDefaultConstructor(psiClass) ||
                                                             !PsiDiamondTypeImpl.haveConstructorsGenericsParameters(psiClass);
        if (hasDefaultConstructorOrNoGenericsOne) {
          final PsiDiamondTypeImpl.DiamondInferenceResult inferenceResult = PsiDiamondTypeImpl.resolveInferredTypes(initializer);
          if (inferenceResult.getErrorMessage() == null &&
              !psiClass.hasModifierProperty(PsiModifier.ABSTRACT) &&
              areInferredTypesApplicable(inferenceResult.getTypes(), parameters.getPosition())) {
            psiType = initializer.getType();
          }
        }
      }
      catch (IncorrectOperationException ignore) {}
    }
  }
  final PsiTypeLookupItem item = PsiTypeLookupItem.createLookupItem(psiType, position).setShowPackage();

  if (psiClass.isInterface() || psiClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
    item.setAutoCompletionPolicy(AutoCompletionPolicy.NEVER_AUTOCOMPLETE);
    item.setIndicateAnonymous(true);
  }

  return LookupElementDecorator.withInsertHandler(item, myConstructorInsertHandler);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:56,代码来源:JavaInheritorsGetter.java


示例20: renderElement

import com.intellij.codeInsight.lookup.LookupElementDecorator; //导入依赖的package包/类
@Override
public void renderElement(LookupElementDecorator<LookupElement> element, LookupElementPresentation presentation) {
  element.getDelegate().renderElement(presentation);
  presentation.appendTailText(" [" + myModule.getName() + "]", true);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:RefactoringCompletionContributor.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java TypeDeclaration类代码示例发布时间:2022-05-22
下一篇:
Java ServerCommand类代码示例发布时间: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