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


Java PositionUtil类代码示例

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


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

示例1: getSourcePositionForLocalVariable

import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
@Nullable
protected SourcePosition getSourcePositionForLocalVariable(String name,
                                                           @NotNull Project project,
                                                           @NotNull DebuggerContextImpl context,
                                                           boolean nearest) {
  PsiElement place = PositionUtil.getContextElement(context);
  if (place == null) return null;

  PsiVariable psiVariable = JavaPsiFacade.getInstance(project).getResolveHelper().resolveReferencedVariable(name, place);
  if (psiVariable == null) return null;

  PsiFile containingFile = psiVariable.getContainingFile();
  if(containingFile == null) return null;
  if (nearest) {
    return DebuggerContextUtil.findNearest(context, psiVariable, containingFile);
  }
  return SourcePosition.createFromElement(psiVariable);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:DefaultSourcePositionProvider.java

示例2: getPsiField

import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
public PsiField getPsiField() {
  final SourcePosition sourcePosition = getSourcePosition();
  try {
    final PsiField field = ApplicationManager.getApplication().runReadAction(new Computable<PsiField>() {
      @Override
      public PsiField compute() {
        final PsiClass psiClass = getPsiClassAt(sourcePosition);
        return psiClass != null ? psiClass.findFieldByName(getFieldName(), true) : null;
      }
    });
    if (field != null) {
      return field;
    }
  } catch (IndexNotReadyException ignored) {}
  return PositionUtil.getPsiElementAt(getProject(), PsiField.class, sourcePosition);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:FieldBreakpoint.java

示例3: reload

import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
@Override
protected void reload(PsiFile psiFile) {
  super.reload(psiFile);
  PsiField field = PositionUtil.getPsiElementAt(getProject(), PsiField.class, getSourcePosition());
  if(field != null) {
    setFieldName(field.getName());
    PsiClass psiClass = field.getContainingClass();
    if (psiClass != null) {
      getProperties().myClassName = psiClass.getQualifiedName();
    }
    myIsStatic = field.hasModifierProperty(PsiModifier.STATIC);
  }
  if (myIsStatic) {
    setInstanceFiltersEnabled(false);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:FieldBreakpoint.java

示例4: getDescriptorEvaluation

import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
@Override
public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException {
  PsiElementFactory elementFactory = JavaPsiFacade.getInstance(context.getProject()).getElementFactory();
  String fieldName;
  if(isStatic()) {
    String typeName = myField.declaringType().name().replace('$', '.');
    typeName = DebuggerTreeNodeExpression.normalize(typeName, PositionUtil.getContextElement(context), context.getProject());
    fieldName = typeName + "." + getName();
  }
  else {
    //noinspection HardCodedStringLiteral
    fieldName = isOuterLocalVariableValue()? StringUtil.trimStart(getName(), OUTER_LOCAL_VAR_FIELD_PREFIX) : "this." + getName();
  }
  try {
    return elementFactory.createExpressionFromText(fieldName, null);
  }
  catch (IncorrectOperationException e) {
    throw new EvaluateException(DebuggerBundle.message("error.invalid.field.name", getName()), e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:FieldDescriptorImpl.java

示例5: printContextWithText

import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
protected void printContextWithText(final StackFrameContext context) {
  ApplicationManager.getApplication().runReadAction(new Runnable() {
    @Override
    public void run() {
      if (context.getFrameProxy() != null) {
        SourcePosition sourcePosition = PositionUtil.getSourcePosition(context);
        int offset = sourcePosition.getOffset();
        Document document = PsiDocumentManager.getInstance(myProject).getDocument(sourcePosition.getFile());
        CharSequence text = document.getImmutableCharSequence();
        String positionText = "";
        if (offset > -1) {
          positionText = StringUtil.escapeLineBreak(" [" + text.subSequence(Math.max(0, offset - 20), offset) + "<*>"
          + text.subSequence(offset, Math.min(offset + 20, text.length())) + "]");
        }

        println(sourcePosition.getFile().getVirtualFile().getName()
                + ":" + sourcePosition.getLine()
                + positionText,
                ProcessOutputTypes.SYSTEM);
      }
      else {
        println("Context thread is null", ProcessOutputTypes.SYSTEM);
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:ExecutionWithDebuggerToolsTestCase.java

示例6: getSourcePosition

import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
public SourcePosition getSourcePosition(final Project project, final DebuggerContextImpl context) {
  StackFrameProxyImpl frame = context.getFrameProxy();
  if (frame == null) return null;

  PsiElement place = PositionUtil.getContextElement(context);

  if (place == null) {
    return null;
  }

  PsiVariable psiVariable = JavaPsiFacade.getInstance(project).getResolveHelper().resolveReferencedVariable(getName(), place);
  if (psiVariable == null) {
    return null;
  }

  PsiFile containingFile = psiVariable.getContainingFile();
  if(containingFile == null) return null;

  return SourcePosition.createFromOffset(containingFile, psiVariable.getTextOffset());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:LocalVariableDescriptorImpl.java

示例7: getDescriptorEvaluation

import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException {
  PsiElementFactory elementFactory = JavaPsiFacade.getInstance(context.getProject()).getElementFactory();
  String fieldName;
  if(isStatic()) {
    String typeName = myField.declaringType().name().replace('$', '.');
    typeName = DebuggerTreeNodeExpression.normalize(typeName, PositionUtil.getContextElement(context), context.getProject());
    fieldName = typeName + "." + getName();
  }
  else {
    //noinspection HardCodedStringLiteral
    fieldName = isOuterLocalVariableValue()? StringUtil.trimStart(getName(), OUTER_LOCAL_VAR_FIELD_PREFIX) : "this." + getName();
  }
  try {
    return elementFactory.createExpressionFromText(fieldName, null);
  }
  catch (IncorrectOperationException e) {
    throw new EvaluateException(DebuggerBundle.message("error.invalid.field.name", getName()), e);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:FieldDescriptorImpl.java

示例8: getSourcePositionForLocalVariable

import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
@Nullable
private SourcePosition getSourcePositionForLocalVariable(String name, @NotNull Project project, @NotNull DebuggerContextImpl context, boolean nearest)
{
	PsiElement place = PositionUtil.getContextElement(context);
	if(place == null)
	{
		return null;
	}

	PsiVariable psiVariable = JavaPsiFacade.getInstance(project).getResolveHelper().resolveReferencedVariable(name, place);
	if(psiVariable == null)
	{
		return null;
	}

	PsiFile containingFile = psiVariable.getContainingFile();
	if(containingFile == null)
	{
		return null;
	}
	if(nearest)
	{
		return DebuggerContextUtil.findNearest(context, psiVariable, containingFile);
	}
	return SourcePosition.createFromElement(psiVariable);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:27,代码来源:DefaultSourcePositionProvider.java

示例9: getPsiField

import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
public PsiField getPsiField()
{
	final SourcePosition sourcePosition = getSourcePosition();
	final PsiField field = ApplicationManager.getApplication().runReadAction(new Computable<PsiField>()
	{
		@Override
		public PsiField compute()
		{
			final PsiClass psiClass = getPsiClassAt(sourcePosition);
			return psiClass != null ? psiClass.findFieldByName(getFieldName(), true) : null;
		}
	});
	if(field != null)
	{
		return field;
	}
	return PositionUtil.getPsiElementAt(getProject(), PsiField.class, sourcePosition);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:FieldBreakpoint.java

示例10: reload

import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
@Override
protected void reload(PsiFile psiFile)
{
	super.reload(psiFile);
	PsiField field = PositionUtil.getPsiElementAt(getProject(), PsiField.class, getSourcePosition());
	if(field != null)
	{
		setFieldName(field.getName());
		PsiClass psiClass = field.getContainingClass();
		if(psiClass != null)
		{
			getProperties().myClassName = psiClass.getQualifiedName();
		}
		myIsStatic = field.hasModifierProperty(PsiModifier.STATIC);
	}
	if(myIsStatic)
	{
		setInstanceFiltersEnabled(false);
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:21,代码来源:FieldBreakpoint.java

示例11: getDescriptorEvaluation

import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
@Override
public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException
{
	PsiElementFactory elementFactory = JavaPsiFacade.getInstance(myProject).getElementFactory();
	String fieldName;
	if(isStatic())
	{
		String typeName = myField.declaringType().name().replace('$', '.');
		typeName = DebuggerTreeNodeExpression.normalize(typeName, PositionUtil.getContextElement(context), myProject);
		fieldName = typeName + "." + getName();
	}
	else
	{
		//noinspection HardCodedStringLiteral
		fieldName = isOuterLocalVariableValue() ? StringUtil.trimStart(getName(), OUTER_LOCAL_VAR_FIELD_PREFIX) : "this." + getName();
	}
	try
	{
		return elementFactory.createExpressionFromText(fieldName, null);
	}
	catch(IncorrectOperationException e)
	{
		throw new EvaluateException(DebuggerBundle.message("error.invalid.field.name", getName()), e);
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:26,代码来源:FieldDescriptorImpl.java

示例12: resolveVariable

import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
@Nullable
private static PsiVariable resolveVariable(final StackFrameProxy frame,
                                           final String name,
                                           final Project project,
                                           final DebugProcess process) {
  return ApplicationManager.getApplication().runReadAction(new Computable<PsiVariable>() {
    @Override
    public PsiVariable compute() {
      PsiElement place = PositionUtil.getContextElement(new SimpleStackFrameContext(frame, process));
      if (place == null) return null;
      return JavaPsiFacade.getInstance(project).getResolveHelper().resolveReferencedVariable(name, place);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:LocalVariableEvaluator.java

示例13: getDescriptorEvaluation

import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException {
  PsiElementFactory elementFactory = JavaPsiFacade.getInstance(context.getProject()).getElementFactory();
  try {
    return elementFactory.createExpressionFromText(getName(), PositionUtil.getContextElement(context));
  }
  catch (IncorrectOperationException e) {
    throw new EvaluateException(DebuggerBundle.message("error.invalid.local.variable.name", getName()), e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ArgumentValueDescriptorImpl.java

示例14: getDescriptorEvaluation

import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
@Override
public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException {
  PsiElementFactory elementFactory = JavaPsiFacade.getInstance(context.getProject()).getElementFactory();
  try {
    return elementFactory.createExpressionFromText(getName(), PositionUtil.getContextElement(context));
  }
  catch (IncorrectOperationException e) {
    throw new EvaluateException(DebuggerBundle.message("error.invalid.local.variable.name", getName()), e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:LocalVariableDescriptorImpl.java

示例15: printContext

import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
protected void printContext(final StackFrameContext context) {
  ApplicationManager.getApplication().runReadAction(new Runnable() {
    @Override
    public void run() {
      if (context.getFrameProxy() != null) {
        SourcePosition sourcePosition = PositionUtil.getSourcePosition(context);
        println(sourcePosition.getFile().getVirtualFile().getName() + ":" + sourcePosition.getLine(), ProcessOutputTypes.SYSTEM);
      }
      else {
        println("Context thread is null", ProcessOutputTypes.SYSTEM);
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:ExecutionWithDebuggerToolsTestCase.java


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