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


Java Location.declaringType方法代码示例

本文整理汇总了Java中com.sun.jdi.Location.declaringType方法的典型用法代码示例。如果您正苦于以下问题:Java Location.declaringType方法的具体用法?Java Location.declaringType怎么用?Java Location.declaringType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.jdi.Location的用法示例。


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

示例1: writeLocation

import com.sun.jdi.Location; //导入方法依赖的package包/类
void writeLocation(Location location) {
    ReferenceTypeImpl refType = (ReferenceTypeImpl)location.declaringType();
    byte tag;
    if (refType instanceof ClassType) {
        tag = JDWP.TypeTag.CLASS;
    } else if (refType instanceof InterfaceType) {
        // It's possible to have executable code in an interface
        tag = JDWP.TypeTag.INTERFACE;
    } else {
        throw new InternalException("Invalid Location");
    }
    writeByte(tag);
    writeClassRef(refType.ref());
    writeMethodRef(((MethodImpl)location.method()).ref());
    writeLong(location.codeIndex());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:PacketStream.java

示例2: getClassName

import com.sun.jdi.Location; //导入方法依赖的package包/类
private static String getClassName(StackFrameProxyImpl stackFrameProxy) {
  if (stackFrameProxy != null) {
    try {
      Location location = stackFrameProxy.location();
      if (location != null) {
        ReferenceType type = location.declaringType();
        if (type != null) {
          return type.name();
        }
      }
    }
    catch (EvaluateException ignore) {
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:AddSteppingFilterAction.java

示例3: getContextKeyForFrame

import com.sun.jdi.Location; //导入方法依赖的package包/类
@Nullable
public static String getContextKeyForFrame(final StackFrameProxyImpl frame) {
  if (frame == null) {
    return null;
  }
  try {
    final Location location = frame.location();
    final Method method = location.method();
    final ReferenceType referenceType = location.declaringType();
    final StringBuilder builder = StringBuilderSpinAllocator.alloc();
    try {
      return builder.append(referenceType.signature()).append("#").append(method.name()).append(method.signature()).toString();
    }
    finally {
      StringBuilderSpinAllocator.dispose(builder);
    }
  }
  catch (EvaluateException e) {
    return null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:NodeManagerImpl.java

示例4: getPsiFileByLocation

import com.sun.jdi.Location; //导入方法依赖的package包/类
@Nullable
@Override
protected PsiFile getPsiFileByLocation(Project project, Location location) {
  PsiFile psiFile = super.getPsiFileByLocation(project, location);
  if (psiFile != null) {
    return psiFile;
  }
  ReferenceType refType = location.declaringType();
  return refType != null ? qualifiedNameToPsiFile.get(refType.name()) : null;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:11,代码来源:ExternalFilePositionManager.java

示例5: getPsiFileByLocation

import com.sun.jdi.Location; //导入方法依赖的package包/类
@Nullable
private PsiFile getPsiFileByLocation(final Project project, final Location location) {
  if (location == null) {
    return null;
  }
  final ReferenceType refType = location.declaringType();
  if (refType == null) {
    return null;
  }

  if (DumbService.getInstance(project).isDumb()) {
    return null;
  }

  final String originalQName = refType.name();
  int dollar = originalQName.indexOf('$');
  final String qName = dollar >= 0 ? originalQName.substring(0, dollar) : originalQName;
  final GlobalSearchScope searchScope = myDebugProcess.getSearchScope();
  PsiClass psiClass = DebuggerUtils.findClass(qName, project, searchScope);
  if (psiClass == null && dollar >= 0 /*originalName and qName really differ*/) {
    psiClass = DebuggerUtils.findClass(originalQName, project, searchScope); // try to lookup original name
  }
  
  if (psiClass != null) {
    final PsiElement element = psiClass.getNavigationElement();
    return element.getContainingFile();
  }

  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:31,代码来源:PositionManagerImpl.java

示例6: getPsiFileByLocation

import com.sun.jdi.Location; //导入方法依赖的package包/类
@Nullable
protected PsiFile getPsiFileByLocation(final Project project, final Location location) {
  if (location == null) {
    return null;
  }
  final ReferenceType refType = location.declaringType();
  if (refType == null) {
    return null;
  }

  // We should find a class no matter what
  // setAlternativeResolveEnabled is turned on here
  //if (DumbService.getInstance(project).isDumb()) {
  //  return null;
  //}

  final String originalQName = refType.name();
  final GlobalSearchScope searchScope = myDebugProcess.getSearchScope();
  PsiClass psiClass = DebuggerUtils.findClass(originalQName, project, searchScope); // try to lookup original name first
  if (psiClass == null) {
    int dollar = originalQName.indexOf('$');
    if (dollar > 0) {
      final String qName = originalQName.substring(0, dollar);
      psiClass = DebuggerUtils.findClass(qName, project, searchScope);
    }
  }

  if (psiClass != null) {
    PsiElement element = psiClass.getNavigationElement();
    // see IDEA-137167, prefer not compiled elements
    if (element instanceof PsiCompiledElement) {
      PsiElement fileElement = psiClass.getContainingFile().getNavigationElement();
      if (!(fileElement instanceof PsiCompiledElement)) {
        element = fileElement;
      }
    }
    return element.getContainingFile();
  }
  else {
    // try to search by filename
    try {
      PsiFile[] files = FilenameIndex.getFilesByName(project, refType.sourceName(), GlobalSearchScope.allScope(project));
      for (PsiFile file : files) {
        if (file instanceof PsiJavaFile) {
          for (PsiClass cls : ((PsiJavaFile)file).getClasses()) {
            if (StringUtil.equals(originalQName, cls.getQualifiedName())) {
              return file;
            }
          }
        }
      }
    }
    catch (AbsentInformationException ignore) {
    }
  }

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

示例7: getSourcePosition

import com.sun.jdi.Location; //导入方法依赖的package包/类
public SourcePosition getSourcePosition(final Location location) throws NoDataException {
  DebuggerManagerThreadImpl.assertIsManagerThread();
  if(location == null) {
    return null;
  }

  PsiFile psiFile = getPsiFileByLocation(getDebugProcess().getProject(), location);
  if(psiFile == null ) {
    return null;
  }

  LOG.assertTrue(myDebugProcess != null);
  if (location == null) {
    return SourcePosition.createFromLine(psiFile, -1);
  }

  int lineNumber;
  try {
    lineNumber = location.lineNumber() - 1;
  }
  catch (InternalError e) {
    lineNumber = -1;
  }

  if (psiFile instanceof PsiCompiledElement || lineNumber < 0) {
    final String methodSignature = location.method().signature();
    if (methodSignature == null) {
      return SourcePosition.createFromLine(psiFile, -1);
    }
    final String methodName = location.method().name();
    if(methodName == null) {
      return SourcePosition.createFromLine(psiFile, -1);
    }
    if(location.declaringType() == null) {
      return SourcePosition.createFromLine(psiFile, -1);
    }

    final MethodFinder finder = new MethodFinder(location.declaringType().name(), methodSignature);
    psiFile.accept(finder);

    final PsiMethod compiledMethod = finder.getCompiledMethod();
    if (compiledMethod == null) {
      return SourcePosition.createFromLine(psiFile, -1);
    }
    return SourcePosition.createFromElement(compiledMethod);
  }

  return SourcePosition.createFromLine(psiFile, lineNumber);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:50,代码来源:PositionManagerImpl.java

示例8: handleExceptionThrown

import com.sun.jdi.Location; //导入方法依赖的package包/类
void handleExceptionThrown(final ExceptionEvent event) throws IncompatibleThreadStateException
{
  boolean mapException = false;
  // Check if the exception was thrown in-model
  final ReferenceType throwingType = event.location().declaringType();
  if (eventFilter().acceptsType(throwingType))
  {
    mapException = true;
  }
  else
  {
    // Check if the exception wasn't caught
    final Location catchLocation = event.catchLocation();
    if (catchLocation == null)
    {
      // Check if there are any in-model frames on the stack
      if (containsInModelFrames(event.thread(), null))
      {
        mapException = true;
      }
    }
    else
    {
      // Check if the exception was caught in-model
      final ReferenceType catchingType = catchLocation.declaringType();
      if (eventFilter().acceptsType(catchingType))
      {
        mapException = true;
      }
      else
      {
        // Check if there are any in-model frames between the
        // throw and catch locations
        if (containsInModelFrames(event.thread(), catchLocation))
        {
          mapException = true;
        }
      }
    }
  }
  if (mapException)
  {
    executionState().observedException(event.thread().uniqueID(), event);
  }
}
 
开发者ID:UBPL,项目名称:jive,代码行数:46,代码来源:JDIEventHandlerDelegate.java


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