本文整理汇总了Java中com.intellij.debugger.SourcePosition.createFromElement方法的典型用法代码示例。如果您正苦于以下问题:Java SourcePosition.createFromElement方法的具体用法?Java SourcePosition.createFromElement怎么用?Java SourcePosition.createFromElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.debugger.SourcePosition
的用法示例。
在下文中一共展示了SourcePosition.createFromElement方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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);
}
示例4: getJVMQualifiedName
import com.intellij.debugger.SourcePosition; //导入方法依赖的package包/类
public static JVMName getJVMQualifiedName(@NotNull PsiClass psiClass) {
final String name = getNonAnonymousClassName(psiClass);
if (name != null) {
return getJVMRawText(name);
}
else {
return new JVMClassAt(SourcePosition.createFromElement(psiClass));
}
}