Riff Addict, I stickied a thread in this forum, called "In a rut with your improvs? Read on... " where a lot of answers to your question have been addressed.
Summing up my feeling about the problem you're referring to: you can try humming the lead line you imagine in your head, then try to match it with the guitar.
To kick things up a bit, you can imagine a 2-guitar conversation during this lead part, where you play one sentence with the neck pickup
for instance, concluding it on a root note from the key you'replaying, or on a note that leaves the solo suspended (like a question mark). Next, you flip the pickup to bridge and you go by answering the question your guitar asked the measure before (in a slightly different voice).
One of your parts can be played legato, while the responding part can be done with plam mutted strings and a descending lick in two-handed hammer-ons.
Find your voice(s) and see how jaws drop!
Note: Shredding and cramming the most notes per measure can have catastrophic effects if you don't know how to pace your phrasing. This is why some really good and fast players are boring as heck, because no-one can make sense of their playing,