@@ -1249,12 +1249,28 @@ impl FormatDeclaration {
12491249
12501250impl Searcher for FormatDeclaration {
12511251 fn search_decl ( & mut self , decl : FoundDeclaration ) -> SearchState {
1252- if decl. named_entity ( ) . map ( |ent| ent. id ( ) ) == Some ( self . ent . id ( ) ) {
1253- self . result = Some ( decl. to_hover ( ) ) ;
1254- Finished ( Found )
1252+ let ent = if let Some ( ent) = decl. named_entity ( ) {
1253+ ent
12551254 } else {
1256- NotFinished
1255+ return NotFinished ;
1256+ } ;
1257+
1258+ if let Some ( ref implicit_of) = self . ent . implicit_of {
1259+ // Implicit
1260+ if implicit_of. id ( ) == ent. id ( ) {
1261+ self . result = Some ( format ! (
1262+ "-- {}\n \n -- Implicitly defined by:\n {}\n " ,
1263+ self . ent. describe( ) ,
1264+ decl,
1265+ ) ) ;
1266+ return Finished ( Found ) ;
1267+ }
1268+ } else if self . ent . id ( ) == ent. id ( ) {
1269+ // Explicit
1270+ self . result = Some ( decl. to_string ( ) ) ;
1271+ return Finished ( Found ) ;
12571272 }
1273+ NotFinished
12581274 }
12591275}
12601276
@@ -1355,74 +1371,74 @@ impl<'a> HasSrcPos for FoundDeclaration<'a> {
13551371 }
13561372}
13571373
1358- impl FoundDeclaration < ' _ > {
1359- fn to_hover ( & self ) -> String {
1374+ impl std :: fmt :: Display for FoundDeclaration < ' _ > {
1375+ fn fmt ( & self , f : & mut std :: fmt :: Formatter < ' _ > ) -> std :: fmt :: Result {
13601376 match self {
13611377 FoundDeclaration :: InterfaceObject ( ref value) => match value. list_type {
1362- InterfaceListType :: Port => format ! ( "```vhdl \n port {};\n ``` ", value) ,
1363- InterfaceListType :: Generic => format ! ( "```vhdl \n generic {};\n ``` ", value) ,
1364- InterfaceListType :: Parameter => format ! ( "```vhdl \n {};\n ``` ", value) ,
1378+ InterfaceListType :: Port => write ! ( f , "port {};", value) ,
1379+ InterfaceListType :: Generic => write ! ( f , "generic {};", value) ,
1380+ InterfaceListType :: Parameter => write ! ( f , " {};", value) ,
13651381 } ,
13661382 FoundDeclaration :: ForIndex ( ref ident, ref drange) => {
1367- format ! ( "```vhdl \n for {} in {} loop\n ``` ", ident, drange)
1383+ write ! ( f , "for {} in {} loop", ident, drange)
13681384 }
13691385 FoundDeclaration :: ForGenerateIndex ( ref ident, ref value) => match ident {
1370- Some ( ident) => format ! ( "```vhdl \n {}: {}\n ``` ", ident, value) ,
1371- None => format ! ( "```vhdl \n {} \n ``` ", value) ,
1386+ Some ( ident) => write ! ( f , " {}: {}", ident, value) ,
1387+ None => write ! ( f , "{} ", value) ,
13721388 } ,
13731389 FoundDeclaration :: Library ( ref value) => {
1374- format ! ( "```vhdl \n library {};\n ``` ", value)
1390+ write ! ( f , "library {};", value)
13751391 }
13761392 FoundDeclaration :: Function ( ref value) => {
1377- format ! ( "```vhdl \n {};\n ``` ", value)
1393+ write ! ( f , " {};", value)
13781394 }
13791395 FoundDeclaration :: Procedure ( ref value) => {
1380- format ! ( "```vhdl \n {};\n ``` ", value)
1396+ write ! ( f , " {};", value)
13811397 }
13821398 FoundDeclaration :: Object ( ref value) => {
1383- format ! ( "```vhdl \n {} \n ``` ", value)
1399+ write ! ( f , "{} ", value)
13841400 }
13851401 FoundDeclaration :: ElementDeclaration ( elem) => {
1386- format ! ( "```vhdl \n {} \n ``` ", elem)
1402+ write ! ( f , "{} ", elem)
13871403 }
13881404 FoundDeclaration :: EnumerationLiteral ( ident, elem) => {
1389- format ! ( "```vhdl \n {} : {}\n ``` ", elem, ident)
1405+ write ! ( f , " {} : {}", elem, ident)
13901406 }
13911407 FoundDeclaration :: File ( ref value) => {
1392- format ! ( "```vhdl \n {} \n ``` ", value)
1408+ write ! ( f , "{} ", value)
13931409 }
13941410 FoundDeclaration :: Type ( ref value) => {
1395- format ! ( "```vhdl \n {} \n ``` ", value)
1411+ write ! ( f , "{} ", value)
13961412 }
13971413 FoundDeclaration :: Component ( ref value) => {
1398- format ! ( "```vhdl \n {} \n ``` ", value)
1414+ write ! ( f , "{} ", value)
13991415 }
14001416 FoundDeclaration :: Alias ( ref value) => {
1401- format ! ( "```vhdl \n {} \n ``` ", value)
1417+ write ! ( f , "{} ", value)
14021418 }
14031419 FoundDeclaration :: Package ( ref value) => {
1404- format ! ( "```vhdl \n {} \n ``` ", value)
1420+ write ! ( f , "{} ", value)
14051421 }
14061422 FoundDeclaration :: PackageInstance ( ref value) => {
1407- format ! ( "```vhdl \n {} \n ``` ", value)
1423+ write ! ( f , "{} ", value)
14081424 }
14091425 FoundDeclaration :: Configuration ( ref value) => {
1410- format ! ( "```vhdl \n {} \n ``` ", value)
1426+ write ! ( f , "{} ", value)
14111427 }
14121428 FoundDeclaration :: Entity ( ref value) => {
1413- format ! ( "```vhdl \n {} \n ``` ", value)
1429+ write ! ( f , "{} ", value)
14141430 }
14151431 FoundDeclaration :: Context ( ref value) => {
1416- format ! ( "```vhdl \n {} \n ``` ", value)
1432+ write ! ( f , "{} ", value)
14171433 }
14181434 FoundDeclaration :: GenerateBody ( value) => {
1419- format ! ( "```vhdl \n {} \n ``` ", value)
1435+ write ! ( f , "{} ", value)
14201436 }
14211437 FoundDeclaration :: ConcurrentStatement ( value) => {
1422- format ! ( "```vhdl \n {} \n ``` ", value)
1438+ write ! ( f , "{} ", value)
14231439 }
14241440 FoundDeclaration :: SequentialStatement ( value) => {
1425- format ! ( "```vhdl \n {} \n ``` ", value)
1441+ write ! ( f , "{} ", value)
14261442 }
14271443 }
14281444 }
0 commit comments