brackets-archive / bracketsIssues

Archive of issues in brackets.
0 stars 0 forks source link

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

Open core-ai-bot opened 3 years ago

core-ai-bot commented 3 years ago

Issue by redmunds Tuesday Apr 30, 2013 at 21:28 GMT Originally opened as https://github.com/adobe/brackets/issues/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};
    },
core-ai-bot commented 3 years ago

Comment by peterflynn Tuesday Apr 30, 2013 at 21:49 GMT


One way we could address this would be via my larger pull to clean up our usage of token-related APIs in general. (Rationalizing some of the API inconsistencies and reducing raw access to _codeMirror). That would be post-MAX, maybe post-Sprint-25 though... but OTOH this doesn't seem urgent yet.

core-ai-bot commented 3 years ago

Comment by jeffslofish Friday May 03, 2013 at 00:46 GMT


I made a pull request for this issue and referenced the issue number in the pull request. I don't know why it didn't get mentioned here. See: https://github.com/adobe/brackets/pull/3697

core-ai-bot commented 3 years ago

Comment by TomMalbran Friday May 03, 2013 at 00:50 GMT


You need to add the reference in the issue description (not in the title) or comments for it to get mentioned here.

core-ai-bot commented 3 years ago

Comment by pthiess Friday May 03, 2013 at 20:50 GMT


@redmunds - please ping@peterflynn to get feedback on whether we should take the pull request at this point. I assigned the pull request to you as well.

core-ai-bot commented 3 years ago

Comment by redmunds Friday May 03, 2013 at 22:38 GMT


@peterflynn The pull request is pretty straight forward. I don't see any reason why we wouldn't take it. Let me know if you think otherwise.

core-ai-bot commented 3 years ago

Comment by peterflynn Friday May 03, 2013 at 22:40 GMT


@redmunds I agree, seems fine to merge this now.

core-ai-bot commented 3 years ago

Comment by redmunds Sunday May 05, 2013 at 17:31 GMT


Confirmed. Closing.

core-ai-bot commented 3 years ago

Comment by redmunds Sunday May 05, 2013 at 18:00 GMT


Re-opening. The pull request had merge errors, so I backed it out.

core-ai-bot commented 3 years ago

Comment by redmunds Tuesday May 07, 2013 at 02:15 GMT


Closing.