From 6b17a6b1bc620acb49f54d384707012e9a32e49c Mon Sep 17 00:00:00 2001 From: Daniel Brauner Date: Fri, 10 Jan 2025 16:04:44 +0100 Subject: [PATCH 1/2] Fix false positive of builtin rule annotator --- .../blaze/base/lang/buildfile/psi/FuncallExpression.java | 7 +++++++ .../lang/buildfile/validation/BuiltInRuleAnnotator.java | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/base/src/com/google/idea/blaze/base/lang/buildfile/psi/FuncallExpression.java b/base/src/com/google/idea/blaze/base/lang/buildfile/psi/FuncallExpression.java index 5877ef3bb9b..eaf80568142 100644 --- a/base/src/com/google/idea/blaze/base/lang/buildfile/psi/FuncallExpression.java +++ b/base/src/com/google/idea/blaze/base/lang/buildfile/psi/FuncallExpression.java @@ -109,6 +109,13 @@ public boolean isTopLevel() { return parent == null || parent.getElementType() == BuildElementTypes.BUILD_FILE; } + /** If the function is called as a member on something. */ + public boolean isMemberFunction() { + // if there are more than one reference to something, it is safe to assume that this is a member function + return findChildByType(BuildElementTypes.REFERENCE_EXPRESSION) != + findLastChildByType(BuildElementTypes.REFERENCE_EXPRESSION); + } + public boolean mightBeBuildRule() { return isTopLevel() || getNameArgument() != null; } diff --git a/base/src/com/google/idea/blaze/base/lang/buildfile/validation/BuiltInRuleAnnotator.java b/base/src/com/google/idea/blaze/base/lang/buildfile/validation/BuiltInRuleAnnotator.java index 6728da13a50..9bf455d8815 100644 --- a/base/src/com/google/idea/blaze/base/lang/buildfile/validation/BuiltInRuleAnnotator.java +++ b/base/src/com/google/idea/blaze/base/lang/buildfile/validation/BuiltInRuleAnnotator.java @@ -38,6 +38,10 @@ public void visitFuncallExpression(FuncallExpression node) { if (spec == null) { return; } + if (node.isMemberFunction()) { + // if the function is a member function, it cannot be a rule + return; + } String ruleName = node.getFunctionName(); RuleDefinition rule = spec.getRule(ruleName); if (rule == null) { From 085de4cf7dba89d7c9953b4b4b1bd2a187ab41c9 Mon Sep 17 00:00:00 2001 From: Daniel Brauner Date: Fri, 10 Jan 2025 16:04:57 +0100 Subject: [PATCH 2/2] Added comment to HeaderRootTrimmer --- cpp/src/com/google/idea/blaze/cpp/HeaderRootTrimmer.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cpp/src/com/google/idea/blaze/cpp/HeaderRootTrimmer.java b/cpp/src/com/google/idea/blaze/cpp/HeaderRootTrimmer.java index 8bb220a1a55..7fc7e5fd0d9 100644 --- a/cpp/src/com/google/idea/blaze/cpp/HeaderRootTrimmer.java +++ b/cpp/src/com/google/idea/blaze/cpp/HeaderRootTrimmer.java @@ -194,6 +194,10 @@ private static Set collectExecutionRootPaths( paths.addAll(target.getcIdeInfo().getTransitiveQuoteIncludeDirectories()); } } + + // Builtin includes should not be added to the switch builder, because CLion discovers builtin include paths during + // the compiler info collection, and therefore it would be safe to filter these header roots. But this would make + // the filter stricter, and it is unclear if this would affect any users. Set toolchains = new LinkedHashSet<>(toolchainLookupMap.values()); for (CToolchainIdeInfo toolchain : toolchains) { paths.addAll(toolchain.getBuiltInIncludeDirectories());