DGNavigation.hs revision 88e08f20c80fea4b7892bbb5e70c5002f7c1da18
ecd98975b8a8ab5a7bc075562bdab51cf47d2a90Christian MaederModule : $Header$
ecd98975b8a8ab5a7bc075562bdab51cf47d2a90Christian MaederDescription : Navigation through the Development Graph
54ea981a0503c396c2923a1c06421c6235baf27fChristian MaederCopyright : (c) Ewaryst Schulz, DFKI Bremen 2011
ecd98975b8a8ab5a7bc075562bdab51cf47d2a90Christian MaederLicense : GPLv2 or higher, see LICENSE.txt
ecd98975b8a8ab5a7bc075562bdab51cf47d2a90Christian MaederMaintainer : ewaryst.schulz@dfki.de
ecd98975b8a8ab5a7bc075562bdab51cf47d2a90Christian MaederStability : experimental
ecd98975b8a8ab5a7bc075562bdab51cf47d2a90Christian MaederPortability : non-portable (via imports)
ecd98975b8a8ab5a7bc075562bdab51cf47d2a90Christian MaederNavigation through the Development Graph based on Node and Link predicates
54ea981a0503c396c2923a1c06421c6235baf27fChristian Maederusing Depth First Search.
f456529a89bfb620d39e5fd5b0a53b24643db96dDominik Lueckeimport qualified Data.Set as Set
54ea981a0503c396c2923a1c06421c6235baf27fChristian Maeder-- * Navigator Class
54ea981a0503c396c2923a1c06421c6235baf27fChristian Maederclass DevGraphNavigator a where
54ea981a0503c396c2923a1c06421c6235baf27fChristian Maeder -- | get all the incoming ledges of the given node
54ea981a0503c396c2923a1c06421c6235baf27fChristian Maeder incoming :: a -> Node -> [LEdge DGLinkLab]
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder -- | get the label of the given node
54ea981a0503c396c2923a1c06421c6235baf27fChristian Maeder getLabel :: a -> Node -> DGNodeLab
54ea981a0503c396c2923a1c06421c6235baf27fChristian Maeder -- | get the local (not referenced) environment of the given node
ecd98975b8a8ab5a7bc075562bdab51cf47d2a90Christian Maeder getLocalNode :: a -> Node -> (DGraph, LNode DGNodeLab)
ecd98975b8a8ab5a7bc075562bdab51cf47d2a90Christian Maeder getInLibEnv :: a -> (LibEnv -> DGraph -> b) -> b
6f08518fe3561930fef290b8e01384a6f1c90598Till Mossakowski getCurrent :: a -> [LNode DGNodeLab]
6f08518fe3561930fef290b8e01384a6f1c90598Till Mossakowski relocate :: a -> DGraph -> [LNode DGNodeLab] -> a
6f08518fe3561930fef290b8e01384a6f1c90598Till Mossakowski-- | Get all the incoming ledges of the given node and eventually
6f08518fe3561930fef290b8e01384a6f1c90598Till Mossakowski-- cross the border to an other 'DGraph'. The new 'DevGraphNavigator'
ecd98975b8a8ab5a7bc075562bdab51cf47d2a90Christian Maeder-- is returned with 'DGraph' set to the new graph and current node to
54ea981a0503c396c2923a1c06421c6235baf27fChristian Maeder-- the given node.
ecd98975b8a8ab5a7bc075562bdab51cf47d2a90Christian MaederfollowIncoming :: DevGraphNavigator a => a -> Node
f456529a89bfb620d39e5fd5b0a53b24643db96dDominik Luecke -> (a, LNode DGNodeLab, [LEdge DGLinkLab])
1e39a4ee4e97d16c48003d49e4af3d181f25ad71Christian MaederfollowIncoming dgn n = (dgn', lbln, incoming dgn' n')
1e39a4ee4e97d16c48003d49e4af3d181f25ad71Christian Maeder where (dgn', lbln@(n', _)) = followNode dgn n
f456529a89bfb620d39e5fd5b0a53b24643db96dDominik Luecke-- | get the local (not referenced) label of the given node
7ab2df3001654dd1b7a2cfc3da1ccef11c39a503Christian MaedergetLocalLabel :: DevGraphNavigator a => a -> Node -> DGNodeLab
0a65899b09e78455a94af9128455f6613441ab71cmaedergetLocalLabel dgnav = snd . snd . getLocalNode dgnav
54ea981a0503c396c2923a1c06421c6235baf27fChristian MaederfollowNode :: DevGraphNavigator a => a -> Node -> (a, LNode DGNodeLab)
54ea981a0503c396c2923a1c06421c6235baf27fChristian MaederfollowNode dgnav n = (relocate dgnav dg [lbln], lbln)
54ea981a0503c396c2923a1c06421c6235baf27fChristian Maeder where (dg, lbln) = getLocalNode dgnav n
getLocalSyms :: DevGraphNavigator a => a -> Node -> Set.Set G_symbol
_ -> Set.empty