Skip to content

Commit

Permalink
Remove cobol_indent/cobol_indent.ml
Browse files Browse the repository at this point in the history
  • Loading branch information
lefessan committed Feb 1, 2024
1 parent c628049 commit 5160068
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 56 deletions.
26 changes: 0 additions & 26 deletions src/lsp/cobol_indent/cobol_indent.ml

This file was deleted.

2 changes: 1 addition & 1 deletion src/lsp/cobol_indent/indent_check.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ open EzCompat

open Cobol_common.Srcloc

open Indent_type
open Types
open Indent_keywords
open Indent_util

Expand Down
4 changes: 2 additions & 2 deletions src/lsp/cobol_indent/indent_check.mli
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@

val check_indentation
:Cobol_preproc.Text.t
-> Indent_type.indent_state
-> Indent_type.indent_state
-> Types.indent_state
-> Types.indent_state
2 changes: 1 addition & 1 deletion src/lsp/cobol_indent/indent_config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
(* *)
(**************************************************************************)

open Indent_type
open Types
open Indent_keywords

type t = indent_config
Expand Down
4 changes: 2 additions & 2 deletions src/lsp/cobol_indent/indent_config.mli
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
(* *)
(**************************************************************************)

type t = Indent_type.indent_config
type t = Types.indent_config

val default : t

Expand All @@ -20,4 +20,4 @@ val merge : t -> t -> t

val of_list : (string * int) list -> t

val offset_of_keyword: t -> Indent_type.context_kind -> int
val offset_of_keyword: t -> Types.context_kind -> int
2 changes: 1 addition & 1 deletion src/lsp/cobol_indent/indent_keywords.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
TODO: use the aforementioned associations instead of redefining them
below. *)

open Indent_type
open Types

(*data division *)
let data_context_of_str : string -> data_context = function
Expand Down
10 changes: 5 additions & 5 deletions src/lsp/cobol_indent/indent_keywords.mli
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
(* *)
(**************************************************************************)

val string_of_keyword: Indent_type.context_kind -> string
val string_of_keyword: Types.context_kind -> string

val data_context_of_str: string -> Indent_type.data_context
val data_context_of_str: string -> Types.data_context

val proc_context_of_str: string -> Indent_type.proc_context
val proc_context_of_str: string -> Types.proc_context

(* To check whether the string is a keyword of statement *)
val is_statement: string -> bool

(* To check whether the keyword is implicitly terminable *)
val is_not_imp_terminable: Indent_type.context_kind -> bool
val is_not_imp_terminable: Types.context_kind -> bool

(* To check whether the keyword is a keyword of phrase *)
val is_phrase: Indent_type.context_kind -> bool
val is_phrase: Types.context_kind -> bool
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
(* *)
(**************************************************************************)

open Indent_type
open Types

(*indent a range of file, with the default indent_config*)
let indent_range ~dialect ~source_format ~indent_config ~range ~filename ~contents =
Expand Down Expand Up @@ -42,3 +42,12 @@ let indent_range ~dialect ~source_format ~indent_config ~range ~filename ~conten
in
(* NB: note here we ignore diagnostics *)
state.result.acc

let indent_range_str
~dialect ~source_format ~indent_config ~range ~filename ~contents
=
indent_range
~dialect ~source_format ~indent_config ~range ~filename ~contents
|> Indent_util.apply contents

let config l = Indent_config.(merge default (of_list l))
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@ val indent_range
: dialect: Cobol_config.Types.dialect
-> source_format:Cobol_config.Types.source_format_spec
-> indent_config:Indent_config.t option
-> range:Indent_type.range option
-> range:Types.range option
-> filename:string
-> contents:string
-> Indent_type.indent_record list
-> Types.indent_record list


val indent_range_str :
dialect:Cobol_config.Types.dialect ->
source_format:Cobol_config.Types.source_format_spec ->
indent_config:Types.indent_config option ->
range:Types.range option ->
filename:string -> contents:string -> string

val config : (string * int) list -> Types.indent_config
2 changes: 1 addition & 1 deletion src/lsp/cobol_indent/indent_util.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

open Cobol_common.Srcloc

open Indent_type
open Types
open Indent_keywords

let check_pos
Expand Down
2 changes: 1 addition & 1 deletion src/lsp/cobol_indent/indent_util.mli
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
(* *)
(**************************************************************************)

open Indent_type
open Types

val check_pos:
Cobol_preproc.Src_format.any ->
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions src/lsp/cobol_lsp/lsp_request.ml
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ let handle_references state (params: ReferenceParams.t) =

(** {3 Formatting} *)

let lsp_text_edit Cobol_indent.Type.{ lnum; offset_orig; offset_modif } =
let lsp_text_edit Cobol_indent.Types.{ lnum; offset_orig; offset_modif } =
let delta = offset_modif - offset_orig in
let position = Position.create ~line:(lnum - 1) ~character:offset_orig in
let range = Range.create ~start:position ~end_:position in
Expand All @@ -250,16 +250,16 @@ let handle_range_formatting registry params =
Lsp_server.find_document doc registry
in
let range_to_indent =
Cobol_indent.Type.{
Cobol_indent.Types.{
start_line = start.line + 1;
end_line = end_.line + 1
}
in
let edit_list =
Cobol_indent.indent_range
Cobol_indent.Indent_main.indent_range
~dialect:(Cobol_config.Config.dialect project.config.cobol_config)
~source_format:project.config.source_format
~indent_config:(Some (Cobol_indent.config project.config.indent_config))
~indent_config:(Some (Cobol_indent.Indent_main.config project.config.indent_config))
~filename:(Lsp.Uri.to_path doc.uri)
~contents:(Lsp.Text_document.text textdoc)
~range:(Some range_to_indent)
Expand All @@ -272,10 +272,10 @@ let handle_formatting registry params =
Lsp_server.find_document doc registry in
try
let editList =
Cobol_indent.indent_range
Cobol_indent.Indent_main.indent_range
~dialect:(Cobol_config.Config.dialect project.config.cobol_config)
~source_format:project.config.source_format
~indent_config:(Some (Cobol_indent.config project.config.indent_config))
~indent_config:(Some (Cobol_indent.Indent_main.config project.config.indent_config))
~filename:(Lsp.Uri.to_path doc.uri)
~contents:(Lsp.Text_document.text textdoc)
~range:None
Expand Down
5 changes: 2 additions & 3 deletions src/lsp/superbol_free_lib/command_indent_file.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

open Ezcmd.V2
open EZCMD.TYPES
open Cobol_indent

open Common_args

Expand All @@ -23,9 +22,9 @@ let action { preproc_options = { source_format; config; _ } ; _ } files =
|> Seq.map (fun filename ->
let project = Project.for_ ~filename in
let contents = Ez_file.V1.EzFile.read_file filename in
indent_range_str
Cobol_indent.Indent_main.indent_range_str
~source_format ~filename ~contents ~range:None
~indent_config:(Some (Cobol_indent.config project.config.indent_config))
~indent_config:(Some (Cobol_indent.Indent_main.config project.config.indent_config))
~dialect:Config.dialect |> Fmt.pr "%s")

let cmd =
Expand Down
7 changes: 3 additions & 4 deletions src/lsp/superbol_free_lib/command_indent_range.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

open Ezcmd.V2
open EZCMD.TYPES
open Cobol_indent

open Common_args

Expand All @@ -22,9 +21,9 @@ let action
=
let module Config = (val config) in
let project = Project.for_ ~filename in
let indent_config = Some (Cobol_indent.config project.config.indent_config) in
let indent_config = Some (Cobol_indent.Indent_main.config project.config.indent_config) in
let contents = Ez_file.V1.EzFile.read_file filename in
indent_range_str ~source_format ~filename ~contents ~range ~indent_config
Cobol_indent.Indent_main.indent_range_str ~source_format ~filename ~contents ~range ~indent_config
~dialect:Config.dialect |> Fmt.pr "%s"

let cmd =
Expand All @@ -39,7 +38,7 @@ let cmd =
let common, common_args = Common_args.get () in
let args = direct_args @ common_args in
let range start_line end_line =
let open Cobol_indent.Type in
let open Cobol_indent.Types in
let start_line = !start_line |> Int32.of_string |> Int32.to_int in
let end_line = !end_line |> Int32.of_string |> Int32.to_int in
Some {start_line; end_line}
Expand Down

0 comments on commit 5160068

Please sign in to comment.