• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SourcePosition类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getSourcePosition

import com.intellij.debugger.SourcePosition; //导入依赖的package包/类
@Override
public SourcePosition getSourcePosition(final Location location) throws NoDataException {
  SourcePosition sourcePosition = null;

  try {
    String sourcePath = getRelativeSourcePathByLocation(location);
    PsiFile file = mySourcesFinder.findSourceFile(sourcePath, myDebugProcess.getProject(), myScope);
    if(file != null) {
      int lineNumber = getLineNumber(location);
      sourcePosition = SourcePosition.createFromLine(file, lineNumber - 1);
    }
  }
  catch (AbsentInformationException ignored) { // ignored
  }
  catch (Throwable e) {
    LOG.info(e);
  }
  if(sourcePosition == null) {
    throw NoDataException.INSTANCE;
  }
  return sourcePosition;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:JSR45PositionManager.java


示例2: getAllClasses

import com.intellij.debugger.SourcePosition; //导入依赖的package包/类
@Override
@NotNull
public List<ReferenceType> getAllClasses(@NotNull SourcePosition classPosition) throws NoDataException {
  checkSourcePositionFileType(classPosition);

  final List<ReferenceType> referenceTypes = myDebugProcess.getVirtualMachineProxy().allClasses();

  final List<ReferenceType> result = new ArrayList<ReferenceType>();

  for (final ReferenceType referenceType : referenceTypes) {
    myGeneratedClassPatternMatcher.reset(referenceType.name());
    if (myGeneratedClassPatternMatcher.matches()) {
      final List<Location> locations = locationsOfClassAt(referenceType, classPosition);
      if (locations != null && locations.size() > 0) {
        result.add(referenceType);
      }
    }
  }

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


示例3: locationsOfLine

import com.intellij.debugger.SourcePosition; //导入依赖的package包/类
@Override
@NotNull
public List<Location> locationsOfLine(@NotNull final ReferenceType type, @NotNull SourcePosition position) {
  VirtualFile file = position.getFile().getVirtualFile();
  if (file != null) {
    LineNumbersMapping mapping = file.getUserData(LineNumbersMapping.LINE_NUMBERS_MAPPING_KEY);
    if (mapping != null) {
      int line = mapping.sourceToBytecode(position.getLine() + 1);
      if (line > -1) {
        position = SourcePosition.createFromLine(position.getFile(), line - 1);
      }
    }
  }

  final SourcePosition finalPosition = position;
  return iterate(new Processor<List<Location>>() {
    @Override
    public List<Location> process(PositionManager positionManager) throws NoDataException {
      return positionManager.locationsOfLine(type, finalPosition);
    }
  }, Collections.<Location>emptyList());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:CompoundPositionManager.java


示例4: createPrepareRequests

import com.intellij.debugger.SourcePosition; //导入依赖的package包/类
@NotNull
@Override
public List<ClassPrepareRequest> createPrepareRequests(@NotNull final ClassPrepareRequestor requestor, @NotNull final SourcePosition position) {
  return iterate(new Processor<List<ClassPrepareRequest>>() {
    @Override
    public List<ClassPrepareRequest> process(PositionManager positionManager) throws NoDataException {
      if (positionManager instanceof MultiRequestPositionManager) {
        return ((MultiRequestPositionManager)positionManager).createPrepareRequests(requestor, position);
      }
      else {
        ClassPrepareRequest prepareRequest = positionManager.createPrepareRequest(requestor, position);
        if (prepareRequest == null) {
          return Collections.emptyList();
        }
        return Collections.singletonList(prepareRequest);
      }
    }
  }, Collections.<ClassPrepareRequest>emptyList());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:CompoundPositionManager.java


示例5: build

import com.intellij.debugger.SourcePosition; //导入依赖的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


示例6: LambdaMethodFilter

import com.intellij.debugger.SourcePosition; //导入依赖的package包/类
public LambdaMethodFilter(PsiLambdaExpression lambda, int expressionOrdinal, Range<Integer> callingExpressionLines) {
  myLambdaOrdinal = expressionOrdinal;
  myCallingExpressionLines = callingExpressionLines;

  SourcePosition firstStatementPosition = null;
  SourcePosition lastStatementPosition = null;
  final PsiElement body = lambda.getBody();
  if (body instanceof PsiCodeBlock) {
    final PsiStatement[] statements = ((PsiCodeBlock)body).getStatements();
    if (statements.length > 0) {
      firstStatementPosition = SourcePosition.createFromElement(statements[0]);
      if (firstStatementPosition != null) {
        final PsiStatement lastStatement = statements[statements.length - 1];
        lastStatementPosition =
          SourcePosition.createFromOffset(firstStatementPosition.getFile(), lastStatement.getTextRange().getEndOffset());
      }
    }
  }
  else if (body != null) {
    firstStatementPosition = SourcePosition.createFromElement(body);
  }
  myFirstStatementPosition = firstStatementPosition;
  myLastStatementLine = lastStatementPosition != null ? lastStatementPosition.getLine() : -1;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:LambdaMethodFilter.java


示例7: AnonymousClassMethodFilter

import com.intellij.debugger.SourcePosition; //导入依赖的package包/类
public AnonymousClassMethodFilter(PsiMethod psiMethod, Range<Integer> lines) {
  super(psiMethod, lines);
  SourcePosition firstStatementPosition = null;
  SourcePosition lastStatementPosition = null;
  final PsiCodeBlock body = psiMethod.getBody();
  if (body != null) {
    final PsiStatement[] statements = body.getStatements();
    if (statements.length > 0) {
      firstStatementPosition = SourcePosition.createFromElement(statements[0]);
      if (firstStatementPosition != null) {
        final PsiStatement lastStatement = statements[statements.length - 1];
        lastStatementPosition = SourcePosition.createFromOffset(firstStatementPosition.getFile(), lastStatement.getTextRange().getEndOffset());
      }
    }
  }
  myBreakpointPosition = firstStatementPosition;
  myLastStatementLine = lastStatementPosition != null? lastStatementPosition.getLine() : -1;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:AnonymousClassMethodFilter.java


示例8: computeSourcePosition

import com.intellij.debugger.SourcePosition; //导入依赖的package包/类
@Nullable
@Override
protected SourcePosition computeSourcePosition(@NotNull NodeDescriptor descriptor,
                                               @NotNull Project project,
                                               @NotNull DebuggerContextImpl context,
                                               boolean nearest) {
  StackFrameProxyImpl frame = context.getFrameProxy();
  if (frame == null) {
    return null;
  }

  if (descriptor instanceof FieldDescriptor) {
    return getSourcePositionForField((FieldDescriptor)descriptor, project, context, nearest);
  }
  else if (descriptor instanceof LocalVariableDescriptor) {
    return getSourcePositionForLocalVariable(descriptor.getName(), project, context, nearest);
  }
  else if (descriptor instanceof ArgumentValueDescriptorImpl) {
    Collection<String> names = ((ArgumentValueDescriptorImpl)descriptor).getVariable().getMatchedNames();
    if (!names.isEmpty()) {
      return getSourcePositionForLocalVariable(names.iterator().next(), project, context, nearest);
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:DefaultSourcePositionProvider.java


示例9: getSourcePositionForLocalVariable

import com.intellij.debugger.SourcePosition; //导入依赖的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


示例10: computeTypeSourcePosition

import com.intellij.debugger.SourcePosition; //导入依赖的package包/类
@Override
public void computeTypeSourcePosition(@NotNull final XNavigatable navigatable) {
  if (myEvaluationContext.getSuspendContext().isResumed()) return;
  DebugProcessImpl debugProcess = myEvaluationContext.getDebugProcess();
  debugProcess.getManagerThread().schedule(new JumpToObjectAction.NavigateCommand(getDebuggerContext(), myValueDescriptor, debugProcess, null) {
    @Override
    public Priority getPriority() {
      return Priority.HIGH;
    }

    @Override
    protected void doAction(@Nullable final SourcePosition sourcePosition) {
      if (sourcePosition != null) {
        ApplicationManager.getApplication().runReadAction(new Runnable() {
          @Override
          public void run() {
            navigatable.setSourcePosition(DebuggerUtilsEx.toXSourcePosition(sourcePosition));
          }
        });
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:JavaValue.java


示例11: getFinallyStatements

import com.intellij.debugger.SourcePosition; //导入依赖的package包/类
private static List<PsiStatement> getFinallyStatements(@Nullable SourcePosition position) {
  if (position == null) {
    return Collections.emptyList();
  }
  List<PsiStatement> res = new ArrayList<PsiStatement>();
  PsiElement element = position.getFile().findElementAt(position.getOffset());
  PsiTryStatement tryStatement = PsiTreeUtil.getParentOfType(element, PsiTryStatement.class);
  while (tryStatement != null) {
    PsiCodeBlock finallyBlock = tryStatement.getFinallyBlock();
    if (finallyBlock != null) {
      ContainerUtil.addAll(res, finallyBlock.getStatements());
    }
    tryStatement = PsiTreeUtil.getParentOfType(tryStatement, PsiTryStatement.class);
  }
  return res;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:PopFrameAction.java


示例12: getPsiField

import com.intellij.debugger.SourcePosition; //导入依赖的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


示例13: getContainingMethod

import com.intellij.debugger.SourcePosition; //导入依赖的package包/类
@Nullable
public PsiElement getContainingMethod(@NotNull LineBreakpoint<?> breakpoint) {
  SourcePosition position = breakpoint.getSourcePosition();
  if (position == null) return null;

  JavaBreakpointProperties properties = breakpoint.getProperties();
  if (properties instanceof JavaLineBreakpointProperties && !(breakpoint instanceof RunToCursorBreakpoint)) {
    Integer ordinal = ((JavaLineBreakpointProperties)properties).getLambdaOrdinal();
    if (ordinal > -1) {
      List<PsiLambdaExpression> lambdas = DebuggerUtilsEx.collectLambdas(position, true);
      if (ordinal < lambdas.size()) {
        return lambdas.get(ordinal);
      }
    }
  }
  return DebuggerUtilsEx.getContainingMethod(position);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:JavaLineBreakpointType.java


示例14: createRequest

import com.intellij.debugger.SourcePosition; //导入依赖的package包/类
public void createRequest(final DebugProcessImpl debugProcess) {
  DebuggerManagerThreadImpl.assertIsManagerThread();
  if (!shouldCreateRequest(debugProcess)) {
    return;
  }

  SourcePosition classPosition = ApplicationManager.getApplication().runReadAction(new Computable<SourcePosition>() {
    public SourcePosition compute() {
      PsiClass psiClass = DebuggerUtils.findClass(getQualifiedName(), myProject, debugProcess.getSearchScope());

      return psiClass != null ? SourcePosition.createFromElement(psiClass) : null;
    }
  });

  if(classPosition == null) {
    createOrWaitPrepare(debugProcess, getQualifiedName());
  }
  else {
    createOrWaitPrepare(debugProcess, classPosition);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ExceptionBreakpoint.java


示例15: getPsiElementAt

import com.intellij.debugger.SourcePosition; //导入依赖的package包/类
@Nullable
public static <T extends PsiElement> T getPsiElementAt(final Project project, final Class<T> expectedPsiElementClass, final SourcePosition sourcePosition) {
  return ApplicationManager.getApplication().runReadAction(new Computable<T>() {
    public T compute() {
      final PsiFile psiFile = sourcePosition.getFile();
      final Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
      if(document == null) {
        return null;
      }
      final int spOffset = sourcePosition.getOffset();
      if (spOffset < 0) {
        return null;
      }
      final int offset = CharArrayUtil.shiftForward(document.getCharsSequence(), spOffset, " \t");
      return PsiTreeUtil.getParentOfType(psiFile.findElementAt(offset), expectedPsiElementClass, false);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:PositionUtil.java


示例16: DebuggerContextImpl

import com.intellij.debugger.SourcePosition; //导入依赖的package包/类
private DebuggerContextImpl(@Nullable DebuggerSession session,
                            @Nullable DebugProcessImpl debugProcess,
                            @Nullable SuspendContextImpl context,
                            ThreadReferenceProxyImpl threadProxy,
                            StackFrameProxyImpl frameProxy,
                            SourcePosition position,
                            PsiElement contextElement,
                            boolean initialized) {
  LOG.assertTrue(frameProxy == null || threadProxy == null || threadProxy == frameProxy.threadProxy());
  LOG.assertTrue(debugProcess != null || frameProxy == null && threadProxy == null);
  myDebuggerSession = session;
  myThreadProxy = threadProxy;
  myFrameProxy = frameProxy;
  myDebugProcess = debugProcess;
  mySourcePosition = position;
  mySuspendContext = context;
  myContextElement = contextElement;
  myInitialized = initialized;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:DebuggerContextImpl.java


示例17: locationsOfLine

import com.intellij.debugger.SourcePosition; //导入依赖的package包/类
@Override
@NotNull
public List<Location> locationsOfLine(@NotNull ReferenceType type, @NotNull SourcePosition position) throws NoDataException {
  checkGroovyFile(position);
  try {
    if (LOG.isDebugEnabled()) {
      LOG.debug("locationsOfLine: " + type + "; " + position);
    }
    int line = position.getLine() + 1;
    List<Location> locations = getDebugProcess().getVirtualMachineProxy().versionHigher("1.4")
                               ? type.locationsOfLine(DebugProcess.JAVA_STRATUM, null, line)
                               : type.locationsOfLine(line);
    if (locations == null || locations.isEmpty()) throw NoDataException.INSTANCE;
    return locations;
  }
  catch (AbsentInformationException e) {
    throw NoDataException.INSTANCE;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GroovyPositionManager.java


示例18: locationsOfLine

import com.intellij.debugger.SourcePosition; //导入依赖的package包/类
@Override
@NotNull
public List<Location> locationsOfLine(@NotNull final ReferenceType type, @NotNull final SourcePosition position) throws NoDataException {
  List<Location> locations = locationsOfClassAt(type, position);
  return locations != null ? locations : Collections.<Location>emptyList();

}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:JSR45PositionManager.java


示例19: getAllClasses

import com.intellij.debugger.SourcePosition; //导入依赖的package包/类
@NotNull
@Override
public List<ReferenceType> getAllClasses(@NotNull final SourcePosition classPosition) throws NoDataException {
  int line;
  String className;

  AccessToken accessToken = ReadAction.start();
  try {
    className = findEnclosingName(classPosition);
    if (className == null) throw NoDataException.INSTANCE;

    line = classPosition.getLine();
  }
  finally {
    accessToken.finish();
  }

  List<ReferenceType> referenceTypes = myDebugProcess.getVirtualMachineProxy().classesByName(className);
  if (referenceTypes.isEmpty()) throw NoDataException.INSTANCE;

  Set<ReferenceType> res = new HashSet<ReferenceType>();

  for (ReferenceType referenceType : referenceTypes) {
    findNested(res, referenceType, line);
  }

  if (res.isEmpty()) {
    throw NoDataException.INSTANCE;
  }

  return new ArrayList<ReferenceType>(res);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:SpringLoadedPositionManager.java


示例20: onClassPrepare

import com.intellij.debugger.SourcePosition; //导入依赖的package包/类
protected void onClassPrepare(final DebugProcess debuggerProcess, final ReferenceType referenceType,
                            final SourcePosition position, final ClassPrepareRequestor requestor) {
  try {
    if(locationsOfClassAt(referenceType, position) != null) {
      requestor.processClassPrepare(debuggerProcess, referenceType);
    }
  }
  catch (NoDataException ignored) {
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:JSR45PositionManager.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SimplexNoiseGenerator类代码示例发布时间:2022-05-22
下一篇:
Java CmdHandler类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap