-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathRLangMode.java
More file actions
123 lines (105 loc) · 3.19 KB
/
Copy pathRLangMode.java
File metadata and controls
123 lines (105 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package rprocessing.mode;
import java.io.File;
import processing.app.Base;
import processing.app.Messages;
import processing.app.Mode;
import processing.app.syntax.TokenMarker;
import processing.app.ui.Editor;
import processing.app.ui.EditorException;
import processing.app.ui.EditorState;
import rprocessing.mode.run.SketchRunner;
import rprocessing.mode.run.SketchServiceManager;
/**
*
* @author github.com/gaocegege
*/
public class RLangMode extends Mode {
private static final boolean VERBOSE = Boolean.parseBoolean(System.getenv("VERBOSE_RLANG_MODE"));
/**
* If the environment variable SKETCH_RUNNER_FIRST is equal to the string "true", then
* {@link RLangMode} expects that the {@link SketchRunner} is already running and waiting to be
* communicated with (as when you're debugging it in Eclipse, for example).
*/
public static final boolean SKETCH_RUNNER_FIRST =
Boolean.parseBoolean(System.getenv("SKETCH_RUNNER_FIRST"));
private final SketchServiceManager sketchServiceManager;
@SuppressWarnings("unused")
private static void log(final String msg) {
if (VERBOSE) {
System.err.println(RLangEditor.class.getSimpleName() + ": " + msg);
}
}
public RLangMode(final Base base, final File folder) {
super(base, folder);
log("DEBUG the RLangMode");
sketchServiceManager = new SketchServiceManager(this);
}
public SketchServiceManager getSketchServiceManager() {
return sketchServiceManager;
}
/**
* @see processing.app.Mode#createEditor(processing.app.Base, java.lang.String,
* processing.app.ui.EditorState)
*/
@Override
public Editor createEditor(Base base, final String path, final EditorState state)
throws EditorException {
// Lazily start the sketch running service only when an editor is required.
if (!sketchServiceManager.isStarted()) {
sketchServiceManager.start();
}
try {
return new RLangEditor(base, path, state, this);
} catch (EditorException exception) {
Messages.showError("Editor Exception", "Issue Creating Editor", exception);
return null;
}
}
/**
*
* @see processing.app.Mode#getDefaultExtension()
*/
@Override
public String getDefaultExtension() {
// TODO: Finish this function.
return "rpde";
}
@Override
public String getModuleExtension() {
return "R";
}
@Override
public TokenMarker createTokenMarker() {
return new RLangTokenMarker();
}
/**
* @see processing.app.Mode#getExtensions()
*/
@Override
public String[] getExtensions() {
return new String[] {getDefaultExtension(), getModuleExtension()};
}
/**
* @see processing.app.Mode#getExampleCategoryFolders()
*/
@Override
public File[] getExampleCategoryFolders() {
return new File[] {new File(examplesFolder, "Basics"), new File(examplesFolder, "Libraries"),
new File(examplesFolder, "reference"), new File(examplesFolder, "R Packages"),
new File(examplesFolder, "Examples")};
}
/**
* @see processing.app.Mode#getIgnorable()
*/
@Override
public String[] getIgnorable() {
return null;
}
/**
* @see processing.app.Mode#getTitle()
*/
@Override
public String getTitle() {
return "R";
}
}