recalculate invalid psi elements if possible

This commit is contained in:
Eugene Zhuravlev
2011-12-09 16:39:40 +01:00
parent 91ed2272c9
commit fea83b914a
2 changed files with 14 additions and 2 deletions
@@ -101,7 +101,8 @@ public final class DebuggerContextImpl implements DebuggerContext {
public PsiElement getContextElement() {
LOG.assertTrue(myInitialized);
if(myContextElement != null && !myContextElement.isValid()) {
PsiElement contextElement = myContextElement;
if(contextElement != null && !contextElement.isValid()) {
myContextElement = ContextUtil.getContextElement(mySourcePosition);
}
return myContextElement;
@@ -107,7 +107,7 @@ public abstract class SourcePosition implements Navigatable{
}
private void updateData() {
if(myModificationStamp != myFile.getModificationStamp()) {
if(dataUpdateNeeded()) {
myModificationStamp = myFile.getModificationStamp();
myLine = null;
myOffset = null;
@@ -115,6 +115,17 @@ public abstract class SourcePosition implements Navigatable{
}
}
private boolean dataUpdateNeeded() {
if (myModificationStamp != myFile.getModificationStamp()) {
return true;
}
final PsiElement psiElement = myPsiElement;
if (psiElement != null && !psiElement.isValid()) {
return true;
}
return false;
}
public int getLine() {
updateData();
if (myLine == null) {