-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
361 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,249 +2,55 @@ | |
(* *) | ||
(* SuperBOL OSS Studio *) | ||
(* *) | ||
(* Copyright (c) 2022-2023 OCamlPro SAS *) | ||
(* *) | ||
(* Copyright (c) 2023 OCamlPro SAS *) | ||
(* *) | ||
(* All rights reserved. *) | ||
(* This source code is licensed under the MIT license found in the *) | ||
(* LICENSE.md file in the root directory of this source tree. *) | ||
(* *) | ||
(* All rights reserved. *) | ||
(* This source code is licensed under the GNU Affero General Public *) | ||
(* License version 3 found in the LICENSE.md file in the root directory *) | ||
(* of this source tree. *) | ||
(* *) | ||
(**************************************************************************) | ||
|
||
open Vscode_json | ||
open Manifest | ||
|
||
let vscode_engine = "1.64.0" | ||
|
||
|
||
let marketplace = Manifest.marketplace | ||
"ocamlpro" | ||
~categories: [ | ||
"Formatters" ; | ||
"Programming Languages" ; | ||
"Linters" ; | ||
"Snippets" ; | ||
"Other" | ||
] | ||
|
||
let package = | ||
Manifest.package | ||
"superbol" | ||
~displayName: "Superbol Studio OSS" | ||
~description: "Provides a COBOL mode in VSCode, based on SuperBOL Language Server Protocol for COBOL" | ||
~license: "MIT" | ||
~version: "0.1.0" | ||
~repository: { | ||
type_ = Some "git" ; | ||
url = "https://github.com/OCamlPro/superbol-studio-oss" | ||
} | ||
~homepage: "https://get-superbol.com" | ||
~author: { | ||
author_name = "SuperBOL at OCamlPro" ; | ||
author_email = Some "[email protected]" | ||
} | ||
~keywords: [ "cobol" ; "gnucobol" ] | ||
~main: "./_dist/superbol_vscode_platform.bc.js" | ||
~scripts: [ | ||
"compile", | ||
"make compile" ; | ||
|
||
"release", | ||
"make release" ; | ||
open Ez_file.V1 | ||
|
||
"package" , | ||
"vsce package --out superbol-vscode-platform.vsix --yarn" ; | ||
module DIAGS = Cobol_common.Diagnostics | ||
|
||
"deploy:vsce" , | ||
"vsce publish --packagePath superbol-vscode-platform.vsix --yarn" ; | ||
|
||
"deploy:ovsx" , | ||
"ovsx publish --yarn" | ||
] | ||
~dependencies: [ | ||
"@vscode/debugadapter", "^1.61.0" ; | ||
"@vscode/debugprotocol", "^1.61.0" ; | ||
"polka" , "^1.0.0-next.22" ; | ||
"sirv" , "^2.0.2" ; | ||
"vscode-languageclient" , "8.0.2" | ||
] | ||
~devDependencies: [ | ||
"@types/vscode" , vscode_engine ; | ||
"esbuild" , "0.15.16" ; | ||
"fs-extra" , "10.0.1" ; | ||
"mocha" , "9.2.2" ; | ||
"npm-run-all" , "4.1.5" ; | ||
"ovsx" , "0.1.0-next.97d460c" ; | ||
"prettier" , "^2.5.1" ; | ||
"vsce" , "^2.15.0" ; | ||
"vscode-test" , "1.6.1" | ||
] | ||
|
||
let contributes = | ||
Manifest.contributes () | ||
~languages: [ | ||
Manifest.language "cobol" | ||
~aliases: [ "COBOL" ] | ||
~filenamePatterns: [ "*.cbl"; "*.cob" ] | ||
] | ||
~debuggers: [ | ||
Manifest.debugger "cobol" | ||
~label:"GnuCOBOL Debugger" | ||
~languages: [ "cobol" ] | ||
~program: "gdb" | ||
(* TODO unsupported ??? | ||
"args": [ | ||
"--init-eval-command=\"source /usr/local/bin/cobcd.py\"" | ||
], | ||
*) | ||
~configurationAttributes: | ||
(Manifest.any | ||
{| { | ||
"launch": { | ||
"type": "cobol", | ||
"required": [ | ||
"program" | ||
], | ||
"properties": { | ||
"program": { | ||
"type": "string", | ||
"default": "${workspaceFolder}/a.out" | ||
} | ||
} | ||
} | ||
} | ||
|} | ||
) | ||
~configurationSnippets: | ||
[ | ||
Manifest.any | ||
{| | ||
{ | ||
"label": "Debug COBOL", | ||
"description": "New COBOL debugging configuration", | ||
"body": { | ||
"type": "cobol", | ||
"request": "launch", | ||
"name": "${2:Launch Program}", | ||
"program": "${workspaceFolder}/${1:Program}" | ||
let layout = | ||
Superbol_project.{ | ||
project_config_filename = "superbol.toml"; | ||
relative_work_dirname = "_superbol"; | ||
} | ||
} | ||
|} | ||
] | ||
] | ||
~breakpoints: [ Manifest.breakpoint "COBOL" ] | ||
~configuration: | ||
( Manifest.configuration ~title:"Superbol COBOL" | ||
[ | ||
Manifest.PROPERTY.bool | ||
"superbol.globalFormatTakesSelection" | ||
~default:false | ||
~description: | ||
"If something is selected, only format the selection" ; | ||
|
||
Manifest.PROPERTY.string "superbol.path" | ||
~default:"superbol-free" | ||
~description: | ||
"Name of the `superbol` executable if available in PATH; \ | ||
otherwise may be an absolute path." | ||
] ) | ||
~taskDefinitions: [ | ||
Manifest.taskDefinition | ||
"superbol" | ||
~properties: [ | ||
Manifest.PROPERTY.array "copybooks" | ||
~description:"The list of copybooks paths" ; | ||
|
||
Manifest.PROPERTY.enum "sourceFormat" | ||
~cases:Cobol_config.DIALECT.all_canonical_names | ||
~description: "The source format of the code" | ||
; | ||
|
||
Manifest.PROPERTY.string "dialect" | ||
~description: "The COBOL dialect used" ; | ||
|
||
Manifest.PROPERTY.bool "forDebugging" | ||
~description: "Build for debugging" ; | ||
|
||
Manifest.PROPERTY.array "extensions" | ||
~description: "Add cobol file extensions" | ||
] | ||
] | ||
~problemPatterns:[ | ||
Manifest.problemPattern | ||
(Some "^(.*): ?(\\d+): (error|warning): ([^[]*)(\\[(.*)\\])?$") | ||
~name:"gnucobol" | ||
~file:1 | ||
~line:2 | ||
~severity:3 | ||
~message:4 | ||
~code:6; | ||
Manifest.problemPattern | ||
(Some "^(.*):(\\d+):\\s?(warning|Warnung|[wW]aarschuwing|[aA]lerta|avertissement|упозорење)\\s?:([^[]*)(\\[(.*)\\])?$") | ||
~name:"gnucobol-warning" | ||
~file:1 | ||
~line:2 | ||
~message:4 | ||
~code:6; | ||
Manifest.problemPattern | ||
(Some "^(.*): ?(\\d+):\\s?(error|Fehler|[fF]out|[eE]rrores|[eE]rrores|erreur|грешка)\\s?:\\s?([^[]*)(\\[(.*)\\])?$") | ||
~name:"gnucobol-error" | ||
~file:1 | ||
~line:2 | ||
~message:4 | ||
~code:6; | ||
Manifest.problemPattern | ||
(Some "^(.*): ?(\\d+): (note|Anmerkung|[nN]ota): ([^[]*)(\\[(.*)\\])?$") | ||
~name:"gnucobol-note" | ||
~file:1 | ||
~line:2 | ||
~message:4 | ||
~code:6; | ||
] | ||
~problemMatchers:[ | ||
Manifest.problemMatcher () | ||
~name:"gnucobol" | ||
~owner:"cobol" | ||
~fileLocation:["absolute"] | ||
~pattern:[Manifest.ProblemName "$gnucobol"] | ||
~source:"GnuCOBOL"; | ||
Manifest.problemMatcher () | ||
~name:"gnucobol-warning" | ||
~owner:"cobol" | ||
~fileLocation:["absolute"] | ||
~pattern:[Manifest.ProblemName "$gnucobol-warning"] | ||
~severity:"warning" | ||
~source:"GnuCOBOL"; | ||
Manifest.problemMatcher () | ||
~name:"gnucobol-error" | ||
~owner:"cobol" | ||
~fileLocation:["absolute"] | ||
~pattern:[Manifest.ProblemName "$gnucobol-error"] | ||
~severity:"error" | ||
~source:"GnuCOBOL"; | ||
Manifest.problemMatcher () | ||
~name:"gnucobol-note" | ||
~owner:"cobol" | ||
~fileLocation:["absolute"] | ||
~pattern:[Manifest.ProblemName "$gnucobol-note"] | ||
~severity:"info" | ||
~source:"GnuCOBOL"; | ||
] | ||
~commands:[ | ||
Manifest.command () | ||
~command:"superbol.server.restart" | ||
~title:"Restart Language Server" | ||
~category:"Superbol" | ||
] | ||
|
||
let manifest = | ||
Manifest.vscode | ||
package | ||
~marketplace | ||
~engines: ( "^" ^ vscode_engine ) | ||
~activationEvents: [ | ||
"onLanguage:cobol" ; | ||
"onDebug" | ||
] | ||
~contributes | ||
let try_load ~f arg = | ||
try f arg with | ||
| Superbol_project.Config.ERROR e -> | ||
DIAGS.(pp Fmt.stderr @@ One.error "%a" | ||
Superbol_project.Diagnostics.pp_error e); | ||
exit 2 | ||
| Sys_error msg | Invalid_argument msg -> | ||
DIAGS.(pp Fmt.stderr @@ One.error "%s" msg); | ||
exit 2 | ||
|
||
(* Direct loading (based on directory name) *) | ||
|
||
let in_ ~dirname = | ||
Pretty.error "Loading project in `%s'@." dirname; | ||
try_load () ~f:begin fun () -> | ||
let rootdir = Superbol_project.rootdir_at ~dirname in | ||
let project = Superbol_project.for_ ~rootdir ~layout in | ||
DIAGS.show_n_forget project | ||
end | ||
|
||
let load ?(dirname = EzFile.current_dir_name) () = in_ ~dirname | ||
|
||
(* Indirect loading (based on file name, looking up the directory hierarchy) *) | ||
|
||
let for_ ~filename = | ||
Pretty.error "Looking up project for `%s'@." filename; | ||
try_load () ~f:begin fun () -> | ||
let rootdir = Superbol_project.rootdir_for ~filename ~layout in | ||
let project = Superbol_project.for_ ~rootdir ~layout in | ||
DIAGS.show_n_forget project | ||
end | ||
|
||
let for_filename filename = for_ ~filename |
Oops, something went wrong.