本文整理汇总了Java中com.intellij.codeInsight.template.ExpressionContext.getPsiElementAtStartOffset方法的典型用法代码示例。如果您正苦于以下问题:Java ExpressionContext.getPsiElementAtStartOffset方法的具体用法?Java ExpressionContext.getPsiElementAtStartOffset怎么用?Java ExpressionContext.getPsiElementAtStartOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.codeInsight.template.ExpressionContext
的用法示例。
在下文中一共展示了ExpressionContext.getPsiElementAtStartOffset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVariables
import com.intellij.codeInsight.template.ExpressionContext; //导入方法依赖的package包/类
@Nullable
@Override
protected PsiElement[] getVariables(Expression[] params, ExpressionContext context)
{
final PsiElement psiElementAtStartOffset = context.getPsiElementAtStartOffset();
if(psiElementAtStartOffset == null)
{
return PsiElement.EMPTY_ARRAY;
}
List<DotNetVariable> variables = CSharpLiveTemplateMacroUtil.resolveAllVariables(context.getPsiElementAtStartOffset());
List<DotNetVariable> list = new SmartList<DotNetVariable>();
for(DotNetVariable variable : variables)
{
DotNetTypeRef typeRefOfVariable = variable.toTypeRef(true);
if(CSharpTypeDeclarationImplUtil.isInheritOrSelf(typeRefOfVariable, psiElementAtStartOffset, ourAcceptableTypes))
{
list.add(variable);
}
}
return list.toArray(new PsiElement[list.size()]);
}
示例2: getVariables
import com.intellij.codeInsight.template.ExpressionContext; //导入方法依赖的package包/类
@Nullable
@Override
protected PsiElement[] getVariables(Expression[] params, ExpressionContext context)
{
final PsiElement psiElementAtStartOffset = context.getPsiElementAtStartOffset();
if(psiElementAtStartOffset == null)
{
return PsiElement.EMPTY_ARRAY;
}
List<DotNetVariable> variables = CSharpLiveTemplateMacroUtil.resolveAllVariables(context.getPsiElementAtStartOffset());
List<DotNetVariable> list = new SmartList<DotNetVariable>();
for(DotNetVariable variable : variables)
{
DotNetTypeRef typeRefOfVariable = variable.toTypeRef(true);
if(CSharpTypeDeclarationImplUtil.isInheritOrSelf(typeRefOfVariable, psiElementAtStartOffset, DotNetTypes2.System.Collections.Generic
.IList$1))
{
list.add(variable);
}
}
return list.toArray(new PsiElement[list.size()]);
}
示例3: getVariables
import com.intellij.codeInsight.template.ExpressionContext; //导入方法依赖的package包/类
@Nullable
@Override
protected PsiElement[] getVariables(Expression[] params, ExpressionContext context)
{
final PsiElement psiElementAtStartOffset = context.getPsiElementAtStartOffset();
if(psiElementAtStartOffset == null)
{
return PsiElement.EMPTY_ARRAY;
}
List<DotNetVariable> variables = CSharpLiveTemplateMacroUtil.resolveAllVariables(context.getPsiElementAtStartOffset());
List<DotNetVariable> list = new SmartList<DotNetVariable>();
for(DotNetVariable variable : variables)
{
DotNetTypeRef typeRefOfVariable = variable.toTypeRef(true);
if(typeRefOfVariable instanceof CSharpArrayTypeRef && ((CSharpArrayTypeRef) typeRefOfVariable).getDimensions() == 0)
{
list.add(variable);
}
}
return list.toArray(new PsiElement[list.size()]);
}
示例4: calculateResult
import com.intellij.codeInsight.template.ExpressionContext; //导入方法依赖的package包/类
@Nullable
@Override
@RequiredReadAction
public Result calculateResult(
@NotNull Expression[] params, ExpressionContext context)
{
if(params.length != 1)
{
return null;
}
Result result = params[0].calculateResult(context);
if(result == null)
{
return null;
}
String text = result.toString();
PsiElement place = context.getPsiElementAtStartOffset();
CSharpFragmentFileImpl expressionFragment = CSharpFragmentFactory.createExpressionFragment(context.getProject(), text, place);
DotNetExpression expression = PsiTreeUtil.getChildOfType(expressionFragment, DotNetExpression.class);
if(expression == null)
{
return null;
}
DotNetTypeRef typeRef = CSharpResolveUtil.resolveIterableType(place, expression.toTypeRef(false));
if(typeRef == DotNetTypeRef.ERROR_TYPE)
{
return null;
}
return new TextResult(CSharpTypeRefPresentationUtil.buildShortText(typeRef, place));
}