Rep does not allow for comment, so I'll post as answer.
This is NOT meant to be one though. So please, do not upvote it, as it would be a real lack of respect for all who have used the comments to post tips.
Scouting, as said, is vital to understand what your opponent can do.
This does not always translate (specially at higher levels) to what your opponent will do.
So how can you tell what will be done from what you see ?
Short answer is, you can't.
However, you can prepare yourself for what you think could happen, and with enough practice, leave the door open for rapid adaptation.
Now, I am not a high level player, nor close at all, but I have noticed that my game has dramatically improved by watching what others do. How they open, how they pwn me :D, and specially, watching others get defeated (which enables me to go "...hey, he could've done X, or Y,...").
So, the best advice I can give you is play. A lot. Watch your replays, see what your opponent does, see what you do and how you react, watch high level replays, those will teach you about adaptability, watch the Day[9] dailies ("...where we learn to be a better gamer..."), watch the GSL, etc, etc.
Of course, no one would spend 1050 min and 150 gas to build 6 tech barracks to throw you off and then go mass viking. >D
Cheers!
Best Answer
If your Mothership is cloaking your buildings while you are being revealed they will not be able to see them if they hover over the buildings. They will, however, be able to see them on the mini-map. This way they still won't be able to attack the building while you are being revealed.
EDIT: Without detection that is. They won't be able to attack your buildings without Detection.