On 5/18/2015 5:49 PM, John Yeung wrote:
But to really Do It Right, I think you have to write your own comment
parser. It's definitely a shame, since everyone is having the same
thought: The editor component has already highlighted the comment, so
it has already done the work of figuring out what's a comment and
what's not; if only we could leverage that instead of re-engineering
it.
Cross-posted to WDSCI-L.
RDi already exposes whether the line is a comment or not. Here are some
examples:
* Strip Out the Mailing Zip
query elementClasses
elementClasses COMMENTS commentOnly Fixed
C EXSR GETMZIP
query elementClasses
elementClasses CONTROL Fixed
C IF *IN95 = *OFF
95 on = EOF/NO = MAT
query elementClasses
elementClasses COMMENTS CONTROL Fixed
// U1 - get additional looser match counts
query elementClasses
elementClasses COMMENTS commentOnly Free
if *inu1;
query elementClasses
elementClasses CONTROL Free CSpec
exec sql
select
(cursor here) count(*) -- count
into :foundE
from sometable
where match = 'F';
query elementClasses
elementClasses COMMENTS SQL Free CFreeSQL forwardLink backwardLink
It is therefore already possible to identify lines which are entirely
made of comments as well as lines which have right side comments.
Knowing that, a plugin could exclude the comment-only lines thusly: set
excludedClasses commentOnly Once excluded, a findText could then search
only the 'code' lines. This would still have false positives with right
hand comments, but a plugin could handle those as a special case. Wrap
the plugin inside something which iterates through a list of
tabs/members/filters and the general case is solved. For RPG.
And if I were any sort of a Java programmer I'd do it.
As an Amazon Associate we earn from qualifying purchases.