advpl-tlpp
Skill1 starsChanged 6 months agoMITView on GitHub
TLPP (TOTVS Language Plus Productive) — sucessor moderno do ADVPL com OO completa, namespaces, annotations @Get/@Post/@Test, JSON nativo, try/catch, reflection. Use ao trabalhar com arquivos .tlpp/.th, código TLPP novo, REST moderno, classes com herança/interfaces, ou migração ADVPL→TLPP.
In this repository29 other files it gives its agents.
- advpl-advancedSkill
- advpl-code-reviewSkill
- advpl-dicionario-sxSkill
- advpl-embedded-sqlSkill
- advpl-encodingSkill
- advpl-fundamentalsSkill
- advpl-jobs-rpcSkill
- advpl-matxfisSkill
- advpl-mvc-avancadoSkill
- advpl-mvcSkill
- advpl-pontos-entradaSkill
- advpl-webserviceSkill
- advpl-webSkill
- archSkill
- calleesSkill
- callersSkill
- doctorSkill
- findSkill
- grepSkill
- helpSkill
- ingestSkill
- initSkill
- lintSkill
- paramSkill
- plugadvpl-index-usageSkill
- reindexSkill
- setupSkill
- statusSkill
- tablesSkill
The file
Files
advpl-tlpp — TLPP (TOTVS Language Plus Productive)
TLPP é a evolução moderna do ADVPL lançada pela TOTVS para suportar paradigmas atuais: orientação a objetos completa, namespaces, annotations, exceções estruturadas, JSON nativo, reflection. Coexiste com ADVPL no mesmo RPO/tlpp.rpo — código TLPP chama ADVPL e vice-versa.
Quando usar
- Edit/criação de arquivos
.tlppou.th(header TLPP). - Endpoints REST com annotations (
@Get,@Post,@Put,@Delete). - Classes com herança, interfaces, modificadores de acesso (
public/protected/private). - Testes unitários com PROBAT (
@Test,@Before,@After). - Migração ADVPL → TLPP.
- Uso de
JsonObject,try/catch/finally,throw.
Extensões e includes
.tlpp— fonte TLPP (compilado paratlpp.rpo)..th— header TLPP (substitui.chdo ADVPL).- Includes essenciais:
#include "tlpp-core.th"— features básicas (try/catch, JsonObject, annotations).#include "tlpp-rest.th"— annotations REST.#include "tlpp-object.th"— classes/interfaces.
Tipagem opcional e parâmetros nomeados
function processOrder(string cNumero, numeric nValor := 0.00, boolean lEmite := .T.) as logical
return .T.
endfunctionTipos: string, numeric, boolean, date, array, object, codeblock, json, character, logical.
Namespaces
namespace custom.mvc.customer
class Customer
public data cCodigo as string
method New() constructor
method save() as logical
endclassusing namespace custom.mvc.customer no consumidor. Convenção: minúsculo, dot-separated, começa pelo cliente.
Orientação a objetos completa
class Vehicle
public data cPlate as string
private data nMileage as numeric
protected data dService as date
public method New(cPlate) constructor
public method getInfo() as string
protected method updateService(dDate) as logical
endclass
method New(cPlate) class Vehicle
self:cPlate := cPlate
endmethod
method getInfo() class Vehicle
return "Vehicle: " + self::cPlate- Herança:
class Car from Vehicle. - Interfaces:
interface IPrintable+class Foo implements IPrintable. - Métodos estáticos:
static method utility() class Foo.
Annotations
@Get(endpoint="/v1/customer/:id", description="Get customer by id")
@Auth(roles="admin,seller")
user function getCustomer()
local cId := oRest:GetUrlParam("id")
// ...
return .T.Annotations customizadas via reflection:
@MyAnnotation(value="x")
function foo()
// descobrível via FwReflection
endfunctionREST moderno (FWRest)
namespace custom.api.customer
using namespace tlpp.web
class CustomerApi from FWRest
@Get(endpoint="/v1/customers")
method list() as json
@Post(endpoint="/v1/customers")
method create() as json
endclassResposta JSON nativa, sem oRest:SetResponse(cString) manual.
try/catch/finally + throw
try
if Empty(cId)
throw ErrorClass():New("400", "ID obrigatório")
endif
// ...
catch oErr
conout("Erro: " + oErr:getDescription())
oRest:SetStatusCode(500)
finally
if oFile != nil
oFile:close()
endif
endtryErrorClass permite codes estruturados (HTTP-style).
JSON nativo
local oJson := JsonObject():New()
oJson["nome"] := "ACME"
oJson["itens"] := {1, 2, 3}
oJson["sub"] := JsonObject():New()
oJson["sub"]["x"] := 10
local cStr := oJson:ToJson()
local cErr := oJson:FromJson(cInput)Listas: array nativo. Booleano: .T./.F.. Null: nil.
PROBAT — testes unitários
@Test
function testAddition()
local nResult := 2 + 2
paAssertEqual(4, nResult, "2+2 deve ser 4")
endfunctionRode via TDS ou tdscli probat.
Interoperabilidade com ADVPL
- TLPP chama ADVPL: chamada direta de
User FunctionADVPL existente. - ADVPL chama TLPP: precisa
using namespaceno fonte TLPP exportado; ADVPL chamaMyClass():New()se a classe for compilada. StaticCallestá deprecado em TLPP — use namespaces.
Anti-padrões
- Misturar TLPP e ADVPL clássico no mesmo arquivo
.tlppdesnecessariamente (compila, mas perde idiomática). - Esquecer
endclass/endmethod— TLPP é stricter que ADVPL. Publicglobal em TLPP — viola encapsulamento; usestaticna classe.throwsemtry/catchno ponto chamador → derruba thread.- Annotations sem
tlpp-core.thno include → erro de compilação.
Referência profunda
Para detalhes completos (~2.4k linhas), consulte reference.md ao lado deste arquivo:
- Comparativo lado-a-lado TLPP × ADVPL (sintaxe, tipos, OO, exceções).
- Catálogo de annotations padrão (
@Get,@Post,@Put,@Delete,@Test,@Auth,@Cache,@Sync). - Hierarquia completa de
ErrorClasse como criar exceções customizadas. - Reflection API (
FwReflection, leitura de annotations em runtime). - TDS (TOTVS Developer Studio) — workflow de compilação, debug, patches via VSCode.
- Estratégias de migração ADVPL → TLPP com armadilhas comuns documentadas.
Comandos plugadvpl relacionados
/plugadvpl:find function <metodo>— localiza classes/métodos TLPP./plugadvpl:lint <arq.tlpp>— checagens específicas TLPP./plugadvpl:grep "@Get|@Post"— lista endpoints REST.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

