-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding analyzer for need for speed
concept exercise
#134
Adding analyzer for need for speed
concept exercise
#134
Conversation
I have a couple of doubts of this particular case, cause this exercise has two classes, so I need to create an analyzer for |
Overall this looks good!
No there is no need to create separate analyzers for each class. The analyzer is invoked with a list of If your analyzer needs to have some logic specific to a single class of a multi-class solution, there are multiple ways of achieving this. Here's one from the top of my head: public class NeedForSpeedAnalyzer implements Analyzer {
@Override
public void analyze(Solution solution, OutputCollector output) {
var needForSpeedClassAnalyzer = new NeedForSpeedClassAnalyzer();
var raceTrackClassAnalyzer = new RaceTrackClassAnalyzer();
for (var compilationUnit : solution.getCompilationUnits()) {
compilationUnit.getClassByName("NeedForSpeed").ifPresent(c -> c.accept(needForSpeedClassAnalyzer, output));
compilationUnit.getClassByName("RaceTrack").ifPresent(c -> c.accept(raceTrackClassAnalyzer, output));
}
}
}
class NeedForSpeedClassAnalyzer extends VoidVisitorAdapter<OutputCollector> {
@Override
public void visit(MethodDeclaration node, OutputCollector output) {
// Only called for methods in the NeedForSpeed class
}
}
class RaceTrackClassAnalyzer extends VoidVisitorAdapter<OutputCollector> {
@Override
public void visit(MethodDeclaration node, OutputCollector output) {
// Only called for methods in the RaceTrack class
}
} Hope that helps! |
src/main/java/analyzer/exercises/needforspeed/AvoidConditionalLogic.java
Outdated
Show resolved
Hide resolved
src/main/java/analyzer/exercises/needforspeed/AvoidConditionalLogic.java
Outdated
Show resolved
Hide resolved
src/main/java/analyzer/exercises/needforspeed/AvoidConditionalLogic.java
Outdated
Show resolved
Hide resolved
Modifying order to be alphabetical on AnalyzerRoot Updating path to use exercise slug need-for-speed Adding javadoc to analyzer comments and do not make them public
src/main/java/analyzer/exercises/needforspeed/NeedForSpeedAnalyzer.java
Outdated
Show resolved
Hide resolved
…yzer.java Co-authored-by: Sander Ploegsma <[email protected]>
Analyzer comments have been merged into |
closes #109
To do:
Need For Speed
website-copy#2325