[workspace] SourceFile.is_under_project_root true when under workspace too

Summary:
This is needed for `infer reportdiff` to report issues that are in files
in the same workspace but were captured under a different project root,
but it's also legit to do so in general as "under project root" really
means "this file belongs to the project under analysis".

Reviewed By: martintrojer

Differential Revision: D24755592

fbshipit-source-id: fa8fab127
master
Jules Villard 5 years ago committed by Facebook GitHub Bot
parent 9166d60af7
commit 2f8e1ed940

@ -146,17 +146,9 @@ let is_invalid = function Invalid _ -> true | _ -> false
let is_under_project_root = function let is_under_project_root = function
| Invalid {ml_source_file} -> | Invalid {ml_source_file} ->
L.(die InternalError) "cannot be called with Invalid source file from %s" ml_source_file L.die InternalError "cannot be called with Invalid source file from %s" ml_source_file
| RelativeProjectRoot _ -> | RelativeProjectRoot _ | RelativeProjectRootAndWorkspace _ ->
true true
| RelativeProjectRootAndWorkspace {workspace_rel_root= foreign_rel_project_root}
when Option.equal String.equal workspace_rel_root_opt (Some foreign_rel_project_root) ->
(* relative to the same project root *)
true
| RelativeProjectRootAndWorkspace _ ->
(* Relative to a possibly-different project root. We should check if it the absolute file path
is inside the current project root but just return [false] instead. *)
false
| Absolute _ -> | Absolute _ ->
false false

@ -40,7 +40,7 @@ val create : ?warn_on_error:bool -> string -> t
given path (e.g. if it does not exist). *) given path (e.g. if it does not exist). *)
val is_under_project_root : t -> bool val is_under_project_root : t -> bool
(** Returns true if the file is in project root *) (** Returns true if the file is under the project root or the workspace directory if it exists *)
val of_header : ?warn_on_error:bool -> t -> t option val of_header : ?warn_on_error:bool -> t -> t option
(** Return approximate source file corresponding to the parameter if it's header file and file (** Return approximate source file corresponding to the parameter if it's header file and file

Loading…
Cancel
Save