You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Actually metrics are computed equally for each parser through the metrics function contained in spaces.rs file. This approach though doesn't allow to customize parsers.
To overcome the problem above, it would be helpful to split up parsers in two great classes:
Metric parsers. They contain a metric function that allows only determined metrics to be computed
Non-metric parsers. They do other things, but they do not compute metrics. For now we can consider them like metric parsers but without the methods to compute metrics
Possible structure for the metric parsers
let parser = CppParser::new(...);// This function sets the list of metrics to be computed for the CppParser.// Returns an error if the ones specified aren't available for the CppParser
parser.set_metrics(...).unwrap();// Compute the metrics
parser.compute_metrics().unwrap();
Advantages
Each parser computes only the metrics related to the structure of its language (i.e. For the HTML language, loc, but not nom because there aren't functions or closures in it)
A user can choose the metrics to be computed through the set_metrics function
This new design can be useful for other features other than metrics
Disdvantages
Refactor lots of code
Implementing this new kind of design could introduce further issues
The text was updated successfully, but these errors were encountered:
Actually metrics are computed equally for each parser through the
metrics
function contained inspaces.rs
file. This approach though doesn't allow to customize parsers.To overcome the problem above, it would be helpful to split up parsers in two great classes:
metric
function that allows only determined metrics to be computedPossible structure for the metric parsers
Advantages
loc
, but notnom
because there aren't functions or closures in it)set_metrics
functionDisdvantages
The text was updated successfully, but these errors were encountered: