From 2134e5372c2bbdb2116498350274b59e11b9bf9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alan=20C=C3=A2ndido?= Date: Tue, 6 Sep 2022 20:30:46 -0300 Subject: [PATCH 1/3] Update package.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Atualização das versões de pacotes dependentes. --- package.json | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 3d28629..e2fe43e 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "url": "https://github.com/AlencarGabriel/ProtheusDoc-VsCode/issues" }, "engines": { - "vscode": "^1.52.0" + "vscode": "^1.71.0" }, "categories": [ "Other", @@ -299,20 +299,20 @@ "test": "node ./out/test/runTest.js" }, "devDependencies": { - "@types/glob": "^7.1.3", - "@types/mocha": "^5.2.7", - "@types/node": "^12.19.15", - "@types/semver": "^7.3.4", - "@types/vscode": "^1.52.0", - "glob": "^7.1.5", - "mocha": "^6.2.3", - "tslint": "^5.20.0", - "typescript": "^3.9.7", - "vscode-test": "^1.4.1" + "@types/glob": "^8.0.0", + "@types/mocha": "^9.1.1", + "@types/node": "^18.7.15", + "@types/semver": "^7.3.12", + "@types/vscode": "^1.71.0", + "glob": "^8.0.3", + "mocha": "^10.0.0", + "tslint": "^6.1.3", + "typescript": "^4.8.2", + "vscode-test": "^1.6.1" }, "dependencies": { "opn": "^6.0.0", - "protheusdoc-html": "^1.1.4", - "semver": "^7.3.4" + "protheusdoc-html": "^1.1.6", + "semver": "^7.3.7" } } From 9958ffb953540da3feeb544243e209d63820d080 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alan=20C=C3=A2ndido?= Date: Tue, 6 Sep 2022 20:31:34 -0300 Subject: [PATCH 2/3] =?UTF-8?q?Adequa=C3=A7=C3=A3o=20de=20c=C3=B3digo=20as?= =?UTF-8?q?=20atualiza=C3=A7=C3=B5es=20de=20vers=C3=B5es=20de=20dependente?= =?UTF-8?q?s.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/objects/Utils.ts | 2 +- src/test/suite/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/objects/Utils.ts b/src/objects/Utils.ts index e0c3004..44c3174 100644 --- a/src/objects/Utils.ts +++ b/src/objects/Utils.ts @@ -34,7 +34,7 @@ export class Utils { return authorDefault.trim(); } else { - return os.userInfo({ encoding: this.getEncoding() }).username; + return os.userInfo().username; } } diff --git a/src/test/suite/index.ts b/src/test/suite/index.ts index 2cd152c..5e36473 100644 --- a/src/test/suite/index.ts +++ b/src/test/suite/index.ts @@ -6,8 +6,8 @@ export function run(): Promise { // Create the mocha test const mocha = new Mocha({ ui: 'tdd', + color: true }); - mocha.useColors(true); const testsRoot = path.resolve(__dirname, '..'); From b8ae4ce0599261b0b26cd865688e9e6f3ec1b090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alan=20C=C3=A2ndido?= Date: Tue, 6 Sep 2022 20:33:03 -0300 Subject: [PATCH 3/3] Update extension.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adicionado tratamento para verificação de instalação do TDS-VSCode 1.4.0, para que esta extensão não sobrescreva as funcionalidades de _hover_ e _completion_ que serão liberadas em breve. --- src/extension.ts | 113 ++++++++++++++++++++++++----------------------- 1 file changed, 58 insertions(+), 55 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index a2693c0..eec4869 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -36,64 +36,67 @@ export function activate(context: vscode.ExtensionContext) { context.subscriptions.push(addGenerateHTMLFilesOpened()); context.subscriptions.push(addGenerateHTMLFile()); - vscode.languages.registerHoverProvider(ELanguageSupport.advpl, { - provideHover(document: vscode.TextDocument, position: vscode.Position, _token: vscode.CancellationToken) { - let symbol = document.getText(document.getWordRangeAtPosition(position)); - let _docs = new Array(); - - // Tratamento para User Functions - // tslint:disable-next-line: curly - if (symbol.toUpperCase().startsWith("U_")) - symbol = symbol.substr(2); - - // Filtra a ocorrência do Hover na tabela de documentações - let documentation = documentations.filter(doc => doc.identifier.trim().toUpperCase() === symbol.trim().toUpperCase()); - - if (documentation) { - - // Verifica se existe documentação do identificador no arquivo atual (Static Function/Method) - let docInFile = documentation.filter(doc => doc.file.fsPath === document.uri.fsPath); - - // Se a documentação estiver definida no fonte posicionado, retorna somente do fonte atual - if (docInFile.length > 0) { - docInFile.forEach(doc => { _docs.push(doc.getHover()); }); - } else { - // Se a documentação não estiver definida no fonte atual, lista todas as ocorrências caso exista - documentation.forEach(doc => { _docs.push(doc.getHover()); }); + const tdsVscode: vscode.Extension | undefined = vscode.extensions.getExtension("TOTVS.tds-vscode"); + if (tdsVscode?.packageJSON["version"] < "1.4.0") { + context.subscriptions.push( + vscode.languages.registerHoverProvider(ELanguageSupport.advpl, { + provideHover(document: vscode.TextDocument, position: vscode.Position, _token: vscode.CancellationToken) { + let symbol = document.getText(document.getWordRangeAtPosition(position)); + let _docs = new Array(); + + // Tratamento para User Functions + // tslint:disable-next-line: curly + if (symbol.toUpperCase().startsWith("U_")) + symbol = symbol.substr(2); + + // Filtra a ocorrência do Hover na tabela de documentações + let documentation = documentations.filter(doc => doc.identifier.trim().toUpperCase() === symbol.trim().toUpperCase()); + + if (documentation) { + + // Verifica se existe documentação do identificador no arquivo atual (Static Function/Method) + let docInFile = documentation.filter(doc => doc.file.fsPath === document.uri.fsPath); + + // Se a documentação estiver definida no fonte posicionado, retorna somente do fonte atual + if (docInFile.length > 0) { + docInFile.forEach(doc => { _docs.push(doc.getHover()); }); + } else { + // Se a documentação não estiver definida no fonte atual, lista todas as ocorrências caso exista + documentation.forEach(doc => { _docs.push(doc.getHover()); }); + } } + + return new vscode.Hover(_docs); } - - return new vscode.Hover(_docs); - } - }); - - context.subscriptions.push(vscode.languages.registerCompletionItemProvider( - [ELanguageSupport.advpl], - { - provideCompletionItems: (document: vscode.TextDocument, position: vscode.Position, _token: vscode.CancellationToken) => { - // const line = document.lineAt(position.line).text; - // const prefix = line.slice(0, position.character); - const util = new Utils; - let list = new vscode.CompletionList(); - - // Adiciona o Completion "Add ProtheusDoc Block" - list.items.push(new CompletionAddBlock(document, position)); - list.items.push(new CompletionAuthor(position)); - list.items.push(new CompletionHistory(position)); - list.items.push(new CompletionVersion(position)); - - // Adiciona o Completion de todas as palavras encontradas no Documento - // Verifica se o usuário deseja utilizar a sugestão de texto customizada da extensão no IntelliSense. - if (util.getUseSuggestCustom()) { - // Obs.: Necessário fazer assim pois o uso de Completion Provider faz - // com que o VsCode pare de mostrar os itens de texto no IntelliSense. - _wordsDocument.map(word => list.items.push(new vscode.CompletionItem(word, vscode.CompletionItemKind.Text))); + }), + vscode.languages.registerCompletionItemProvider( + [ELanguageSupport.advpl], + { + provideCompletionItems: (document: vscode.TextDocument, position: vscode.Position, _token: vscode.CancellationToken) => { + // const line = document.lineAt(position.line).text; + // const prefix = line.slice(0, position.character); + const util = new Utils; + let list = new vscode.CompletionList(); + + // Adiciona o Completion "Add ProtheusDoc Block" + list.items.push(new CompletionAddBlock(document, position)); + list.items.push(new CompletionAuthor(position)); + list.items.push(new CompletionHistory(position)); + list.items.push(new CompletionVersion(position)); + + // Adiciona o Completion de todas as palavras encontradas no Documento + // Verifica se o usuário deseja utilizar a sugestão de texto customizada da extensão no IntelliSense. + if (util.getUseSuggestCustom()) { + // Obs.: Necessário fazer assim pois o uso de Completion Provider faz + // com que o VsCode pare de mostrar os itens de texto no IntelliSense. + _wordsDocument.map(word => list.items.push(new vscode.CompletionItem(word, vscode.CompletionItemKind.Text))); + } + + return list; } - - return list; - } - }) - ); + }) + ); + } vscode.window.onDidChangeActiveTextEditor(editor => {