#include "llvm/Support/ScopedPrinter.h"
#include <algorithm>
#include <iterator>
+#include <limits>
// We log detailed candidate here if you run with -debug-only=codecomplete.
#define DEBUG_TYPE "CodeComplete"
evaluateSymbolAndRelevance(Scores.Quality, Scores.Relevance);
// NameMatch is in fact a multiplier on total score, so rescoring is
// sound.
- Scores.ExcludingName = Relevance.NameMatch
- ? Scores.Total / Relevance.NameMatch
- : Scores.Quality;
+ Scores.ExcludingName =
+ Relevance.NameMatch > std::numeric_limits<float>::epsilon()
+ ? Scores.Total / Relevance.NameMatch
+ : Scores.Quality;
return Scores;
case RM::DecisionForest:
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/ScopedPrinter.h"
+#include <limits>
#include <tuple>
#define DEBUG_TYPE "FindSymbols"
return;
}
Relevance.merge(Sym);
- auto Score = evaluateSymbolAndRelevance(Quality.evaluateHeuristics(),
- Relevance.evaluateHeuristics());
+ auto QualScore = Quality.evaluateHeuristics();
+ auto RelScore = Relevance.evaluateHeuristics();
+ auto Score = evaluateSymbolAndRelevance(QualScore, RelScore);
dlog("FindSymbols: {0}{1} = {2}\n{3}{4}\n", Sym.Scope, Sym.Name, Score,
Quality, Relevance);
Info.containerName = Scope.str();
// Exposed score excludes fuzzy-match component, for client-side re-ranking.
- Info.score = Score / Relevance.NameMatch;
+ Info.score = Relevance.NameMatch > std::numeric_limits<float>::epsilon()
+ ? Score / Relevance.NameMatch
+ : QualScore;
Top.push({Score, std::move(Info)});
});
for (auto &R : std::move(Top).items())