From 73e2f15232863a3c7f67a3f0fd6722cbe0496564 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Mon, 1 Mar 2021 14:10:34 +0100 Subject: [PATCH] Fix java commenting issues --- src/main/java/app/model/languages/Java.java | 29 ++++++++++----------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/main/java/app/model/languages/Java.java b/src/main/java/app/model/languages/Java.java index cf833e9..d3bb51b 100644 --- a/src/main/java/app/model/languages/Java.java +++ b/src/main/java/app/model/languages/Java.java @@ -35,20 +35,20 @@ public class Java implements ProgrammingLanguage { private static final Map pattern = Map.ofEntries( - e("\"([^\"\\\\]|\\\\.)*\"", "string"), - e("\\bthis\\b", "this"), - e("\\btrue\\b", "true"), - e("\\bfalse\\b", "false"), - e("(?<=\\.?)\\w+(?=\\()", "method"), - e("\\(|\\)", "paranthesis"), - e("\\{|\\}", "curlyBrackets"), - e("\\[|\\]", "squareBrackets"), - e(";", "semicolon"), - e("\\.\\w+\\b(?!\\()", "property"), - e("\\b[A-Z]\\w+\\b", "identifier"), + e("\"([^\"\\\\]|\\\\.)*\"", "string"), + e("\\bthis\\b", "this"), + e("\\btrue\\b", "true"), + e("\\bfalse\\b", "false"), + e("(?<=\\.?)\\w+(?=\\()", "method"), + e("\\(|\\)", "paranthesis"), + e("\\{|\\}", "curlyBrackets"), + e("\\[|\\]", "squareBrackets"), + e(";", "semicolon"), + e("\\.\\w+\\b(?!\\()", "property"), + e("\\b[A-Z]\\w+\\b", "identifier"), e("\\b(" + String.join("|", keywords) + ")\\b", - "keyword"), - e("(?://.*)|/\\*(?:\\n|.)*\\*/", "comment") + "keyword"), + e("(?://.*)|/\\*(?:\\n|.)*?\\*/", "comment") ); public String getName() { @@ -113,8 +113,7 @@ public class Java implements ProgrammingLanguage { lines.length < 2 || Arrays.asList(Arrays.copyOfRange(lines, 1, lines.length - 1)) .stream() - .map(l -> l.startsWith(" * ")) - .allMatch(b -> b); + .allMatch(l -> l.startsWith(" * ")); return Stream.of(