Skip to content

Commit 89542e6

Browse files
committed
new LaunchShortcuts don't work, needs debugging (NodeclispeDev Console);
update site, node perspective
1 parent 48ee285 commit 89542e6

File tree

12 files changed

+214
-119
lines changed

12 files changed

+214
-119
lines changed

org.nodeclipse.debug/README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,38 @@ in 2 classes: [LaunchConfigurationDelegate.java](https://github.com/Nodeclipse/n
2626

2727
org.nodeclipse.debug\src\org\nodeclipse\debug\launch\LaunchConfigurationDelegate.java
2828

29+
NodeclispeDev console is in .ui package,
30+
no need for
2931

32+
Import-Package: org.eclipse.ui.console
33+
34+
35+
## TODO
36+
37+
http://wiki.eclipse.org/FAQ_How_do_I_write_to_the_console_from_a_plug-in%3F
38+
39+
#### How to write a hyperlink to an eclipse console from a plugin
40+
41+
This may be used to show coffee compilation errors as links.
42+
43+
http://stackoverflow.com/questions/591018/how-to-write-a-hyperlink-to-an-eclipse-console-from-a-plugin
44+
45+
console = new MessageConsole("myconsole", null);
46+
console.activate();
47+
ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{ console });
48+
49+
IPath path = Path.fromOSString(filePath);
50+
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
51+
FileLink fileLink = new FileLink(file, null, -1, -1, -1);
52+
console.addHyperlink(fileLink, 10, 5);
53+
54+
### Many node instances running
55+
56+
currecntly `private static RuntimeProcess nodeProcess`, that is only one Node process may be running.
3057

3158
--debug-brk=5858
3259

3360
http://stackoverflow.com/questions/11947409/nodejs-eclipse-v8-deb
3461

35-
Port should be set per file basis, e.g. in Run Configuration
62+
Port should be set per file basis, e.g. in Run Configuration
63+

org.nodeclipse.debug/src/org/nodeclipse/debug/launch/LaunchConfigurationDelegate.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.nodeclipse.debug.util.NodeDebugUtil;
3131
import org.nodeclipse.debug.util.VariablesUtil;
3232
import org.nodeclipse.ui.Activator;
33+
import org.nodeclipse.ui.NodeclipseConsole;
3334
import org.nodeclipse.ui.preferences.PreferenceConstants;
3435

3536
/**
@@ -60,6 +61,7 @@ public void launch(ILaunchConfiguration configuration, String mode,
6061
return;
6162
}
6263

64+
6365
// Using configuration to build command line
6466
IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
6567
String nodePath= preferenceStore.getString(PreferenceConstants.NODE_PATH);
@@ -76,6 +78,7 @@ public void launch(ILaunchConfiguration configuration, String mode,
7678
List<String> cmdLine = new ArrayList<String>();
7779
// Application path should be stored in preference.
7880
cmdLine.add(nodePath);
81+
7982
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
8083
// -brk says to Node runtime wait until Chromium Debugger starts and connects
8184
// that is causing "stop on first line" behavior,
@@ -178,6 +181,11 @@ public void launch(ILaunchConfiguration configuration, String mode,
178181
envp[idx++] = key + "=" + value;
179182
}
180183

184+
for(String s : cmdLine){
185+
NodeclipseConsole.write(s+" ");
186+
}
187+
NodeclipseConsole.write("\n");
188+
181189
String[] cmds = {};
182190
cmds = cmdLine.toArray(cmds);
183191
// Launch a process to debug.eg,

org.nodeclipse.debug/src/org/nodeclipse/debug/launch/LaunchShortcutCoffeeCompile.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
44
import org.nodeclipse.debug.util.Constants;
5+
import org.nodeclipse.ui.NodeclipseConsole;
56

67
/**
78
* Using "Run As" --> "coffee -c" will lead here
@@ -13,6 +14,7 @@ public class LaunchShortcutCoffeeCompile extends LaunchShortcut{
1314

1415
@Override
1516
protected void setMoreAttributes(ILaunchConfigurationWorkingCopy workingCopy) {
17+
NodeclipseConsole.write("LaunchShortcutCoffeeCompile\n");
1618
workingCopy.setAttribute(Constants.ATTR_COFFEE_COMPILE, "-c"); // any value
1719
}
1820
}

org.nodeclipse.debug/src/org/nodeclipse/debug/launch/LaunchShortcutTypescriptCompiler.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
44
import org.nodeclipse.debug.util.Constants;
5+
import org.nodeclipse.ui.NodeclipseConsole;
56

67
/**
78
* Using "Run As" --> "tsc" will lead here
@@ -13,6 +14,7 @@ public class LaunchShortcutTypescriptCompiler extends LaunchShortcut{
1314

1415
@Override
1516
protected void setMoreAttributes(ILaunchConfigurationWorkingCopy workingCopy) {
17+
NodeclipseConsole.write("LaunchShortcutTypescriptCompiler\n");
1618
workingCopy.setAttribute(Constants.ATTR_TYPESCRIPT_COMPILER, "tsc"); // any value
1719
}
1820
}

org.nodeclipse.debug/src/org/nodeclipse/debug/launch/LaunchShortcutWithMonitor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
44
import org.nodeclipse.debug.util.Constants;
5+
import org.nodeclipse.ui.NodeclipseConsole;
56

67
/**
78
* Using "Run As" --> "Node with monitor" will lead here
@@ -13,6 +14,7 @@ public class LaunchShortcutWithMonitor extends LaunchShortcut{
1314

1415
@Override
1516
protected void setMoreAttributes(ILaunchConfigurationWorkingCopy workingCopy) {
17+
NodeclipseConsole.write("LaunchShortcutWithMonitor\n");
1618
workingCopy.setAttribute(Constants.ATTR_NODE_MONITOR, "e.g. node_dev"); // any value
1719
}
1820
}

org.nodeclipse.site/category.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<site>
3-
<category-def name="Nodeclipse" label="Nodeclipse">
3+
<category-def name="Nodeclipse" label="Nodeclipse Core (nodeclispe-1)">
44
<description>
55
Nodeclipse-1 core, Chromium tools
66
</description>
77
</category-def>
8-
<category-def name="npm-bundle" label="Node package module bundle">
8+
<category-def name="npm-bundle" label="Optional Node.js modules bundles">
99
<description>
1010
No need to install these plug-ins, if you have already installed these Node.js packages using npm (e.g. npm installl express -g).
1111
</description>
1212
</category-def>
13-
<category-def name="Tools" label="Tools">
13+
<category-def name="Tools" label="Enide NodeX Tools">
1414
<description>
1515
Markdown Editor, JSHInt integration
1616
</description>
@@ -43,7 +43,7 @@
4343
<feature url="features/com.eclipsesource.jshint.feature" id="com.eclipsesource.jshint.feature" version="0.9.8.qualifier">
4444
<category name="Tools"/>
4545
</feature>
46-
<feature url="features/de.bastiankrol.startexplorer.feature_1.4.1.jar" id="de.bastiankrol.startexplorer.feature" version="1.4.1">
46+
<feature url="features/de.bastiankrol.startexplorer.feature_1.5.0.jar" id="de.bastiankrol.startexplorer.feature" version="1.5.0">
4747
<category name="Tools"/>
4848
</feature>
4949

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package org.nodeclipse.ui;
2+
3+
import java.io.IOException;
4+
5+
import org.eclipse.ui.console.ConsolePlugin;
6+
import org.eclipse.ui.console.IConsole;
7+
import org.eclipse.ui.console.IOConsoleOutputStream;
8+
import org.eclipse.ui.console.MessageConsole;
9+
10+
/**
11+
* For tracing node launch parameters
12+
*
13+
* @author pverest
14+
*
15+
*/
16+
public class NodeclipseConsole {
17+
18+
private static NodeclipseConsole instance = null;
19+
private static IOConsoleOutputStream stream = null;
20+
21+
public NodeclipseConsole() {
22+
MessageConsole console = new MessageConsole("NodeclipseDev", null);
23+
console.activate();
24+
ConsolePlugin.getDefault().getConsoleManager()
25+
.addConsoles(new IConsole[] { console });
26+
stream = console.newOutputStream();
27+
}
28+
29+
private static NodeclipseConsole getInstance() {
30+
if (instance == null)
31+
instance = new NodeclipseConsole();
32+
return instance;
33+
}
34+
35+
public static void write(String s) {
36+
instance = getInstance();
37+
try {
38+
stream.write(s);
39+
} catch (IOException e) {
40+
e.printStackTrace();
41+
}
42+
}
43+
44+
@Override
45+
public void finalize() {
46+
try {
47+
stream.close();
48+
} catch (IOException e) {
49+
e.printStackTrace();
50+
}
51+
}
52+
53+
}
Lines changed: 94 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,94 @@
1-
package org.nodeclipse.ui.npm;
2-
3-
import java.io.File;
4-
import java.util.ArrayList;
5-
import java.util.List;
6-
7-
import org.eclipse.core.resources.ResourcesPlugin;
8-
import org.eclipse.core.runtime.CoreException;
9-
import org.eclipse.core.runtime.IProgressMonitor;
10-
import org.eclipse.debug.core.DebugPlugin;
11-
import org.eclipse.debug.core.ILaunch;
12-
import org.eclipse.debug.core.ILaunchConfiguration;
13-
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
14-
import org.nodeclipse.ui.Activator;
15-
import org.nodeclipse.ui.preferences.PreferenceConstants;
16-
import org.nodeclipse.ui.util.Constants;
17-
import org.nodeclipse.ui.util.OSUtils;
18-
19-
public class LaunchConfigurationDelegate implements ILaunchConfigurationDelegate {
20-
21-
/*
22-
* (non-Javadoc)
23-
*
24-
* @see
25-
* org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.
26-
* eclipse.debug.core.ILaunchConfiguration, java.lang.String,
27-
* org.eclipse.debug.core.ILaunch,
28-
* org.eclipse.core.runtime.IProgressMonitor)
29-
*/
30-
@Override
31-
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
32-
// Using configuration to build command line
33-
List<String> cmdLine = new ArrayList<String>();
34-
String nodePath = Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.NODE_PATH);
35-
cmdLine.add(findNpm(nodePath));
36-
37-
String goal = configuration.getAttribute(Constants.KEY_GOAL, Constants.BLANK_STRING);
38-
cmdLine.add(goal);
39-
String file = configuration.getAttribute(Constants.KEY_FILE_PATH, Constants.BLANK_STRING);
40-
String filePath = ResourcesPlugin.getWorkspace().getRoot().findMember(file).getLocation().toOSString();
41-
42-
String[] cmds = {};
43-
cmds = cmdLine.toArray(cmds);
44-
Process p = null;
45-
if(OSUtils.isMacOS()) {
46-
String[] env = {"PATH=" + nodePath.substring(0, nodePath.lastIndexOf(File.separator))};
47-
p = DebugPlugin.exec(cmds, (new File(filePath)).getParentFile(), env);
48-
} else {
49-
p = DebugPlugin.exec(cmds, (new File(filePath)).getParentFile());
50-
}
51-
DebugPlugin.newProcess(launch, p, Constants.NPM_PROCESS_MESSAGE + goal);
52-
}
53-
54-
private static String findNpm(String nodePath) {
55-
// Application path should be stored in preference.
56-
String npmFileName = getNpmFileName();
57-
String npmPath = nodePath.substring(0, nodePath.lastIndexOf(File.separator) + 1) + npmFileName;
58-
File npmFile = new File(npmPath);
59-
if(npmFile.exists()) {
60-
return npmFile.getAbsolutePath();
61-
}
62-
63-
String path = System.getenv("PATH");
64-
String[] paths = path.split("" + File.pathSeparatorChar, 0);
65-
List<String> directories = new ArrayList<String>();
66-
for(String p : paths) {
67-
directories.add(p);
68-
}
69-
70-
// ensure /usr/local/bin is included for OS X
71-
if (OSUtils.isMacOS()) {
72-
directories.add("/usr/local/bin");
73-
}
74-
75-
// search for Node.js in the PATH directories
76-
for (String directory : directories) {
77-
npmFile = new File(directory, npmFileName);
78-
79-
if (npmFile.exists()) {
80-
return npmFile.getAbsolutePath();
81-
}
82-
}
83-
84-
throw new IllegalStateException("Could not find npm.");
85-
}
86-
87-
private static String getNpmFileName() {
88-
if (OSUtils.isWindows()) {
89-
return "npm.cmd";
90-
}
91-
92-
return "npm";
93-
}
94-
}
1+
package org.nodeclipse.ui.npm;
2+
3+
import java.io.File;
4+
import java.util.ArrayList;
5+
import java.util.List;
6+
7+
import org.eclipse.core.resources.ResourcesPlugin;
8+
import org.eclipse.core.runtime.CoreException;
9+
import org.eclipse.core.runtime.IProgressMonitor;
10+
import org.eclipse.debug.core.DebugPlugin;
11+
import org.eclipse.debug.core.ILaunch;
12+
import org.eclipse.debug.core.ILaunchConfiguration;
13+
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
14+
import org.nodeclipse.ui.Activator;
15+
import org.nodeclipse.ui.preferences.PreferenceConstants;
16+
import org.nodeclipse.ui.util.Constants;
17+
import org.nodeclipse.ui.util.OSUtils;
18+
19+
public class LaunchConfigurationDelegate implements ILaunchConfigurationDelegate {
20+
21+
/*
22+
* (non-Javadoc)
23+
*
24+
* @see
25+
* org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.
26+
* eclipse.debug.core.ILaunchConfiguration, java.lang.String,
27+
* org.eclipse.debug.core.ILaunch,
28+
* org.eclipse.core.runtime.IProgressMonitor)
29+
*/
30+
@Override
31+
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
32+
// Using configuration to build command line
33+
List<String> cmdLine = new ArrayList<String>();
34+
String nodePath = Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.NODE_PATH);
35+
cmdLine.add(findNpm(nodePath));
36+
37+
String goal = configuration.getAttribute(Constants.KEY_GOAL, Constants.BLANK_STRING);
38+
cmdLine.add(goal);
39+
String file = configuration.getAttribute(Constants.KEY_FILE_PATH, Constants.BLANK_STRING);
40+
String filePath = ResourcesPlugin.getWorkspace().getRoot().findMember(file).getLocation().toOSString();
41+
42+
String[] cmds = {};
43+
cmds = cmdLine.toArray(cmds);
44+
Process p = null;
45+
if(OSUtils.isMacOS()) {
46+
String[] env = {"PATH=" + nodePath.substring(0, nodePath.lastIndexOf(File.separator))};
47+
p = DebugPlugin.exec(cmds, (new File(filePath)).getParentFile(), env);
48+
} else {
49+
p = DebugPlugin.exec(cmds, (new File(filePath)).getParentFile());
50+
}
51+
DebugPlugin.newProcess(launch, p, Constants.NPM_PROCESS_MESSAGE + goal);
52+
}
53+
54+
private static String findNpm(String nodePath) {
55+
//TODO npm application path should be stored in preference.
56+
String npmFileName = getNpmFileName();
57+
String npmPath = nodePath.substring(0, nodePath.lastIndexOf(File.separator) + 1) + npmFileName;
58+
File npmFile = new File(npmPath);
59+
if(npmFile.exists()) {
60+
return npmFile.getAbsolutePath();
61+
}
62+
63+
String path = System.getenv("PATH");
64+
String[] paths = path.split("" + File.pathSeparatorChar, 0);
65+
List<String> directories = new ArrayList<String>();
66+
for(String p : paths) {
67+
directories.add(p);
68+
}
69+
70+
// ensure /usr/local/bin is included for OS X
71+
if (OSUtils.isMacOS()) {
72+
directories.add("/usr/local/bin");
73+
}
74+
75+
// search for Node.js in the PATH directories
76+
for (String directory : directories) {
77+
npmFile = new File(directory, npmFileName);
78+
79+
if (npmFile.exists()) {
80+
return npmFile.getAbsolutePath();
81+
}
82+
}
83+
84+
throw new IllegalStateException("Could not find npm.");
85+
}
86+
87+
private static String getNpmFileName() {
88+
if (OSUtils.isWindows()) {
89+
return "npm.cmd";
90+
}
91+
92+
return "npm";
93+
}
94+
}

0 commit comments

Comments
 (0)