资源描述:
《Explore refactoring functions in Eclipse JDTEclipse JDT中重构函数地探讨.pdf》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、ExplorerefactoringfunctionsinEclipseJDTPrashantDevaNovember24,2009ThisarticledescribesthevariousrefactoringsavailableinEclipseJava™DevelopmentTools(JDT),includingwhateachrefactoringdoes,whentouseit,andhowtouseit.ItalsoexplorestherefactoringscriptfunctionalityinEclipse,whichallowslibrarydevelopersto
2、sharecoderefactoringswiththeirclients.TherefactoringfunctionalitiesinEclipsemakeitamodern-dayJavaintegrateddevelopmentenvironment(IDE),ratherthananordinarytexteditor.Usingrefactoring,youcaneasilymakechangestoyourcodewithoutworryingaboutbreakingthingssomewhereelse.Withrefactoring,youcanwritesomecode
3、justtoseeifitworkswithoutworryingabouthowitlooks,thenusetherefactoringtoolstoquicklyandeasilyturnthatcodeintocleanandhighlymodularizedcode.ThisarticledescribesandshowshowtousesomeofthepowerfulrefactoringfunctionsavailableinEclipse.RefactoringtypesRenameRenameisprobablythemost-usedrefactoringinEclip
4、se.Itallowsyoutorenamevariables,classes,methods,packages,folders,andalmostanyJavaidentifiers.Whenyourenameanidentifier,allreferencestothatidentifierarealsorenamed.TheshortcuttoinvoketheRenamerefactoringisAlt+Shift+R.WhenyouinvoketheshortcutonanidentifierintheEclipseeditor,asmallboxdisplayswithinthe
5、editoritselfwhereyoucanchangetheidentifiername.WhenyoupressEnter,allreferencestothatidentifierarechanged,too.MoveYoucanuseMovetomoveaclassfromonepackagetoanother.Itphysicallymovestheclasstothefoldercorrespondingtothepackageandalsochangesallreferencestotheclasstorefertothenewpackage.Youcandraganddro
6、paclasstoanewpackageinthePackageExplorerview,andtherefactoringwilltakeplaceautomatically.ExtractLocalVariableTheExtractLocalVariablerefactoringallowsyoutoassigntheresultofaJavaexpressiontoanewlocalvariable.UseittosimplifyacomplexJavaexpressionbyquicklydividingitintomultiplelines.Or,wheneditingcode,
7、typetheexpressionfirstandusethisrefactoringtoautomatically©CopyrightIBMCorporation2009TrademarksExplorerefactoringfunctionsinEclipseJDTPage1of10developerWorks®ibm.com/developerWorks/createanewlocalvariablet