Skip to content

Commit

Permalink
Merge branch 'dev2' of https://github.com/totvs/tds-vscode into dev2
Browse files Browse the repository at this point in the history
  • Loading branch information
lwtnb-wrk committed Aug 15, 2024
2 parents 311a15c + bd8e562 commit 82c29fb
Show file tree
Hide file tree
Showing 7 changed files with 529 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Este problema estava limitado a pastas com alguns caracteres específico de acen

Realizado ajustes para evitar alterações de encoding em SO Linux e MacOS.

#### Não exibe informações do Json ao depurar [#1090](https://github.com/totvs/tds-vscode/issues/1090)

Implementado tratamento específico para objetos JSON com array no 1o nível.

## Versão [2.0.8]

### Melhorias
Expand Down
4 changes: 4 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import serverProvider from "./serverItemProvider";
import { registerWorkspace } from "./workspace";
import { sendTelemetry } from "./protocolMessages";
import { registerXRef } from "./xreferences";
import { tlppTools } from "./tlpp-tools/tlppTools";

export let languageClient: TotvsLanguageClientA;

Expand Down Expand Up @@ -603,6 +604,9 @@ export function activate(context: ExtensionContext) {
): Promise<boolean> {
return createNewProtheusServer(serverName, port, address, secure, buildVersion, environment, username);
},
apiTlppTools(message: string): Promise<string> {
return tlppTools(message);
}
};

window.showInformationMessage('"TDS-VSCode" is ready.');
Expand Down
73 changes: 73 additions & 0 deletions src/tlpp-tools/tlppTools.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
Copyright 2021-2024 TOTVS S.A
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http: //www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import * as vscode from "vscode";

import { languageClient } from "../extension";
import { ServerItem } from "../serverItem";
import { ServersConfig } from "../utils";

export function tlppTools(message: string): Promise<string> {
return new Promise<string>((resolve, reject) => {
let serverResponse: string;
const server = ServersConfig.getCurrentServer();

if (server) {
const allInfoServer: any = ServersConfig.getServerById(server.id);
if (allInfoServer) {
server.address = allInfoServer.address;
server.port = allInfoServer.port;
}
}
else {
reject(
new Error(
"No server connected. Check if there is a server connected in 'totvs.tds-vscode' extension."
)
);
return;
}

doRequest(server, message).then((result) => {
serverResponse = result;
resolve(serverResponse);
});
});
}

async function doRequest(
server: ServerItem,
params: string,
) {
return languageClient.sendRequest("$totvstlpptools/tlppTools", {
getTlppTools: {
connectionToken: server.token,
environment: server.environment,
requestParams: params
},
})
.then(
(response: any) => {
return response.requestResponse;
},
(err: Error) => {
languageClient.error(err.message);
vscode.window.showErrorMessage(
err.message + vscode.l10n.t(". See log for details.")
);
}
);
}
2 changes: 1 addition & 1 deletion syntaxes/advpl_sql.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"fileTypes": [],
"injectionSelector": "L:source.advpl",
"injectionSelector": "L:source.advpl - comment.block.advpl - comment.line.double-slash",
"scopeName": "sql.advpl",
"patterns": [
{
Expand Down
27 changes: 27 additions & 0 deletions test/resources/projects/advpl/files/json/TSTADAP.tlpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#INCLUDE 'TOTVS.CH'

User Function TSTADAP
Local jTeste := JsonObject():New()
Local jTeste2 := JsonObject():New()
Local cJson := ''
Local oFile := Nil
Local aLines := {}

oFile := FwFileReader():New('W:\ws_tds_vscode\tds-vscode\test\resources\projects\advpl\files\json\jsonteste.json')
If(oFile:Open())
aLines := oFile:GetAllLines()
oFile:Close()
aEval(aLines, { |x| cJson += x })
EndIf
jTeste:FromJson(cJson)

cJson := ""
oFile := FwFileReader():New('W:\ws_tds_vscode\tds-vscode\test\resources\projects\advpl\files\json\jsonteste2.json')
If(oFile:Open())
aLines := oFile:GetAllLines()
oFile:Close()
aEval(aLines, { |x| cJson += x })
EndIf
jTeste2:FromJson(cJson)

Return
209 changes: 209 additions & 0 deletions test/resources/projects/advpl/files/json/jsonteste.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
[
{
"campo": "ZV2_FILIAL",
"tipo_campo": "C",
"tamanho_campo": 2,
"titulo_campo": "Filial do Sistema",
"id_agrupamento": "",
"ordem_campo": "01",
"agrupamento": "",
"mascara": "",
"obrigatorio": false,
"virtual": false,
"inicializador": "",
"opcoes": [],
"configuracoes": {
"tamanho_coluna": 4,
"regra_exibicao": {
"visualizar": true,
"incluir": true,
"alterar": true,
"excluir": true
}
}
},
{
"campo": "ZV2_DOC",
"tipo_campo": "C",
"tamanho_campo": 9,
"titulo_campo": "Numero do Documento",
"id_agrupamento": "",
"ordem_campo": "02",
"agrupamento": "",
"mascara": "",
"obrigatorio": false,
"virtual": false,
"inicializador": "",
"opcoes": [],
"configuracoes": {
"tamanho_coluna": 4,
"regra_exibicao": {
"visualizar": true,
"incluir": true,
"alterar": true,
"excluir": true
}
}
},
{
"campo": "ZV2_COD",
"tipo_campo": "C",
"tamanho_campo": 30,
"titulo_campo": "Codigo do Produto",
"id_agrupamento": "",
"ordem_campo": "03",
"agrupamento": "",
"mascara": "",
"obrigatorio": true,
"virtual": false,
"inicializador": "",
"opcoes": [],
"configuracoes": {
"tamanho_coluna": 4,
"regra_exibicao": {
"visualizar": true,
"incluir": true,
"alterar": true,
"excluir": true
}
}
},
{
"campo": "ZV2_DESCRI",
"tipo_campo": "C",
"tamanho_campo": 30,
"titulo_campo": "Descricao do Produto",
"id_agrupamento": "",
"ordem_campo": "04",
"agrupamento": "",
"mascara": "",
"obrigatorio": false,
"virtual": true,
"inicializador": "",
"opcoes": [],
"configuracoes": {
"tamanho_coluna": 4,
"regra_exibicao": {
"visualizar": true,
"incluir": true,
"alterar": true,
"excluir": true
}
}
},
{
"campo": "ZV2_UM",
"tipo_campo": "C",
"tamanho_campo": 2,
"titulo_campo": "Unidade de Medida",
"id_agrupamento": "",
"ordem_campo": "05",
"agrupamento": "",
"mascara": "",
"obrigatorio": false,
"virtual": false,
"inicializador": "",
"opcoes": [],
"configuracoes": {
"tamanho_coluna": 4,
"regra_exibicao": {
"visualizar": true,
"incluir": true,
"alterar": true,
"excluir": true
}
}
},
{
"campo": "ZV2_QUANT",
"tipo_campo": "N",
"tamanho_campo": 12,
"titulo_campo": "Quantidade na 1a Unidade",
"id_agrupamento": "",
"ordem_campo": "06",
"agrupamento": "",
"mascara": "9,999,999.9999",
"obrigatorio": false,
"virtual": false,
"inicializador": "",
"opcoes": [],
"configuracoes": {
"tamanho_coluna": 4,
"regra_exibicao": {
"visualizar": true,
"incluir": true,
"alterar": true,
"excluir": true
}
}
},
{
"campo": "ZV2_DTVALI",
"tipo_campo": "D",
"tamanho_campo": 8,
"titulo_campo": "Data de Validade",
"id_agrupamento": "",
"ordem_campo": "07",
"agrupamento": "",
"mascara": "",
"obrigatorio": false,
"virtual": false,
"inicializador": "",
"opcoes": [],
"configuracoes": {
"tamanho_coluna": 4,
"regra_exibicao": {
"visualizar": true,
"incluir": true,
"alterar": true,
"excluir": true
}
}
},
{
"campo": "ZV2_QUANT2",
"tipo_campo": "N",
"tamanho_campo": 12,
"titulo_campo": "Quantidade na 2a Unidade",
"id_agrupamento": "",
"ordem_campo": "08",
"agrupamento": "",
"mascara": "9,999,999.9999",
"obrigatorio": false,
"virtual": false,
"inicializador": "",
"opcoes": [],
"configuracoes": {
"tamanho_coluna": 4,
"regra_exibicao": {
"visualizar": true,
"incluir": true,
"alterar": true,
"excluir": true
}
}
},
{
"campo": "ZV2_OBS",
"tipo_campo": "M",
"tamanho_campo": 10,
"titulo_campo": "Observacao",
"id_agrupamento": "",
"ordem_campo": "09",
"agrupamento": "",
"mascara": "",
"obrigatorio": false,
"virtual": false,
"inicializador": "",
"opcoes": [],
"configuracoes": {
"tamanho_coluna": 4,
"regra_exibicao": {
"visualizar": true,
"incluir": true,
"alterar": true,
"excluir": true
}
}
}
]
Loading

0 comments on commit 82c29fb

Please sign in to comment.