Commit 1a5e7864 by Mitsuhiro Tanda

fix

parent 56c0d91e
......@@ -21,7 +21,7 @@ export class PromCompleter {
var metricName;
switch (token.type) {
case 'keyword':
case 'entity.name.tag':
metricName = this.findMetricName(session, pos.row, pos.column);
if (!metricName) {
callback(null, this.transformToCompletions(['__name__', 'instance', 'job'], 'label name'));
......@@ -43,14 +43,14 @@ export class PromCompleter {
callback(null, labelNames);
});
return;
case 'string':
case 'string.quoted':
metricName = this.findMetricName(session, pos.row, pos.column);
if (!metricName) {
callback(null, []);
return;
}
var labelNameToken = this.findToken(session, pos.row, pos.column, 'keyword', null, 'paren.lparen');
var labelNameToken = this.findToken(session, pos.row, pos.column, 'entity.name.tag', null, 'paren.lparen');
if (!labelNameToken) {
callback(null, []);
return;
......@@ -135,11 +135,11 @@ export class PromCompleter {
var metricName = '';
var tokens;
var nameLabelNameToken = this.findToken(session, row, column, 'keyword', '__name__', 'paren.lparen');
var nameLabelNameToken = this.findToken(session, row, column, 'entity.name.tag', '__name__', 'paren.lparen');
if (nameLabelNameToken) {
tokens = session.getTokens(nameLabelNameToken.row);
var nameLabelValueToken = tokens[nameLabelNameToken.index + 2];
if (nameLabelValueToken && nameLabelValueToken.type === 'string') {
if (nameLabelValueToken && nameLabelValueToken.type === 'string.quoted') {
metricName = nameLabelValueToken.value.slice(1, -1); // cut begin/end quotation
}
} else {
......
......@@ -65,13 +65,13 @@ var PrometheusHighlightRules = function() {
regex : "\\s+"
} ],
"start-label-matcher" : [ {
token : "keyword",
token : "entity.name.tag",
regex : '[a-zA-Z_][a-zA-Z0-9_]*'
}, {
token : "keyword.operator",
regex : '=~|=|!~|!='
}, {
token : "string",
token : "string.quoted",
regex : '"[^"]*"|\'[^\']*\''
}, {
token : "punctuation.operator",
......@@ -401,7 +401,7 @@ var PrometheusCompletions = function() {};
(function() {
this.getCompletions = function(state, session, pos, prefix, callback) {
var token = session.getTokenAt(pos.row, pos.column);
if (token.type === 'label.name' || token.type === 'label.value') {
if (token.type === 'entity.name.tag' || token.type === 'string.quoted') {
return callback(null, []);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment