-
Notifications
You must be signed in to change notification settings - Fork 458
Play nice with ghcide #369
Changes from all commits
298c37f
7262484
a8a3bca
17f860a
f68fa5e
8d6eecc
9770cbd
29db8b3
b2ad11a
fa865e8
29085fd
a2ec2ae
6230181
22f1e72
b07382d
3a18af8
eeec38a
60886eb
4941cb8
890d05d
0c89785
17fe2b0
50fb138
c6c729d
cab72da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# HLint configuration file | ||
# https://github.com/ndmitchell/hlint | ||
|
||
- arguments: [--color=auto, -XDataKinds, -XDeriveFoldable, -XDeriveFunctor, -XDeriveGeneric, -XDeriveTraversable, -XFlexibleContexts, -XFlexibleInstances, -XMultiParamTypeClasses, -XOverloadedStrings, -XRecordWildCards, -XStandaloneDeriving, -XStrictData, -XTypeApplications, -XDerivingVia] | ||
- arguments: [--color=auto, -XStrictData] | ||
|
||
# Blacklist some functions by default. | ||
- functions: | ||
|
@@ -23,7 +23,7 @@ | |
- warn: {group: {name: default}} | ||
|
||
# Ignore the highly noisy module export list hint | ||
- ignore: {name: Use module export list} | ||
- ignore: {name: Use explicit module export list} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one apparently changed. |
||
|
||
# Ignore some builtin hints | ||
- ignore: {name: Use mappend} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,31 +2,22 @@ | |
|
||
module Evaluation (benchmarks) where | ||
|
||
import Algebra.Graph | ||
import Control.Monad | ||
Comment on lines
-5
to
-6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you know we didn’t have warnings enabled in the benchmarks? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😮 |
||
import Control.Carrier.Parse.Simple | ||
import qualified Data.Duration as Duration | ||
import Data.Abstract.Evaluatable | ||
import Data.Abstract.FreeVariables | ||
import Data.Blob | ||
import Data.Blob.IO (readBlobFromFile') | ||
import Data.Bifunctor | ||
import Data.Functor.Classes | ||
import Data.Functor.Foldable (Base, Recursive) | ||
import "semantic" Data.Graph (Graph (..), topologicalSort) | ||
import Data.Graph.ControlFlowVertex | ||
import "semantic" Data.Graph (topologicalSort) | ||
import qualified Data.Language as Language | ||
import Data.Project | ||
import Data.Proxy | ||
import Data.Term | ||
import Gauge.Main | ||
import Parsing.Parser | ||
import Semantic.Config (defaultOptions) | ||
import Semantic.Graph | ||
import Semantic.Task (SomeException, TaskSession (..), runTask, withOptions) | ||
import Semantic.Task (TaskSession (..), runTask, withOptions) | ||
import Semantic.Util | ||
import Source.Loc | ||
import Source.Span (HasSpan) | ||
import qualified System.Path as Path | ||
import System.Path ((</>)) | ||
|
||
|
@@ -40,20 +31,22 @@ callGraphProject' :: ( Language.SLanguage lang | |
-> Path.RelFile | ||
-> IO (Either String ()) | ||
callGraphProject' session proxy path | ||
| let lang = Language.reflect proxy | ||
, Just (SomeParser parser) <- parserForLanguage analysisParsers lang = fmap (bimap show (const ())) . runTask session $ do | ||
| Just (SomeParser parser) <- parserForLanguage analysisParsers lang = fmap (bimap show (const ())) . runTask session $ do | ||
blob <- readBlobFromFile' (fileForTypedPath path) | ||
package <- fmap snd <$> runParse (Duration.fromSeconds 10) (parsePackage parser (Project (Path.toString (Path.takeDirectory path)) [blob] lang [])) | ||
modules <- topologicalSort <$> runImportGraphToModules proxy package | ||
runCallGraph proxy False modules package | ||
| otherwise = error $ "Analysis not supported for: " <> show lang | ||
where lang = Language.reflect proxy | ||
|
||
callGraphProject proxy paths = withOptions defaultOptions $ \ config logger statter -> | ||
callGraphProject' (TaskSession config "" False logger statter) proxy paths | ||
|
||
evaluateProject proxy path | ||
| let lang = Language.reflect proxy | ||
, Just (SomeParser parser) <- parserForLanguage analysisParsers lang = withOptions defaultOptions $ \ config logger statter -> | ||
| Just (SomeParser parser) <- parserForLanguage analysisParsers lang = withOptions defaultOptions $ \ config logger statter -> | ||
fmap (const ()) . justEvaluating =<< evaluateProject' (TaskSession config "" False logger statter) proxy parser [Path.toString path] | ||
| otherwise = error $ "Analysis not supported for: " <> show lang | ||
where lang = Language.reflect proxy | ||
|
||
pyEval :: Path.RelFile -> Benchmarkable | ||
pyEval p = nfIO $ evaluateProject (Proxy @'Language.Python) (Path.relDir "bench/bench-fixtures/python" </> p) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module Main where | ||
module Main (main) where | ||
|
||
import Gauge | ||
import qualified Evaluation | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,20 +25,22 @@ flag release | |
-- GHC extensions shared between targets | ||
common haskell | ||
default-language: Haskell2010 | ||
default-extensions: DataKinds | ||
, DeriveFoldable | ||
, DeriveFunctor | ||
, DeriveGeneric | ||
, DeriveTraversable | ||
, FlexibleContexts | ||
, FlexibleInstances | ||
, MonadFailDesugaring | ||
, MultiParamTypeClasses | ||
, OverloadedStrings | ||
, RecordWildCards | ||
, StandaloneDeriving | ||
, StrictData | ||
, TypeApplications | ||
Comment on lines
-28
to
-41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of these have been moved to the |
||
default-extensions: StrictData | ||
ghc-options: | ||
-Weverything | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hard mode. |
||
-Wno-missing-local-signatures | ||
-Wno-missing-import-lists | ||
-Wno-implicit-prelude | ||
-Wno-safe | ||
-Wno-unsafe | ||
-Wno-name-shadowing | ||
-Wno-monomorphism-restriction | ||
-Wno-missed-specialisations | ||
-Wno-all-missed-specialisations | ||
-Wno-star-is-type | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Slightly less hard mode. |
||
if (impl(ghc >= 8.8)) | ||
ghc-options: -Wno-missing-deriving-strategies | ||
|
||
|
||
-- Except in case of vendored dependencies, these deps should be expressed | ||
-- as caret-operator bounds relative to a version in Stackage. | ||
|
@@ -74,11 +76,8 @@ common dependencies | |
common executable-flags | ||
ghc-options: -threaded -rtsopts "-with-rtsopts=-N -A4m -n2m" | ||
|
||
common ghc-warnings | ||
ghc-options: -Wall -Wmissing-export-lists -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -Wno-name-shadowing | ||
|
||
library | ||
import: haskell, dependencies, ghc-warnings | ||
import: haskell, dependencies | ||
hs-source-dirs: src | ||
exposed-modules: | ||
-- Analyses & term annotations | ||
|
@@ -317,7 +316,7 @@ executable semantic | |
, semantic | ||
|
||
test-suite test | ||
import: haskell, dependencies, executable-flags, ghc-warnings | ||
import: haskell, dependencies, executable-flags | ||
type: exitcode-stdio-1.0 | ||
hs-source-dirs: test | ||
main-is: Spec.hs | ||
|
@@ -371,8 +370,6 @@ test-suite test | |
, HUnit ^>= 1.6.0.0 | ||
, leancheck >= 0.8 && <1 | ||
, temporary ^>= 1.3 | ||
if flag(release) | ||
ghc-options: -dynamic | ||
Comment on lines
-374
to
-375
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was dodgy as hell. |
||
|
||
test-suite parse-examples | ||
import: haskell, dependencies, executable-flags | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{-# LANGUAGE GeneralizedNewtypeDeriving, TypeOperators #-} | ||
{-# LANGUAGE DeriveFunctor, FlexibleContexts, GeneralizedNewtypeDeriving, TypeApplications, TypeOperators #-} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A lot of these |
||
module Analysis.Abstract.Caching.FlowInsensitive | ||
( cachingTerms | ||
, convergingModules | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{-# LANGUAGE DerivingVia, LambdaCase, RankNTypes, ScopedTypeVariables, TypeFamilies, TypeOperators, UndecidableInstances #-} | ||
{-# LANGUAGE DerivingVia, FlexibleContexts, FlexibleInstances, LambdaCase, MultiParamTypeClasses, OverloadedStrings, RankNTypes, ScopedTypeVariables, TypeFamilies, UndecidableInstances #-} | ||
module Analysis.Abstract.Graph | ||
( Graph(..) | ||
, ControlFlowVertex(..) | ||
|
@@ -35,12 +35,12 @@ style = (defaultStyle (T.encodeUtf8Builder . vertexIdentifier)) | |
{ vertexAttributes = vertexAttributes | ||
, edgeAttributes = edgeAttributes | ||
} | ||
where vertexAttributes Package{} = [ "style" := "dashed", "shape" := "box" ] | ||
vertexAttributes Module{} = [ "style" := "dotted, rounded", "shape" := "box" ] | ||
vertexAttributes UnknownModule{} = [ "style" := "dotted, rounded", "shape" := "box", "color" := "red", "fontcolor" := "red" ] | ||
vertexAttributes Variable{..} = [ "label" := T.encodeUtf8Builder (vertexName <> " (Variable)"), "tooltip" := T.encodeUtf8Builder (showSpan vertexSpan), "style" := "rounded", "shape" := "box" ] | ||
vertexAttributes Method{..} = [ "label" := T.encodeUtf8Builder (vertexName <> " (Method)"), "tooltip" := T.encodeUtf8Builder (showSpan vertexSpan) , "style" := "rounded", "shape" := "box" ] | ||
vertexAttributes Function{..} = [ "label" := T.encodeUtf8Builder (vertexName <> " (Function)"), "tooltip" := T.encodeUtf8Builder (showSpan vertexSpan), "style" := "rounded", "shape" := "box" ] | ||
where vertexAttributes Package{} = [ "style" := "dashed", "shape" := "box" ] | ||
vertexAttributes Module{} = [ "style" := "dotted, rounded", "shape" := "box" ] | ||
vertexAttributes UnknownModule{} = [ "style" := "dotted, rounded", "shape" := "box", "color" := "red", "fontcolor" := "red" ] | ||
vertexAttributes (Variable n _ s) = [ "label" := T.encodeUtf8Builder (n <> " (Variable)"), "tooltip" := T.encodeUtf8Builder (showSpan s), "style" := "rounded", "shape" := "box" ] | ||
vertexAttributes (Method n _ s) = [ "label" := T.encodeUtf8Builder (n <> " (Method)"), "tooltip" := T.encodeUtf8Builder (showSpan s) , "style" := "rounded", "shape" := "box" ] | ||
vertexAttributes (Function n _ s) = [ "label" := T.encodeUtf8Builder (n <> " (Function)"), "tooltip" := T.encodeUtf8Builder (showSpan s), "style" := "rounded", "shape" := "box" ] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fallout from the changes to |
||
edgeAttributes Module{} Module{} = [ "len" := "5.0", "label" := "imports" ] | ||
edgeAttributes Module{} UnknownModule{} = [ "len" := "5.0", "label" := "imports" ] | ||
edgeAttributes Package{} Module{} = [ "len" := "5.0", "style" := "dashed" ] | ||
|
@@ -78,7 +78,7 @@ graphingTerms recur term = do | |
case toVertex definedInModule term of | ||
Just (v@Function{}, name) -> recurWithContext v name | ||
Just (v@Method{}, name) -> recurWithContext v name | ||
Just (v@Variable{..}, name) -> do | ||
Just (v@Variable{}, name) -> do | ||
variableDefinition v | ||
slot <- lookupSlot (Declaration name) | ||
defined <- gets (Map.lookup slot) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{-# LANGUAGE ScopedTypeVariables, TypeFamilies, UndecidableInstances #-} | ||
{-# LANGUAGE DataKinds, FlexibleInstances, MultiParamTypeClasses, RecordWildCards, ScopedTypeVariables, TypeApplications, TypeFamilies, UndecidableInstances #-} | ||
module Analysis.PackageDef | ||
( PackageDef(..) | ||
, HasPackageDef | ||
|
@@ -15,7 +15,7 @@ import Prologue | |
import Source.Loc | ||
|
||
newtype PackageDef = PackageDef { moduleDefIdentifier :: T.Text } | ||
deriving (Eq, Generic, Show) | ||
deriving (Eq, Show) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also took the opportunity to 🔥 a few |
||
|
||
-- | An r-algebra producing 'Just' a 'PackageDef' for syntax nodes corresponding to high-level declarations, or 'Nothing' otherwise. | ||
-- | ||
|
@@ -80,8 +80,8 @@ class HasPackageDefWithStrategy (strategy :: Strategy) syntax where | |
-- If you’re seeing errors about missing a 'CustomHasPackageDef' instance for a given type, you’ve probably listed it in here but not defined a 'CustomHasPackageDef' instance for it, or else you’ve listed the wrong type in here. Conversely, if your 'customHasPackageDef' method is never being called, you may have forgotten to list the type in here. | ||
type family PackageDefStrategy syntax where | ||
PackageDefStrategy Language.Go.Syntax.Package = 'Custom | ||
PackageDefStrategy (Sum fs) = 'Custom | ||
PackageDefStrategy a = 'Default | ||
PackageDefStrategy (Sum _) = 'Custom | ||
PackageDefStrategy _ = 'Default | ||
|
||
|
||
-- | The 'Default' strategy produces 'Nothing'. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yay!