DEV Community

CrabPascal
CrabPascal

Posted on

Full IDE Integration: Problems, Tasks, and Debug | Integração IDE completa

Bilingual post · Post bilíngue

Jump to: English · Português


English {#english}

Full IDE Integration: Problems, Tasks, and Debug

After post 033 you can install CrabPascal and run hello-world from the terminal. The next productivity jump is IDE integration: errors in the Problems panel, one-key build/run, and diagnostics that point to real line/column — not 1:1 placeholders.

The Mintlify guides integracao-ide-completa-v2-0-0 and guia-integracao-vscode-cursor document the full stack. This post distills the workflow.

The check command is the IDE backbone

IDEs do not need execution to be useful — they need fast, accurate static analysis. CrabPascal's check runs lexer + parser + semantic analyzer without running your program:

crab-pascal check MyUnit.pas
Enter fullscreen mode Exit fullscreen mode

Output follows the VS Code problem matcher convention:

MyUnit.pas:10:5: error: Undefined variable 'z'
MyUnit.pas:15:8: warning: Variable 'y' declared but never used
Enter fullscreen mode Exit fullscreen mode

Since Sprint 1 (v2.9.9), parse errors report real spans. Semantic errors improved in later sprints — but the format stayed stable so extensions never broke.

Internally, src/error_formatter.rs defines CompilerError with file, line, column, level, and message. Keeping stderr machine-readable was an explicit design choice.

Problem matcher configuration

Whether you use the marketplace extension or manual setup, the regex pattern is the same:

{
  "problemMatcher": {
    "owner": "crabpascal",
    "fileLocation": ["relative", "${workspaceFolder}"],
    "pattern": {
      "regexp": "^(.+?):(\\d+):(\\d+):\\s+(error|warning|info):\\s+(.+)$",
      "file": 1,
      "line": 2,
      "column": 3,
      "severity": 4,
      "message": 5
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Windows paths like C:\proj\unit.pas broke naive split(':') parsers early on. The fix: locate : error: from the right side of the string. If you write custom tooling, copy the pattern from the repo's tests/check_diagnostics.rs fixtures.

Tasks and keyboard shortcuts

Three tasks cover daily Pascal work:

Task Default key Command
Verify syntax crab-pascal check ${file}
Build current file Ctrl+Shift+B compile / check pipeline
Run current file Ctrl+F5 crab-pascal run ${file}

The official extension (crabpascal.crabpascal) ships these pre-wired — see guia-integracao-vscode-cursor. Manual .vscode/tasks.json still works for contributors hacking the compiler itself.

Recommended settings.json associations:

{
  "files.associations": {
    "*.pas": "pascal",
    "*.dpr": "pascal",
    "*.pp": "pascal"
  },
  "editor.tabSize": 2
}
Enter fullscreen mode Exit fullscreen mode

Extension vs manual setup

Option 1 (recommended): Install from VS Code Marketplace. Auto-install of crab-pascal.exe is optional on first run.

Option 2: Point tasks at target/release/crab-pascal.exe after cargo build --release. Useful when testing a local compiler build against the same .pas files.

Cursor users follow the identical path — it's VS Code-compatible.

Debug workflow today

Full GDB/LLDB debug of generated C is on the roadmap. Practical workflow now:

  1. check on save (task or extension) → fix red squiggles in Problems
  2. run for interpreter path — fastest iteration
  3. build-exe when you need native speed or deployment artifacts

For Horse APIs, run the server in a terminal panel; hit endpoints with Postman (post 036). The IDE handles Pascal sources; HTTP testing stays in REST tools.

Troubleshooting checklist

  • Problems empty but terminal shows errors? Problem matcher owner mismatch — ensure task label matches extension config.
  • All errors at 1:1? Upgrade to v2.9.9+; verify you're running the same binary the extension invokes.
  • Horse example won't run from task? Long-running servers block tasks — use dedicated terminal, not build task.

Read the full integration doc for banner/version alignment notes the squad tracked in Sprint 1 review.

Next in series

Post 035 — How We Ship the VS Code Extension explains marketplace publishing, why tasks live inside vscode-extension/ instead of repo-root .vscode/, and the vsce release loop.


Português {#portugus}

Integração IDE completa: Problems, Tasks e Debug

Depois do post 033 você instala o CrabPascal e roda hello-world no terminal. O próximo salto de produtividade é a integração com IDE: erros no painel Problems, build/run em uma tecla e diagnósticos com linha/coluna reais — não placeholders 1:1.

Os guias Mintlify integracao-ide-completa-v2-0-0 e guia-integracao-vscode-cursor documentam a pilha completa. Este post destila o fluxo.

O comando check é a espinha dorsal da IDE

IDEs não precisam executar código para ser úteis — precisam de análise estática rápida e precisa. O check do CrabPascal roda lexer + parser + analisador semântico sem executar o programa:

crab-pascal check MyUnit.pas
Enter fullscreen mode Exit fullscreen mode

A saída segue a convenção do problem matcher do VS Code:

MyUnit.pas:10:5: error: Undefined variable 'z'
MyUnit.pas:15:8: warning: Variable 'y' declared but never used
Enter fullscreen mode Exit fullscreen mode

Desde o Sprint 1 (v2.9.9), erros de parse reportam spans reais. Erros semânticos melhoraram em sprints posteriores — mas o formato permaneceu estável para não quebrar extensões.

Internamente, src/error_formatter.rs define CompilerError com arquivo, linha, coluna, nível e mensagem. Manter stderr legível por máquina foi escolha explícita de design.

Configuração do problem matcher

Com extensão do Marketplace ou setup manual, o regex é o mesmo:

{
  "problemMatcher": {
    "owner": "crabpascal",
    "fileLocation": ["relative", "${workspaceFolder}"],
    "pattern": {
      "regexp": "^(.+?):(\\d+):(\\d+):\\s+(error|warning|info):\\s+(.+)$",
      "file": 1,
      "line": 2,
      "column": 3,
      "severity": 4,
      "message": 5
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Paths Windows como C:\proj\unit.pas quebraram parsers ingênuos com split(':'). A correção: localizar : error: pelo lado direito da string. Se escrever ferramentas custom, copie o padrão dos fixtures em tests/check_diagnostics.rs.

Tasks e atalhos de teclado

Três tasks cobrem o trabalho Pascal diário:

Task Tecla padrão Comando
Verificar sintaxe crab-pascal check ${file}
Compilar arquivo atual Ctrl+Shift+B pipeline compile / check
Executar arquivo atual Ctrl+F5 crab-pascal run ${file}

A extensão oficial (crabpascal.crabpascal) já vem configurada — veja guia-integracao-vscode-cursor. .vscode/tasks.json manual ainda funciona para quem altera o compilador.

settings.json recomendado:

{
  "files.associations": {
    "*.pas": "pascal",
    "*.dpr": "pascal",
    "*.pp": "pascal"
  },
  "editor.tabSize": 2
}
Enter fullscreen mode Exit fullscreen mode

Extensão vs configuração manual

Opção 1 (recomendada): Instalar pelo VS Code Marketplace. Auto-instalação do crab-pascal.exe é opcional na primeira execução.

Opção 2: Apontar tasks para target/release/crab-pascal.exe após cargo build --release. Útil ao testar build local do compilador nos mesmos .pas.

Usuários Cursor seguem o mesmo caminho — compatível com VS Code.

Fluxo de debug hoje

Debug GDB/LLDB completo do C gerado está no roadmap. Fluxo prático atual:

  1. check ao salvar (task ou extensão) → corrigir squiggles no Problems
  2. run no interpretador — iteração mais rápida
  3. build-exe quando precisar de velocidade nativa ou artefatos de deploy

Para APIs Horse, rode o servidor em um terminal; teste endpoints com Postman (post 036). A IDE cuida do Pascal; HTTP fica em ferramentas REST.

Checklist de troubleshooting

  • Problems vazio mas terminal mostra erros? Owner do matcher diferente — alinhe label da task com a extensão.
  • Todos os erros em 1:1? Atualize para v2.9.9+; confirme que a extensão chama o mesmo binário.
  • Exemplo Horse não roda na task? Servidores longos bloqueiam tasks — use terminal dedicado.

Leia o doc completo de integração para notas de alinhamento banner/versão que a squad registrou no review do Sprint 1.

Próximo da série

Post 035 — Como publicamos a extensão VS Code explica publicação no Marketplace, por que tasks ficam em vscode-extension/ e não em .vscode/ na raiz, e o ciclo de release com vsce.


Published on dev.to/@crabpascal · Código em CrabPascal

Top comments (0)