IDEA-77786: XSLT debug: on debugging 2.0 stylesheet highlighting in Evaluate Expression and Watches could follow 2.0 syntax

This commit is contained in:
Sascha Weinreuter
2011-11-29 15:34:31 +01:00
parent 2a3bc7116c
commit 160561505c
8 changed files with 75 additions and 21 deletions
@@ -54,7 +54,7 @@ import java.util.List;
import static org.intellij.lang.xpath.xslt.run.XsltRunConfiguration.isEmpty;
class XsltCommandLineState extends CommandLineState {
public class XsltCommandLineState extends CommandLineState {
private static final Logger LOG = Logger.getInstance(XsltCommandLineState.class.getName());
public static final Key<XsltCommandLineState> STATE = Key.create("STATE");
@@ -145,7 +145,8 @@ class XsltCommandLineState extends CommandLineState {
assert descriptor != null;
pluginPath = descriptor.getPath();
} else {
pluginPath = new File(System.getProperty("xslt.plugin.path"));
// -Dxslt.plugin.path=C:\work\java\intellij/ultimate\out\classes\production\xslt-rt
pluginPath = new File(System.getProperty("xslt.plugin.path"));
}
LOG.debug("Plugin Path = " + pluginPath.getAbsolutePath());
@@ -187,7 +188,11 @@ class XsltCommandLineState extends CommandLineState {
return myPort;
}
private class MyProcessAdapter extends ProcessAdapter {
public UserDataHolder getExtensionData() {
return myExtensionData;
}
private class MyProcessAdapter extends ProcessAdapter {
public void processTerminated(final ProcessEvent event) {
@@ -20,7 +20,8 @@
</change-notes>
<extensions defaultExtensionNs="com.intellij">
<xdebugger.breakpointType implementation="org.intellij.plugins.xsltDebugger.XsltBreakpointType"/>
<xdebugger.breakpointType implementation="org.intellij.plugins.xsltDebugger.XsltBreakpointType$V1"/>
<xdebugger.breakpointType implementation="org.intellij.plugins.xsltDebugger.XsltBreakpointType$V2"/>
<programRunner implementation="org.intellij.plugins.xsltDebugger.XsltDebuggerRunner"/>
</extensions>
@@ -13,6 +13,7 @@ import com.intellij.xdebugger.breakpoints.XLineBreakpointType;
import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider;
import com.intellij.xdebugger.ui.DebuggerIcons;
import org.intellij.lang.xpath.xslt.XsltSupport;
import org.intellij.lang.xpath.xslt.impl.XsltChecker;
import org.intellij.plugins.xsltDebugger.impl.XsltDebuggerEditorsProvider;
import org.jetbrains.annotations.NotNull;
@@ -23,12 +24,12 @@ import javax.swing.*;
* User: sweinreuter
* Date: 03.03.11
*/
public final class XsltBreakpointType extends XLineBreakpointType<XBreakpointProperties> {
public abstract class XsltBreakpointType extends XLineBreakpointType<XBreakpointProperties> {
private final XsltDebuggerEditorsProvider myMyEditorsProvider = new XsltDebuggerEditorsProvider();
private final XsltDebuggerEditorsProvider myMyEditorsProvider = new XsltDebuggerEditorsProvider(getLanguageLevel());
public XsltBreakpointType() {
super("xslt", "XSLT Breakpoints");
protected XsltBreakpointType(final String id) {
super(id, "XSLT Breakpoints");
}
@Override
@@ -44,9 +45,11 @@ public final class XsltBreakpointType extends XLineBreakpointType<XBreakpointPro
if (fileType != StdFileTypes.XML || !XsltSupport.isXsltFile(psiFile)) {
return false;
}
return true;
return getLanguageLevel() == XsltSupport.getXsltLanguageLevel(psiFile);
}
protected abstract XsltChecker.LanguageLevel getLanguageLevel();
@Override
public XDebuggerEditorsProvider getEditorsProvider() {
return myMyEditorsProvider;
@@ -68,4 +71,26 @@ public final class XsltBreakpointType extends XLineBreakpointType<XBreakpointPro
public XBreakpointProperties createBreakpointProperties(@NotNull VirtualFile file, int line) {
return null;
}
public static final class V1 extends XsltBreakpointType {
public V1() {
super("xslt");
}
@Override
protected XsltChecker.LanguageLevel getLanguageLevel() {
return XsltChecker.LanguageLevel.V1;
}
}
public static final class V2 extends XsltBreakpointType {
public V2() {
super("xslt2");
}
@Override
protected XsltChecker.LanguageLevel getLanguageLevel() {
return XsltChecker.LanguageLevel.V2;
}
}
}
@@ -61,6 +61,7 @@ import java.util.jar.Manifest;
public class XsltDebuggerExtension extends XsltRunnerExtension {
private static final Logger LOG = Logger.getInstance(XsltDebuggerExtension.class.getName());
public static final Key<XsltChecker.LanguageLevel> VERSION = Key.create("VERSION");
private static final Key<Integer> PORT = Key.create("PORT");
private static final Key<Manifest> MANIFEST = Key.create("MANIFEST");
@@ -133,6 +134,7 @@ public class XsltDebuggerExtension extends XsltRunnerExtension {
assert descriptor != null;
pluginPath = descriptor.getPath();
} else {
// -Dxslt-debugger.plugin.path=C:\work\java\intellij/ultimate\out\classes\production\xslt-debugger-engine
pluginPath = new File(System.getProperty("xslt-debugger.plugin.path"));
}
@@ -192,12 +194,20 @@ public class XsltDebuggerExtension extends XsltRunnerExtension {
parameters.getVMParametersList().defineProperty("xslt.transformer.type", "xalan");
}
}
final VirtualFile xsltFile = configuration.findXsltFile();
final PsiManager psiManager = PsiManager.getInstance(configuration.getProject());
final XsltChecker.LanguageLevel level;
if (xsltFile != null) {
level = XsltSupport.getXsltLanguageLevel(psiManager.findFile(xsltFile));
} else {
level = XsltChecker.LanguageLevel.V1;
}
extensionData.putUserData(VERSION, level);
if (!parameters.getVMParametersList().hasProperty("xslt.transformer.type")) {
// add saxon for backward-compatibility
final VirtualFile xsltFile = configuration.findXsltFile();
final PsiManager psiManager = PsiManager.getInstance(configuration.getProject());
if (xsltFile != null && XsltSupport.getXsltLanguageLevel(psiManager.findFile(xsltFile)) == XsltChecker.LanguageLevel.V2)
{
if (level == XsltChecker.LanguageLevel.V2) {
parameters.getVMParametersList().defineProperty("xslt.transformer.type", "saxon9");
addSaxon(parameters, pluginPath, SAXON_9_JAR);
} else {
@@ -14,6 +14,7 @@ import com.intellij.xdebugger.XDebugProcess;
import com.intellij.xdebugger.XDebugProcessStarter;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.XDebuggerManager;
import org.intellij.lang.xpath.xslt.run.XsltCommandLineState;
import org.intellij.lang.xpath.xslt.run.XsltRunConfiguration;
import org.intellij.plugins.xsltDebugger.impl.XsltDebugProcess;
import org.jetbrains.annotations.NonNls;
@@ -63,8 +64,9 @@ public class XsltDebuggerRunner extends DefaultProgramRunner {
public XDebugProcess start(@NotNull final XDebugSession session) throws ExecutionException {
ACTIVE.set(Boolean.TRUE);
try {
final XsltCommandLineState c = (XsltCommandLineState)runProfileState;
final ExecutionResult result = runProfileState.execute(executor, XsltDebuggerRunner.this);
return new XsltDebugProcess(session, result);
return new XsltDebugProcess(session, result, c.getExtensionData().getUserData(XsltDebuggerExtension.VERSION));
} finally {
ACTIVE.remove();
}
@@ -29,8 +29,8 @@ import org.jetbrains.annotations.Nullable;
public class XsltBreakpointHandler extends XBreakpointHandler<XLineBreakpoint<XBreakpointProperties>> {
private XsltDebugProcess myXsltDebugProcess;
public XsltBreakpointHandler(XsltDebugProcess xsltDebugProcess) {
super(XsltBreakpointType.class);
public XsltBreakpointHandler(XsltDebugProcess xsltDebugProcess, final Class<? extends XsltBreakpointType> typeClass) {
super(typeClass);
myXsltDebugProcess = xsltDebugProcess;
}
@@ -17,7 +17,9 @@ import com.intellij.xdebugger.breakpoints.XBreakpointHandler;
import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider;
import com.intellij.xdebugger.frame.XExecutionStack;
import com.intellij.xdebugger.frame.XSuspendContext;
import org.intellij.lang.xpath.xslt.impl.XsltChecker;
import org.intellij.plugins.xsltDebugger.VMPausedException;
import org.intellij.plugins.xsltDebugger.XsltBreakpointType;
import org.intellij.plugins.xsltDebugger.XsltDebuggerSession;
import org.intellij.plugins.xsltDebugger.rt.engine.Breakpoint;
import org.intellij.plugins.xsltDebugger.rt.engine.BreakpointManager;
@@ -38,16 +40,17 @@ public class XsltDebugProcess extends XDebugProcess implements Disposable {
private BreakpointManager myBreakpointManager = new BreakpointManagerImpl();
private final XBreakpointHandler<?>[] myXBreakpointHandlers = new XBreakpointHandler<?>[]{
new XsltBreakpointHandler(this)
new XsltBreakpointHandler(this, XsltBreakpointType.V1.class),
new XsltBreakpointHandler(this, XsltBreakpointType.V2.class)
};
private XsltDebuggerSession myDebuggerSession;
public XsltDebugProcess(XDebugSession session, ExecutionResult executionResult) {
public XsltDebugProcess(XDebugSession session, ExecutionResult executionResult, XsltChecker.LanguageLevel data) {
super(session);
myProcessHandler = executionResult.getProcessHandler();
myProcessHandler.putUserData(KEY, this);
myExecutionConsole = executionResult.getExecutionConsole();
myEditorsProvider = new XsltDebuggerEditorsProvider();
myEditorsProvider = new XsltDebuggerEditorsProvider(data);
Disposer.register(myExecutionConsole, this);
}
@@ -12,16 +12,24 @@ import com.intellij.xdebugger.XSourcePosition;
import com.intellij.xdebugger.evaluation.EvaluationMode;
import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider;
import org.intellij.lang.xpath.XPathFileType;
import org.intellij.lang.xpath.xslt.impl.XsltChecker;
import org.intellij.plugins.xsltDebugger.BreakpointContext;
import org.intellij.plugins.xsltDebugger.rt.engine.Debugger;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class XsltDebuggerEditorsProvider extends XDebuggerEditorsProvider {
private final XPathFileType myFileType;
public XsltDebuggerEditorsProvider(XsltChecker.LanguageLevel level) {
myFileType = level == XsltChecker.LanguageLevel.V2 ? XPathFileType.XPATH2 : XPathFileType.XPATH;
}
@NotNull
@Override
public FileType getFileType() {
return XPathFileType.XPATH;
return myFileType;
}
@NotNull
@@ -31,7 +39,7 @@ public class XsltDebuggerEditorsProvider extends XDebuggerEditorsProvider {
@Nullable XSourcePosition sourcePosition,
@NotNull EvaluationMode mode) {
final PsiFile psiFile = PsiFileFactory.getInstance(project)
.createFileFromText("XPathExpr.xpath", XPathFileType.XPATH, text, LocalTimeCounter.currentTime(), true);
.createFileFromText("XPathExpr." + myFileType.getDefaultExtension(), myFileType, text, LocalTimeCounter.currentTime(), true);
if (sourcePosition instanceof XsltSourcePosition && ((XsltSourcePosition)sourcePosition).getLocation() instanceof Debugger.StyleFrame) {
final Debugger.Locatable location = ((XsltSourcePosition)sourcePosition).getLocation();