completer.ts 578 B

123456789101112131415161718192021222324
  1. ///<reference path="../../../headers/common.d.ts" />
  2. import {PrometheusDatasource} from "./datasource";
  3. export class PromCompleter {
  4. identifierRegexps = [/[\[\]a-zA-Z_0-9=]/];
  5. constructor(private datasource: PrometheusDatasource) {
  6. }
  7. getCompletions(editor, session, pos, prefix, callback) {
  8. var query = prefix;
  9. return this.datasource.performSuggestQuery(query).then(metricNames => {
  10. callback(null, metricNames.map(name => {
  11. return {
  12. caption: name,
  13. value: name,
  14. meta: 'metric',
  15. };
  16. }));
  17. });
  18. }
  19. }