glsl4idea icon indicating copy to clipboard operation
glsl4idea copied to clipboard

Understand preprocessor conditionals

Open AbigailBuccaneer opened this issue 9 years ago • 3 comments

Currently preprocessor conditionals are just ignored - everything in them is parsed as usual regardless of whether the condition is true. This would lead to parser errors in a bunch of different ways.

AbigailBuccaneer avatar Apr 29 '15 21:04 AbigailBuccaneer

Do you have any idea how to fix this? Seems very complicated, considering how much corner cases this could have.

Darkyenus avatar Apr 29 '15 21:04 Darkyenus

This is only really feasible once constant expression analysis is implemented - I think it should work out okay to use the same analysis for other expressions as with preprocessor conditions. Even if we can't get the conditions right, it's still better to parse it either one way or the other than it is to assume both an #if and #else block are true.

AbigailBuccaneer avatar Apr 29 '15 21:04 AbigailBuccaneer

CLion's approach to this is to generate OCDirective elements for the #ifdef/#else/#endif as usual, but to replace the element types of whichever branch is inactive with a special comment token type, so all the non-compiled PsiElements end up as PsiComment(CONDITIONALLY_NON_COMPILED_COMMENT).

AbigailBuccaneer avatar Jun 23 '15 09:06 AbigailBuccaneer