forked from google/proto-lens
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce the API of proto-lens-protoc. (google#357)
Previously we exposed most of the internals as a library, with the hope that they'd be useful for plugins (i.e. for services). But now we're exposing service information at the type level, and the library continues to be unused. Removing most of it allows us to change the internals without requiring a major version bump. For example, with this change the migration to ghc-source-gen would have only required a minor version bump. Fixes google#347. I think it's not feasible to completely remove the library at this time, since we still want to share logic around module names between proto-lens-protoc and proto-lens-setup.
- Loading branch information
Showing
10 changed files
with
49 additions
and
54 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Data.ProtoLens.Compiler.ModuleName | ||
( protoModuleName ) where | ||
|
||
import Data.Char (toUpper) | ||
import Data.List (intercalate) | ||
import System.FilePath | ||
|
||
-- | Get the Haskell module name corresponding to a given .proto file. | ||
protoModuleName :: FilePath -> String | ||
protoModuleName path = fixModuleName rawModuleName | ||
where | ||
fixModuleName "" = "" | ||
-- Characters allowed in Bazel filenames but not in module names: | ||
fixModuleName ('.':c:cs) = '.' : toUpper c : fixModuleName cs | ||
fixModuleName ('_':c:cs) = toUpper c : fixModuleName cs | ||
fixModuleName ('-':c:cs) = toUpper c : fixModuleName cs | ||
fixModuleName (c:cs) = c : fixModuleName cs | ||
rawModuleName = intercalate "." | ||
. (prefix :) | ||
. splitDirectories $ dropExtension | ||
$ path | ||
|
||
prefix :: String | ||
prefix = "Proto" |