code_editor.adoc 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. = jMonkeyEngine SDK: Code Editor and Palette
  2. :revnumber: 2.0
  3. :revdate: 2020/07/09
  4. :keywords: documentation, sdk, editor
  5. The Source Code Editor is the central part of the jMonkeyEngine SDK. This documentation shows you how to make the most of the jMonkeyEngine SDK's assistive features.
  6. include::partial$sdk-features-tip.adoc[]
  7. == Code Completion and Code Generation
  8. While typing Java code in the source code editor, you will see popups that help you to write more quickly by completing keywords, and generating code snippets. Additionally, they will let you see the javadoc for the classes you are working with.
  9. image::netbeans_code_completion.png[netbeans_code_completion.png,width="",height=""]
  10. *Code Completion*
  11. * Complete keyword / method / variable: kbd:[Ctrl+Space] +
  12. Alternatively you can also use kbd:[Ctrl+\ ]
  13. ** Customize Code Completion options: menu:Tools[Options > Editor > Code Completion]
  14. * Show expected parameters of this method in a tooltip: kbd:[Ctrl+P]
  15. * Complete any string (even non-Java) that has been used before: kbd:[Shift+Ctrl+K]
  16. *Code Generation*
  17. * Auto-fix import statements: kbd:[Ctrl+Shift+I]
  18. * Auto-generate getters/setters, try/catch, equals/hashCode: kbd:[Alt+Insert]
  19. ** Customize code completion: Choose menu:Tools[Options > Editor > Code Completion]
  20. * Auto-generate common code snippets such as loops, declarations, println, by typing the *template name* + kbd:[Tab]
  21. ** Customize code templates: Choose menu:Tools[Options > Editor > Code Templates]
  22. * Rename, move, or introduce methods, fields, and variables, without breaking the project: *Refactoring menu*
  23. == Semantic and Syntactic Coloring
  24. image::jmonkeyplatform-docu-5.png[jmonkeyplatform-docu-5.png,width="421",height="298"]
  25. The text color in the editor gives you important hints how the compiler will interpret what you typed, even before you compiled it.
  26. Examples:
  27. * Java keywords are *blue*, variables and fields are *green*, parameters are *orange*.
  28. * +++<strike>Strikethrough</strike>+++ means deprecated method or field.
  29. * +++<u>Gray underline</u>+++ means unused variable or method.
  30. * Place the caret in a method or variable and all its occurrences are marked *tan*.
  31. * Place the caret in a method's return type to highlight all exit points
  32. * and many more…
  33. To customize Colors and indentation:
  34. * menu:Tools[Options > Editor > Formatting]
  35. * menu:Tools[Options > Fonts and Colors]
  36. == Editor Hints and Quick Fixes (a.k.a. Lightbulbs)
  37. Editor hints and quick fixes show as lightbulbs along the left edge of the editor. They point out warnings and errors, and often propose useful solutions!
  38. * Execute a quick fix: Place the caret in the line next to the lightbulb and press kbd:[Alt+Enter] (or click the lightbulb)
  39. ** Customize hints: Choose menu:Tools[Options > Editor > Hints]
  40. == Javadoc
  41. * Place the caret above a method or a class that has no Javadoc, type
  42. +
  43. [source,html]
  44. ----
  45. /**
  46. ----
  47. and press Enter: The editor generates skeleton code for a Javadoc comment.
  48. * btn:[RMB] click the project in the Projects window and choose Generate Javadoc.
  49. * btn:[RMB] click a file and choose menu:Tools[Analyze Javadoc]
  50. To display a javadoc popup in the editor, place the caret in a line and press kbd:[Ctrl+Space] (Alternatively use kbd:[Ctrl+\ ]).
  51. * If the javadoc popup doesn't work, make certain that
  52. ** You have the Java JDK documentation installed and set up: menu:Tools[Java Platforms]
  53. ** You downloaded and set up javadoc for third-party libraries: menu:Project properties[Libraries > Edit]
  54. == Navigating the jME3 Source
  55. When the JavaDoc does not deliver enough information, you can have a look at the source of every method or object of jME3 that you use. Just btn:[RMB] click the variable or method, select menu:Navigate[Go to source] and an editor will open showing you the source file of jME3.
  56. == Palette
  57. image::jmonkeyplatform-docu-4.png[jmonkeyplatform-docu-4.png,width="421",height="298"]
  58. Choose menu:Windows[Palette] to open the context-sensitive Palette. The jMonkeyEngine SDK provides you with jme3 code snippets here that you can drag and drop into your source files.
  59. * Examples: Node and Model creation code snippets.
  60. [TIP]
  61. ====
  62. Choose menu:Tools[Add to Palette] from the menu to add your own code snippets to the Palette. (not available yet in beta build)
  63. ====
  64. == Keyboard Shortcuts
  65. Keyboard Shortcuts save you time when when you need to repeat common actions such as Build&amp;Run or navigation to files.
  66. * Go to File: kbd:[Alt+Shift+O]
  67. * Go to Type: kbd:[Ctrl+O]
  68. * Open in Projects / Files / Favorites window: kbd:[Ctrl+Shift+1]/ kbd:[2] / kbd:[3]
  69. * Build&amp;Run the main class of the Project: kbd:[F6]
  70. * Run the open file: kbd:[Shift+F6]
  71. * Switch to Editor / Projects / Files / Navigator: kbd:[Ctrl+0] /kbd:[1] / kbd:[3] / kbd:[7]
  72. * Indent code: kbd:[Ctrl+Shift+F]
  73. By default, jMonkeyEngine uses the same link:http://netbeans.org/project_downloads/www/shortcuts-6.5.pdf[Editor Shortcuts] as the NetBeans IDE, but you can also switch to an Eclipse Keymap, or create your own set.
  74. * Customize keyboard shortcuts: menu:Tools[Options > Keymap]
  75. == Tips and Tricks
  76. * To browse the physical file structure of your project, use the Files window: kbd:[Ctrl+2]
  77. * To open a file that is not part of a Java project, add it to the Favorites window: kbd:[Ctrl+3]
  78. * If you cannot find a particular menu item or option panel, use the IDE Search box in the top right! kbd:[Ctrl+i]
  79. * If a code block, class, or javadoc is quite long and you don't want to scroll over it, click the *+/-* signs to collapse (fold) the code block temporarily.
  80. * Press kbd:[F1] for Help
  81. '''
  82. See also
  83. * link:http://netbeans.org/kb/docs/java/editor-codereference.html[Code Assistance]