@@ -6,8 +6,8 @@ use std::path::{Path, PathBuf};
66use orgize:: { Org , ast:: OrgElementSelector } ;
77use serde:: Deserialize ;
88use xiuxian_qianji_bpmn_engine:: { BpmnSourceFile , lint_bpmn_source} ;
9- use xiuxian_wendao_parsers:: { OrgizeLintOutputFormat , OrgizeLintRequest , lint_org_files} ;
109
10+ use super :: org_lint:: validate_org_syntax;
1111use crate :: QianjiClientError ;
1212
1313#[ derive( Debug , Clone , PartialEq , Eq ) ]
@@ -248,26 +248,14 @@ fn validate_required_org_surface(
248248 surface_path : & Path ,
249249 diagnostics : & mut Vec < String > ,
250250) -> Result < bool , QianjiClientError > {
251- let request = OrgizeLintRequest {
252- paths : vec ! [ surface_path. to_path_buf( ) ] ,
253- output_format : OrgizeLintOutputFormat :: Compact ,
254- priority_highest : None ,
255- priority_lowest : None ,
256- priority_default : None ,
257- fix : false ,
258- } ;
259- let report = lint_org_files ( & request) . map_err ( |error| {
251+ let source = read_to_string ( surface_path, "required Flowhub Org surface" ) . map_err ( |error| {
260252 QianjiClientError :: message ( format ! (
261- "Failed to lint required Flowhub Org surface `{}` from manifest `{}`: {error}" ,
253+ "Failed to read required Flowhub Org surface `{}` from manifest `{}`: {error}" ,
262254 required_surface,
263255 manifest_path. display( )
264256 ) )
265257 } ) ?;
266- if report. is_clean ( ) {
267- return Ok ( true ) ;
268- }
269- diagnostics. push ( report. render ( OrgizeLintOutputFormat :: Compact ) ) ;
270- Ok ( false )
258+ Ok ( validate_org_syntax ( surface_path, & source, diagnostics) )
271259}
272260
273261fn validate_required_bpmn_surface (
@@ -325,24 +313,7 @@ fn validate_policy_org_source(
325313 passed &=
326314 validate_policy_contract_graph_selector ( policy_path, & source, & properties, diagnostics) ;
327315
328- let request = OrgizeLintRequest {
329- paths : vec ! [ policy_path. to_path_buf( ) ] ,
330- output_format : OrgizeLintOutputFormat :: Compact ,
331- priority_highest : None ,
332- priority_lowest : None ,
333- priority_default : None ,
334- fix : false ,
335- } ;
336- let report = lint_org_files ( & request) . map_err ( |error| {
337- QianjiClientError :: message ( format ! (
338- "Failed to lint Flowhub policy entry `{}`: {error}" ,
339- policy_path. display( )
340- ) )
341- } ) ?;
342- if !report. is_clean ( ) {
343- diagnostics. push ( report. render ( OrgizeLintOutputFormat :: Compact ) ) ;
344- passed = false ;
345- }
316+ passed &= validate_org_syntax ( policy_path, & source, diagnostics) ;
346317 Ok ( passed)
347318}
348319
@@ -685,24 +656,7 @@ fn validate_org_source(
685656 passed = false ;
686657 }
687658
688- let request = OrgizeLintRequest {
689- paths : vec ! [ source_pair. org_source. clone( ) ] ,
690- output_format : OrgizeLintOutputFormat :: Compact ,
691- priority_highest : None ,
692- priority_lowest : None ,
693- priority_default : None ,
694- fix : false ,
695- } ;
696- let report = lint_org_files ( & request) . map_err ( |error| {
697- QianjiClientError :: message ( format ! (
698- "Failed to lint Flowhub Org source `{}`: {error}" ,
699- source_pair. org_source. display( )
700- ) )
701- } ) ?;
702- if !report. is_clean ( ) {
703- diagnostics. push ( report. render ( OrgizeLintOutputFormat :: Compact ) ) ;
704- passed = false ;
705- }
659+ passed &= validate_org_syntax ( & source_pair. org_source , & source, diagnostics) ;
706660 Ok ( passed)
707661}
708662
0 commit comments