Skip to content

Commit 0db786e

Browse files
authored
Merge pull request #121 from Krzmbrzl/plugin
finished work on 0.7.1
2 parents 85717a8 + f628139 commit 0db786e

File tree

67 files changed

+837
-837
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+837
-837
lines changed

plugin/Raven.SQDev.Editors/META-INF/MANIFEST.MF

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: Editors
44
Bundle-SymbolicName: raven.sqdev.editors;singleton:=true
5-
Bundle-Version: 0.6.0
5+
Bundle-Version: 0.6.2
66
Bundle-Activator: raven.sqdev.editors.activator.Activator
77
Require-Bundle: org.eclipse.ui,
88
org.eclipse.core.runtime,
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

plugin/Raven.SQDev.Editors/src/raven/sqdev/editors/BasicCodeEditor.java

+41-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import org.eclipse.core.runtime.IProgressMonitor;
1212
import org.eclipse.core.runtime.IStatus;
1313
import org.eclipse.core.runtime.Status;
14+
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
15+
import org.eclipse.core.runtime.jobs.IJobChangeListener;
1416
import org.eclipse.core.runtime.jobs.Job;
1517
import org.eclipse.jface.preference.IPreferenceStore;
1618
import org.eclipse.jface.text.BadLocationException;
@@ -100,6 +102,8 @@ public class BasicCodeEditor extends TextEditor {
100102
*/
101103
protected List<CharacterPair> characterPairs;
102104

105+
private Job parseJob;
106+
103107
public BasicCodeEditor() {
104108
super();
105109

@@ -380,7 +384,43 @@ public boolean parseInput() {
380384
return false;
381385
}
382386

383-
Job parseJob = new Job("Parsing \"" + getEditorInput().getName() + "\"...") {
387+
if (parseJob != null && parseJob.getState() != Job.NONE) {
388+
// Ther previous Job is still running -> reschedule
389+
parseJob.addJobChangeListener(new IJobChangeListener() {
390+
391+
@Override
392+
public void sleeping(IJobChangeEvent event) {
393+
}
394+
395+
@Override
396+
public void scheduled(IJobChangeEvent event) {
397+
}
398+
399+
@Override
400+
public void running(IJobChangeEvent event) {
401+
}
402+
403+
@Override
404+
public void done(IJobChangeEvent event) {
405+
// As there has been a request to parse the input again do
406+
// it now as the old parsing process is finished
407+
parseInput();
408+
}
409+
410+
@Override
411+
public void awake(IJobChangeEvent event) {
412+
}
413+
414+
@Override
415+
public void aboutToRun(IJobChangeEvent event) {
416+
}
417+
});
418+
419+
return false;
420+
}
421+
422+
parseJob = new Job(
423+
"Parsing \"" + getEditorInput().getName() + "\"...") {
384424

385425
@Override
386426
protected IStatus run(IProgressMonitor monitor) {

plugin/Raven.SQDev.Editors/src/raven/sqdev/editors/BasicErrorListener.java

+96-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package raven.sqdev.editors;
22

3+
import java.util.ArrayList;
4+
import java.util.List;
5+
36
import org.antlr.v4.runtime.BaseErrorListener;
47
import org.antlr.v4.runtime.RecognitionException;
58
import org.antlr.v4.runtime.Recognizer;
@@ -16,11 +19,44 @@
1619
*
1720
*/
1821
public class BasicErrorListener extends BaseErrorListener {
22+
protected class Error {
23+
private int offset;
24+
private int length;
25+
private String message;
26+
27+
public Error(int offset, int length, String message) {
28+
this.offset = offset;
29+
this.length = length;
30+
this.message = message;
31+
}
32+
33+
public int getOffset() {
34+
return offset;
35+
}
36+
37+
public int getLength() {
38+
return length;
39+
}
40+
41+
public String getMessage() {
42+
return message;
43+
}
44+
}
45+
1946
/**
2047
* The editor this listener resports to
2148
*/
2249
private BasicCodeEditor editor;
2350

51+
/**
52+
* Indicates whether errors should be suppressed and stored instead of being
53+
* reported
54+
*/
55+
private boolean suppressErrors;
56+
57+
private List<Error> suppressedErrors;
58+
59+
2460
/**
2561
* Create an instance of this error listener
2662
*
@@ -30,11 +66,14 @@ public class BasicErrorListener extends BaseErrorListener {
3066
public BasicErrorListener(BasicCodeEditor editor) {
3167
Assert.isNotNull(editor);
3268
this.editor = editor;
69+
70+
suppressedErrors = new ArrayList<Error>();
3371
}
3472

3573
@Override
36-
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line,
37-
int charPositionInline, String msg, RecognitionException e) {
74+
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol,
75+
int line, int charPositionInline, String msg,
76+
RecognitionException e) {
3877
if (line < 1 || !(offendingSymbol instanceof Token)) {
3978
return;
4079
}
@@ -44,20 +83,72 @@ public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int
4483
int length = (offendingToken.getType() == Token.EOF) ? 0
4584
: offendingToken.getText().length();
4685

47-
reportError(offendingToken.getStartIndex(), length, msg);
86+
reportError(new Error(offendingToken.getStartIndex(), length, msg));
87+
}
88+
89+
/**
90+
* Reports an error to the respective editor
91+
*
92+
* @param error
93+
* The Error to report
94+
*/
95+
public void reportError(Error error) {
96+
if (suppressErrors) {
97+
synchronized (suppressedErrors) {
98+
suppressedErrors.add(error);
99+
}
100+
} else {
101+
editor.createMarker(IMarker.PROBLEM, error.getOffset(),
102+
error.getLength(), error.getMessage(),
103+
IMarker.SEVERITY_ERROR);
104+
}
48105
}
49106

50107
/**
51108
* Reports an error to the respective editor
52109
*
53110
* @param offset
54-
* The offset of the error start
111+
* The offset of the error
55112
* @param length
56113
* The length of the error
57114
* @param msg
58115
* The error message
59116
*/
60117
public void reportError(int offset, int length, String msg) {
61-
editor.createMarker(IMarker.PROBLEM, offset, length, msg, IMarker.SEVERITY_ERROR);
118+
reportError(new Error(offset, length, msg));
119+
}
120+
121+
/**
122+
* Specifies whether errors should be directly marked or rather be
123+
* suppressed and stored internally
124+
*
125+
* @param suppress
126+
* Whether to suppress erros
127+
*/
128+
public void suppressErrors(boolean suppress) {
129+
suppressErrors = suppress;
130+
}
131+
132+
/**
133+
* Reports all errors that have been suppressed to this point and clears the
134+
* list of suppressed errors
135+
*/
136+
public void flushSuppressedErros() {
137+
synchronized (suppressedErrors) {
138+
for (Error currentError : suppressedErrors) {
139+
reportError(currentError);
140+
}
141+
142+
suppressedErrors.clear();
143+
}
144+
}
145+
146+
/**
147+
* Clears the list of suppressed errors
148+
*/
149+
public void clearSuppressedErrors() {
150+
synchronized (suppressedErrors) {
151+
suppressedErrors.clear();
152+
}
62153
}
63154
}

plugin/Raven.SQDev.Editors/src/raven/sqdev/editors/BasicPartitionScanner.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,23 @@ public class BasicPartitionScanner extends RuleBasedPartitionScanner {
3030
/**
3131
* The rule for a multiline comment
3232
*/
33-
public static final IPredicateRule MULTILINE_COMMENT_RULE = new MultiLineRule("/*", "*/",
34-
new Token(BASIC_COMMENT));
33+
public static final IPredicateRule MULTILINE_COMMENT_RULE = new MultiLineRule(
34+
"/*", "*/", new Token(BASIC_COMMENT), (char) 0, true);
3535
/**
3636
* The rule for a singleline comment
3737
*/
38-
public static final IPredicateRule SINGLELINE_COMMENT_RULE = new EndOfLineRule("//",
39-
new Token(BASIC_COMMENT));
38+
public static final IPredicateRule SINGLELINE_COMMENT_RULE = new EndOfLineRule(
39+
"//", new Token(BASIC_COMMENT));
4040
/**
4141
* The rule for a string encapsulated by double quotation marks
4242
*/
43-
public static final IPredicateRule DOUBLE_QUOTE_STRING_RULE = new MultiLineRule("\"", "\"",
44-
new Token(BASIC_STRING), '\\');
43+
public static final IPredicateRule DOUBLE_QUOTE_STRING_RULE = new MultiLineRule(
44+
"\"", "\"", new Token(BASIC_STRING), '\\', true);
4545
/**
4646
* The rule for a string encapsulated by single quotation marks
4747
*/
48-
public static final IPredicateRule SINGLE_QUOTE_STRING_RULE = new MultiLineRule("'", "'",
49-
new Token(BASIC_STRING));
48+
public static final IPredicateRule SINGLE_QUOTE_STRING_RULE = new MultiLineRule(
49+
"'", "'", new Token(BASIC_STRING), '\\', true);
5050

5151
/**
5252
* An array containing all currently used rules

plugin/Raven.SQDev.Editors/src/raven/sqdev/editors/ISQDevColorConstants.java

-21
This file was deleted.

plugin/Raven.SQDev.Editors/src/raven/sqdev/editors/parser/preprocessor/PreprocessorParseListener.java

+14-2
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,18 @@ public void exitInclude(IncludeContext ctx) {
154154
ctx.file.getText().length() - 1);
155155
IPath root;
156156

157+
if (strFilePath.contains("/")) {
158+
// backslashes have to be used
159+
reportError(ctx.file.getStartIndex() + strFilePath.indexOf("/") + 1,
160+
1, ProblemMessages.backslashHasToBeUsed());
161+
162+
// Abort because of syntax error
163+
return;
164+
}
165+
166+
// In unix systems the backslash has to be replaced
167+
strFilePath = strFilePath.replace("\\", File.separator);
168+
157169
if (strFilePath.startsWith("\\")) {
158170
root = new Path(SQDevPreferenceUtil.getArmaProgramDirectory());
159171
} else {
@@ -174,12 +186,12 @@ public void exitInclude(IncludeContext ctx) {
174186
if (!file.isFile()) {
175187
// must be a file
176188
reportError(includedFileStart, includedFileLength,
177-
"Reference is not a file");
189+
ProblemMessages.referenceNotAFile());
178190
} else {
179191
if (includedFiles.contains(filePath)) {
180192
// report cycle in hierarchy
181193
reportError(includedFileStart, includedFileLength,
182-
CYCLE_IN_HIERARCHY_MSG);
194+
ProblemMessages.cycleInHierarchy());
183195

184196
includedFiles.clear();
185197

plugin/Raven.SQDev.Misc/META-INF/MANIFEST.MF

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: Misc
44
Bundle-SymbolicName: raven.sqdev.misc;singleton:=true
5-
Bundle-Version: 0.4.0
5+
Bundle-Version: 0.4.2
66
Bundle-Activator: raven.sqdev.activator.Activator
77
Require-Bundle: org.eclipse.core.runtime,
88
org.eclipse.swt,
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

plugin/Raven.SQDev.Misc/src/raven/sqdev/constants/ProblemMessages.java

+21
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,25 @@ public static final String isCaseSensitive(String correct) {
231231
return "This operator is case-sensitive! It has to be \"" + correct
232232
+ "\"!";
233233
}
234+
235+
/**
236+
* The error message stating that the reference is not a file
237+
*/
238+
public static final String referenceNotAFile() {
239+
return "Reference is not a file!";
240+
}
241+
242+
/**
243+
* The error message stating that there is a cycle in hierarchy
244+
*/
245+
public static final String cycleInHierarchy() {
246+
return "Cycle in hierarchy!";
247+
}
248+
249+
/**
250+
* The error message stating that only a bachslash can be used
251+
*/
252+
public static final String backslashHasToBeUsed() {
253+
return "Only a backslash can be used in this context";
254+
}
234255
}

0 commit comments

Comments
 (0)