Skip to content

Commit

Permalink
attemp at fixing #85. Still need to add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju committed Feb 26, 2024
1 parent d7fad14 commit efd0967
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/lang/cpp/internal/BindingsResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private ISourceLocation ownedBinding(IBinding binding, String scheme, ISourceLoc
}

private ISourceLocation ownedBinding(IBinding binding, String scheme, String postfix, ISourceLocation origin, boolean isStatic) throws URISyntaxException {
String name = binding.getName() + postfix;
String name = renameOperators(binding.getName(), scheme) + postfix;
ISourceLocation ownerLocation = resolveOwner(binding, origin);
ISourceLocation location = null;
boolean isAtRoot = "cpp+translationUnit".equals(ownerLocation.getScheme());
Expand Down Expand Up @@ -217,6 +217,15 @@ private ISourceLocation ownedBinding(IBinding binding, String scheme, String pos
return location;
}

private String renameOperators(String name, String scheme) {
if ("cpp+operatorMethod".equals(scheme)) {
// remove the additional spaces to avoid accidental synonyms
name = name.replaceAll(" ", "");
}

return name;
}

private ISourceLocation resolveOwner(IBinding binding, ISourceLocation origin) throws URISyntaxException {
if (binding == null) {
return translationUnitRoot;
Expand Down Expand Up @@ -681,6 +690,9 @@ else if (binding instanceof ICPPMethod) {
else if (binding.getName().startsWith("~")) {
scheme = "cpp+destructor";
}
else if (binding.getName().startsWith("operator") && binding.getName().contains("[<>\\-+*/=%!&\\|\\^\\?\\.]")) {
scheme = "cpp+operatorMethod";
}
else {
scheme = "cpp+method";
}
Expand Down

0 comments on commit efd0967

Please sign in to comment.