Implement priority based clearsnippets.

Implement priority-based clearsnippets and add corresponding test cases (#335).
It is not refined version.  It will be removed in the following CLs.