D12587: Indentation script for R

Thomas Friedrichsmeier noreply at phabricator.kde.org
Sun Apr 29 20:13:26 UTC 2018


tfry added a comment.


  Regarding the unit tests: Take a look at e.g. https://cgit.kde.org/ktexteditor.git/tree/autotests/input/indent/cmake/enter1 . You start with an initial text "origin", then emulate some input "input.js", an specify the expected state at the end "expected".
  
  Again, I have no experience with indentation scripts, so no good idea what they should look like. A nitpick / idea is inlined.

INLINE COMMENTS

> r.js:174
> +// Returns -1 if nothing was found
> +function findAlignOperator(lineNr, pos) {
> +    var lineString = document.line(lineNr);

I wonder if this cannot be simplified (but not sure I understand the complete logic). Pseudo-code:

  var brackets = new Array();
  for ([iterating backwards, skipping strings and comments]) {
     var current_char = [...];
     var closing_type = closings.indexOf(current_char);
     if (closing_type >= 0) {
       brackets.push(current_char);
     } else {
       var opening_type = openings.indexOf(current_char);
       if (opening_type >= 0 && brackets.pop() != current_char) {
          [mismatch: return]
       }
       [...]
     }
  }

REPOSITORY
  R39 KTextEditor

REVISION DETAIL
  https://phabricator.kde.org/D12587

To: devillemereuil, #ktexteditor, #rkward
Cc: tfry, dhaumann, #frameworks, michaelh, kevinapavew, ngraham, bruns, demsking, cullmann, sars
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20180429/1695d0e7/attachment-0001.html>


More information about the Kde-frameworks-devel mailing list