aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/haskell/haskelltokenizer.cpp
diff options
context:
space:
mode:
authorEike Ziller <git@eikeziller.de>2017-04-24 16:23:29 +0200
committerEike Ziller <git@eikeziller.de>2017-10-01 20:11:08 +0200
commitd1c0bd6491e9ff5a2d9ce31d523901640eadbb66 (patch)
treeac509c23b3936dbddef6667c1e669968eac352e4 /plugins/haskell/haskelltokenizer.cpp
parent5798e33d742c0f413d2d865fdb75739b4374ce98 (diff)
Add editor tooltips with type and symbol info
There is one ghcmod process started in a separate thread per project directory of opened files. If there are no more files open for a project, that ghcmod thread is exited. This doesn't take unsaved modifications into account.
Diffstat (limited to 'plugins/haskell/haskelltokenizer.cpp')
-rw-r--r--plugins/haskell/haskelltokenizer.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/plugins/haskell/haskelltokenizer.cpp b/plugins/haskell/haskelltokenizer.cpp
index 527e505..b59b48b 100644
--- a/plugins/haskell/haskelltokenizer.cpp
+++ b/plugins/haskell/haskelltokenizer.cpp
@@ -150,6 +150,19 @@ Tokens::Tokens(std::shared_ptr<QString> source)
{
}
+Token Tokens::tokenAtColumn(int col) const
+{
+ auto it = std::upper_bound(begin(), end(), col, [](int c, const Token &i) {
+ return c < i.startCol;
+ });
+ if (it == begin())
+ return Token();
+ --it;
+ if (it->startCol + it->length > col)
+ return *it;
+ return Token();
+}
+
static int grab(const QString &line, int begin,
const std::function<bool(const QChar&)> &test)
{
@@ -160,7 +173,6 @@ static int grab(const QString &line, int begin,
return current - begin;
};
-
static bool isIdentifierChar(const QChar &c)
{
return c.isLetterOrNumber() || c == '\'' || c == '_';