File tree 5 files changed +35
-4
lines changed
build/shared/lib/languages
src/processing/mode/java/preproc
test/processing/mode/java
5 files changed +35
-4
lines changed Original file line number Diff line number Diff line change @@ -415,6 +415,7 @@ editor.status.bad.generic = Possibly missing type in generic near '%s'?
415
415
editor.status.bad.identifier = Bad identifier? Did you forget a variable or start an identifier with digits near '%s'?
416
416
editor.status.bad.parameter = Error on parameter or method declaration near '%s'?
417
417
editor.status.bad.import = Import not allowed here.
418
+ editor.status.bad.mixed_mode = You may be mixing active and static modes which is not allowed.
418
419
editor.status.extraneous = Incomplete statement or extra code near '%s'?
419
420
editor.status.mismatched = Missing operator, semicolon, or '}' near '%s'?
420
421
editor.status.missing.name = Missing name or ; near '%s'?
@@ -644,4 +645,4 @@ movie_maker.progress.creating_output_file = Creating output file
644
645
movie_maker.progress.initializing = Initializing...
645
646
movie_maker.progress.processing = Processing %s.
646
647
647
- movie_maker.progress.handling_frame = Converting frame %s of %s...
648
+ movie_maker.progress.handling_frame = Converting frame %s of %s...
Original file line number Diff line number Diff line change @@ -387,6 +387,7 @@ editor.status.bad.identifier = Error en este identificador? Es posible que tu ol
387
387
editor.status.bad.generic = Error en genérico cerca '%s'. Falta un tipo?
388
388
editor.status.bad.parameter = Error en un parámetro o una declaración de método cerca '%s'?
389
389
editor.status.bad.import = Una declaración de importación no es permitida en una definición de una clasa.
390
+ editor.status.bad.mixed_mode = Es possible que estás usando el modo estático y activo.
390
391
editor.status.extraneous = Una declaración incompleta o un imprevisto clave cerca '%s'?
391
392
editor.status.mismatched = Falta un punto y coma, un operador, o un '}' cerca '%s'?
392
393
editor.status.missing.name = Falta ; o nombre cerca '%s'?
Original file line number Diff line number Diff line change @@ -316,6 +316,23 @@ public void exitProcessingSketch(ProcessingParser.ProcessingSketchContext ctx) {
316
316
footerResult = prepareFooter (rewriter , length );
317
317
}
318
318
319
+ @ Override
320
+ public void enterWarnMixedModes (ProcessingParser .WarnMixedModesContext ctx ) {
321
+ pdeParseTreeErrorListenerMaybe .ifPresent ((listener ) -> {
322
+ Token token = ctx .getStart ();
323
+ int line = token .getLine ();
324
+ int charOffset = token .getCharPositionInLine ();
325
+
326
+ listener .onError (new PdePreprocessIssue (
327
+ line ,
328
+ charOffset ,
329
+ PreprocessIssueMessageSimplifier .getLocalStr (
330
+ "editor.status.bad.mixed_mode"
331
+ )
332
+ ));
333
+ });
334
+ }
335
+
319
336
/**
320
337
* Endpoint for ANTLR to call when finished parsing a method invocatino.
321
338
*
@@ -770,7 +787,7 @@ protected boolean calledFromGlobalOrSetup(ParserRuleContext callContext) {
770
787
* @return True if setup and false otherwise.
771
788
*/
772
789
protected boolean isMethodSetup (ParserRuleContext declaration ) {
773
- if (declaration .getChildCount () < 2 ) {
790
+ if (declaration == null || declaration .getChildCount () < 2 ) {
774
791
return false ;
775
792
}
776
793
return declaration .getChild (1 ).getText ().equals ("setup" );
Original file line number Diff line number Diff line change @@ -23,27 +23,34 @@ processingSketch
23
23
: javaProcessingSketch
24
24
| staticProcessingSketch
25
25
| activeProcessingSketch
26
+ | warnMixedModes
26
27
;
27
28
28
29
// java mode, is a compilation unit
29
30
javaProcessingSketch
30
31
: packageDeclaration? importDeclaration* typeDeclaration+ EOF
31
32
;
32
33
34
+ // No method declarations, just statements
33
35
staticProcessingSketch
34
36
: (importDeclaration | blockStatement)* EOF
35
37
;
36
38
37
39
// active mode, has function definitions
38
40
activeProcessingSketch
39
- : (importDeclaration | classBodyDeclaration)* EOF
40
- ;
41
+ : (importDeclaration | classBodyDeclaration)* EOF
42
+ ;
41
43
42
44
variableDeclaratorId
43
45
: warnTypeAsVariableName
44
46
| IDENTIFIER (' [' ' ]' )*
45
47
;
46
48
49
+ warnMixedModes
50
+ : (importDeclaration | classBodyDeclaration | blockStatement)* blockStatement classBodyDeclaration (importDeclaration | classBodyDeclaration | blockStatement)*
51
+ | (importDeclaration | classBodyDeclaration | blockStatement)* classBodyDeclaration blockStatement (importDeclaration | classBodyDeclaration | blockStatement)*
52
+ ;
53
+
47
54
// bug #93
48
55
// https://github.com/processing/processing/issues/93
49
56
// prevent from types being used as variable names
Original file line number Diff line number Diff line change @@ -405,4 +405,9 @@ public void testSizeThis() {
405
405
expectGood ("sizethis" );
406
406
}
407
407
408
+ @ Test
409
+ public void testMixing () {
410
+ expectRunnerException ("mixing" , 1 );
411
+ }
412
+
408
413
}
You can’t perform that action at this time.
0 commit comments