@@ -1250,74 +1250,7 @@ impl FormatDeclaration {
12501250impl Searcher for FormatDeclaration {
12511251 fn search_decl ( & mut self , decl : FoundDeclaration ) -> SearchState {
12521252 if decl. named_entity ( ) . map ( |ent| ent. id ( ) ) == Some ( self . ent . id ( ) ) {
1253- self . result = Some ( match decl {
1254- FoundDeclaration :: InterfaceObject ( ref value) => match value. list_type {
1255- InterfaceListType :: Port => format ! ( "```vhdl\n port {};\n ```" , value) ,
1256- InterfaceListType :: Generic => format ! ( "```vhdl\n generic {};\n ```" , value) ,
1257- InterfaceListType :: Parameter => format ! ( "```vhdl\n {};\n ```" , value) ,
1258- } ,
1259- FoundDeclaration :: ForIndex ( ref ident, ref drange) => {
1260- format ! ( "```vhdl\n for {} in {} loop\n ```" , ident, drange)
1261- }
1262- FoundDeclaration :: ForGenerateIndex ( ref ident, ref value) => match ident {
1263- Some ( ident) => format ! ( "```vhdl\n {}: {}\n ```" , ident, value) ,
1264- None => format ! ( "```vhdl\n {}\n ```" , value) ,
1265- } ,
1266- FoundDeclaration :: Library ( ref value) => {
1267- format ! ( "```vhdl\n library {};\n ```" , value)
1268- }
1269- FoundDeclaration :: Function ( ref value) => {
1270- format ! ( "```vhdl\n {};\n ```" , value)
1271- }
1272- FoundDeclaration :: Procedure ( ref value) => {
1273- format ! ( "```vhdl\n {};\n ```" , value)
1274- }
1275- FoundDeclaration :: Object ( ref value) => {
1276- format ! ( "```vhdl\n {}\n ```" , value)
1277- }
1278- FoundDeclaration :: ElementDeclaration ( elem) => {
1279- format ! ( "```vhdl\n {}\n ```" , elem)
1280- }
1281- FoundDeclaration :: EnumerationLiteral ( ident, elem) => {
1282- format ! ( "```vhdl\n {} : {}\n ```" , elem, ident)
1283- }
1284- FoundDeclaration :: File ( ref value) => {
1285- format ! ( "```vhdl\n {}\n ```" , value)
1286- }
1287- FoundDeclaration :: Type ( ref value) => {
1288- format ! ( "```vhdl\n {}\n ```" , value)
1289- }
1290- FoundDeclaration :: Component ( ref value) => {
1291- format ! ( "```vhdl\n {}\n ```" , value)
1292- }
1293- FoundDeclaration :: Alias ( ref value) => {
1294- format ! ( "```vhdl\n {}\n ```" , value)
1295- }
1296- FoundDeclaration :: Package ( ref value) => {
1297- format ! ( "```vhdl\n {}\n ```" , value)
1298- }
1299- FoundDeclaration :: PackageInstance ( ref value) => {
1300- format ! ( "```vhdl\n {}\n ```" , value)
1301- }
1302- FoundDeclaration :: Configuration ( ref value) => {
1303- format ! ( "```vhdl\n {}\n ```" , value)
1304- }
1305- FoundDeclaration :: Entity ( ref value) => {
1306- format ! ( "```vhdl\n {}\n ```" , value)
1307- }
1308- FoundDeclaration :: Context ( ref value) => {
1309- format ! ( "```vhdl\n {}\n ```" , value)
1310- }
1311- FoundDeclaration :: GenerateBody ( value) => {
1312- format ! ( "```vhdl\n {}\n ```" , value)
1313- }
1314- FoundDeclaration :: ConcurrentStatement ( value) => {
1315- format ! ( "```vhdl\n {}\n ```" , value)
1316- }
1317- FoundDeclaration :: SequentialStatement ( value) => {
1318- format ! ( "```vhdl\n {}\n ```" , value)
1319- }
1320- } ) ;
1253+ self . result = Some ( decl. to_hover ( ) ) ;
13211254 Finished ( Found )
13221255 } else {
13231256 NotFinished
@@ -1421,3 +1354,76 @@ impl<'a> HasSrcPos for FoundDeclaration<'a> {
14211354 }
14221355 }
14231356}
1357+
1358+ impl FoundDeclaration < ' _ > {
1359+ fn to_hover ( & self ) -> String {
1360+ match self {
1361+ 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) ,
1365+ } ,
1366+ FoundDeclaration :: ForIndex ( ref ident, ref drange) => {
1367+ format ! ( "```vhdl\n for {} in {} loop\n ```" , ident, drange)
1368+ }
1369+ FoundDeclaration :: ForGenerateIndex ( ref ident, ref value) => match ident {
1370+ Some ( ident) => format ! ( "```vhdl\n {}: {}\n ```" , ident, value) ,
1371+ None => format ! ( "```vhdl\n {}\n ```" , value) ,
1372+ } ,
1373+ FoundDeclaration :: Library ( ref value) => {
1374+ format ! ( "```vhdl\n library {};\n ```" , value)
1375+ }
1376+ FoundDeclaration :: Function ( ref value) => {
1377+ format ! ( "```vhdl\n {};\n ```" , value)
1378+ }
1379+ FoundDeclaration :: Procedure ( ref value) => {
1380+ format ! ( "```vhdl\n {};\n ```" , value)
1381+ }
1382+ FoundDeclaration :: Object ( ref value) => {
1383+ format ! ( "```vhdl\n {}\n ```" , value)
1384+ }
1385+ FoundDeclaration :: ElementDeclaration ( elem) => {
1386+ format ! ( "```vhdl\n {}\n ```" , elem)
1387+ }
1388+ FoundDeclaration :: EnumerationLiteral ( ident, elem) => {
1389+ format ! ( "```vhdl\n {} : {}\n ```" , elem, ident)
1390+ }
1391+ FoundDeclaration :: File ( ref value) => {
1392+ format ! ( "```vhdl\n {}\n ```" , value)
1393+ }
1394+ FoundDeclaration :: Type ( ref value) => {
1395+ format ! ( "```vhdl\n {}\n ```" , value)
1396+ }
1397+ FoundDeclaration :: Component ( ref value) => {
1398+ format ! ( "```vhdl\n {}\n ```" , value)
1399+ }
1400+ FoundDeclaration :: Alias ( ref value) => {
1401+ format ! ( "```vhdl\n {}\n ```" , value)
1402+ }
1403+ FoundDeclaration :: Package ( ref value) => {
1404+ format ! ( "```vhdl\n {}\n ```" , value)
1405+ }
1406+ FoundDeclaration :: PackageInstance ( ref value) => {
1407+ format ! ( "```vhdl\n {}\n ```" , value)
1408+ }
1409+ FoundDeclaration :: Configuration ( ref value) => {
1410+ format ! ( "```vhdl\n {}\n ```" , value)
1411+ }
1412+ FoundDeclaration :: Entity ( ref value) => {
1413+ format ! ( "```vhdl\n {}\n ```" , value)
1414+ }
1415+ FoundDeclaration :: Context ( ref value) => {
1416+ format ! ( "```vhdl\n {}\n ```" , value)
1417+ }
1418+ FoundDeclaration :: GenerateBody ( value) => {
1419+ format ! ( "```vhdl\n {}\n ```" , value)
1420+ }
1421+ FoundDeclaration :: ConcurrentStatement ( value) => {
1422+ format ! ( "```vhdl\n {}\n ```" , value)
1423+ }
1424+ FoundDeclaration :: SequentialStatement ( value) => {
1425+ format ! ( "```vhdl\n {}\n ```" , value)
1426+ }
1427+ }
1428+ }
1429+ }
0 commit comments