Skip to content

[CLOSED] Code Cleanup: CodeMirror.getTokenAt() #3448

@core-ai-bot

Description

@core-ai-bot

Issue by redmunds
Tuesday Apr 30, 2013 at 21:28 GMT
Originally opened as adobe/brackets#3676


In the CodeMirror getTokenAt() method, it states that the className property is deprecated and to use type instead. We have > 500 hits when searching Brackets code on ".className", so we should start cleaning this up before a random pull from CodeMirror breaks a lot of code.

    // Fetch the parser token for a given character. Useful for hacks
    // that want to inspect the mode state (say, for completion).
    getTokenAt: function(pos) {
      var doc = this.doc;
      pos = clipPos(doc, pos);
      var state = getStateBefore(this, pos.line), mode = this.doc.mode;
      var line = getLine(doc, pos.line);
      var stream = new StringStream(line.text, this.options.tabSize);
      while (stream.pos < pos.ch && !stream.eol()) {
        stream.start = stream.pos;
        var style = mode.token(stream, state);
      }
      return {start: stream.start,
              end: stream.pos,
              string: stream.current(),
              className: style || null, // Deprecated, use 'type' instead
              type: style || null,
              state: state};
    },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions