本文整理汇总了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());
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}