mirror of
https://github.com/github/semantic.git
synced 2024-11-27 12:57:49 +03:00
Tag functions, methods, and their calls.
This commit is contained in:
parent
1c8eaa7fbe
commit
056a47ab5a
@ -2,6 +2,7 @@
|
||||
{-# LANGUAGE DisambiguateRecordFields #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE NamedFieldPuns #-}
|
||||
{-# LANGUAGE OverloadedLists #-}
|
||||
{-# LANGUAGE TypeApplications #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
module Language.PHP.Tags (tags) where
|
||||
@ -57,10 +58,40 @@ yieldTag name kind loc range = do
|
||||
|
||||
instance ToTags PHP.FunctionDefinition where
|
||||
tags t@PHP.FunctionDefinition
|
||||
{ PHP.ann = loc@Loc { byteRange }
|
||||
, PHP.name = PHP.Name { text }
|
||||
} = yieldTag text Method loc byteRange >> gtags t
|
||||
|
||||
instance ToTags PHP.MethodDeclaration where
|
||||
tags t@PHP.MethodDeclaration
|
||||
{ PHP.ann = loc@Loc { byteRange }
|
||||
, PHP.name = PHP.Name { text }
|
||||
} = yieldTag text Function loc byteRange >> gtags t
|
||||
|
||||
instance ToTags PHP.FunctionCallExpression where
|
||||
tags t@PHP.FunctionCallExpression
|
||||
{ PHP.ann = loc@Loc { byteRange }
|
||||
, PHP.function = func
|
||||
} = match func
|
||||
where
|
||||
yield name = yieldTag name Call loc byteRange >> gtags t
|
||||
match expr = case expr of
|
||||
Prj (PHP.VariableName { extraChildren = PHP.Name { text } })
|
||||
-> yield text *> gtags t
|
||||
Prj (PHP.QualifiedName { extraChildren = [Prj (PHP.Name { text })] })
|
||||
-> yield text *> gtags t
|
||||
_
|
||||
-> gtags t
|
||||
|
||||
instance ToTags PHP.MemberCallExpression where
|
||||
tags t@PHP.MemberCallExpression
|
||||
{ PHP.ann = loc@Loc { byteRange }
|
||||
, PHP.name = item
|
||||
} = case item of
|
||||
Prj (PHP.Name { text }) -> yieldTag text Call loc byteRange >> gtags t
|
||||
_ -> gtags t
|
||||
|
||||
|
||||
instance ToTags PHP.AnonymousFunctionCreationExpression
|
||||
instance ToTags PHP.AnonymousFunctionUseClause
|
||||
instance ToTags PHP.Arguments
|
||||
@ -105,7 +136,6 @@ instance ToTags PHP.Float
|
||||
instance ToTags PHP.ForStatement
|
||||
instance ToTags PHP.ForeachStatement
|
||||
instance ToTags PHP.FormalParameters
|
||||
instance ToTags PHP.FunctionCallExpression
|
||||
instance ToTags PHP.FunctionStaticDeclaration
|
||||
instance ToTags PHP.GlobalDeclaration
|
||||
instance ToTags PHP.GotoStatement
|
||||
@ -118,8 +148,6 @@ instance ToTags PHP.InterfaceDeclaration
|
||||
instance ToTags PHP.ListLiteral
|
||||
instance ToTags PHP.Literal
|
||||
instance ToTags PHP.MemberAccessExpression
|
||||
instance ToTags PHP.MemberCallExpression
|
||||
instance ToTags PHP.MethodDeclaration
|
||||
instance ToTags PHP.Name
|
||||
instance ToTags PHP.NamedLabelStatement
|
||||
instance ToTags PHP.NamespaceAliasingClause
|
||||
|
2
test/fixtures/php/analysis/foo.php
vendored
2
test/fixtures/php/analysis/foo.php
vendored
@ -2,3 +2,5 @@
|
||||
function foo() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
foo()
|
||||
|
Loading…
Reference in New Issue
Block a user