From efd0967e7ee0d9dee798d0fc31fd143b76607c36 Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Mon, 26 Feb 2024 17:06:01 +0100 Subject: [PATCH] attemp at fixing #85. Still need to add tests --- src/lang/cpp/internal/BindingsResolver.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/lang/cpp/internal/BindingsResolver.java b/src/lang/cpp/internal/BindingsResolver.java index e6ee7175..2741e110 100644 --- a/src/lang/cpp/internal/BindingsResolver.java +++ b/src/lang/cpp/internal/BindingsResolver.java @@ -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()); @@ -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; @@ -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"; }