diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/run/XsltCommandLineState.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/run/XsltCommandLineState.java index 7e9e88d549c9..f1994c65e9ca 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/run/XsltCommandLineState.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/run/XsltCommandLineState.java @@ -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 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) { diff --git a/plugins/xslt-debugger/src/META-INF/plugin.xml b/plugins/xslt-debugger/src/META-INF/plugin.xml index 2670f2b5e4bf..c02c972de3da 100644 --- a/plugins/xslt-debugger/src/META-INF/plugin.xml +++ b/plugins/xslt-debugger/src/META-INF/plugin.xml @@ -20,7 +20,8 @@ - + + diff --git a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltBreakpointType.java b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltBreakpointType.java index dbfb1b09581e..65fa36c0ee2b 100644 --- a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltBreakpointType.java +++ b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltBreakpointType.java @@ -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 { +public abstract class XsltBreakpointType extends XLineBreakpointType { - 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 VERSION = Key.create("VERSION"); private static final Key PORT = Key.create("PORT"); private static final Key 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 { diff --git a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltDebuggerRunner.java b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltDebuggerRunner.java index 0aa7e9b17c83..b0b1939d56e3 100644 --- a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltDebuggerRunner.java +++ b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltDebuggerRunner.java @@ -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(); } diff --git a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltBreakpointHandler.java b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltBreakpointHandler.java index e5e69d9d7ca3..ce001241ad72 100644 --- a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltBreakpointHandler.java +++ b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltBreakpointHandler.java @@ -29,8 +29,8 @@ import org.jetbrains.annotations.Nullable; public class XsltBreakpointHandler extends XBreakpointHandler> { private XsltDebugProcess myXsltDebugProcess; - public XsltBreakpointHandler(XsltDebugProcess xsltDebugProcess) { - super(XsltBreakpointType.class); + public XsltBreakpointHandler(XsltDebugProcess xsltDebugProcess, final Class typeClass) { + super(typeClass); myXsltDebugProcess = xsltDebugProcess; } diff --git a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltDebugProcess.java b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltDebugProcess.java index 29ab7418c8ce..d108aea47652 100644 --- a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltDebugProcess.java +++ b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltDebugProcess.java @@ -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); } diff --git a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltDebuggerEditorsProvider.java b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltDebuggerEditorsProvider.java index 8872caf1f3c5..d1fec61805b3 100644 --- a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltDebuggerEditorsProvider.java +++ b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltDebuggerEditorsProvider.java @@ -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();