diff --git a/package.json b/package.json index 0d5460f..66815e3 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Cairo language support for StarkNet in VS Code", "author": "Eric Lau", "license": "EPL-2.0", - "version": "0.0.26", + "version": "0.0.27", "preview": true, "icon": "images/logo.png", "repository": { diff --git a/server/CHANGELOG.md b/server/CHANGELOG.md index 3651333..f19d71c 100644 --- a/server/CHANGELOG.md +++ b/server/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 0.0.9 + +- Support Cairo 0.10 + ## 0.0.8 - Support adding custom Cairo paths in settings. ([#41](https://github.com/ericglau/cairo-ls/pull/41)) diff --git a/server/package.json b/server/package.json index ce28831..feebc9d 100644 --- a/server/package.json +++ b/server/package.json @@ -1,7 +1,7 @@ { "name": "cairo-ls", "description": "Cairo Language Server", - "version": "0.0.8", + "version": "0.0.9", "author": "Eric Lau", "license": "EPL-2.0", "engines": { diff --git a/server/src/server.ts b/server/src/server.ts index 7b4da86..e305cc2 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -224,7 +224,7 @@ end let withinImportModule: string | undefined; for (var i = 0; i < lines.length; i++) { var line: string = lines[i].trim(); - if (line.length == 0 || line.startsWith("#")) { // ignore whitespace or comments + if (line.length == 0 || line.startsWith("//")) { // ignore whitespace or comments continue; } if (line.startsWith("from")) { @@ -311,7 +311,7 @@ end let context: ParsingContext | undefined; for (var i = 0; i < lines.length; i++) { let line: string = lines[i].trim(); - if (line.length == 0 || line.startsWith("#")) { // ignore whitespace or comments + if (line.length == 0 || line.startsWith("//")) { // ignore whitespace or comments continue; } if (context !== undefined && context.namespace !== undefined) { @@ -352,19 +352,19 @@ end } if (startsWith(line, 'struct')) { - pushDefinitionIfFound(line, importName, moduleUrl, ":", STRUCT); + pushDefinitionIfFound(line, importName, moduleUrl, "{", STRUCT); } if (startsWith(line, 'namespace')) { // get namespace from line - const searchNamespace = line.substring('namespace'.length, line.lastIndexOf(':')).trim(); + const searchNamespace = line.substring('namespace'.length, line.lastIndexOf('{')).trim(); context = { namespace: searchNamespace }; connection.console.log(`Going into namespace: ${context.namespace}`); const [ namespace ] = wordWithDot.split('.'); // if we are hovering over the namespace portion in namespace.function, add the namespace definition from the imported module if (word === namespace) { - pushDefinitionIfFound(line, importName, moduleUrl, ":", NAMESPACE); + pushDefinitionIfFound(line, importName, moduleUrl, "{", NAMESPACE); } } } @@ -375,7 +375,7 @@ end let lines = textDocumentContents.split('\n'); for (var i = 0; i < lines.length; i++) { let line: string = lines[i].trim(); - if (line.length == 0 || line.startsWith("#")) { // ignore whitespace or comments + if (line.length == 0 || line.startsWith("//")) { // ignore whitespace or comments continue; } if (line.startsWith("func") && line.length > 5 && line.charAt(4).match(/\s/)) { // look for functions @@ -758,7 +758,7 @@ function getPythonPackageDir(basePath: string) { } else { continue; } - } else if (line.startsWith("#")) { + } else if (line.startsWith("//")) { continue; } if (line === '[options.packages.find]') { @@ -818,7 +818,7 @@ function getCompileCommand(settings: CairoLSSettings, tempFiles: TempFiles, text var directivesFound: boolean = false; for (var i = 0; i < lines.length; i++) { var line: string = lines[i].trim(); - if (line.length == 0 || line.startsWith("#")) { // ignore whitespace or comments + if (line.length == 0 || line.startsWith("//")) { // ignore whitespace or comments continue; } if (line.startsWith("%")) { @@ -1066,8 +1066,8 @@ enum SyntaxType { ImportKeyword, // from ImportFunction, // from import ImportFunctionP, // from import ( ... ) - FunctionDecl, // between "func" and ":" - Function, // between ":" and "end" + FunctionDecl, // between "func" and "{" + Function, // between "{" and "end" WithAttr, // with_attr Base // file level } @@ -1275,12 +1275,12 @@ connection.onCompletion( } // Capture function declaration - if (line.trimLeft().startsWith("func") && !line.includes(":")) { + if (line.trimLeft().startsWith("func") && !line.includes("{")) { return SyntaxType.FunctionDecl; } // Capture function body - if (lastType === SyntaxType.FunctionDecl && line.trimRight().endsWith(":")) { + if (lastType === SyntaxType.FunctionDecl && line.trimRight().endsWith("{")) { return SyntaxType.Function; } @@ -1331,7 +1331,7 @@ function getModuleNameFromImportPosition(textDocPositionParams: TextDocumentPosi let importItems: Set = new Set(); // keep a set of unique entries for (var i = 0; i < lines.length; i++) { let line: string = lines[i].trim(); - if (line.length == 0 || line.startsWith("#")) { // ignore whitespace or comments + if (line.length == 0 || line.startsWith("//")) { // ignore whitespace or comments continue; } const FUNC = "func";