Skip to content

Commit

Permalink
Fix red code in MODULE.bazel (#7217)
Browse files Browse the repository at this point in the history
Fix false positives of builtin rule annotator.
  • Loading branch information
LeFrosch authored Jan 13, 2025
1 parent 28f8725 commit fa69310
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/com/google/idea/blaze/cpp/HeaderRootTrimmer.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ private static Set<ExecutionRootPath> 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<CToolchainIdeInfo> toolchains = new LinkedHashSet<>(toolchainLookupMap.values());
for (CToolchainIdeInfo toolchain : toolchains) {
paths.addAll(toolchain.getBuiltInIncludeDirectories());
Expand Down

0 comments on commit fa69310

Please sign in to comment.