本文整理汇总了Java中com.intellij.debugger.impl.PositionUtil类的典型用法代码示例。如果您正苦于以下问题:Java PositionUtil类的具体用法?Java PositionUtil怎么用?Java PositionUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PositionUtil类属于com.intellij.debugger.impl包,在下文中一共展示了PositionUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSourcePositionForLocalVariable
import com.intellij.debugger.impl.PositionUtil; //导入依赖的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);
}
示例2: getPsiField
import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
public PsiField getPsiField() {
final SourcePosition sourcePosition = getSourcePosition();
try {
final PsiField field = ApplicationManager.getApplication().runReadAction(new Computable<PsiField>() {
@Override
public PsiField compute() {
final PsiClass psiClass = getPsiClassAt(sourcePosition);
return psiClass != null ? psiClass.findFieldByName(getFieldName(), true) : null;
}
});
if (field != null) {
return field;
}
} catch (IndexNotReadyException ignored) {}
return PositionUtil.getPsiElementAt(getProject(), PsiField.class, sourcePosition);
}
示例3: reload
import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
@Override
protected void reload(PsiFile psiFile) {
super.reload(psiFile);
PsiField field = PositionUtil.getPsiElementAt(getProject(), PsiField.class, getSourcePosition());
if(field != null) {
setFieldName(field.getName());
PsiClass psiClass = field.getContainingClass();
if (psiClass != null) {
getProperties().myClassName = psiClass.getQualifiedName();
}
myIsStatic = field.hasModifierProperty(PsiModifier.STATIC);
}
if (myIsStatic) {
setInstanceFiltersEnabled(false);
}
}
示例4: getDescriptorEvaluation
import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
@Override
public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException {
PsiElementFactory elementFactory = JavaPsiFacade.getInstance(context.getProject()).getElementFactory();
String fieldName;
if(isStatic()) {
String typeName = myField.declaringType().name().replace('$', '.');
typeName = DebuggerTreeNodeExpression.normalize(typeName, PositionUtil.getContextElement(context), context.getProject());
fieldName = typeName + "." + getName();
}
else {
//noinspection HardCodedStringLiteral
fieldName = isOuterLocalVariableValue()? StringUtil.trimStart(getName(), OUTER_LOCAL_VAR_FIELD_PREFIX) : "this." + getName();
}
try {
return elementFactory.createExpressionFromText(fieldName, null);
}
catch (IncorrectOperationException e) {
throw new EvaluateException(DebuggerBundle.message("error.invalid.field.name", getName()), e);
}
}
示例5: printContextWithText
import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
protected void printContextWithText(final StackFrameContext context) {
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
if (context.getFrameProxy() != null) {
SourcePosition sourcePosition = PositionUtil.getSourcePosition(context);
int offset = sourcePosition.getOffset();
Document document = PsiDocumentManager.getInstance(myProject).getDocument(sourcePosition.getFile());
CharSequence text = document.getImmutableCharSequence();
String positionText = "";
if (offset > -1) {
positionText = StringUtil.escapeLineBreak(" [" + text.subSequence(Math.max(0, offset - 20), offset) + "<*>"
+ text.subSequence(offset, Math.min(offset + 20, text.length())) + "]");
}
println(sourcePosition.getFile().getVirtualFile().getName()
+ ":" + sourcePosition.getLine()
+ positionText,
ProcessOutputTypes.SYSTEM);
}
else {
println("Context thread is null", ProcessOutputTypes.SYSTEM);
}
}
});
}
示例6: getSourcePosition
import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
public SourcePosition getSourcePosition(final Project project, final DebuggerContextImpl context) {
StackFrameProxyImpl frame = context.getFrameProxy();
if (frame == null) return null;
PsiElement place = PositionUtil.getContextElement(context);
if (place == null) {
return null;
}
PsiVariable psiVariable = JavaPsiFacade.getInstance(project).getResolveHelper().resolveReferencedVariable(getName(), place);
if (psiVariable == null) {
return null;
}
PsiFile containingFile = psiVariable.getContainingFile();
if(containingFile == null) return null;
return SourcePosition.createFromOffset(containingFile, psiVariable.getTextOffset());
}
示例7: getDescriptorEvaluation
import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException {
PsiElementFactory elementFactory = JavaPsiFacade.getInstance(context.getProject()).getElementFactory();
String fieldName;
if(isStatic()) {
String typeName = myField.declaringType().name().replace('$', '.');
typeName = DebuggerTreeNodeExpression.normalize(typeName, PositionUtil.getContextElement(context), context.getProject());
fieldName = typeName + "." + getName();
}
else {
//noinspection HardCodedStringLiteral
fieldName = isOuterLocalVariableValue()? StringUtil.trimStart(getName(), OUTER_LOCAL_VAR_FIELD_PREFIX) : "this." + getName();
}
try {
return elementFactory.createExpressionFromText(fieldName, null);
}
catch (IncorrectOperationException e) {
throw new EvaluateException(DebuggerBundle.message("error.invalid.field.name", getName()), e);
}
}
示例8: getSourcePositionForLocalVariable
import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
@Nullable
private 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);
}
示例9: getPsiField
import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
public PsiField getPsiField()
{
final SourcePosition sourcePosition = getSourcePosition();
final PsiField field = ApplicationManager.getApplication().runReadAction(new Computable<PsiField>()
{
@Override
public PsiField compute()
{
final PsiClass psiClass = getPsiClassAt(sourcePosition);
return psiClass != null ? psiClass.findFieldByName(getFieldName(), true) : null;
}
});
if(field != null)
{
return field;
}
return PositionUtil.getPsiElementAt(getProject(), PsiField.class, sourcePosition);
}
示例10: reload
import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
@Override
protected void reload(PsiFile psiFile)
{
super.reload(psiFile);
PsiField field = PositionUtil.getPsiElementAt(getProject(), PsiField.class, getSourcePosition());
if(field != null)
{
setFieldName(field.getName());
PsiClass psiClass = field.getContainingClass();
if(psiClass != null)
{
getProperties().myClassName = psiClass.getQualifiedName();
}
myIsStatic = field.hasModifierProperty(PsiModifier.STATIC);
}
if(myIsStatic)
{
setInstanceFiltersEnabled(false);
}
}
示例11: getDescriptorEvaluation
import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
@Override
public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException
{
PsiElementFactory elementFactory = JavaPsiFacade.getInstance(myProject).getElementFactory();
String fieldName;
if(isStatic())
{
String typeName = myField.declaringType().name().replace('$', '.');
typeName = DebuggerTreeNodeExpression.normalize(typeName, PositionUtil.getContextElement(context), myProject);
fieldName = typeName + "." + getName();
}
else
{
//noinspection HardCodedStringLiteral
fieldName = isOuterLocalVariableValue() ? StringUtil.trimStart(getName(), OUTER_LOCAL_VAR_FIELD_PREFIX) : "this." + getName();
}
try
{
return elementFactory.createExpressionFromText(fieldName, null);
}
catch(IncorrectOperationException e)
{
throw new EvaluateException(DebuggerBundle.message("error.invalid.field.name", getName()), e);
}
}
示例12: resolveVariable
import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
@Nullable
private static PsiVariable resolveVariable(final StackFrameProxy frame,
final String name,
final Project project,
final DebugProcess process) {
return ApplicationManager.getApplication().runReadAction(new Computable<PsiVariable>() {
@Override
public PsiVariable compute() {
PsiElement place = PositionUtil.getContextElement(new SimpleStackFrameContext(frame, process));
if (place == null) return null;
return JavaPsiFacade.getInstance(project).getResolveHelper().resolveReferencedVariable(name, place);
}
});
}
示例13: getDescriptorEvaluation
import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException {
PsiElementFactory elementFactory = JavaPsiFacade.getInstance(context.getProject()).getElementFactory();
try {
return elementFactory.createExpressionFromText(getName(), PositionUtil.getContextElement(context));
}
catch (IncorrectOperationException e) {
throw new EvaluateException(DebuggerBundle.message("error.invalid.local.variable.name", getName()), e);
}
}
示例14: getDescriptorEvaluation
import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
@Override
public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException {
PsiElementFactory elementFactory = JavaPsiFacade.getInstance(context.getProject()).getElementFactory();
try {
return elementFactory.createExpressionFromText(getName(), PositionUtil.getContextElement(context));
}
catch (IncorrectOperationException e) {
throw new EvaluateException(DebuggerBundle.message("error.invalid.local.variable.name", getName()), e);
}
}
示例15: printContext
import com.intellij.debugger.impl.PositionUtil; //导入依赖的package包/类
protected void printContext(final StackFrameContext context) {
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
if (context.getFrameProxy() != null) {
SourcePosition sourcePosition = PositionUtil.getSourcePosition(context);
println(sourcePosition.getFile().getVirtualFile().getName() + ":" + sourcePosition.getLine(), ProcessOutputTypes.SYSTEM);
}
else {
println("Context thread is null", ProcessOutputTypes.SYSTEM);
}
}
});
}