From bbea4c78847aa16477ad99db0ca4c60164bc7e2c Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Wed, 30 Nov 2011 14:05:52 +0400 Subject: [PATCH 1/2] fix stub mismatch problem (caused by index being used noncommitted document for indexing that has the same document stamp as committed one) --- .../intellij/util/indexing/FileBasedIndex.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java index 37e3f6dc0c90..7bb4ac18757f 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java @@ -165,6 +165,7 @@ public class FileBasedIndex implements ApplicationComponent { synchronized (myTransactionMap) { myTransactionMap.remove(doc); } + incTransactionCount(doc); } }); @@ -1234,7 +1235,8 @@ public class FileBasedIndex implements ApplicationComponent { content = new AuthenticContent(document); } - final long currentDocStamp = content.getModificationStamp(); + final long currentDocStamp = content.getModificationStamp() + + getTransactionCount(document); // we add transaction count in order to deal with committed status if (currentDocStamp != myLastIndexedDocStamps.getAndSet(document, requestedIndexId, currentDocStamp)) { final Ref exRef = new Ref(null); ProgressManager.getInstance().executeNonCancelableSection(new Runnable() { @@ -1280,6 +1282,18 @@ public class FileBasedIndex implements ApplicationComponent { return true; } + public static final Key TRANSACTION_COUNT = new Key("Transaction count"); + + private long getTransactionCount(@NotNull Document document) { + Integer data = document.getUserData(TRANSACTION_COUNT); + return data != null ? data : 0; + } + + private void incTransactionCount(@NotNull Document document) { + Integer data = document.getUserData(TRANSACTION_COUNT); + document.putUserData(TRANSACTION_COUNT, (data != null ? data : 0) + 1); + } + public static final Key EDITOR_HIGHLIGHTER = new Key("Editor"); @Nullable From 3d55e6c38184840c9db550880d6606899d6a8144 Mon Sep 17 00:00:00 2001 From: Sascha Weinreuter Date: Wed, 30 Nov 2011 11:16:31 +0100 Subject: [PATCH 2/2] IDEA-77658 XSLT debug: breakpoint in xsl:sequence inside xsl:function is not hit --- .../local/saxon9/Saxon9TraceListener.java | 65 ++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9TraceListener.java b/plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9TraceListener.java index a50e0e4d5e4c..92e15e790085 100644 --- a/plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9TraceListener.java +++ b/plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9TraceListener.java @@ -17,13 +17,20 @@ package org.intellij.plugins.xsltDebugger.rt.engine.local.saxon9; import net.sf.saxon.expr.XPathContext; +import net.sf.saxon.expr.instruct.InstructionDetails; import net.sf.saxon.lib.TraceListener; import net.sf.saxon.om.Item; import net.sf.saxon.om.NodeInfo; import net.sf.saxon.style.StyleElement; import net.sf.saxon.trace.InstructionInfo; +import org.intellij.plugins.xsltDebugger.rt.engine.Debugger; +import org.intellij.plugins.xsltDebugger.rt.engine.Value; import org.intellij.plugins.xsltDebugger.rt.engine.local.LocalDebugger; +import javax.xml.transform.Source; +import javax.xml.transform.SourceLocator; +import java.util.List; + public class Saxon9TraceListener implements TraceListener { private static final boolean TRACE = "true".equals(System.getProperty("xslt.debugger.trace", "false")); @@ -63,6 +70,8 @@ public class Saxon9TraceListener implements TraceListener { } if (instructionInfo instanceof StyleElement) { myDebugger.enter(new Saxon9StyleFrame(myDebugger.getCurrentFrame(), (StyleElement)instructionInfo, xPathContext)); + } else if (instructionInfo instanceof InstructionDetails) { + myDebugger.enter(new VirtualFrame(myDebugger.getCurrentFrame(), (InstructionDetails)instructionInfo)); } } @@ -70,7 +79,7 @@ public class Saxon9TraceListener implements TraceListener { if (TRACE) { trace(""); } - if (instructionInfo instanceof StyleElement) { + if (instructionInfo instanceof StyleElement || instructionInfo instanceof InstructionDetails) { myDebugger.leave(); } } @@ -89,4 +98,58 @@ public class Saxon9TraceListener implements TraceListener { myDebugger.popSource(); } } + + private static class VirtualFrame extends AbstractSaxon9Frame implements Debugger.StyleFrame { + + public VirtualFrame(Debugger.StyleFrame previous, InstructionDetails instr) { + super(previous, new MySource(instr)); + } + + @Override + public String getInstruction() { + return getPrevious().getInstruction(); + } + + @Override + public Value eval(String expr) throws Debugger.EvaluationException { + return getPrevious().eval(expr); + } + + @Override + public List getVariables() { + return getPrevious().getVariables(); + } + + private static class MySource implements Source, SourceLocator { + private final InstructionDetails myInstruction; + + public MySource(InstructionDetails instr) { + myInstruction = instr; + } + + @Override + public void setSystemId(String systemId) { + } + + @Override + public String getPublicId() { + return null; + } + + @Override + public String getSystemId() { + return myInstruction.getSystemId(); + } + + @Override + public int getLineNumber() { + return myInstruction.getLineNumber(); + } + + @Override + public int getColumnNumber() { + return myInstruction.getColumnNumber(); + } + } + } } \ No newline at end of file