Script: Custom method
Created at 2008-02-11 by acatl
/* * Menu: Actionscript > Generate Custom Method * Key: M3+1 * DOM: http://download.eclipse.org/technology/dash/update/org.eclipse.eclipsemonkey.lang.javascript * Author: Acatl Pacheco */ function main() { var methods = ["public", "private", "protected"]; var editor = editors.activeEditor var source = editor.source if (editor.selectionRange) { var range = editor.selectionRange var offset = range.startingOffset var text = source.substring (offset, range.endingOffset) var p = ask_method_scope(); if (p < 0 || p > methods.length-1) p = 0; var o= ""; o += "\n\t\t /** Method Description */"; o += "\n\t\t" + methods[p] + " function " + text; o += "\n\t\t{"; o += "\n\t\t\treturn null;"; o += "\n\t\t}"; o += "\n" editor.applyEdit(offset, range.endingOffset - offset, o) } } function ask_method_scope() { dialog = new Packages.org.eclipse.jface.dialogs.InputDialog( window.getShell(), "Method scope", "(0) public\n(1) private\n(2) protected", "1", null) result = dialog.open() if (result == Packages.org.eclipse.jface.window.Window.OK) { return dialog.getValue(); } }
Comment:
prompts a window with the method's scope options u can add more to the script
Tags:
method, actionscript, selection create