Community
Participate
Working Groups
I refer to this SO thread: https://stackoverflow.com/questions/50435974/how-to-suppress-syntax-error-in-eclipse-4-7-3a This very simple C++17 example generates 2 Syntax Errors and they cannot be suppressed as other errors: http://en.cppreference.com/w/cpp/utility/variant/visit The fact is that lot of C++17 features are still not implemented and I guess it won't be better with other/following standards. E.q. the implementation will took longer than the standard becomes active. I consider it as a good feature, especially also for the future. Just adding the error type "Syntax Error" in "Preferences | C/C++ | Code Analysis"
I agree, this would be a useful feature to have. It's not very trivial to implement, because the current @suppress feature is a Codan feature, and syntax errors are not created by Codan. (They don't even use IMarkers the way Codan errors do. They create IAnnotations directly, which happens in TranslationUnitAnnotationModel, CDT's customized version of ResourceMarkerAnnotationModel). Possible implementation strategies are: - Get syntax errors to be reported by Codan, by writing a new checker like SyntaxErrorChecker. The checker can query the problems directly from the AST, similar to how CModelBuilder2.buildModel() currently does. The code in TranslationUnitAnnotationModel to create IAnnotations for syntax problems can be removed. If we go this route, the support for @suppress will come automatically. - Factor out the relevant code for supporting @supress from Codan, and use it when creating IAnnotations for syntax problems in TranslationUnitAnnotationModel. I don't expect to have time to work on this, but if someone would like to tackle it, I'm happy to provide guidance.
The first option would require some extra plumbing if we want to syntax errors to continue to have their own icon and underline style (distinct from other Codan errors). There may also be some differences in how soon the syntax errors show up (i.e. we might currently do the model building, which produces the syntax errors, more often than we run the Codan checkers; I'm not actually sure, that's just my impression based on how quickly the two kinds of errors show up).
I tried to add a new checker moving the code from CModelBuilder2 as Nathan said. It works quite well but there are some problems from UI point of view in my opinion. At the moment we have a unique annotation "Index Marker" with specific symbol. Codan problems have three level of severity: error, warning and info. At the moment I created a specific marker codanSyntaxProblem (child of codanProblem) and I linked it to the current Index annotation for all severity levels. It works but if you open the codan ui what's the point to set the severity if everything points to the same value? I mean to keep consistent behavior we should use the same approach, so three level of severity as other codan problems, maybe keeping error as default in this case. Another option would be to use three new icons for this specific problems, but honestly I'm not a UI designer so I don't know what's the best option.
New Gerrit change created: https://git.eclipse.org/r/155155