mirror of
https://github.com/github/semantic.git
synced 2024-11-23 16:37:50 +03:00
Handle a couple more function call cases
This commit is contained in:
parent
13c49ee0a4
commit
c1cf16ed03
@ -7,6 +7,7 @@ module Language.TSX.Tags
|
||||
import AST.Element
|
||||
import Control.Effect.Reader
|
||||
import Control.Effect.Writer
|
||||
import Data.Foldable
|
||||
import Data.Monoid (Ap (..))
|
||||
import Data.Text as Text
|
||||
import GHC.Generics
|
||||
@ -41,15 +42,13 @@ data Strategy = Generic | Custom
|
||||
|
||||
type family ToTagsInstance t :: Strategy where
|
||||
ToTagsInstance (_ :+: _) = 'Custom
|
||||
ToTagsInstance Tsx.Function = 'Custom
|
||||
ToTagsInstance Tsx.FunctionSignature = 'Custom
|
||||
ToTagsInstance Tsx.FunctionDeclaration = 'Custom
|
||||
ToTagsInstance Tsx.MethodDefinition = 'Custom
|
||||
ToTagsInstance Tsx.ClassDeclaration = 'Custom
|
||||
ToTagsInstance Tsx.CallExpression = 'Custom
|
||||
|
||||
ToTagsInstance Tsx.Class = 'Custom
|
||||
|
||||
ToTagsInstance Tsx.ClassDeclaration = 'Custom
|
||||
ToTagsInstance Tsx.Function = 'Custom
|
||||
ToTagsInstance Tsx.FunctionDeclaration = 'Custom
|
||||
ToTagsInstance Tsx.FunctionSignature = 'Custom
|
||||
ToTagsInstance Tsx.MethodDefinition = 'Custom
|
||||
ToTagsInstance _ = 'Generic
|
||||
|
||||
instance ToTagsBy 'Custom Tsx.Function where
|
||||
@ -97,9 +96,12 @@ instance ToTagsBy 'Custom Tsx.CallExpression where
|
||||
match expr = case expr of
|
||||
Prj Tsx.Identifier { text } -> yield text
|
||||
Prj Tsx.NewExpression { constructor = Prj Tsx.Identifier { text } } -> yield text
|
||||
-- Prj Tsx.MemberExpression { property = Tsx.PropertyIdentifier { text }, object = (Tsx.Expression expr) } -> yieldTag text Call loc byteRange >> match expr
|
||||
Prj Tsx.CallExpression { function = Tsx.Expression expr } -> match expr
|
||||
Prj Tsx.MemberExpression { property = Tsx.PropertyIdentifier { text } } -> yield text
|
||||
Prj Tsx.Function { name = Just Tsx.Identifier { text }} -> yield text
|
||||
Prj Tsx.ParenthesizedExpression { extraChildren } -> for_ extraChildren $ \ x -> case x of
|
||||
Prj (Tsx.Expression expr) -> match expr
|
||||
_ -> tags x
|
||||
_ -> gtags t
|
||||
yield name = yieldTag name Call loc byteRange >> gtags t
|
||||
|
||||
|
@ -7,6 +7,7 @@ module Language.TypeScript.Tags
|
||||
import AST.Element
|
||||
import Control.Effect.Reader
|
||||
import Control.Effect.Writer
|
||||
import Data.Foldable
|
||||
import Data.Monoid (Ap (..))
|
||||
import Data.Text as Text
|
||||
import GHC.Generics
|
||||
@ -41,12 +42,12 @@ data Strategy = Generic | Custom
|
||||
|
||||
type family ToTagsInstance t :: Strategy where
|
||||
ToTagsInstance (_ :+: _) = 'Custom
|
||||
ToTagsInstance Ts.Function = 'Custom
|
||||
ToTagsInstance Ts.FunctionSignature = 'Custom
|
||||
ToTagsInstance Ts.FunctionDeclaration = 'Custom
|
||||
ToTagsInstance Ts.MethodDefinition = 'Custom
|
||||
ToTagsInstance Ts.ClassDeclaration = 'Custom
|
||||
ToTagsInstance Ts.CallExpression = 'Custom
|
||||
ToTagsInstance Ts.ClassDeclaration = 'Custom
|
||||
ToTagsInstance Ts.Function = 'Custom
|
||||
ToTagsInstance Ts.FunctionDeclaration = 'Custom
|
||||
ToTagsInstance Ts.FunctionSignature = 'Custom
|
||||
ToTagsInstance Ts.MethodDefinition = 'Custom
|
||||
ToTagsInstance _ = 'Generic
|
||||
|
||||
instance ToTagsBy 'Custom Ts.Function where
|
||||
@ -94,9 +95,12 @@ instance ToTagsBy 'Custom Ts.CallExpression where
|
||||
match expr = case expr of
|
||||
Prj Ts.Identifier { text } -> yield text
|
||||
Prj Ts.NewExpression { constructor = Prj Ts.Identifier { text } } -> yield text
|
||||
-- Prj Ts.MemberExpression { property = Ts.PropertyIdentifier { text }, object = (Ts.Expression expr) } -> yieldTag text Call loc byteRange >> match expr
|
||||
Prj Ts.CallExpression { function = Ts.Expression expr } -> match expr
|
||||
Prj Ts.MemberExpression { property = Ts.PropertyIdentifier { text } } -> yield text
|
||||
Prj Ts.Function { name = Just Ts.Identifier { text }} -> yield text
|
||||
Prj Ts.ParenthesizedExpression { extraChildren } -> for_ extraChildren $ \ x -> case x of
|
||||
Prj (Ts.Expression expr) -> match expr
|
||||
_ -> tags x
|
||||
_ -> gtags t
|
||||
yield name = yieldTag name Call loc byteRange >> gtags t
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user