PageRenderTime 415ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/bundles/plugins-trunk/SideKick/macros/JumpToBeginningOfFunction.bsh

#
Unknown | 22 lines | 20 code | 2 blank | 0 comment | 0 complexity | e300473a628baf1f5efe6f40783b6dc6 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. void JumpToBeginningOfFunction(JEditTextArea textArea)
  2. {
  3. int position = textArea.getCaretPosition();
  4. // Select the current asset
  5. sidekick.SideKickActions.selectAsset(view);
  6. // Search for the first occurrence of '{'
  7. Selection[] selection = textArea.getSelection();
  8. String s = null;
  9. if (selection == null || selection.length == 0) {
  10. return;
  11. }
  12. int start = selection[0].getStart();
  13. s = textArea.getSelectedText(selection[0]);
  14. for (int i = 0; i < s.length(); i++) {
  15. if (s.charAt(i) == '{') {
  16. textArea.setCaretPosition(start + i);
  17. return;
  18. }
  19. }
  20. }