Commit 1a5e7864 by Mitsuhiro Tanda

fix

parent 56c0d91e
...@@ -21,7 +21,7 @@ export class PromCompleter { ...@@ -21,7 +21,7 @@ export class PromCompleter {
var metricName; var metricName;
switch (token.type) { switch (token.type) {
case 'keyword': case 'entity.name.tag':
metricName = this.findMetricName(session, pos.row, pos.column); metricName = this.findMetricName(session, pos.row, pos.column);
if (!metricName) { if (!metricName) {
callback(null, this.transformToCompletions(['__name__', 'instance', 'job'], 'label name')); callback(null, this.transformToCompletions(['__name__', 'instance', 'job'], 'label name'));
...@@ -43,14 +43,14 @@ export class PromCompleter { ...@@ -43,14 +43,14 @@ export class PromCompleter {
callback(null, labelNames); callback(null, labelNames);
}); });
return; return;
case 'string': case 'string.quoted':
metricName = this.findMetricName(session, pos.row, pos.column); metricName = this.findMetricName(session, pos.row, pos.column);
if (!metricName) { if (!metricName) {
callback(null, []); callback(null, []);
return; 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) { if (!labelNameToken) {
callback(null, []); callback(null, []);
return; return;
...@@ -135,11 +135,11 @@ export class PromCompleter { ...@@ -135,11 +135,11 @@ export class PromCompleter {
var metricName = ''; var metricName = '';
var tokens; 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) { if (nameLabelNameToken) {
tokens = session.getTokens(nameLabelNameToken.row); tokens = session.getTokens(nameLabelNameToken.row);
var nameLabelValueToken = tokens[nameLabelNameToken.index + 2]; 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 metricName = nameLabelValueToken.value.slice(1, -1); // cut begin/end quotation
} }
} else { } else {
......
...@@ -65,13 +65,13 @@ var PrometheusHighlightRules = function() { ...@@ -65,13 +65,13 @@ var PrometheusHighlightRules = function() {
regex : "\\s+" regex : "\\s+"
} ], } ],
"start-label-matcher" : [ { "start-label-matcher" : [ {
token : "keyword", token : "entity.name.tag",
regex : '[a-zA-Z_][a-zA-Z0-9_]*' regex : '[a-zA-Z_][a-zA-Z0-9_]*'
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : '=~|=|!~|!=' regex : '=~|=|!~|!='
}, { }, {
token : "string", token : "string.quoted",
regex : '"[^"]*"|\'[^\']*\'' regex : '"[^"]*"|\'[^\']*\''
}, { }, {
token : "punctuation.operator", token : "punctuation.operator",
...@@ -401,7 +401,7 @@ var PrometheusCompletions = function() {}; ...@@ -401,7 +401,7 @@ var PrometheusCompletions = function() {};
(function() { (function() {
this.getCompletions = function(state, session, pos, prefix, callback) { this.getCompletions = function(state, session, pos, prefix, callback) {
var token = session.getTokenAt(pos.row, pos.column); 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, []); 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