packages feed

calligraphy 0.1.0 → 0.1.1

raw patch · 7 files changed

+24/−9 lines, 7 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Calligraphy.Compat.Lib: isPointSpan :: Span -> Bool

Files

CHANGELOG.md view
@@ -1,5 +1,10 @@ # Changelog +## 0.1.1++### [Changed]+- [#2] [#3] Ignore all identifiers that have a zero-width span. These are the result of generated code, and should be rejected elsewhere, but apparently can occasionally creep through.+ ## 0.1.0  ### [Added]
README.md view
@@ -9,7 +9,7 @@ It works directly on GHC-generated HIE files, giving us features that would otherwise be tricky, like type information and support for generated files. `calligraphy` has been tested with all versions of GHC that can produce HIE files (i.e. GHC 8.8, 8.10, 9.0, and 9.2.) -See [the accompanying blog post](https://jonascarpay.com/posts/2022-04-01-salt.html) for more examples, and an extended tutorial.+See [the accompanying blog post](https://jonascarpay.com/posts/2022-04-26-calligraphy-tutorial.html) for more examples, and an extended tutorial.  ## Usage @@ -19,7 +19,7 @@ 2. Install [GraphViz](https://graphviz.org/). By default, `calligraphy` needs `dot` to be available in the search path.  3. Generate HIE files for your project by passing the `-fwrite-ide-info` to GHC.-If you're using Cabal, for example, you'd invoke `cabal new-build --ghc-options=-fwrite-ide-info`+If you're using Cabal, for example, you'd invoke `cabal build --ghc-options=-fwrite-ide-info`  4. Run `calligraphy`. You probably want to start by running `calligraphy --help` to see what options it supports, but as an example, the above graph was produced using the following command:
calligraphy.cabal view
@@ -1,6 +1,6 @@ cabal-version:   2.4 name:            calligraphy-version:         0.1.0+version:         0.1.1 license:         BSD-3-Clause build-type:      Simple license-file:    LICENSE
src/Calligraphy/Compat/Lib.hs view
@@ -13,6 +13,7 @@     isDerivingNode,     showAnns,     spanSpans,+    isPointSpan,   ) where @@ -109,3 +110,6 @@         (realSrcSpanEnd sp1)         (realSrcSpanEnd sp2)     )++isPointSpan :: Span -> Bool+isPointSpan sp = realSrcSpanEnd sp <= realSrcSpanStart sp
src/Calligraphy/Phases/Parse.hs view
@@ -13,6 +13,7 @@  import qualified Calligraphy.Compat.GHC as GHC import Calligraphy.Compat.Lib (isDerivingNode, isInlineNode, isInstanceNode, isMinimalNode, isTypeSignatureNode, sourceInfo, spanSpans)+import qualified Calligraphy.Compat.Lib as GHC import Calligraphy.Util.LexTree (LexTree, TreeError (..), foldLexTree) import qualified Calligraphy.Util.LexTree as LT import Calligraphy.Util.Printer@@ -228,11 +229,13 @@             forM_ (M.toList $ GHC.nodeIdentifiers nodeInfo) $ \case               (Right name, GHC.IdentifierDetails ty info)                 | not (isGenerated name) -> do-                  mapM_ (tellType name) ty-                  case classifyIdentifier info of-                    IdnIgnore -> pure ()-                    IdnUse -> tellUse (GHC.realSrcSpanStart $ GHC.nodeSpan node) (ghcNameKey name)-                    IdnDecl typ sp -> tellDecl (typ, sp, name, spanToLoc sp)+                    mapM_ (tellType name) ty+                    case classifyIdentifier info of+                      IdnIgnore -> pure ()+                      IdnUse -> tellUse (GHC.realSrcSpanStart $ GHC.nodeSpan node) (ghcNameKey name)+                      IdnDecl typ sp+                        | GHC.isPointSpan sp -> pure ()+                        | otherwise -> tellDecl (typ, sp, name, spanToLoc sp)               _ -> pure ()             mapM_ collect' children 
src/Calligraphy/Phases/Render.hs view
@@ -80,7 +80,7 @@      renderTreeNode :: Prints (Tree Decl)     renderTreeNode (Node decl@(Decl _ key _ exported typ _) children) = do-      strLn $ show (unKey key) <> " " <> style ["label" .= show (nodeLabel decl), "shape" .= nodeShape typ, "style" .= nodeStyle]+      strLn $ show (unKey key) <> " " <> style ["label" .= ("\"" <> nodeLabel decl <> "\""), "shape" .= nodeShape typ, "style" .= nodeStyle]       forM_ children $ \child@(Node childDecl _) -> do         renderTreeNode child         edge key (declKey childDecl)
test/Test/Reference.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE DefaultSignatures #-}+{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE StandaloneDeriving #-}@@ -17,11 +18,13 @@ import Data.Functor.Identity import Data.Kind (Type) import qualified Data.Map as M+import GHC.Generics (Generic)  data ExportedT   = Exported (Identity Int)   | NotExported (M.Map Int Int)   | Single+  deriving (Generic)  deriving instance Eq ExportedT