-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: dart language support #68
Changes from 2 commits
db16402
3f3309e
c684ad6
3185b79
a4f111c
a69219b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,4 +39,6 @@ export const CS: LanguagePattern[] = [ | |
{ pattern: /System\.(in|out)\.\w+/, type: 'not' }, | ||
// Avoiding Ruby confusion | ||
{ pattern: /\bmodule\s\S/, type: 'not' }, | ||
// Avoiding Dart confusion | ||
{ pattern: /^import\s("|')dart:\w+("|')/, type: 'not' }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. import statement can't be preceded with a whitespace? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bisa aja sih sebenernya, but don't know |
||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import type { LanguagePattern } from '../types'; | ||
|
||
export const Dart: LanguagePattern[] = [ | ||
// Variable declaration | ||
{ | ||
pattern: | ||
/^\s*(const|final|var|dynamic|late)?\s*(int|double|String|bool|List<[A-Za-z [\](),]+>|HashMap<[A-Za-z [\](),]+>|Iterator<[A-Za-z [\](),]+>|Set<[A-Za-z [\](),]+>)?(\?)?\s\w+(\s=\s.+)?(;|,)$/, | ||
type: 'keyword.variable', | ||
}, | ||
{ pattern: /\bstdout.write\(.+\);/, type: 'keyword.print' }, | ||
{ pattern: /\bprint\(.+\);/, type: 'keyword.print' }, | ||
{ pattern: /^import\s("|')dart:\w+("|')/, type: 'meta.import', nearTop: true }, | ||
{ pattern: /^import\s("|')package:\w+("|')/, type: 'meta.import', nearTop: true }, | ||
{ pattern: /^library\s\w+;/, type: 'meta.module', nearTop: true }, | ||
{ pattern: /^(void\s)?main\(\)\s(async\s)?{/, type: 'keyword.function' }, | ||
// function with type definition | ||
{ | ||
pattern: | ||
/^\s*(List<[A-Za-z [\](),]+>|HashMap<[A-Za-z [\](),]+>|int|double|String|bool|void|Iterator<[A-Za-z [\](),]+>|Set<[A-Za-z [\](),]+>)\s\w+\(.+\)\s*\{$/, | ||
type: 'keyword.function', | ||
}, | ||
// arrow function | ||
{ | ||
pattern: | ||
/^\s*(int|double|String|bool|List<[A-Za-z [\](),]+>|HashMap<[A-Za-z [\](),]+>|Iterator<[A-Za-z [\](),]+>|Set<[A-Za-z [\](),]+>)\s\w+\(.+\)\s=>/, | ||
type: 'keyword.function', | ||
}, | ||
{ pattern: /\bnew\s(List|Map|Iterator|HashMap|Set)<\w+>\(\);$/, type: 'keyword.variable' }, | ||
{ | ||
pattern: /^(abstract\s)?class\s\w+\s(extends\s\w+\s)?(with\s\w+\s)?(implements\s\w+\s)?{(})?$/, | ||
type: 'keyword.control', | ||
}, | ||
{ pattern: /\bget\s\w+=>\w+/, type: 'keyword.control' }, | ||
{ pattern: /^\s*@override$/, type: 'keyword.control' }, | ||
{ pattern: /\bset\s\w+\(.+\)/, type: 'keyword.control' }, | ||
{ pattern: /^\s*Future<w+>\s\w+\(.+\)\sasync/, type: 'keyword.control' }, | ||
{ pattern: /^\s*await\sfor/, type: 'keyword.control' }, | ||
{ pattern: /^\s*typedef\s.+\s=/, type: 'keyword.control' }, | ||
// Avoiding confusion with C | ||
{ pattern: /\blong\b/, type: 'not' }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can the |
||
{ pattern: /\s*function\b/, type: 'not' }, | ||
// Avoiding confusion with Java | ||
{ pattern: /\bArrayList/, type: 'not' }, | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be
\s+
instead of\s
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ga ada hubungannya sama dart