Skip to content

Commit 48ee285

Browse files
committed
coffee -c, tsc; add new Preferences for 0.6; update help (coffee,
typescript, node.js)
1 parent 5dc238c commit 48ee285

20 files changed

Lines changed: 450 additions & 59 deletions

org.nodeclipse.debug/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ Open `plugin.xml`, in "Testing" section click "Launch an Eclipse application"
1717
2. create new `public class LaunchShortcutName implements ILaunchShortcut`
1818

1919

20-
## TODO notes
20+
## notes
2121

22-
debug port 5858 is hard-coded
22+
debug port 5858 was hard-coded
2323

24-
in 2 classes: [LaunchConfigurationDelegate](https://github.com/Nodeclipse/nodeclipse-1/blob/master/org.nodeclipse.debug/src/org/nodeclipse/debug/launch/LaunchConfigurationDelegate.java)
24+
in 2 classes: [LaunchConfigurationDelegate.java](https://github.com/Nodeclipse/nodeclipse-1/blob/master/org.nodeclipse.debug/src/org/nodeclipse/debug/launch/LaunchConfigurationDelegate.java)
2525
& NodeDebugUtil
2626

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

org.nodeclipse.debug/plugin.xml

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@
2222
modes="run, debug"
2323
name="Node Application">
2424
</launchConfigurationType>
25-
<!-- node run/debug with monitor (not yet used)-->
25+
<!-- node run/debug with monitor (not yet used)
2626
<launchConfigurationType
2727
delegate="org.nodeclipse.debug.launch.LaunchConfigurationDelegate"
2828
id="org.nodeclipse.debug.launch.LaunchTypeWithMonitor"
2929
modes="run, debug"
3030
name="Node with monitor">
3131
</launchConfigurationType>
32+
-->
3233
<launchConfigurationType
3334
id="org.nodeclipse.debug.launch.LaunchType$StandaloneV8"
3435
delegate="org.nodeclipse.debug.launch.StandaloneV8LaunchTypeWrapper"
@@ -140,7 +141,7 @@
140141
<count
141142
value= "1" >
142143
</count>
143-
<iterate> <!-- TODO how to? 3 filenameext -->
144+
<iterate>
144145
<or>
145146
<test
146147
property= "org.eclipse.debug.ui.matchesPattern"
@@ -155,7 +156,78 @@
155156
value= "*.coffee.md" >
156157
</test>
157158
</or>
158-
159+
</iterate>
160+
</with>
161+
</enablement>
162+
</contextualLaunch>
163+
</shortcut>
164+
</extension>
165+
<!-- coffee -c (compile) -->
166+
<extension
167+
point= "org.eclipse.debug.ui.launchShortcuts" >
168+
<shortcut
169+
class= "org.nodeclipse.debug.launch.LaunchShortcutCoffeeCompile"
170+
icon= "icons/coffee.png"
171+
id= "org.nodeclipse.debug.launch.LaunchShortcutCoffeeCompile"
172+
label= "coffee -c"
173+
modes= "run, debug" >
174+
<configurationType
175+
id= "org.nodeclipse.debug.launch.LaunchConfigurationType" >
176+
</configurationType>
177+
<contextualLaunch>
178+
<enablement>
179+
<with
180+
variable= "selection" >
181+
<count
182+
value= "1" >
183+
</count>
184+
<iterate>
185+
<or>
186+
<test
187+
property= "org.eclipse.debug.ui.matchesPattern"
188+
value= "*.coffee" >
189+
</test>
190+
<test
191+
property= "org.eclipse.debug.ui.matchesPattern"
192+
value= "*.litcoffee" >
193+
</test>
194+
<test
195+
property= "org.eclipse.debug.ui.matchesPattern"
196+
value= "*.coffee.md" >
197+
</test>
198+
</or>
199+
</iterate>
200+
</with>
201+
</enablement>
202+
</contextualLaunch>
203+
</shortcut>
204+
</extension>
205+
<!-- typescript compiler -->
206+
<extension
207+
point= "org.eclipse.debug.ui.launchShortcuts" >
208+
<shortcut
209+
class= "org.nodeclipse.debug.launch.LaunchShortcutTypescriptCompiler"
210+
icon= "icons/coffee.png"
211+
id= "org.nodeclipse.debug.launch.LaunchShortcutTypescriptCompiler"
212+
label= "tsc"
213+
modes= "run, debug" >
214+
<configurationType
215+
id= "org.nodeclipse.debug.launch.LaunchConfigurationType" >
216+
</configurationType>
217+
<contextualLaunch>
218+
<enablement>
219+
<with
220+
variable= "selection" >
221+
<count
222+
value= "1" >
223+
</count>
224+
<iterate>
225+
<or>
226+
<test
227+
property= "org.eclipse.debug.ui.matchesPattern"
228+
value= "*.ts" >
229+
</test>
230+
</or>
159231
</iterate>
160232
</with>
161233
</enablement>

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

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@
3333
import org.nodeclipse.ui.preferences.PreferenceConstants;
3434

3535
/**
36-
* launch() implements starting Node and passing all parameters
36+
* launch() implements starting Node and passing all parameters.
37+
* Node is launched as node, coffee, coffee -c, tsc or node-dev(or other monitors)
3738
*
38-
* @author Lamb, Tomoyuki, Pushkar, Paul Vverest
39+
* @author Lamb, Tomoyuki, Pushkar, Paul Verest
3940
*/
4041
public class LaunchConfigurationDelegate implements
4142
ILaunchConfigurationDelegate {
@@ -54,8 +55,9 @@ public class LaunchConfigurationDelegate implements
5455
public void launch(ILaunchConfiguration configuration, String mode,
5556
ILaunch launch, IProgressMonitor monitor) throws CoreException {
5657
if(nodeProcess != null && !nodeProcess.isTerminated()) {
57-
throw new CoreException(new Status(IStatus.OK, ChromiumDebugPlugin.PLUGIN_ID, null, null));
58-
//TODO show warning dialog
58+
//throw new CoreException(new Status(IStatus.OK, ChromiumDebugPlugin.PLUGIN_ID, null, null));
59+
showErrorDialog("Other node process is running!");
60+
return;
5961
}
6062

6163
// Using configuration to build command line
@@ -124,10 +126,21 @@ public void launch(ILaunchConfiguration configuration, String mode,
124126
return;
125127
}
126128
cmdLine.add(nodeMonitorPath);
127-
} else {
128-
if("coffee".equals(extension)) {
129-
cmdLine.add(preferenceStore.getString(PreferenceConstants.COFFEE_PATH));
129+
} else if ( ("coffee".equals(extension))||("litcoffee".equals(extension))||("md".equals(extension)) ) {
130+
cmdLine.add(preferenceStore.getString(PreferenceConstants.COFFEE_PATH));
131+
// coffee -c
132+
String coffeeCompile = configuration.getAttribute(Constants.ATTR_COFFEE_COMPILE, "");
133+
if(!coffeeCompile.equals("")) { // any value
134+
cmdLine.add("-c");
135+
String coffeeCompileOptions = preferenceStore.getString(PreferenceConstants.COFFEE_COMPILE_OPTIONS);
136+
if(!coffeeCompileOptions.equals("")) {
137+
cmdLine.add(coffeeCompileOptions);
138+
}
130139
}
140+
} else if ("ts".equals(extension)) {
141+
// the only thing we can do now with .ts is to compile, so no need to check if it was launched as tsc
142+
//String typescriptCompiler = configuration.getAttribute(Constants.ATTR_TYPESCRIPT_COMPILER, "");
143+
cmdLine.add(preferenceStore.getString(PreferenceConstants.TYPESCRIPT_COMPILER_PATH));
131144
}
132145

133146
String filePath =
@@ -178,6 +191,18 @@ public void launch(ILaunchConfiguration configuration, String mode,
178191
nodeProcess = process;
179192
}
180193

194+
private void showErrorDialog(final String message) {
195+
Display.getDefault().syncExec(new Runnable() {
196+
public void run() {
197+
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
198+
199+
MessageDialog dialog = new MessageDialog(shell, "Nodeclipse", null, message,
200+
MessageDialog.ERROR, new String[] { "OK" }, 0);
201+
dialog.open();
202+
}
203+
});
204+
}
205+
181206
private void showPreferencesDialog(final String message) {
182207
Display.getDefault().syncExec(new Runnable() {
183208
public void run() {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.nodeclipse.debug.launch;
2+
3+
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
4+
import org.nodeclipse.debug.util.Constants;
5+
6+
/**
7+
* Using "Run As" --> "coffee -c" will lead here
8+
*
9+
* @author Paul Verest
10+
* @since 0.6
11+
**/
12+
public class LaunchShortcutCoffeeCompile extends LaunchShortcut{
13+
14+
@Override
15+
protected void setMoreAttributes(ILaunchConfigurationWorkingCopy workingCopy) {
16+
workingCopy.setAttribute(Constants.ATTR_COFFEE_COMPILE, "-c"); // any value
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.nodeclipse.debug.launch;
2+
3+
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
4+
import org.nodeclipse.debug.util.Constants;
5+
6+
/**
7+
* Using "Run As" --> "tsc" will lead here
8+
*
9+
* @author Paul Verest
10+
* @since 0.6
11+
**/
12+
public class LaunchShortcutTypescriptCompiler extends LaunchShortcut{
13+
14+
@Override
15+
protected void setMoreAttributes(ILaunchConfigurationWorkingCopy workingCopy) {
16+
workingCopy.setAttribute(Constants.ATTR_TYPESCRIPT_COMPILER, "tsc"); // any value
17+
}
18+
}

org.nodeclipse.debug/src/org/nodeclipse/debug/util/Constants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,7 @@ public class Constants {
3434
public static final String ATTR_ENVIRONMENT_VARIABLES = "attr_environment_variables";
3535
public static final String ATTR_APPEND_ENVIRONMENT_VARIABLES = "attr_append_environment_variables";
3636

37+
public static final String ATTR_COFFEE_COMPILE = "attr_coffee_compile";
38+
public static final String ATTR_TYPESCRIPT_COMPILER = "attr_typescript_compiler";
3739
public static final String ATTR_NODE_MONITOR = "attr_node_monitor";
3840
}

org.nodeclipse.help/HelpToc.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
<toc label="Nodeclipse Help" topic="contents/.index.md.html">
55
<topic label="Configuration" href="contents/.configuration.md.html"/>
6+
<topic label="Node.js" href="contents/.nodejs.md.html"/>
67
<topic label="Run" href="contents/.run.md.html"/>
78
<topic label="Debug" href="contents/.debug.md.html"/>
89
<topic label="Monitor" href="contents/.monitor.md.html"/>

org.nodeclipse.help/contents/.coffeescript.md.html

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5-
<title>C:\Users\pverest\git\org.nodeclipse.help\contents\.coffeescript.md.html</title>
5+
<title>C:\Users\pverest\git\nodeclipse-056\org.nodeclipse.help\contents\.coffeescript.md.html</title>
66

77

88
<style type="text/css">
@@ -70,13 +70,46 @@
7070

7171
</head>
7272
<body class="markdown-body">
73-
<h2>
74-
<a name="coffeesctipt-editor" class="anchor" href="#coffeesctipt-editor"><span class="octicon octicon-link"></span></a>CoffeeSctipt Editor</h2>
75-
76-
<p>Included in <a href="nodeclipse.org/enide">Enide</a> since 0.4.20</p>
77-
78-
<p>It has XText dependency, that can usually be automatically resolved by Eclipse (that was downloaded from eclipse.org)</p>
79-
80-
<p>for other Eclipse distributions use Enide or install prior from <a href="http://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/">http://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/</a></p>
73+
<p>Title: Nodeclipse Online Help - CoffeeScript </p>
74+
<h2> <a name="coffeesctipt-editor" class="anchor" href="..md.html#coffeesctipt-editor"><span class="octicon octicon-link"></span></a>CoffeeSctipt Editor</h2>
75+
<p>Included in <a href="www.nodeclipse.org\.enide.md.html">Enide</a> since 0.4.20</p>
76+
<p>It has XText dependency, that can usually be automatically resolved by Eclipse (that was downloaded from eclipse.org)</p>
77+
<p>for other Eclipse distributions use Enide or install prior from <a href="http://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/">http://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/</a></p>
78+
<h3> <a name="hello-world-server-in-coffeescript" class="anchor" href="..md.html#hello-world-server-in-coffeescript"><span class="octicon octicon-link"></span></a>Hello world server in CoffeeScript</h3>
79+
<pre><code>http = require 'http'
80+
81+
http.createServer (req, res) -&gt;
82+
res.writeHead 200, {'Content-Type': 'text/plain'}
83+
res.end 'Hello World\n'
84+
.listen 1337, '127.0.0.1'
85+
86+
console.log 'Server running at http://127.0.0.1:1337/'
87+
</code></pre>
88+
<h3> <a name="runningdebugging" class="anchor" href="..md.html#runningdebugging"><span class="octicon octicon-link"></span></a>Running/debugging</h3>
89+
<p>Nodeclipse since version 0.6 allows to run and debug .coffee file directly. Node.js command line tool 'coffee' is used. Note that when debugging, source map are not implemeted, and execution start from this coffee tool that compiles your module. Stay in Node perspective until compilation to see your modules appear in V8 virtual project. Then open those files and set breakpoints.</p>
90+
<h3> <a name="coffee-util" class="anchor" href="..md.html#coffee-util"><span class="octicon octicon-link"></span></a>coffee Util</h3>
91+
<pre><code>$coffee --help
92+
93+
Usage: coffee [options] path/to/script.coffee -- [args]
94+
95+
If called without options, `coffee` will run your script.
96+
97+
-b, --bare compile without a top-level function wrapper
98+
-c, --compile compile to JavaScript and save as .js files
99+
-e, --eval pass a string from the command line as input
100+
-h, --help display this help message
101+
-i, --interactive run an interactive CoffeeScript REPL
102+
-j, --join concatenate the source CoffeeScript before compiling
103+
-m, --map generate source map and save as .map files
104+
-n, --nodes print out the parse tree that the parser produces
105+
--nodejs pass options directly to the &quot;node&quot; binary
106+
-o, --output set the output directory for compiled JavaScript
107+
-p, --print print out the compiled JavaScript
108+
-s, --stdio listen for and compile scripts over stdio
109+
-l, --literate treat stdio as literate style coffee-script
110+
-t, --tokens print out the tokens that the lexer/rewriter produce
111+
-v, --version display the version number
112+
-w, --watch watch scripts for changes and rerun commands
113+
</code></pre>
81114
</body>
82115
</html>
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
2+
<html>
3+
<head>
4+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5+
<title>C:\Users\pverest\git\nodeclipse-056\org.nodeclipse.help\contents\.nodejs.md.html</title>
6+
7+
8+
<style type="text/css">
9+
10+
.markdown-body {
11+
border: 1px solid #CACACA;
12+
padding: 30px;
13+
font-size: 14px;
14+
line-height: 1.6;
15+
}
16+
17+
.markdown-body h2 {
18+
border-bottom: 1px solid #CCCCCC;
19+
}
20+
21+
.markdown-body code {
22+
white-space: nowrap;
23+
}
24+
25+
.markdown-body code, .markdown-body tt {
26+
background-color: #F8F8F8;
27+
border: 1px solid #EAEAEA;
28+
border-radius: 3px 3px 3px 3px;
29+
margin: 0 2px;
30+
padding: 0 5px;
31+
}
32+
33+
.markdown-body .highlight pre, .markdown-body pre {
34+
background-color: #F8F8F8;
35+
border: 1px solid #CCCCCC;
36+
border-radius: 3px 3px 3px 3px;
37+
font-size: 13px;
38+
line-height: 19px;
39+
overflow: auto;
40+
padding: 6px 10px;
41+
}
42+
43+
.markdown-body img {
44+
border: 0 none;
45+
}
46+
47+
pre, code, tt {
48+
font-family: Consolas,"Liberation Mono",Courier,monospace;
49+
font-size: 12px;
50+
}
51+
</style>
52+
53+
54+
<script type="text/javascript">
55+
56+
function getDocumentScrollTop()
57+
{
58+
var res = document.body.scrollTop || document.documentElement.scrollTop || window.pageYOffset || 0;
59+
// alert(res);
60+
return res;
61+
}
62+
63+
function setDocumentScrollTop(ypos)
64+
{
65+
window.scrollTo(0, ypos);
66+
}
67+
68+
</script>
69+
70+
71+
</head>
72+
<body class="markdown-body">
73+
<h3> <a name="nodejs-sources" class="anchor" href="..md.html#nodejs-sources"><span class="octicon octicon-link"></span></a>Node.js sources</h3>
74+
<p>Node.js sources have &quot;Node.js Core Modules&quot; in <code>lib</code> foilder, that may be useful.</p>
75+
<p>Add following snippet to project <code>.project</code> file to reference Node.js sources.</p>
76+
<pre><code>&lt;linkedResources&gt;
77+
&lt;link&gt;
78+
&lt;name&gt;nodejs-sources-lib&lt;/name&gt;
79+
&lt;type&gt;2&lt;/type&gt;
80+
&lt;location&gt;E:/Enide/node-sources/node-v0.10.19/lib/&lt;/location&gt;
81+
&lt;/link&gt;
82+
&lt;/linkedResources&gt;
83+
</code></pre>
84+
<p><a href="images/nodejs-sources-lib.PNG" target="_blank"><img src="images/nodejs-sources-lib.PNG" alt="" style="max-width:100%;" /></a></p>
85+
</body>
86+
</html>

0 commit comments

Comments
 (0)