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


Java DebuggerUtilsEx.findAppropriateCodeFragmentFactory方法代码示例

本文整理汇总了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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:JavaDebuggerEditorsProvider.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:EvaluatorBuilderImpl.java

示例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);
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:24,代码来源:JavaDebuggerEditorsProvider.java

示例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());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ValueHint.java

示例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);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:14,代码来源:EvaluatorBuilderImpl.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:40,代码来源:CachedEvaluator.java


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