Lively Kernel canvas
//
DraftMergeLayerIntoClass40true
merginglayersismanualworkwhichIwanttogetridof...20null
Wikicontrol220357truetrue
module('draft.TestMergeLayerIntoClassDummyModule').requires().toRun(function(){Object.subclass('MyDummyClass',{m1:function(){return24},m2:function(){return24},},'mycategory',{m3:function(){}})})22150015
orignalclass22652417
layerdefinition22652417
229048null
moduleName='TestMergeLayerIntoClassDummyModule';fileName='draft/'+moduleName+'.js';moduleUrl=newURL(Config.codeBase).withFilename(fileName);source=$morph('originalCode').textStringnewWebResource(moduleUrl).put(source)className='MyDummyClass';methodName='m2'layerName='TestDraftLayer';//oldsourcecodeinmodulemoduleAst=lively.ide.startSourceControl().addModule(fileName).ast();classNodes=moduleAst.subElements().select(function(ea){returnea.type=='klassDef'}).select(function(ea){returnea.name==className})classNode=classNodes[0];//theremaybeotherclassextensionspropertyNodes=classNode.subElements().select(function(ea){returnea.type=='propertyDef'}).select(function(ea){returnea.name==methodName})propertyNode=propertyNodes[0];//newcodeinlayermethodSource=getLayerDefinitionForObject(cop.create(layerName),eval(className).prototype)[methodName]propertyNode.getSourceCode()propertyNode.putSourceCode('m2:function(){\n'+'return28\n'+'},')newSource=''+methodName+':'+methodSource.toString()+','propertyNode.putSourceCode(newSource)$morph('mergedCode').setTextString(newWebResource(moduleUrl).get().content)46
cop.create('TestDraftLayer').refineClass(MyDummyClass,{m2:function(){//somecommentreturn25},})2215005
module('draft.TestMergeLayerIntoClassDummyModule').requires().toRun(function(){Object.subclass('MyDummyClass',{m1:function(){return24},m2:function(){//somecommentreturn25;},},'mycategory',{m3:function(){}})})22150016null
mergedsource22652417
null74