本文整理汇总了Java中com.sun.jdi.Location.lineNumber方法的典型用法代码示例。如果您正苦于以下问题:Java Location.lineNumber方法的具体用法?Java Location.lineNumber怎么用?Java Location.lineNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jdi.Location
的用法示例。
在下文中一共展示了Location.lineNumber方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldHandleStepInto
import com.sun.jdi.Location; //导入方法依赖的package包/类
protected boolean shouldHandleStepInto(final Location location)
{
try
{
if (getOriginalStepStackDepth() != getUnderlyingFrameCount())
{
return true;
}
if (getOriginalStepLocation().lineNumber() != location.lineNumber())
{
return true;
}
return false;
}
catch (final DebugException e)
{
// TODO log error
return false;
}
}
示例2: computeLineRange
import com.sun.jdi.Location; //导入方法依赖的package包/类
private void computeLineRange(final int[] lineRange, final List<?> locations)
{
int lineFrom = -1;
int lineTo = -1;
for (final Object o : locations)
{
final Location location = (Location) o;
if (lineFrom == -1 || lineFrom > location.lineNumber())
{
lineFrom = location.lineNumber();
}
if (lineTo == -1 || lineTo < location.lineNumber())
{
lineTo = location.lineNumber();
}
}
lineRange[0] = lineFrom;
lineRange[1] = lineTo;
}
示例3: shouldDoExtraStepInto
import com.sun.jdi.Location; //导入方法依赖的package包/类
/**
* Check if the current top stack is same as the original top stack.
*
* @throws IncompatibleThreadStateException
* if the thread is not suspended in the target VM.
*/
private boolean shouldDoExtraStepInto(int originalStackDepth, Location originalLocation, int currentStackDepth, Location currentLocation)
throws IncompatibleThreadStateException {
if (originalStackDepth != currentStackDepth) {
return false;
}
if (originalLocation == null) {
return false;
}
Method originalMethod = originalLocation.method();
Method currentMethod = currentLocation.method();
if (!originalMethod.equals(currentMethod)) {
return false;
}
if (originalLocation.lineNumber() != currentLocation.lineNumber()) {
return false;
}
return true;
}
示例4: shouldHandleStepOver
import com.sun.jdi.Location; //导入方法依赖的package包/类
protected boolean shouldHandleStepOver(final Location location)
{
try
{
if (getOriginalStepStackDepth() == getUnderlyingFrameCount()
&& getOriginalStepLocation().lineNumber() != location.lineNumber())
{
return true;
}
if (getOriginalStepStackDepth() > getUnderlyingFrameCount())
{
return true;
}
return false;
}
catch (final DebugException e)
{
// TODO log error
return false;
}
}
示例5: resolveLine
import com.sun.jdi.Location; //导入方法依赖的package包/类
private ILineValue resolveLine(final Location location)
{
if (location != null)
{
try
{
final String fileName = location.sourcePath();
final int lineNumber = location.lineNumber();
return staticModelFactory().lookupLine(fileName, lineNumber);
}
catch (final AbsentInformationException e)
{
}
}
return valueFactory().createUnavailableLine();
}
示例6: printLocation
import com.sun.jdi.Location; //导入方法依赖的package包/类
protected void printLocation(SuspendContextImpl suspendContext) {
try {
Location location = suspendContext.getFrameProxy().location();
String message = "paused at " + location.sourceName() + ":" + location.lineNumber();
println(message, ProcessOutputTypes.SYSTEM);
}
catch (Throwable e) {
addException(e);
}
}
示例7: calcLineIndex
import com.sun.jdi.Location; //导入方法依赖的package包/类
private int calcLineIndex(Location location) {
LOG.assertTrue(myDebugProcess != null);
if (location == null) return -1;
try {
return location.lineNumber() - 1;
}
catch (InternalError e) {
return -1;
}
}
示例8: getLocationId
import com.sun.jdi.Location; //导入方法依赖的package包/类
public long getLocationId(final Location location)
{
final String sig = Signatures.getPrefixed(location);
Long sourceId = store.get(sig);
if (sourceId == null)
{
sourceId = register(Signatures.PREFIX_SOURCE, sig, SOURCE_ID.incrementAndGet());
}
final long lineId = location != null ? location.lineNumber() : EventHandlerLite.ID_NONE;
return ((EventHandlerLite.MASK_SOURCE_ID & sourceId) << EventHandlerLite.BITS_LINE_NO)
| (EventHandlerLite.MASK_LINE_NO & lineId);
}
示例9: findNested
import com.sun.jdi.Location; //导入方法依赖的package包/类
@Nullable
private ReferenceType findNested(final ReferenceType fromClass, final int currentDepth, final PsiClass classToFind, final int requiredDepth, final SourcePosition position) {
final VirtualMachineProxyImpl vmProxy = myDebugProcess.getVirtualMachineProxy();
if (fromClass.isPrepared()) {
try {
if (currentDepth < requiredDepth) {
final List<ReferenceType> nestedTypes = vmProxy.nestedTypes(fromClass);
for (ReferenceType nested : nestedTypes) {
final ReferenceType found = findNested(nested, currentDepth + 1, classToFind, requiredDepth, position);
if (found != null) {
return found;
}
}
return null;
}
int rangeBegin = Integer.MAX_VALUE;
int rangeEnd = Integer.MIN_VALUE;
for (Location location : fromClass.allLineLocations()) {
final int lnumber = location.lineNumber();
if (lnumber <= 1) {
// should be a native method, skipping
// sometimes compiler generates location where line number is exactly 1 (e.g. GWT)
// such locations are hardly correspond to real lines in code, so skipping them too
continue;
}
final Method method = location.method();
if (method == null || DebuggerUtils.isSynthetic(method) || method.isBridge()) {
// do not take into account synthetic stuff
continue;
}
int locationLine = lnumber - 1;
PsiFile psiFile = position.getFile().getOriginalFile();
if (psiFile instanceof PsiCompiledFile) {
locationLine = bytecodeToSourceLine(psiFile, locationLine);
if (locationLine < 0) continue;
}
rangeBegin = Math.min(rangeBegin, locationLine);
rangeEnd = Math.max(rangeEnd, locationLine);
}
final int positionLine = position.getLine();
if (positionLine >= rangeBegin && positionLine <= rangeEnd) {
// choose the second line to make sure that only this class' code exists on the line chosen
// Otherwise the line (depending on the offset in it) can contain code that belongs to different classes
// and JVMNameUtil.getClassAt(candidatePosition) will return the wrong class.
// Example of such line:
// list.add(new Runnable(){......
// First offsets belong to parent class, and offsets inside te substring "new Runnable(){" belong to anonymous runnable.
final int finalRangeBegin = rangeBegin;
final int finalRangeEnd = rangeEnd;
return ApplicationManager.getApplication().runReadAction(new NullableComputable<ReferenceType>() {
public ReferenceType compute() {
if (!classToFind.isValid()) {
return null;
}
final int line = Math.min(finalRangeBegin + 1, finalRangeEnd);
Set<PsiClass> lineClasses = getLineClasses(position.getFile(), line);
if (lineClasses.size() > 1) {
// if there's more than one class on the line - try to match by name
for (PsiClass aClass : lineClasses) {
if (classToFind.equals(aClass)) {
return fromClass;
}
}
}
else if (!lineClasses.isEmpty()){
return classToFind.equals(lineClasses.iterator().next())? fromClass : null;
}
return null;
}
});
}
}
catch (AbsentInformationException ignored) {
}
}
return null;
}
示例10: 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);
}
示例11: findNested
import com.sun.jdi.Location; //导入方法依赖的package包/类
@Nullable
private ReferenceType findNested(final ReferenceType fromClass, final PsiClass classToFind, SourcePosition classPosition) {
final VirtualMachineProxyImpl vmProxy = myDebugProcess.getVirtualMachineProxy();
if (fromClass.isPrepared()) {
final List<ReferenceType> nestedTypes = vmProxy.nestedTypes(fromClass);
try {
final int lineNumber = classPosition.getLine() + 1;
for (ReferenceType nested : nestedTypes) {
final ReferenceType found = findNested(nested, classToFind, classPosition);
if (found != null) {
// check if enclosing class also has executable code at the same line, and if yes, prefer enclosing class
return fromClass.locationsOfLine(lineNumber).isEmpty()? found : fromClass;
}
}
if (fromClass.locationsOfLine(lineNumber).size() > 0) {
return fromClass;
}
int rangeBegin = Integer.MAX_VALUE;
int rangeEnd = Integer.MIN_VALUE;
for (Location location : fromClass.allLineLocations()) {
final int locationLine = location.lineNumber() - 1;
rangeBegin = Math.min(rangeBegin, locationLine);
rangeEnd = Math.max(rangeEnd, locationLine);
}
if (classPosition.getLine() >= rangeBegin && classPosition.getLine() <= rangeEnd) {
// choose the second line to make sure that only this class' code exists on the line chosen
// Otherwise the line (depending on the offset in it) can contain code that belongs to different classes
// and JVMNameUtil.getClassAt(candidatePosition) will return the wrong class.
// Example of such line:
// list.add(new Runnable(){......
// First offsets belong to parent class, and offsets inside te substring "new Runnable(){" belong to anonymous runnable.
final int finalRangeBegin = rangeBegin;
final int finalRangeEnd = rangeEnd;
return ApplicationManager.getApplication().runReadAction(new NullableComputable<ReferenceType>() {
public ReferenceType compute() {
if (!classToFind.isValid()) {
return null;
}
final int line = Math.min(finalRangeBegin + 1, finalRangeEnd);
final SourcePosition candidatePosition = SourcePosition.createFromLine(classToFind.getContainingFile(), line);
return classToFind.equals(JVMNameUtil.getClassAt(candidatePosition)) ? fromClass : null;
}
});
}
}
catch (AbsentInformationException ignored) {
}
}
return null;
}