Commit 56c0d91e by Mitsuhiro Tanda

follow token name change

parent d530ccff
...@@ -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 'label.name': case 'keyword':
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 'label.value': case 'string':
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, 'label.name', null, 'paren.lparen'); var labelNameToken = this.findToken(session, pos.row, pos.column, 'keyword', 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, 'label.name', '__name__', 'paren.lparen'); var nameLabelNameToken = this.findToken(session, row, column, 'keyword', '__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 === 'label.value') { if (nameLabelValueToken && nameLabelValueToken.type === 'string') {
metricName = nameLabelValueToken.value.slice(1, -1); // cut begin/end quotation metricName = nameLabelValueToken.value.slice(1, -1); // cut begin/end quotation
} }
} else { } else {
......
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