Some improvements to langs

This commit is contained in:
qwerty287 2022-09-05 21:49:14 +02:00
parent fabf5702eb
commit f8a509b935
No known key found for this signature in database
GPG key ID: E0464C650D9D25B2
7 changed files with 14 additions and 6 deletions

View file

@ -2,6 +2,7 @@ package org.mian.gitnex.helpers.codeeditor.languages;
import com.amrdeveloper.codeview.Code;
import com.amrdeveloper.codeview.Keyword;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@ -21,7 +22,7 @@ public class GoLanguage extends Language {
//Data
private static final Pattern PATTERN_NUMBERS = Pattern.compile("\\b(\\d*[.]?\\d+)\\b");
private static final Pattern PATTERN_CHAR = Pattern.compile("['](.*?)[']");
private static final Pattern PATTERN_STRING = Pattern.compile("[\"](.*?)[\"]");
private static final Pattern PATTERN_STRING = Pattern.compile("[\"`](.*?)[\"`]");
private static final Pattern PATTERN_HEX = Pattern.compile("0x[0-9a-fA-F]+");
private static final Pattern PATTERN_SINGLE_LINE_COMMENT = Pattern.compile("//[^\\n]*");

View file

@ -2,6 +2,7 @@ package org.mian.gitnex.helpers.codeeditor.languages;
import com.amrdeveloper.codeview.Code;
import com.amrdeveloper.codeview.Keyword;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

View file

@ -2,6 +2,7 @@ package org.mian.gitnex.helpers.codeeditor.languages;
import com.amrdeveloper.codeview.Code;
import com.amrdeveloper.codeview.Keyword;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

View file

@ -2,6 +2,7 @@ package org.mian.gitnex.helpers.codeeditor.languages;
import com.amrdeveloper.codeview.Code;
import com.amrdeveloper.codeview.Keyword;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@ -22,9 +23,9 @@ public class PhpLanguage extends Language {
private static final Pattern PATTERN_CHAR = Pattern.compile("['](.*?)[']");
private static final Pattern PATTERN_STRING = Pattern.compile("[\"](.*?)[\"]");
private static final Pattern PATTERN_HEX = Pattern.compile("0x[0-9a-fA-F]+");
private static final Pattern PATTERN_SINGLE_LINE_COMMENT = Pattern.compile("//[^\\n]*");
private static final Pattern PATTERN_SINGLE_LINE_COMMENT = Pattern.compile("(//|#)[^\\n]*");
private static final Pattern PATTERN_MULTI_LINE_COMMENT = Pattern.compile("/\\*[^*]*\\*+(?:[^/*][^*]*\\*+)*/");
private static final Pattern PATTERN_TODO_COMMENT = Pattern.compile("//\\s?(TODO|todo)\\s[^\\n]*");
private static final Pattern PATTERN_TODO_COMMENT = Pattern.compile("(//|#)\\s?(TODO|todo)\\s[^\\n]*");
private static final Pattern PATTERN_ATTRIBUTE = Pattern.compile("(?<=->)[a-zA-Z0-9_]+");
private static final Pattern PATTERN_OPERATION = Pattern.compile(":|==|>|<|!=|>=|<=|->|=|>|<|%|-|-=|%=|\\+|\\-|\\-=|\\+=|\\^|\\&|\\|::|\\?|\\*");
@ -74,7 +75,7 @@ public class PhpLanguage extends Language {
return new String[]{"<?php", "__construct", "var_dump", "define", "echo", "var", "float", "int", "bool", "false", "true", "function", "private", "public", "protected", "interface", "return", "copy", "struct",
"abstract", "extends", "trait", "static", "namespace", "implements", "__set", "__get", "unlink", "this", "try", "catch", "Throwable", "Exception", "pdo", "throw", "new", "and", "or", "if", "else", "elseif",
"switch", "case", "default", "match", "require", "include", "require_once", "include_once", "goto", "do", "while", "for", "foreach", "map", "hash", "array", "range", "break", "continue", "preg_match",
"preg_match_all", "preg_replace", "str_replace", "form", "date", "abs", "min", "max", "strtotime", "mktime"};
"preg_match_all", "preg_replace", "str_replace", "form", "date", "abs", "min", "max", "strtotime", "mktime", "use", "enum", "class"};
}
@Override

View file

@ -2,6 +2,7 @@ package org.mian.gitnex.helpers.codeeditor.languages;
import com.amrdeveloper.codeview.Code;
import com.amrdeveloper.codeview.Keyword;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@ -27,6 +28,7 @@ public class PythonLanguage extends Language {
private static final Pattern PATTERN_ATTRIBUTE = Pattern.compile("\\.[a-zA-Z0-9_]+");
private static final Pattern PATTERN_OPERATION = Pattern.compile(":|==|>|<|!=|>=|<=|->|=|>|<|%|-|-=|%=|\\+|\\-|\\-=|\\+=|\\^|\\&|\\|::|\\?|\\*");
private static final Pattern PATTERN_HASH_COMMENT = Pattern.compile("#(?!TODO )[^\\n]*");
private static final Pattern PATTERN_ANNOTATION = Pattern.compile("@.[a-zA-Z0-9_]+");
public static String getCommentStart() {
return "#";
@ -59,9 +61,9 @@ public class PythonLanguage extends Language {
return PATTERN_OPERATION;
case TODO_COMMENT:
return PATTERN_TODO_COMMENT;
case ANNOTATION:
// TODO supported by Python
return PATTERN_ANNOTATION;
case GENERIC:
case MULTI_LINE_COMMENT:
default:

View file

@ -1,6 +1,7 @@
package org.mian.gitnex.helpers.codeeditor.languages;
import com.amrdeveloper.codeview.Code;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

View file

@ -2,6 +2,7 @@ package org.mian.gitnex.helpers.codeeditor.languages;
import com.amrdeveloper.codeview.Code;
import com.amrdeveloper.codeview.Keyword;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;