File tree Expand file tree Collapse file tree
build/shared/lib/languages
src/processing/mode/java/preproc
test/processing/mode/java Expand file tree Collapse file tree 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'?
415415editor.status.bad.identifier = Bad identifier? Did you forget a variable or start an identifier with digits near '%s'?
416416editor.status.bad.parameter = Error on parameter or method declaration near '%s'?
417417editor.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.
418419editor.status.extraneous = Incomplete statement or extra code near '%s'?
419420editor.status.mismatched = Missing operator, semicolon, or '}' near '%s'?
420421editor.status.missing.name = Missing name or ; near '%s'?
@@ -644,4 +645,4 @@ movie_maker.progress.creating_output_file = Creating output file
644645movie_maker.progress.initializing = Initializing...
645646movie_maker.progress.processing = Processing %s.
646647
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
387387editor.status.bad.generic = Error en genérico cerca '%s'. Falta un tipo?
388388editor.status.bad.parameter = Error en un parámetro o una declaración de método cerca '%s'?
389389editor.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.
390391editor.status.extraneous = Una declaración incompleta o un imprevisto clave cerca '%s'?
391392editor.status.mismatched = Falta un punto y coma, un operador, o un '}' cerca '%s'?
392393editor.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) {
316316 footerResult = prepareFooter (rewriter , length );
317317 }
318318
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+
319336 /**
320337 * Endpoint for ANTLR to call when finished parsing a method invocatino.
321338 *
@@ -770,7 +787,7 @@ protected boolean calledFromGlobalOrSetup(ParserRuleContext callContext) {
770787 * @return True if setup and false otherwise.
771788 */
772789 protected boolean isMethodSetup (ParserRuleContext declaration ) {
773- if (declaration .getChildCount () < 2 ) {
790+ if (declaration == null || declaration .getChildCount () < 2 ) {
774791 return false ;
775792 }
776793 return declaration .getChild (1 ).getText ().equals ("setup" );
Original file line number Diff line number Diff line change @@ -23,27 +23,34 @@ processingSketch
2323 : javaProcessingSketch
2424 | staticProcessingSketch
2525 | activeProcessingSketch
26+ | warnMixedModes
2627 ;
2728
2829// java mode, is a compilation unit
2930javaProcessingSketch
3031 : packageDeclaration? importDeclaration* typeDeclaration+ EOF
3132 ;
3233
34+ // No method declarations, just statements
3335staticProcessingSketch
3436 : (importDeclaration | blockStatement)* EOF
3537 ;
3638
3739// active mode, has function definitions
3840activeProcessingSketch
39- : (importDeclaration | classBodyDeclaration)* EOF
40- ;
41+ : (importDeclaration | classBodyDeclaration)* EOF
42+ ;
4143
4244variableDeclaratorId
4345 : warnTypeAsVariableName
4446 | IDENTIFIER (' [' ' ]' )*
4547 ;
4648
49+ warnMixedModes
50+ : (importDeclaration | classBodyDeclaration | blockStatement)* blockStatement classBodyDeclaration (importDeclaration | classBodyDeclaration | blockStatement)*
51+ | (importDeclaration | classBodyDeclaration | blockStatement)* classBodyDeclaration blockStatement (importDeclaration | classBodyDeclaration | blockStatement)*
52+ ;
53+
4754// bug #93
4855// https://github.com/processing/processing/issues/93
4956// 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() {
405405 expectGood ("sizethis" );
406406 }
407407
408+ @ Test
409+ public void testMixing () {
410+ expectRunnerException ("mixing" , 1 );
411+ }
412+
408413}
You can’t perform that action at this time.
0 commit comments