@dodona/dolos-lib
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -26,12 +26,10 @@ var _a; | ||
async loadLanguageModule() { | ||
try { | ||
if (this.languageModule === undefined) { | ||
// @ts-ignore | ||
this.languageModule = (await import("@dodona/dolos-parsers")).default[this.name]; | ||
if (this.languageModule === undefined) { | ||
this.languageModule = (await import(`tree-sitter-${this.name}`)).default; | ||
throw new LanguageError("Could not find language module for: " + this.name); | ||
} | ||
return this.languageModule; | ||
} | ||
catch (error) { | ||
throw new Error(`The module 'tree-sitter-${this.name}' could not be found. ` + | ||
"Try to install it using npm or yarn, but it may not be supported (yet)."); | ||
} | ||
return this.languageModule; | ||
} | ||
@@ -88,4 +86,4 @@ async createTokenizer() { | ||
for (const extension of language.extensions) { | ||
this.byExtension.set(extension, language); | ||
this.byName.set(language.name, language); | ||
this.byExtension.set(extension.toLowerCase(), language); | ||
this.byName.set(language.name.toLowerCase(), language); | ||
} | ||
@@ -107,6 +105,6 @@ } | ||
for (const file of files) { | ||
const count = ((_b = counts.get(file.extension)) !== null && _b !== void 0 ? _b : 0) + 1; | ||
const count = ((_b = counts.get(file.extension.toLowerCase())) !== null && _b !== void 0 ? _b : 0) + 1; | ||
if (count > maxCount) { | ||
maxCount = count; | ||
language = this.byExtension.get(file.extension); | ||
language = this.byExtension.get(file.extension.toLowerCase()); | ||
} | ||
@@ -126,5 +124,5 @@ counts.set(file.extension, count); | ||
async findLanguage(name) { | ||
let language = this.byName.get(name); | ||
let language = this.byName.get(name.toLowerCase()); | ||
if (language == null) { | ||
const proglang = new ProgrammingLanguage(name, []); | ||
const proglang = new ProgrammingLanguage(name.toLowerCase(), []); | ||
// Try to load the language module to see if it exists, | ||
@@ -146,11 +144,10 @@ // will throw an error if it does not exist. | ||
new ProgrammingLanguage("php", [".php", ".php3", ".php4", ".php5", ".php7", ".phps", ".phpt", ".phtml"]), | ||
new ProgrammingLanguage("modelica", [".mo", ".mos"]), | ||
new ProgrammingLanguage("java", [".java"]), | ||
new ProgrammingLanguage("javascript", [".js"]), | ||
new CustomTreeSitterLanguage("elm", [".elm"], "@elm-tooling/tree-sitter-elm"), | ||
new CustomTreeSitterLanguage("typescript", [".ts"], | ||
// @ts-ignore | ||
async () => (await import("tree-sitter-typescript")).default.typescript), | ||
new CustomTreeSitterLanguage("tsx", [".tsx"], | ||
// @ts-ignore | ||
async () => (await import("tree-sitter-typescript")).default.tsx), | ||
new ProgrammingLanguage("elm", [".elm"]), | ||
new ProgrammingLanguage("r", [".r", ".rdata", ".rds", ".rda"]), | ||
new ProgrammingLanguage("sql", [".sql"]), | ||
new ProgrammingLanguage("typescript", [".ts"]), | ||
new ProgrammingLanguage("tsx", [".tsx"]), | ||
new CustomTokenizerLanguage("char", [".txt", ".md"], async (self) => { | ||
@@ -157,0 +154,0 @@ const { CharTokenizer } = await import("./tokenizer/charTokenizer.js"); |
{ | ||
"name": "@dodona/dolos-lib", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"exports": "./dist/index.js", | ||
@@ -30,3 +30,3 @@ "type": "module", | ||
"@ava/typescript": "4.1.0", | ||
"@types/d3-dsv": "3.0.5", | ||
"@types/d3-dsv": "3.0.7", | ||
"@types/node": "^20.3.2", | ||
@@ -36,23 +36,12 @@ "@typescript-eslint/eslint-plugin": "6.8.0", | ||
"ava": "5.3.1", | ||
"eslint": "8.52.0", | ||
"node-gyp": "^9.4.0", | ||
"eslint": "8.53.0", | ||
"node-gyp": "^9.4.1", | ||
"typescript": "5.2.2" | ||
}, | ||
"dependencies": { | ||
"@dodona/dolos-core": "1.0.0", | ||
"d3-dsv": "^3.0.0" | ||
"@dodona/dolos-parsers": "1.0.0", | ||
"@dodona/dolos-core": "1.0.1", | ||
"d3-dsv": "^3.0.1", | ||
"tree-sitter": "^0.20.6" | ||
}, | ||
"optionalDependencies": { | ||
"@elm-tooling/tree-sitter-elm": "5.6.6", | ||
"tree-sitter": "^0.20.5", | ||
"tree-sitter-bash": "^0.20.3", | ||
"tree-sitter-c": "^0.20.4", | ||
"tree-sitter-c-sharp": "^0.20.0", | ||
"tree-sitter-cpp": "^0.20.2", | ||
"tree-sitter-javascript": "^0.20.0", | ||
"tree-sitter-java": "^0.20.0", | ||
"tree-sitter-php": "^0.19.0", | ||
"tree-sitter-python": "^0.20.3", | ||
"tree-sitter-typescript": "^0.20.0" | ||
}, | ||
"bugs": { | ||
@@ -59,0 +48,0 @@ "url": "https://github.com/dodona-edu/dolos/issues" |
@@ -17,8 +17,9 @@ # Dolos lib | ||
Dolos uses [tree-sitter](https://www.npmjs.com/package/tree-sitter) to parse | ||
source code files. Tree-sitter currently only runs in node and will thus not | ||
run in browser environments. Since some of the library's functionality is use | ||
by the [Dolos Web UI](https://www.npmjs.com/package/@dodona/dolos-web), the | ||
dependency on tree-sitter is optional. | ||
**Required:** Node.js, Python 3 and a compiler (GCC) | ||
Dolos uses [tree-sitter](https://www.npmjs.com/package/tree-sitter) to parse source code files. | ||
Tree-sitter currently only runs in node and will thus not run in browser environments. | ||
If you only require the matching algorithms, you can use the platform-independent library [Dolos Core](https://www.npmjs.com/package/@dodona/dolos-core). | ||
## Usage | ||
@@ -25,0 +26,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
64348
4
39
51
0
854
+ Added@dodona/dolos-parsers@1.0.0
+ Addedtree-sitter@^0.20.6
+ Added@dodona/dolos-core@1.0.1(transitive)
+ Added@dodona/dolos-parsers@1.0.0(transitive)
- Removed@dodona/dolos-core@1.0.0(transitive)
- Removed@elm-tooling/tree-sitter-elm@5.6.6(transitive)
- Removedtree-sitter-bash@0.20.5(transitive)
- Removedtree-sitter-c@0.20.8(transitive)
- Removedtree-sitter-c-sharp@0.20.0(transitive)
- Removedtree-sitter-cpp@0.20.5(transitive)
- Removedtree-sitter-java@0.20.2(transitive)
- Removedtree-sitter-javascript@0.20.4(transitive)
- Removedtree-sitter-php@0.19.0(transitive)
- Removedtree-sitter-python@0.20.4(transitive)
- Removedtree-sitter-typescript@0.20.5(transitive)
- Removedweb-tree-sitter@0.20.8(transitive)
Updated@dodona/dolos-core@1.0.1
Updatedd3-dsv@^3.0.1