-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from ortus-solutions-private/comment-issue
Fixes the error of Javadoc comments in code
- Loading branch information
Showing
4 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/ortus/boxlang/parser/ParserErrorStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package ortus.boxlang.parser; | ||
|
||
import org.antlr.v4.runtime.DefaultErrorStrategy; | ||
import org.antlr.v4.runtime.Parser; | ||
import org.antlr.v4.runtime.Token; | ||
import org.antlr.v4.runtime.misc.IntervalSet; | ||
import ortus.boxlang.parser.antlr.CFLexer; | ||
|
||
/** | ||
* Recover form errors having Javadoc in body | ||
*/ | ||
public class ParserErrorStrategy extends DefaultErrorStrategy { | ||
|
||
@Override | ||
protected void reportUnwantedToken( Parser recognizer ) { | ||
if ( inErrorRecoveryMode( recognizer ) ) { | ||
return; | ||
} | ||
Token t = recognizer.getCurrentToken(); | ||
if ( t.getType() != CFLexer.JAVADOC_COMMENT ) { | ||
super.reportUnwantedToken( recognizer ); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package ortus.boxlang.compiler; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import ortus.boxlang.parser.BoxCFParser; | ||
import ortus.boxlang.parser.ParsingResult; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class TestRecover { | ||
|
||
@Test | ||
public void testRecover() throws IOException { | ||
String code = """ | ||
/** | ||
*/ | ||
function f() { | ||
/** | ||
*/ | ||
} | ||
"""; | ||
|
||
BoxCFParser parser = new BoxCFParser(); | ||
ParsingResult result = parser.parse( code ); | ||
assertTrue( result.isCorrect() ); | ||
} | ||
} |