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


Java JavaTemplateUtil类代码示例

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


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

示例1: calculateLookupItems

import com.intellij.codeInsight.template.impl.JavaTemplateUtil; //导入依赖的package包/类
@Override
public LookupElement[] calculateLookupItems(@NotNull Expression[] params, ExpressionContext context) {
  if (params.length == 0) return LookupElement.EMPTY_ARRAY;
  Result paramResult = params[0].calculateQuickResult(context);
  if (paramResult instanceof PsiTypeResult) {
    final PsiType type = ((PsiTypeResult)paramResult).getType();
    final PsiFile file = PsiDocumentManager.getInstance(context.getProject()).getPsiFile(context.getEditor().getDocument());
    final PsiElement element = file.findElementAt(context.getStartOffset());

    final Set<LookupElement> set = new LinkedHashSet<LookupElement>();
    JavaTemplateUtil.addTypeLookupItem(set, type);
    CodeInsightUtil.processSubTypes(type, element, false, PrefixMatcher.ALWAYS_TRUE, new Consumer<PsiType>() {
      @Override
      public void consume(PsiType psiType) {
        JavaTemplateUtil.addTypeLookupItem(set, psiType);
      }
    });
    return set.toArray(new LookupElement[set.size()]);
  }
  return LookupElement.EMPTY_ARRAY;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:SubtypesMacro.java

示例2: calculateResult

import com.intellij.codeInsight.template.impl.JavaTemplateUtil; //导入依赖的package包/类
@Override
public Result calculateResult(ExpressionContext context) {
  final Project project = context.getProject();
  PsiDocumentManager.getInstance(project).commitAllDocuments();
  if (myItems.isEmpty()) return null;

  final PsiType type = myItems.iterator().next().getType();
  return type == null? null : new PsiTypeResult(type, project) {
    @Override
    public void handleRecalc(PsiFile psiFile, Document document, int segmentStart, int segmentEnd) {
      if (myItems.size() <= 1) {
        super.handleRecalc(psiFile, document, segmentStart, segmentEnd);
      } else {
        JavaTemplateUtil.updateTypeBindings(getType(), psiFile, document, segmentStart, segmentEnd, true);
      }
    }

    @Override
    public String toString() {
      return myItems.size() == 1 ? super.toString() : type.getPresentableText();
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:TypeExpression.java

示例3: calculateResult

import com.intellij.codeInsight.template.impl.JavaTemplateUtil; //导入依赖的package包/类
@Override
public Result calculateResult(ExpressionContext context) {
  final Project project = context.getProject();
  PsiDocumentManager.getInstance(project).commitAllDocuments();
  if (myItems.isEmpty()) return null;

  final PsiType type = myItems.iterator().next().getType();
  return type == null? null : new PsiTypeResult(type, project) {
    @Override
    public void handleRecalc(PsiFile psiFile, Document document, int segmentStart, int segmentEnd) {
      if (myItems.size() <= 1) {
        super.handleRecalc(psiFile, document, segmentStart, segmentEnd);
      } else {
        JavaTemplateUtil.updateTypeBindings(getType(), psiFile, document, segmentStart, segmentEnd, true);
      }
    }

    @Override
    public String toString() {
      return myItems.size() == 1 ? type.getCanonicalText() : super.toString();
    }
  };
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:24,代码来源:TypeExpression.java

示例4: calculateLookupItems

import com.intellij.codeInsight.template.impl.JavaTemplateUtil; //导入依赖的package包/类
@Override
public LookupElement[] calculateLookupItems(@NotNull Expression[] params, final ExpressionContext context) {
  final PsiElement[] vars = getVariables(params, context);
  if (vars == null || vars.length < 2) return null;
  final Set<LookupElement> set = new LinkedHashSet<LookupElement>();
  for (PsiElement var : vars) {
    JavaTemplateUtil.addElementLookupItem(set, var);
  }
  return set.toArray(new LookupElement[set.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:VariableOfTypeMacro.java

示例5: calculateLookupItems

import com.intellij.codeInsight.template.impl.JavaTemplateUtil; //导入依赖的package包/类
@Override
public LookupElement[] calculateLookupItems(@NotNull Expression[] params, final ExpressionContext context) {
  final PsiElement[] vars = getVariables(params, context);
  if (vars == null || vars.length < 2) return null;
  Set<LookupElement> set = new LinkedHashSet<LookupElement>();
  for (PsiElement element : vars) {
    JavaTemplateUtil.addElementLookupItem(set, element);
  }
  return set.toArray(new LookupElement[set.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:VariableTypeMacroBase.java

示例6: calculateLookupItems

import com.intellij.codeInsight.template.impl.JavaTemplateUtil; //导入依赖的package包/类
@Override
public LookupElement[] calculateLookupItems(@NotNull Expression[] params, ExpressionContext context) {
  PsiType[] types = guessTypes(params, context);
  if (types == null || types.length < 2) return null;
  Set<LookupElement> set = new LinkedHashSet<LookupElement>();
  for (PsiType type : types) {
    JavaTemplateUtil.addTypeLookupItem(set, type);
  }
  return set.toArray(new LookupElement[set.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:GuessElementTypeMacro.java

示例7: calculateLookupItems

import com.intellij.codeInsight.template.impl.JavaTemplateUtil; //导入依赖的package包/类
@Override
public LookupElement[] calculateLookupItems(@NotNull Expression[] params, ExpressionContext context) {
  PsiType[] types = getExpectedTypes(params, context);
  if (types == null || types.length < 2) return null;
  Set<LookupElement> set = new LinkedHashSet<LookupElement>();
  for (PsiType type : types) {
    JavaTemplateUtil.addTypeLookupItem(set, type);
  }
  return set.toArray(new LookupElement[set.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:ExpectedTypeMacro.java

示例8: calculateResult

import com.intellij.codeInsight.template.impl.JavaTemplateUtil; //导入依赖的package包/类
@Override
public Result calculateResult(ExpressionContext context) {
  PsiDocumentManager.getInstance(context.getProject()).commitAllDocuments();
  PsiType type = myTypePointer.getType();
  if (type != null) {
    if (myForGroovy && (type.equalsToText(CommonClassNames.JAVA_LANG_OBJECT) || mySelectDef)) {
      return new TextResult(GrModifier.DEF);
    }

    type = TypesUtil.unboxPrimitiveTypeWrapper(type);
    if (type == null) return null;

    final PsiType finalType = type;
    return new PsiTypeResult(finalType, context.getProject()) {
      @Override
      public void handleRecalc(PsiFile psiFile, Document document, int segmentStart, int segmentEnd) {
        if (myItems.size() <= 1) {
          super.handleRecalc(psiFile, document, segmentStart, segmentEnd);
        }
        else {
          JavaTemplateUtil.updateTypeBindings(getType(), psiFile, document, segmentStart, segmentEnd, true);
        }
      }

      @Override
      public String toString() {
        return myItems.size() == 1 ? super.toString() : finalType.getPresentableText();
      }

    };
  }

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

示例9: handleFocused

import com.intellij.codeInsight.template.impl.JavaTemplateUtil; //导入依赖的package包/类
@Override
public void handleFocused(final PsiFile psiFile, final Document document, final int segmentStart, final int segmentEnd) {
  JavaTemplateUtil.updateTypeBindings(getElement(), psiFile, document, segmentStart, segmentEnd);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:JavaPsiElementResult.java

示例10: handleFocused

import com.intellij.codeInsight.template.impl.JavaTemplateUtil; //导入依赖的package包/类
@Override
public void handleFocused(final PsiFile psiFile, final Document document, final int segmentStart, final int segmentEnd) {
  JavaTemplateUtil.updateTypeBindings(getType(), psiFile, document, segmentStart, segmentEnd);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:PsiTypeResult.java

示例11: handleRecalc

import com.intellij.codeInsight.template.impl.JavaTemplateUtil; //导入依赖的package包/类
@Override
public void handleRecalc(final PsiFile psiFile, final Document document, final int segmentStart, final int segmentEnd) {
  JavaTemplateUtil.updateTypeBindings(getType(), psiFile, document, segmentStart, segmentEnd);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:PsiTypeResult.java


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