File tree Expand file tree Collapse file tree
core/src/main/java/io/timeandspace/jpsg Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -615,7 +615,13 @@ class Generator {
615615
616616 @JvmStatic
617617 fun compileBlock (insideBlockRegex : String , keyword : String ): CheckingPattern {
618- val checkingBlock = " /[*/]\\ s*$keyword [^/*]*+[*/]/"
618+ val checkingBlockBlockCommentOpening = " /\\ *\\ s*$keyword [^/*]*+[*/]/"
619+ // Don't allow blocks starting with `//` to be multiline (the only difference of the
620+ // checkingBlockDoubleSlash regex from checkingBlockBlockCommentOpening is exclusion of
621+ // '\n'). This is to reduce false-positive "Malformed template near" errors by JPSG on
622+ // normal // comments that happen to start with "if" or "with".
623+ val checkingBlockDoubleSlash = " //\\ s*$keyword [^/*\\ n]*+[*/]/"
624+ val checkingBlock = " ($checkingBlockBlockCommentOpening |$checkingBlockDoubleSlash )"
619625 val block = " /[*/]\\ s*" + removeSubGroupNames(insideBlockRegex) + " \\ s*[*/]/"
620626 return compile(justBlockOrWholeLine(checkingBlock), justBlockOrWholeLine(block))
621627 }
You can’t perform that action at this time.
0 commit comments