Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Use simplified TraverseAst API from cimple. #71

Merged
merged 1 commit into from
Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
cirrus-ci_task:
container:
image: toxchat/toktok-stack:0.0.30-third_party
image: toxchat/toktok-stack:0.0.31-third_party
cpu: 2
memory: 6G
configure_script:
Expand Down
11 changes: 5 additions & 6 deletions src/Tokstyle/Cimple/Analysis/DeclaredOnce.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
{-# LANGUAGE StrictData #-}
module Tokstyle.Cimple.Analysis.DeclaredOnce (analyse) where

import Control.Monad.State.Lazy (State)
import qualified Control.Monad.State.Lazy as State
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Text (Text)
import Language.Cimple (Lexeme (..), LexemeClass (..),
Node (..))
import Language.Cimple.Diagnostics (HasDiagnostics (..), warn)
import Language.Cimple.TraverseAst (AstActions (..), defaultActions,
import Language.Cimple (AstActions, Lexeme (..),
LexemeClass (..), Node (..),
defaultActions, doNode,
traverseAst)
import Language.Cimple.Diagnostics (HasDiagnostics (..), warn)


data Linter = Linter
Expand All @@ -27,7 +26,7 @@ instance HasDiagnostics Linter where
addDiagnostic diag l@Linter{diags} = l{diags = addDiagnostic diag diags}


linter :: AstActions (State Linter) () Text
linter :: AstActions Linter
linter = defaultActions
{ doNode = \file node act ->
case node of
Expand Down
11 changes: 5 additions & 6 deletions src/Tokstyle/Cimple/Analysis/DeclsHaveDefns.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
{-# LANGUAGE StrictData #-}
module Tokstyle.Cimple.Analysis.DeclsHaveDefns (analyse) where

import Control.Monad.State.Lazy (State)
import qualified Control.Monad.State.Lazy as State
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Maybe (mapMaybe)
import Data.Text (Text)
import Language.Cimple (Lexeme (..), LexemeClass (..),
Node (..))
import qualified Language.Cimple.Diagnostics as Diagnostics
import Language.Cimple.TraverseAst (AstActions (..), defaultActions,
import Language.Cimple (AstActions, Lexeme (..),
LexemeClass (..), Node (..),
defaultActions, doNode,
traverseAst)
import qualified Language.Cimple.Diagnostics as Diagnostics
import System.FilePath (takeFileName)


Expand All @@ -23,7 +22,7 @@ data DeclDefn = DeclDefn
}


collectPairs :: AstActions (State (Map Text DeclDefn)) () Text
collectPairs :: AstActions (Map Text DeclDefn)
collectPairs = defaultActions
{ doNode = \file node act ->
case node of
Expand Down
11 changes: 5 additions & 6 deletions src/Tokstyle/Cimple/Analysis/DocComments.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
{-# LANGUAGE StrictData #-}
module Tokstyle.Cimple.Analysis.DocComments (analyse) where

import Control.Monad.State.Lazy (State)
import qualified Control.Monad.State.Lazy as State
import Data.Text (Text)
import qualified Data.Text as Text
import Language.Cimple (AlexPosn (..), Lexeme (..),
LexemeClass (..), Node (..))
import Language.Cimple (AlexPosn (..), AstActions,
Lexeme (..), LexemeClass (..),
Node (..), defaultActions, doNode,
traverseAst)
import Language.Cimple.Diagnostics (HasDiagnostics (..), warn)
import qualified Language.Cimple.Diagnostics as Diagnostics
import Language.Cimple.Pretty (ppTranslationUnit)
import Language.Cimple.TraverseAst (AstActions (..), defaultActions,
traverseAst)


data Linter = Linter
Expand All @@ -28,7 +27,7 @@ instance HasDiagnostics Linter where
addDiagnostic diag l@Linter{diags} = l{diags = addDiagnostic diag diags}


linter :: AstActions (State Linter) () Text
linter :: AstActions Linter
linter = defaultActions
{ doNode = \file node act ->
case node of
Expand Down
11 changes: 5 additions & 6 deletions src/Tokstyle/Cimple/Analysis/ForLoops.hs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
{-# LANGUAGE OverloadedStrings #-}
module Tokstyle.Cimple.Analysis.ForLoops (analyse) where

import Control.Monad.State.Lazy (State)
import qualified Control.Monad.State.Lazy as State
import Data.Text (Text)
import qualified Data.Text as Text
import Language.Cimple (AssignOp (..), Lexeme (..),
Node (..))
import qualified Language.Cimple.Diagnostics as Diagnostics
import Language.Cimple.TraverseAst (AstActions (..), defaultActions,
import Language.Cimple (AssignOp (..), AstActions,
Lexeme (..), Node (..),
defaultActions, doNode,
traverseAst)
import qualified Language.Cimple.Diagnostics as Diagnostics


linter :: AstActions (State [Text]) () Text
linter :: AstActions [Text]
linter = defaultActions
{ doNode = \file node act ->
case node of
Expand Down
8 changes: 4 additions & 4 deletions src/Tokstyle/Cimple/Analysis/FuncPrototypes.hs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{-# LANGUAGE OverloadedStrings #-}
module Tokstyle.Cimple.Analysis.FuncPrototypes (analyse) where

import Control.Monad.State.Lazy (State)
import qualified Control.Monad.State.Lazy as State
import Data.Text (Text)
import Language.Cimple (Lexeme, Node (..))
import Language.Cimple (AstActions, Lexeme, Node (..),
defaultActions, doNode,
traverseAst)
import qualified Language.Cimple.Diagnostics as Diagnostics
import Language.Cimple.TraverseAst


linter :: AstActions (State [Text]) () Text
linter :: AstActions [Text]
linter = defaultActions
{ doNode = \file node act ->
case node of
Expand Down
10 changes: 5 additions & 5 deletions src/Tokstyle/Cimple/Analysis/LoggerCalls.hs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{-# LANGUAGE OverloadedStrings #-}
module Tokstyle.Cimple.Analysis.LoggerCalls (analyse) where

import Control.Monad.State.Lazy (State)
import qualified Control.Monad.State.Lazy as State
import Data.Text (Text)
import qualified Data.Text as Text
import Language.Cimple (Lexeme (..), LiteralType (String),
Node (..))
import Language.Cimple (AstActions, Lexeme (..),
LiteralType (String), Node (..),
defaultActions, doNode,
traverseAst)
import qualified Language.Cimple.Diagnostics as Diagnostics
import Language.Cimple.TraverseAst
import System.FilePath (takeFileName)


linter :: AstActions (State [Text]) () Text
linter :: AstActions [Text]
linter = defaultActions
{ doNode = \file node act ->
case node of
Expand Down
9 changes: 5 additions & 4 deletions src/Tokstyle/Cimple/Analysis/LoggerNoEscapes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import Control.Monad.State.Lazy (State)
import qualified Control.Monad.State.Lazy as State
import Data.Text (Text, isInfixOf)
import qualified Data.Text as Text
import Language.Cimple (Lexeme (..), LiteralType (String),
Node (..), lexemeText)
import Language.Cimple (AstActions, Lexeme (..),
LiteralType (String), Node (..),
defaultActions, doNode,
lexemeText, traverseAst)
import qualified Language.Cimple.Diagnostics as Diagnostics
import Language.Cimple.TraverseAst


linter :: AstActions (State [Text]) () Text
linter :: AstActions [Text]
linter = defaultActions
{ doNode = \file node act -> case node of
-- LOGGER_ASSERT has its format as the third parameter.
Expand Down
8 changes: 4 additions & 4 deletions src/Tokstyle/Cimple/Analysis/VarUnusedInScope.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import Control.Monad.State.Lazy (State)
import qualified Control.Monad.State.Lazy as State
import Data.Text (Text)
import qualified Data.Text as Text
import Language.Cimple (Lexeme (..), Node (..))
import Language.Cimple.Diagnostics (HasDiagnostics (..), at, warn)
import Language.Cimple.TraverseAst (AstActions (..), defaultActions,
import Language.Cimple (AstActions, Lexeme (..),
Node (..), defaultActions, doNode,
traverseAst)
import Language.Cimple.Diagnostics (HasDiagnostics (..), at, warn)


data Linter = Linter
Expand Down Expand Up @@ -39,7 +39,7 @@ popScope = do
scope:rest -> State.put l{stack = rest} >> return scope


linter :: AstActions (State Linter) () Text
linter :: AstActions Linter
linter = defaultActions
{ doNode = \file node act ->
case node of
Expand Down
2 changes: 1 addition & 1 deletion tokstyle.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ library
base >= 4 && < 5
, aeson >= 0.8.1.0
, bytestring
, cimple >= 0.0.4
, cimple >= 0.0.5
, containers
, deepseq
, filepath
Expand Down