summaryrefslogtreecommitdiff
path: root/tests/snippets/java
diff options
context:
space:
mode:
authoramitkummer <49096391+amitkummer@users.noreply.github.com>2022-01-03 20:40:34 +0200
committerGitHub <noreply@github.com>2022-01-03 19:40:34 +0100
commite0f4e77e9ce4957385a9ea0f6910f04062fe40f0 (patch)
treecce92b8936266712a5216abd45c275fb82c242ce /tests/snippets/java
parenta2ff2f095ac522bde768b290a3b6d0de4d828ef7 (diff)
downloadpygments-git-e0f4e77e9ce4957385a9ea0f6910f04062fe40f0.tar.gz
Java: fix lexing of 'record' soft keyword (#2018)
* Java: fix lexing of 'record' soft keyword Refactor the Java lexer to treat `record` as a soft keyword. Previously, the lexer assumed record is a reserved word, even though it is a soft keyword which can be used as a variable name. This refactor lexes record as a keyword only if it appears at the beggining of the line, with some potential other keywords like public and private preceding it. * Remove repetition in capture group * Update test output
Diffstat (limited to 'tests/snippets/java')
-rw-r--r--tests/snippets/java/test_record.txt54
1 files changed, 53 insertions, 1 deletions
diff --git a/tests/snippets/java/test_record.txt b/tests/snippets/java/test_record.txt
index 48ca6c02..ddae1ddc 100644
--- a/tests/snippets/java/test_record.txt
+++ b/tests/snippets/java/test_record.txt
@@ -1,15 +1,67 @@
---input---
public record RecordTest() {}
+public static record RecordTest() {}
+record Person(String firstName, String lastName) {}
+String[] record = csvReader.getValues();
+
---tokens---
'public' Keyword.Declaration
' ' Text
'record' Keyword.Declaration
' ' Text
-'RecordTest' Name.Function
+'RecordTest' Name.Class
+'(' Punctuation
+')' Punctuation
+' ' Text
+'{' Punctuation
+'}' Punctuation
+'\n' Text
+
+'public' Keyword.Declaration
+' ' Text
+'static' Keyword.Declaration
+' ' Text
+'record' Keyword.Declaration
+' ' Text
+'RecordTest' Name.Class
+'(' Punctuation
+')' Punctuation
+' ' Text
+'{' Punctuation
+'}' Punctuation
+'\n' Text
+
+'record' Keyword.Declaration
+' ' Text
+'Person' Name.Class
'(' Punctuation
+'String' Name
+' ' Text
+'firstName' Name
+',' Punctuation
+' ' Text
+'String' Name
+' ' Text
+'lastName' Name
')' Punctuation
' ' Text
'{' Punctuation
'}' Punctuation
'\n' Text
+
+'String' Name
+'[' Operator
+']' Operator
+' ' Text
+'record' Name
+' ' Text
+'=' Operator
+' ' Text
+'csvReader' Name
+'.' Punctuation
+'getValues' Name.Attribute
+'(' Punctuation
+')' Punctuation
+';' Punctuation
+'\n' Text