本文整理汇总了Java中com.intellij.debugger.impl.DebuggerUtilsEx.findAppropriateCodeFragmentFactory方法的典型用法代码示例。如果您正苦于以下问题:Java DebuggerUtilsEx.findAppropriateCodeFragmentFactory方法的具体用法?Java DebuggerUtilsEx.findAppropriateCodeFragmentFactory怎么用?Java DebuggerUtilsEx.findAppropriateCodeFragmentFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.debugger.impl.DebuggerUtilsEx
的用法示例。
在下文中一共展示了DebuggerUtilsEx.findAppropriateCodeFragmentFactory方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createExpressionCodeFragment
import com.intellij.debugger.impl.DebuggerUtilsEx; //导入方法依赖的package包/类
@Override
protected PsiFile createExpressionCodeFragment(@NotNull Project project,
@NotNull XExpression expression,
@Nullable PsiElement context,
boolean isPhysical) {
TextWithImports text = TextWithImportsImpl.fromXExpression(expression);
if (text != null && context != null) {
CodeFragmentFactory factory = DebuggerUtilsEx.findAppropriateCodeFragmentFactory(text, context);
JavaCodeFragment codeFragment = factory.createPresentationCodeFragment(text, context, project);
codeFragment.forceResolveScope(GlobalSearchScope.allScope(project));
final PsiClass contextClass = PsiTreeUtil.getNonStrictParentOfType(context, PsiClass.class);
if (contextClass != null) {
final PsiClassType contextType =
JavaPsiFacade.getInstance(codeFragment.getProject()).getElementFactory().createType(contextClass);
codeFragment.setThisType(contextType);
}
return codeFragment;
}
else {
return super.createExpressionCodeFragment(project, expression, context, isPhysical);
}
}
示例2: build
import com.intellij.debugger.impl.DebuggerUtilsEx; //导入方法依赖的package包/类
public static ExpressionEvaluator build(final TextWithImports text, @Nullable PsiElement contextElement, final SourcePosition position) throws EvaluateException {
if (contextElement == null) {
throw EvaluateExceptionUtil.CANNOT_FIND_SOURCE_CLASS;
}
final Project project = contextElement.getProject();
CodeFragmentFactory factory = DebuggerUtilsEx.findAppropriateCodeFragmentFactory(text, contextElement);
PsiCodeFragment codeFragment = factory.createCodeFragment(text, contextElement, project);
if (codeFragment == null) {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.invalid.expression", text.getText()));
}
codeFragment.forceResolveScope(GlobalSearchScope.allScope(project));
DebuggerUtils.checkSyntax(codeFragment);
return factory.getEvaluatorBuilder().build(codeFragment, position);
}
示例3: createExpressionCodeFragment
import com.intellij.debugger.impl.DebuggerUtilsEx; //导入方法依赖的package包/类
@Override
protected PsiFile createExpressionCodeFragment(@NotNull Project project, @NotNull XExpression expression, @Nullable PsiElement context, boolean isPhysical)
{
TextWithImports text = TextWithImportsImpl.fromXExpression(expression);
if(text != null && context != null)
{
CodeFragmentFactory factory = DebuggerUtilsEx.findAppropriateCodeFragmentFactory(text, context);
JavaCodeFragment codeFragment = factory.createPresentationCodeFragment(text, context, project);
codeFragment.forceResolveScope(GlobalSearchScope.allScope(project));
final PsiClass contextClass = PsiTreeUtil.getNonStrictParentOfType(context, PsiClass.class);
if(contextClass != null)
{
final PsiClassType contextType = JavaPsiFacade.getInstance(codeFragment.getProject()).getElementFactory().createType(contextClass);
codeFragment.setThisType(contextType);
}
return codeFragment;
}
else
{
return super.createExpressionCodeFragment(project, expression, context, isPhysical);
}
}
示例4: getExpressionEvaluator
import com.intellij.debugger.impl.DebuggerUtilsEx; //导入方法依赖的package包/类
@Nullable
private ExpressionEvaluator getExpressionEvaluator(DebuggerContextImpl debuggerContext) throws EvaluateException {
if (myCurrentExpression instanceof PsiExpression) {
return EvaluatorBuilderImpl.getInstance().build(myCurrentExpression, debuggerContext.getSourcePosition());
}
TextWithImportsImpl textWithImports = new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, myCurrentExpression.getText());
CodeFragmentFactory factory = DebuggerUtilsEx.findAppropriateCodeFragmentFactory(textWithImports, myCurrentExpression);
JavaCodeFragment codeFragment = factory.createCodeFragment(textWithImports, myCurrentExpression.getContext(), getProject());
codeFragment.forceResolveScope(GlobalSearchScope.allScope(getProject()));
return factory.getEvaluatorBuilder().build(codeFragment, debuggerContext.getSourcePosition());
}
示例5: build
import com.intellij.debugger.impl.DebuggerUtilsEx; //导入方法依赖的package包/类
public static ExpressionEvaluator build(final TextWithImports text, @Nullable PsiElement contextElement, @Nullable final SourcePosition position, @NotNull Project project) throws
EvaluateException
{
CodeFragmentFactory factory = DebuggerUtilsEx.findAppropriateCodeFragmentFactory(text, contextElement);
PsiCodeFragment codeFragment = factory.createCodeFragment(text, contextElement, project);
if(codeFragment == null)
{
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.invalid.expression", text.getText()));
}
DebuggerUtils.checkSyntax(codeFragment);
return factory.getEvaluatorBuilder().build(codeFragment, position);
}
示例6: initEvaluatorAndChildrenExpression
import com.intellij.debugger.impl.DebuggerUtilsEx; //导入方法依赖的package包/类
protected Cache initEvaluatorAndChildrenExpression(final Project project)
{
final Cache cache = new Cache();
try
{
Pair<PsiElement, PsiType> psiClassAndType = DebuggerUtilsImpl.getPsiClassAndType(getClassName(), project);
PsiElement context = psiClassAndType.first;
if(context == null)
{
throw EvaluateExceptionUtil.CANNOT_FIND_SOURCE_CLASS;
}
CodeFragmentFactory factory = DebuggerUtilsEx.findAppropriateCodeFragmentFactory(myReferenceExpression, context);
JavaCodeFragment codeFragment = factory.createCodeFragment(myReferenceExpression, overrideContext(context), project);
codeFragment.setThisType(psiClassAndType.second);
DebuggerUtils.checkSyntax(codeFragment);
cache.myPsiChildrenExpression = codeFragment instanceof PsiExpressionCodeFragment ? ((PsiExpressionCodeFragment) codeFragment).getExpression() : null;
try
{
cache.myEvaluator = factory.getEvaluatorBuilder().build(codeFragment, null);
}
catch(UnsupportedExpressionException ex)
{
ExpressionEvaluator eval = CompilingEvaluatorImpl.create(project, context, element -> codeFragment);
if(eval != null)
{
cache.myEvaluator = eval;
}
throw ex;
}
}
catch(EvaluateException e)
{
cache.myException = e;
}
myCache = new SoftReference<>(cache);
return cache;
}