Re: Using Semantic for Style Checking
"Eric M. Ludlam" <[email protected]> Wed, 10 Sep 2014 22:57:59 -0400
| Newsgroups | gmane.emacs.semantic |
|---|---|
| Message-ID | <[email protected]> |
On 09/10/2014 03:51 AM, Alex Murray wrote:
> Hi,
>
> I am trying to write a C style checker in Emacs using Semantic - firstly I just want to be able to check all variables within a file conform to a particular naming scheme.
>
> I am wanting to use Semantic to get the tags for all the variables within a file at all scopes but I can't seem to do this easily.
>
> (semantic-find-tags-by-class) only seems to return the variables in the global scope, so I was trying to use (semantic-fetch-tags) but this only returns variables within the current and all preceeding scopes - not ALL scopes within the buffer. Other than iterating through all positions within the buffer, I can't think of a good way to do this with my current understanding of semantic.
>
> Can anyone advise if this is possible (ie. to easily get all tags at all scopes within a buffer)?
>
> Any help would be greatly appreciated.
Hi,
The tags are all saved in a hierarchical order. When scanning the tag
lists there are 2 kinds of searches:
semantic-find-tags-by-class - finds all tags at the current level, which
is the base of the file by default.
semantic-brute-find-tag-by-class - find all tags at the current level,
and all tags that are children of some tag.
The -brute- functions all basically do a depth first search across the
provided tags table.
These functions will NOT find local variables, for example:
int myfcn() {
int cantfindme;
}
the cantfindme variable won't be found because semantic never parses
stuff between the { } of the function. If you want to do that you
would need to:
1) find-tags-by-class 'function
2) visit each function (move point there)
3) semantic-get-local-variables
Good Luck
Eric
------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk