本文整理汇总了Java中com.intellij.codeInsight.lookup.TailTypeDecorator类的典型用法代码示例。如果您正苦于以下问题:Java TailTypeDecorator类的具体用法?Java TailTypeDecorator怎么用?Java TailTypeDecorator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TailTypeDecorator类属于com.intellij.codeInsight.lookup包,在下文中一共展示了TailTypeDecorator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addInheritors
import com.intellij.codeInsight.lookup.TailTypeDecorator; //导入依赖的package包/类
private static void addInheritors(CompletionParameters parameters,
final CompletionResultSet resultSet,
final PsiClass referencedClass,
final int parameterIndex) {
final List<PsiClassType> typeList = Collections.singletonList((PsiClassType)TypeConversionUtil.typeParameterErasure(
referencedClass.getTypeParameters()[parameterIndex]));
JavaInheritorsGetter.processInheritors(parameters, typeList, resultSet.getPrefixMatcher(), new Consumer<PsiType>() {
@Override
public void consume(final PsiType type) {
final PsiClass psiClass = PsiUtil.resolveClassInType(type);
if (psiClass == null) return;
resultSet.addElement(TailTypeDecorator.withTail(new JavaPsiClassReferenceElement(psiClass),
getTail(parameterIndex == referencedClass.getTypeParameters().length - 1)));
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:TypeArgumentCompletionProvider.java
示例2: addConstantsFromReferencedClassesInSwitch
import com.intellij.codeInsight.lookup.TailTypeDecorator; //导入依赖的package包/类
private void addConstantsFromReferencedClassesInSwitch(final Consumer<LookupElement> results) {
final Set<PsiField> fields = ReferenceExpressionCompletionContributor.findConstantsUsedInSwitch(myPlace);
final Set<PsiClass> classes = new HashSet<PsiClass>();
for (PsiField field : fields) {
ContainerUtil.addIfNotNull(classes, field.getContainingClass());
}
for (PsiClass aClass : classes) {
processMembers(new Consumer<LookupElement>() {
@Override
public void consume(LookupElement element) {
//noinspection SuspiciousMethodCalls
if (!fields.contains(element.getObject())) {
results.consume(TailTypeDecorator.withTail(element, TailType.CASE_COLON));
}
}
}, aClass, true, false);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:JavaMembersGetter.java
示例3: PySpecialMethodNamesCompletionContributor
import com.intellij.codeInsight.lookup.TailTypeDecorator; //导入依赖的package包/类
public PySpecialMethodNamesCompletionContributor() {
extend(
CompletionType.BASIC,
psiElement()
.withLanguage(PythonLanguage.getInstance())
.and(psiElement().inside(psiElement(PyFunction.class).inside(psiElement(PyClass.class))))
.and(psiElement().afterLeaf("def"))
,
new CompletionProvider<CompletionParameters>() {
protected void addCompletions(
@NotNull final CompletionParameters parameters, final ProcessingContext context, @NotNull final CompletionResultSet result
) {
LanguageLevel languageLevel = LanguageLevel.forElement(parameters.getOriginalFile());
for (Map.Entry<String, PyNames.BuiltinDescription> entry: PyNames.getBuiltinMethods(languageLevel).entrySet()) {
LookupElementBuilder item = LookupElementBuilder
.create(entry.getKey() + entry.getValue().getSignature())
.bold()
.withTypeText("predefined")
.withIcon(PythonIcons.Python.Nodes.Cyan_dot)
;
result.addElement(TailTypeDecorator.withTail(item, TailType.CASE_COLON));
}
}
}
);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:PySpecialMethodNamesCompletionContributor.java
示例4: createParametersLookupElement
import com.intellij.codeInsight.lookup.TailTypeDecorator; //导入依赖的package包/类
private static LookupElement createParametersLookupElement(PsiMethod takeParametersFrom, PsiElement call, PsiMethod invoked) {
PsiParameter[] parameters = takeParametersFrom.getParameterList().getParameters();
final String lookupString = StringUtil.join(parameters, new Function<PsiParameter, String>() {
@Override
public String fun(PsiParameter psiParameter) {
return psiParameter.getName();
}
}, ", ");
final int w = PlatformIcons.PARAMETER_ICON.getIconWidth();
LayeredIcon icon = new LayeredIcon(2);
icon.setIcon(PlatformIcons.PARAMETER_ICON, 0, 2*w/5, 0);
icon.setIcon(PlatformIcons.PARAMETER_ICON, 1);
final LookupElement element = LookupElementBuilder.create(lookupString).withIcon(icon);
element.putUserData(JavaCompletionUtil.SUPER_METHOD_PARAMETERS, Boolean.TRUE);
return TailTypeDecorator.withTail(element, ExpectedTypesProvider.getFinalCallParameterTailType(call, invoked.getReturnType(), invoked));
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:SameSignatureCallParametersProvider.java
示例5: addBreakContinue
import com.intellij.codeInsight.lookup.TailTypeDecorator; //导入依赖的package包/类
private static void addBreakContinue(CompletionResultSet result, PsiElement position) {
PsiLoopStatement loop = PsiTreeUtil.getParentOfType(position, PsiLoopStatement.class);
LookupElement br = createKeyword(position, PsiKeyword.BREAK);
LookupElement cont = createKeyword(position, PsiKeyword.CONTINUE);
TailType tailType;
if (psiElement().insideSequence(true, psiElement(PsiLabeledStatement.class),
or(psiElement(PsiFile.class), psiElement(PsiMethod.class),
psiElement(PsiClassInitializer.class))).accepts(position)) {
tailType = TailType.HUMBLE_SPACE_BEFORE_WORD;
}
else {
tailType = TailType.SEMICOLON;
}
br = TailTypeDecorator.withTail(br, tailType);
cont = TailTypeDecorator.withTail(cont, tailType);
if (loop != null && new InsideElementFilter(new ClassFilter(PsiStatement.class)).isAcceptable(position, loop)) {
result.addElement(br);
result.addElement(cont);
}
if (psiElement().inside(PsiSwitchStatement.class).accepts(position)) {
result.addElement(br);
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:JavaCompletionData.java
示例6: RncCompletionContributor
import com.intellij.codeInsight.lookup.TailTypeDecorator; //导入依赖的package包/类
public RncCompletionContributor()
{
CompletionProvider provider = new CompletionProvider()
{
@Override
public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result)
{
String[] keywords = getKeywords(parameters.getPosition());
for(String keyword : keywords)
{
result.addElement(TailTypeDecorator.withTail(LookupElementBuilder.create(keyword).bold(), TailType.SPACE));
}
}
};
extend(null, psiElement().afterLeaf(psiElement(RncTokenTypes.KEYWORD_DEFAULT)), provider);
extend(null, psiElement().andNot(psiElement().inside(psiElement(RncTokenTypes.LITERAL))).
andNot(psiElement().afterLeaf(psiElement().withElementType(RncTokenTypes.KEYWORDS))), provider);
}
开发者ID:consulo,项目名称:consulo-xml,代码行数:19,代码来源:RncCompletionContributor.java
示例7: createParametersLookupElement
import com.intellij.codeInsight.lookup.TailTypeDecorator; //导入依赖的package包/类
private static LookupElement createParametersLookupElement(final PsiMethod takeParametersFrom, PsiElement call, PsiMethod invoked) {
final PsiParameter[] parameters = takeParametersFrom.getParameterList().getParameters();
final String lookupString = StringUtil.join(parameters, new Function<PsiParameter, String>() {
@Override
public String fun(PsiParameter psiParameter) {
return psiParameter.getName();
}
}, ", ");
final int w = PlatformIcons.PARAMETER_ICON.getIconWidth();
LayeredIcon icon = new LayeredIcon(2);
icon.setIcon(PlatformIcons.PARAMETER_ICON, 0, 2*w/5, 0);
icon.setIcon(PlatformIcons.PARAMETER_ICON, 1);
LookupElementBuilder element = LookupElementBuilder.create(lookupString).withIcon(icon);
if (PsiTreeUtil.isAncestor(takeParametersFrom, call, true)) {
element = element.withInsertHandler(new InsertHandler<LookupElement>() {
@Override
public void handleInsert(InsertionContext context, LookupElement item) {
context.commitDocument();
for (PsiParameter parameter : CompletionUtil.getOriginalOrSelf(takeParametersFrom).getParameterList().getParameters()) {
VariableLookupItem.makeFinalIfNeeded(context, parameter);
}
}
});
}
element.putUserData(JavaCompletionUtil.SUPER_METHOD_PARAMETERS, Boolean.TRUE);
return TailTypeDecorator.withTail(element, ExpectedTypesProvider.getFinalCallParameterTailType(call, invoked.getReturnType(), invoked));
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:SameSignatureCallParametersProvider.java
示例8: createLookupElement
import com.intellij.codeInsight.lookup.TailTypeDecorator; //导入依赖的package包/类
protected LookupElement createLookupElement(@NotNull Option option, @NotNull String text) {
LookupElementBuilder res = LookupElementBuilder.create(text);
if (option.getDescription() != null) {
return TailTypeDecorator.withTail(res.withTypeText(option.getDescription(), true), TailType.INSERT_SPACE);
}
return res;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:CommandLineCompletionProvider.java
示例9: addCompletions
import com.intellij.codeInsight.lookup.TailTypeDecorator; //导入依赖的package包/类
protected void addCompletions(@NotNull final CompletionParameters parameters, final ProcessingContext context,
@NotNull final CompletionResultSet result) {
for (String s : myKeywords) {
final PythonLookupElement element = new PythonLookupElement(s, true, null);
if (myInsertHandler != null) {
element.setHandler(myInsertHandler);
}
result.addElement(TailTypeDecorator.withTail(element, myTailType));
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PyKeywordCompletionContributor.java
示例10: PySuperMethodCompletionContributor
import com.intellij.codeInsight.lookup.TailTypeDecorator; //导入依赖的package包/类
public PySuperMethodCompletionContributor() {
extend(CompletionType.BASIC,
psiElement().afterLeafSkipping(psiElement().whitespace(), psiElement().withElementType(PyTokenTypes.DEF_KEYWORD)),
new CompletionProvider<CompletionParameters>() {
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
PsiElement position = parameters.getOriginalPosition();
PyClass containingClass = PsiTreeUtil.getParentOfType(position, PyClass.class);
if (containingClass == null && position instanceof PsiWhiteSpace) {
position = PsiTreeUtil.prevLeaf(position);
containingClass = PsiTreeUtil.getParentOfType(position, PyClass.class);
}
if (containingClass == null) {
return;
}
Set<String> seenNames = new HashSet<String>();
for (PyFunction function : containingClass.getMethods(false)) {
seenNames.add(function.getName());
}
LanguageLevel languageLevel = LanguageLevel.forElement(parameters.getOriginalFile());
seenNames.addAll(PyNames.getBuiltinMethods(languageLevel).keySet());
for (PyClass ancestor : containingClass.getAncestorClasses(null)) {
for (PyFunction superMethod : ancestor.getMethods(false)) {
if (!seenNames.contains(superMethod.getName())) {
String text = superMethod.getName() + superMethod.getParameterList().getText();
LookupElementBuilder element = LookupElementBuilder.create(text);
result.addElement(TailTypeDecorator.withTail(element, TailType.CASE_COLON));
seenNames.add(superMethod.getName());
}
}
}
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:PySuperMethodCompletionContributor.java
示例11: addCompletions
import com.intellij.codeInsight.lookup.TailTypeDecorator; //导入依赖的package包/类
public void addCompletions(@NotNull final CompletionParameters parameters,
final ProcessingContext context,
@NotNull final CompletionResultSet result) {
for (String[] stringArray : RegExpLanguageHosts.getInstance().getAllKnownProperties(parameters.getPosition())) {
result.addElement(
TailTypeDecorator.withTail(createLookupElement(stringArray[0], null, emptyIcon), TailType.createSimpleTailType('}')));
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:RegExpCompletionContributor.java
示例12: get
import com.intellij.codeInsight.lookup.TailTypeDecorator; //导入依赖的package包/类
@Override
public Object[] get(PsiElement context, CompletionContext completionContext) {
return ContainerUtil.map2Array(doGetKeywords(context), LookupElement.class, new Function<String, LookupElement>() {
@Override
public LookupElement fun(String s) {
return TailTypeDecorator.withTail(LookupElementBuilder.create(s).bold(), TailType.SPACE);
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:RncCompletionData.java
示例13: getSystemPropertiesVariants
import com.intellij.codeInsight.lookup.TailTypeDecorator; //导入依赖的package包/类
public static List<LookupElement> getSystemPropertiesVariants() {
if (SYSTEM_PROPERTIES_VARIANTS == null) {
LookupElement[] res = new LookupElement[SYSTEM_PROPERTIES.length];
for (int i = 0; i < res.length; i++) {
res[i] = TailTypeDecorator.withTail(LookupElementBuilder.create("-D" + SYSTEM_PROPERTIES[i]), MyTailTypeEQ.INSTANCE);
}
SYSTEM_PROPERTIES_VARIANTS = Arrays.asList(res);
}
return SYSTEM_PROPERTIES_VARIANTS;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:MvcTargetDialogCompletionUtils.java
示例14: collectVariants
import com.intellij.codeInsight.lookup.TailTypeDecorator; //导入依赖的package包/类
public static Collection<LookupElement> collectVariants(@NotNull Module module, @NotNull String text, int offset, @NotNull String prefix) {
if (prefix.startsWith("-D")) {
return getSystemPropertiesVariants();
}
List<LookupElement> res = new ArrayList<LookupElement>();
if (text.substring(0, offset).matches("\\s*(grails\\s*)?(?:(:?-D\\S+|dev|prod|test)\\s+)*\\S*")) {
// Complete command name because command name is not typed.
for (String completionVariant : getAllTargetNames(module)) {
res.add(TailTypeDecorator.withTail(LookupElementBuilder.create(completionVariant), TailType.SPACE));
}
}
else {
// Command name already typed. Try to complete classes and packages names.
GlobalSearchScope scope = GlobalSearchScope.moduleScope(module);
JavaPsiFacade facade = JavaPsiFacade.getInstance(module.getProject());
// Complete class names if prefix is a package name with dot at end.
if (prefix.endsWith(".") && prefix.length() > 1) {
PsiPackage p = facade.findPackage(prefix.substring(0, prefix.length() - 1));
if (p != null) {
for (PsiClass aClass : p.getClasses(scope)) {
String qualifiedName = aClass.getQualifiedName();
if (qualifiedName != null) {
res.add(LookupElementBuilder.create(aClass, qualifiedName));
}
}
}
}
PsiPackage defaultPackage = facade.findPackage("");
if (defaultPackage != null) {
collectClassesAndPackageNames(res, defaultPackage, scope);
}
}
return res;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:41,代码来源:MvcTargetDialogCompletionUtils.java
示例15: collectClassesAndPackageNames
import com.intellij.codeInsight.lookup.TailTypeDecorator; //导入依赖的package包/类
private static void collectClassesAndPackageNames(Collection<LookupElement> res, @NotNull PsiPackage aPackage, GlobalSearchScope scope) {
PsiPackage[] subPackages = aPackage.getSubPackages(scope);
String qualifiedName = aPackage.getQualifiedName();
if (!qualifiedName.isEmpty()) {
if (subPackages.length == 0 || aPackage.getClasses(scope).length > 0) {
res.add(TailTypeDecorator.withTail(LookupElementBuilder.create(qualifiedName), TailType.DOT));
}
}
for (PsiPackage subPackage : subPackages) {
collectClassesAndPackageNames(res, subPackage, scope);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:MvcTargetDialogCompletionUtils.java
示例16: addGroovyDocKeywords
import com.intellij.codeInsight.lookup.TailTypeDecorator; //导入依赖的package包/类
public static void addGroovyDocKeywords(CompletionParameters parameters, CompletionResultSet result) {
PsiElement position = parameters.getPosition();
if (PlatformPatterns.psiElement(GroovyDocTokenTypes.mGDOC_TAG_NAME).andNot(PlatformPatterns.psiElement().afterLeaf(".")).accepts(
position)) {
String[] tags = position.getParent() instanceof GrDocInlinedTag ? INLINED_DOC_TAGS : DOC_TAGS;
for (String docTag : tags) {
result.addElement(TailTypeDecorator.withTail(LookupElementBuilder.create(docTag), TailType.HUMBLE_SPACE_BEFORE_WORD));
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:GroovyCompletionData.java
示例17: get
import com.intellij.codeInsight.lookup.TailTypeDecorator; //导入依赖的package包/类
public Object[] get(PsiElement context, CompletionContext completionContext) {
return ContainerUtil.map2Array(doGetKeywords(context), LookupElement.class, new Function<String, LookupElement>() {
public LookupElement fun(String s) {
return TailTypeDecorator.withTail(LookupElementBuilder.create(s).bold(), TailType.SPACE);
}
});
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:8,代码来源:RncCompletionData.java
示例18: collectClassesAndPackageNames
import com.intellij.codeInsight.lookup.TailTypeDecorator; //导入依赖的package包/类
private static void collectClassesAndPackageNames(Collection<LookupElement> res, @NotNull PsiPackage aPackage, GlobalSearchScope scope) {
PsiPackage[] subPackages = aPackage.getSubPackages(scope);
String qualifiedName = aPackage.getQualifiedName();
if (qualifiedName.length() > 0) {
if (subPackages.length == 0 || aPackage.getClasses(scope).length > 0) {
res.add(TailTypeDecorator.withTail(LookupElementBuilder.create(qualifiedName), TailType.DOT));
}
}
for (PsiPackage subPackage : subPackages) {
collectClassesAndPackageNames(res, subPackage, scope);
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:15,代码来源:MvcTargetDialogCompletionUtils.java
示例19: createParametersLookupElement
import com.intellij.codeInsight.lookup.TailTypeDecorator; //导入依赖的package包/类
private static LookupElement createParametersLookupElement(final PsiMethod takeParametersFrom, PsiElement call, PsiMethod invoked)
{
final PsiParameter[] parameters = takeParametersFrom.getParameterList().getParameters();
final String lookupString = StringUtil.join(parameters, psiParameter -> psiParameter.getName(), ", ");
final int w = PlatformIcons.PARAMETER_ICON.getIconWidth();
LayeredIcon icon = new LayeredIcon(2);
icon.setIcon(PlatformIcons.PARAMETER_ICON, 0, 2 * w / 5, 0);
icon.setIcon(PlatformIcons.PARAMETER_ICON, 1);
LookupElementBuilder element = LookupElementBuilder.create(lookupString).withIcon(icon);
if(PsiTreeUtil.isAncestor(takeParametersFrom, call, true))
{
element = element.withInsertHandler(new InsertHandler<LookupElement>()
{
@Override
public void handleInsert(InsertionContext context, LookupElement item)
{
context.commitDocument();
for(PsiParameter parameter : CompletionUtil.getOriginalOrSelf(takeParametersFrom).getParameterList().getParameters())
{
VariableLookupItem.makeFinalIfNeeded(context, parameter);
}
}
});
}
element.putUserData(JavaCompletionUtil.SUPER_METHOD_PARAMETERS, Boolean.TRUE);
return TailTypeDecorator.withTail(element, ExpectedTypesProvider.getFinalCallParameterTailType(call, invoked.getReturnType(), invoked));
}
开发者ID:consulo,项目名称:consulo-java,代码行数:31,代码来源:SameSignatureCallParametersProvider.java
示例20: createLookupItems
import com.intellij.codeInsight.lookup.TailTypeDecorator; //导入依赖的package包/类
private void createLookupItems(Consumer<LookupElement> result, PsiElement context, ExpectedTypeInfo info, List<PsiType> expectedArgs, PsiTypeParameterListOwner paramOwner)
{
if(expectedArgs.contains(null))
{
PsiType arg = expectedArgs.get(0);
if(arg != null)
{
result.consume(TailTypeDecorator.withTail(PsiTypeLookupItem.createLookupItem(arg, context), getTail(expectedArgs.size() == 1)));
}
}
else
{
fillAllArgs(result, context, info, expectedArgs, paramOwner);
}
}
开发者ID:consulo,项目名称:consulo-java,代码行数:16,代码来源:TypeArgumentCompletionProvider.java
注:本文中的com.intellij.codeInsight.lookup.TailTypeDecorator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论