-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The support for method header breakpoints was extended to support lambda breakpoints using the vscode inline breakpoint feature.
- Loading branch information
Showing
8 changed files
with
199 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
...oft.java.debug.plugin/src/main/java/com/microsoft/java/debug/LambdaExpressionLocator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package com.microsoft.java.debug; | ||
|
||
import org.eclipse.jdt.core.dom.ASTNode; | ||
import org.eclipse.jdt.core.dom.ASTVisitor; | ||
import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; | ||
import org.eclipse.jdt.core.dom.CompilationUnit; | ||
import org.eclipse.jdt.core.dom.IMethodBinding; | ||
import org.eclipse.jdt.core.dom.LambdaExpression; | ||
|
||
public class LambdaExpressionLocator extends ASTVisitor { | ||
private CompilationUnit compilationUnit; | ||
private int line; | ||
private int column; | ||
private boolean found; | ||
|
||
private IMethodBinding lambdaMethodBinding; | ||
private LambdaExpression lambdaExpression; | ||
|
||
public LambdaExpressionLocator(CompilationUnit compilationUnit, int line, int column) { | ||
this.compilationUnit = compilationUnit; | ||
this.line = line; | ||
this.column = column; | ||
} | ||
|
||
@Override | ||
public boolean visit(LambdaExpression node) { | ||
if (column > -1) { | ||
int startPosition = node.getStartPosition(); | ||
|
||
int columnNumber = this.compilationUnit.getColumnNumber(startPosition); | ||
int lineNumber = this.compilationUnit.getLineNumber(startPosition); | ||
|
||
if (column == columnNumber && lineNumber == line) { | ||
this.lambdaMethodBinding = node.resolveMethodBinding(); | ||
this.found = true; | ||
this.lambdaExpression = node; | ||
return false; | ||
} | ||
} | ||
return super.visit(node); | ||
} | ||
|
||
/** | ||
* Returns <code>true</code> if a lambda is found at given location. | ||
*/ | ||
public boolean isFound() { | ||
return found; | ||
} | ||
|
||
/** | ||
* Returns the signature of lambda method otherwise return null. | ||
*/ | ||
public String getMethodSignature() { | ||
if (!this.found) { | ||
return null; | ||
} | ||
return BreakpointLocationLocator.toSignature(this.lambdaMethodBinding, getMethodName()); | ||
} | ||
|
||
/** | ||
* Returns the name of lambda method otherwise return null. | ||
*/ | ||
public String getMethodName() { | ||
if (!this.found) { | ||
return null; | ||
} | ||
String key = this.lambdaMethodBinding.getKey(); | ||
return key.substring(key.indexOf('.') + 1, key.indexOf('(')); | ||
} | ||
|
||
/** | ||
* Returns the name of the type which the lambda method is found. | ||
*/ | ||
public String getFullyQualifiedTypeName() { | ||
if (this.found) { | ||
ASTNode parent = lambdaExpression.getParent(); | ||
while (parent != null) { | ||
if (parent instanceof AbstractTypeDeclaration) { | ||
AbstractTypeDeclaration declaration = (AbstractTypeDeclaration) parent; | ||
return declaration.resolveBinding().getBinaryName(); | ||
} | ||
parent = parent.getParent(); | ||
} | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters