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

Java InsertHandler类代码示例

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

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



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

示例1: equals

import com.intellij.codeInsight.completion.InsertHandler; //导入依赖的package包/类
@Override
public boolean equals(Object o) {
  if (this == o) return true;
  if (o == null || getClass() != o.getClass()) return false;

  LookupElementBuilder that = (LookupElementBuilder)o;

  final InsertHandler<LookupElement> insertHandler = that.myInsertHandler;
  if (myInsertHandler != null && insertHandler != null ? !myInsertHandler.getClass().equals(insertHandler.getClass())
                                                       : myInsertHandler != insertHandler) return false;
  if (!myLookupString.equals(that.myLookupString)) return false;
  if (!myObject.equals(that.myObject)) return false;

  final LookupElementRenderer<LookupElement> renderer = that.myRenderer;
  if (myRenderer != null && renderer != null ? !myRenderer.getClass().equals(renderer.getClass()) : myRenderer != renderer) return false;

  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:LookupElementBuilder.java


示例2: createLookupBuilder

import com.intellij.codeInsight.completion.InsertHandler; //导入依赖的package包/类
public LookupElementBuilder createLookupBuilder(@NotNull final T item) {
  LookupElementBuilder builder = LookupElementBuilder.create(item, getLookupString(item))
    .withIcon(getIcon(item));

  final InsertHandler<LookupElement> handler = createInsertHandler(item);
  if (handler != null) {
    builder = builder.withInsertHandler(handler);
  }

  final String tailText = getTailText(item);
  if (tailText != null) {
    builder = builder.withTailText(tailText, true);
  }

  final String typeText = getTypeText(item);
  if (typeText != null) {
    builder = builder.withTypeText(typeText);
  }
  return builder;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:TextFieldWithAutoCompletionListProvider.java


示例3: replaceInsertHandler

import com.intellij.codeInsight.completion.InsertHandler; //导入依赖的package包/类
private static void replaceInsertHandler(Object[] variants, final InsertHandler<LookupElement> insertHandler) {
  for (int i=0; i < variants.length; i+=1) {
    Object item = variants[i];
    if (hasChildPackages(item)) continue;
    if (item instanceof LookupElementBuilder) {
      variants[i] = ((LookupElementBuilder)item).withInsertHandler(insertHandler);
    }
    else if (item instanceof PsiNamedElement) {
      final PsiNamedElement element = (PsiNamedElement)item;
      final String name = element.getName();
      assert name != null; // it can't really have null name
      variants[i] = LookupElementBuilder
        .create(name)
        .withIcon(element.getIcon(0))
        .withInsertHandler(insertHandler);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:PyImportReference.java


示例4: fillFromDir

import com.intellij.codeInsight.completion.InsertHandler; //导入依赖的package包/类
/**
 * Adds variants found under given dir.
 */
private void fillFromDir(PsiDirectory targetDir, @Nullable InsertHandler<LookupElement> insertHandler) {
  if (targetDir != null) {
    PsiFile initPy = targetDir.findFile(PyNames.INIT_DOT_PY);
    if (initPy instanceof PyFile) {
      PyModuleType moduleType = new PyModuleType((PyFile)initPy);
      ProcessingContext context = new ProcessingContext();
      context.put(PyType.CTX_NAMES, myNamesAlready);
      Object[] completionVariants = moduleType.getCompletionVariants("", getElement(), context);
      if (insertHandler != null) {
        replaceInsertHandler(completionVariants, insertHandler);
      }
      myObjects.addAll(Arrays.asList(completionVariants));
    }
    else {
      myObjects.addAll(PyModuleType.getSubModuleVariants(targetDir, myElement, myNamesAlready));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:PyImportReference.java


示例5: buildAccessorKeywordsCompletion

import com.intellij.codeInsight.completion.InsertHandler; //导入依赖的package包/类
private static void buildAccessorKeywordsCompletion(CompletionResultSet resultSet, final CSharpXXXAccessorOwner accessorOwner, @Nullable InsertHandler<LookupElement> insertHandler)
{
	TokenSet tokenSet = accessorOwner instanceof CSharpEventDeclaration ? TokenSet.create(CSharpSoftTokens.ADD_KEYWORD, CSharpSoftTokens.REMOVE_KEYWORD) : TokenSet.create(CSharpSoftTokens
			.GET_KEYWORD, CSharpSoftTokens.SET_KEYWORD);

	for(IElementType elementType : tokenSet.getTypes())
	{
		if(!isCanShowAccessorKeyword(elementType, accessorOwner))
		{
			continue;
		}
		LookupElementBuilder builder = LookupElementBuilder.create(CSharpCompletionUtil.textOfKeyword(elementType));
		builder = builder.bold();

		if(insertHandler != null)
		{
			builder = builder.withInsertHandler(insertHandler);
		}

		builder.putUserData(CSharpCompletionUtil.KEYWORD_ELEMENT_TYPE, elementType);

		resultSet.addElement(builder);
	}
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:25,代码来源:CSharpAccessorCompletionContributor.java


示例6: createInsertHandler

import com.intellij.codeInsight.completion.InsertHandler; //导入依赖的package包/类
@Nullable
@Override
protected InsertHandler<LookupElement> createInsertHandler(@Nonnull VcsRef item) {
  return (context, item1) -> {
    mySelectedRef = (VcsRef)item1.getObject();
    ApplicationManager.getApplication().invokeLater(() -> {
      // handleInsert is called in the middle of some other code that works with editor
      // (see CodeCompletionHandlerBase.insertItem)
      // for example, scrolls editor
      // problem is that in onOk we make text field not editable
      // by some reason this is done by disposing its editor and creating a new one
      // so editor gets disposed here and CodeCompletionHandlerBase can not finish doing whatever it is doing with it
      // I counter this by invoking onOk in invokeLater
      myTextField.onOk();
    });
  };
}
 
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:GoToHashOrRefPopup.java


示例7: equals

import com.intellij.codeInsight.completion.InsertHandler; //导入依赖的package包/类
@Override
public boolean equals(Object o) {
  if (this == o) return true;
  if (o == null || getClass() != o.getClass()) return false;

  LookupElementBuilder that = (LookupElementBuilder)o;

  final InsertHandler<LookupElement> insertHandler = that.myInsertHandler;
  if (myInsertHandler != null && insertHandler != null ? !myInsertHandler.getClass().equals(insertHandler.getClass()) : myInsertHandler != insertHandler) {
    return false;
  }
  if (!myLookupString.equals(that.myLookupString)) return false;
  if (!myObject.equals(that.myObject)) return false;

  final LookupElementRenderer<LookupElement> renderer = that.myRenderer;
  if (myRenderer != null && renderer != null ? !myRenderer.getClass().equals(renderer.getClass()) : myRenderer != renderer) return false;

  return true;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:LookupElementBuilder.java


示例8: createLookupBuilder

import com.intellij.codeInsight.completion.InsertHandler; //导入依赖的package包/类
public LookupElementBuilder createLookupBuilder(@Nonnull final T item) {
  LookupElementBuilder builder = LookupElementBuilder.create(item, getLookupString(item))
    .withIcon(getIcon(item));

  final InsertHandler<LookupElement> handler = createInsertHandler(item);
  if (handler != null) {
    builder = builder.withInsertHandler(handler);
  }

  final String tailText = getTailText(item);
  if (tailText != null) {
    builder = builder.withTailText(tailText, true);
  }

  final String typeText = getTypeText(item);
  if (typeText != null) {
    builder = builder.withTypeText(typeText);
  }
  return builder;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:TextFieldWithAutoCompletionListProvider.java


示例9: createLookupBuilder

import com.intellij.codeInsight.completion.InsertHandler; //导入依赖的package包/类
@Nonnull
@Override
public LookupElementBuilder createLookupBuilder(@Nonnull T item) {
  LookupElementBuilder builder = LookupElementBuilder.create(item, getLookupString(item))
          .withIcon(getIcon(item));

  InsertHandler<LookupElement> handler = createInsertHandler(item);
  if (handler != null) {
    builder = builder.withInsertHandler(handler);
  }

  String tailText = getTailText(item);
  if (tailText != null) {
    builder = builder.withTailText(tailText, true);
  }

  String typeText = getTypeText(item);
  if (typeText != null) {
    builder = builder.withTypeText(typeText);
  }
  return builder;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:23,代码来源:DefaultTextCompletionValueDescriptor.java


示例10: LookupElementBuilder

import com.intellij.codeInsight.completion.InsertHandler; //导入依赖的package包/类
private LookupElementBuilder(@NotNull String lookupString, @NotNull Object object, @Nullable InsertHandler<LookupElement> insertHandler,
                             @Nullable LookupElementRenderer<LookupElement> renderer,
                             @Nullable LookupElementPresentation hardcodedPresentation,
                             @NotNull Set<String> allLookupStrings,
                             boolean caseSensitive) {
  myLookupString = lookupString;
  myObject = object;
  myInsertHandler = insertHandler;
  myRenderer = renderer;
  myHardcodedPresentation = hardcodedPresentation;
  myAllLookupStrings = Collections.unmodifiableSet(allLookupStrings);
  myCaseSensitive = caseSensitive;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:LookupElementBuilder.java


示例11: handleInsert

import com.intellij.codeInsight.completion.InsertHandler; //导入依赖的package包/类
@Override
public void handleInsert(final InsertionContext context) {
  final InsertHandler<? extends LookupElement> handler = getInsertHandler();
  if (handler != null) {
    //noinspection unchecked
    ((InsertHandler)handler).handleInsert(context, this);
  }
  if (getTailType() != TailType.UNKNOWN && myInsertHandler == null) {
    context.setAddCompletionChar(false);
    final TailType type = handleCompletionChar(context.getEditor(), this, context.getCompletionChar());
    type.processTail(context.getEditor(), context.getTailOffset());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:LookupItem.java


示例12: initLookupItems

import com.intellij.codeInsight.completion.InsertHandler; //导入依赖的package包/类
private static LookupElement[] initLookupItems(LinkedHashSet<String> names,
                                               PsiNamedElement elementToRename, 
                                               PsiElement nameSuggestionContext,
                                               final boolean shouldSelectAll) {
  if (names == null) {
    names = new LinkedHashSet<String>();
    for (NameSuggestionProvider provider : Extensions.getExtensions(NameSuggestionProvider.EP_NAME)) {
      final SuggestedNameInfo suggestedNameInfo = provider.getSuggestedNames(elementToRename, nameSuggestionContext, names);
      if (suggestedNameInfo != null &&
          provider instanceof PreferrableNameSuggestionProvider &&
          !((PreferrableNameSuggestionProvider)provider).shouldCheckOthers()) {
        break;
      }
    }
  }
  final LookupElement[] lookupElements = new LookupElement[names.size()];
  final Iterator<String> iterator = names.iterator();
  for (int i = 0; i < lookupElements.length; i++) {
    final String suggestion = iterator.next();
    lookupElements[i] = LookupElementBuilder.create(suggestion).withInsertHandler(new InsertHandler<LookupElement>() {
      @Override
      public void handleInsert(InsertionContext context, LookupElement item) {
        if (shouldSelectAll) return;
        final Editor topLevelEditor = InjectedLanguageUtil.getTopLevelEditor(context.getEditor());
        final TemplateState templateState = TemplateManagerImpl.getTemplateState(topLevelEditor);
        if (templateState != null) {
          final TextRange range = templateState.getCurrentVariableRange();
          if (range != null) {
            topLevelEditor.getDocument().replaceString(range.getStartOffset(), range.getEndOffset(), suggestion);
          }
        }
      }
    });
  }
  return lookupElements;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:MyLookupExpression.java


示例13: PythonLookupElement

import com.intellij.codeInsight.completion.InsertHandler; //导入依赖的package包/类
public PythonLookupElement(@NotNull final String lookupString,
                         @Nullable final String tailText,
                         @Nullable final String typeText, final boolean bold,
                         @Nullable final Icon icon,
                         @Nullable final Icon typeIcon,
                         @NotNull final InsertHandler<PythonLookupElement> handler) {
  myLookupString = lookupString;
  myTailText = tailText;
  myTypeText = typeText;
  isBold = bold;
  myIcon = icon;
  myTypeIcon = typeIcon;
  myHandler = handler;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:PythonLookupElement.java


示例14: UserColorLookup

import com.intellij.codeInsight.completion.InsertHandler; //导入依赖的package包/类
public UserColorLookup(final Function<Color, String> colorToStringConverter, int priority) {
  super(PrioritizedLookupElement.withPriority(LookupElementBuilder.create(COLOR_STRING).withInsertHandler(
    new InsertHandler<LookupElement>() {
      @Override
      public void handleInsert(InsertionContext context, LookupElement item) {
        handleUserSelection(context, colorToStringConverter);
      }
    }), priority));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:UserColorLookup.java


示例15: createInsertHandler

import com.intellij.codeInsight.completion.InsertHandler; //导入依赖的package包/类
@Override
protected InsertHandler<LookupElement> createInsertHandler(@NotNull final Task task) {
  return new InsertHandler<LookupElement>() {
    @Override
    public void handleInsert(InsertionContext context, LookupElement item) {
      Document document = context.getEditor().getDocument();
      String s = ((TaskManagerImpl)TaskManager.getManager(context.getProject())).getChangelistName(task);
      s = StringUtil.convertLineSeparators(s);
      document.replaceString(context.getStartOffset(), context.getTailOffset(), s);
      context.getEditor().getCaretModel().moveToOffset(context.getStartOffset() + s.length());

      TaskAutoCompletionListProvider.this.handleInsert(task);
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:TaskAutoCompletionListProvider.java


示例16: insertDivider

import com.intellij.codeInsight.completion.InsertHandler; //导入依赖的package包/类
private static InsertHandler<LookupElement> insertDivider(SectionParser parser) {
  return (context, item) -> {
    Editor editor = context.getEditor();
    Document document = editor.getDocument();
    context.commitDocument();

    String nextTokenText = findNextTokenText(context);
    if (nextTokenText == null || nextTokenText.equals("\n")) {
      document.insertString(context.getTailOffset(), getDivider(parser));
      editor.getCaretModel().moveToOffset(context.getTailOffset());
    }
  };
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:14,代码来源:ProjectViewKeywordCompletionContributor.java


示例17: LookupElementBuilder

import com.intellij.codeInsight.completion.InsertHandler; //导入依赖的package包/类
private LookupElementBuilder(@NotNull String lookupString, @NotNull Object object, @Nullable InsertHandler<LookupElement> insertHandler,
                             @Nullable LookupElementRenderer<LookupElement> renderer,
                             @Nullable LookupElementPresentation hardcodedPresentation,
                             @NotNull Set<String> allLookupStrings,
                             boolean caseSensitive) {
  myLookupString = lookupString;
  myObject = object;
  myInsertHandler = insertHandler;
  myRenderer = renderer;
  myHardcodedPresentation = hardcodedPresentation;
  myAllLookupStrings = allLookupStrings;
  myCaseSensitive = caseSensitive;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:14,代码来源:LookupElementBuilder.java


示例18: UserColorLookup

import com.intellij.codeInsight.completion.InsertHandler; //导入依赖的package包/类
public UserColorLookup(final Function<Color, String> colorToStringConverter) {
  super(PrioritizedLookupElement.withPriority(LookupElementBuilder.create(COLOR_STRING).withInsertHandler(
    new InsertHandler<LookupElement>() {
      @Override
      public void handleInsert(InsertionContext context, LookupElement item) {
        handleUserSelection(context, colorToStringConverter);
      }
    }), LookupValueWithPriority.HIGH));
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:10,代码来源:UserColorLookup.java


示例19: buildInsertHandler

import com.intellij.codeInsight.completion.InsertHandler; //导入依赖的package包/类
@NotNull
public static InsertHandler<LookupElement> buildInsertHandler(final IElementType elementType)
{
	char open = '(';
	char close = ')';

	if(elementType == DO_KEYWORD || elementType == TRY_KEYWORD || elementType == CATCH_KEYWORD || elementType == UNSAFE_KEYWORD || elementType == FINALLY_KEYWORD)
	{
		open = '{';
		close = '}';
	}

	return new ExpressionOrStatementInsertHandler<>(open, close);
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:15,代码来源:CSharpStatementCompletionContributor.java


示例20: addVariantsFromIndex

import com.intellij.codeInsight.completion.InsertHandler; //导入依赖的package包/类
private static void addVariantsFromIndex(final CompletionResultSet resultSet,
                                         final PsiFile targetFile,
                                         @Nullable String prefixPackage,
                                         @Nullable final InsertHandler<LookupElement> insertHandler) {
  final Project project = targetFile.getProject();
  final GlobalSearchScope scope = HaxeResolveUtil.getScopeForElement(targetFile);
  HaxeComponentIndex.processAll(project, new MyProcessor(resultSet, prefixPackage, insertHandler), scope);
}
 
开发者ID:consulo,项目名称:consulo-haxe,代码行数:9,代码来源:HaxeClassNameCompletionContributor.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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