protected Action<ITextControl> ExecuteOnDeclaration(ITsFunctionStatement index, IProgressIndicator progress) { var start = index; var info = new TsClass(); info.NameFull = index.DeclaredName; info.Sources.Add(index); info.ConstructorFunction = new TsFunction(index); info.FindFieldsInsideFunction(info.ConstructorFunction.Block); if (start != null) { var prot = info.FindPrototype(start.NextSibling); if (prot != null) { info.Sources.Add(prot.Item1); info.AnalyzePrototype(prot.Item2); } info.CollectPrototypeSeparateMethods(start.NextSibling); } TsElementFactory factory = TsElementFactory.GetInstance(index); using (WriteLockCookie.Create()) { ModificationUtil.ReplaceChild(info.Sources[0], factory.CreateStatement(info.TransformForTypescript())); for (var i = 1; i < info.Sources.Count; i++) { ModificationUtil.DeleteChild(info.Sources[i]); } } return null; }
protected Action<ITextControl> ExecuteOnExpression(ITsSimpleAssignmentExpression index, IProgressIndicator progress) { var start = TsExpressionStatementNavigator.GetByExpression(TsCompoundExpressionNavigator.GetByExpression(index)); var info = new TsClass(); if (index.Source is ITsFunctionExpression && index.Dest is ITsReferenceExpression) { info.NameFull = index.Dest.GetText(); info.Sources.Add(index); info.ConstructorFunction = new TsFunction(index.Source as ITsFunctionExpression); info.FindFieldsInsideFunction(info.ConstructorFunction.Block); if (start != null) { var prot = info.FindPrototype(start.NextSibling); if (prot != null) { info.Sources.Add(prot.Item1); info.AnalyzePrototype(prot.Item2); } info.CollectPrototypeSeparateMethods(start.NextSibling); } } else if (index.Source is ITsObjectLiteral && index.Dest is ITsReferenceExpression) { info.NameFull = index.Dest.GetText(); info.Sources.Add(index); info.AnalyzeStaticClass(index.Source as ITsObjectLiteral); } TsElementFactory factory = TsElementFactory.GetInstance(index); using (WriteLockCookie.Create()) { ModificationUtil.ReplaceChild(info.Sources[0], factory.CreateStatement(info.TransformForTypescript())); for (var i = 1; i < info.Sources.Count; i++) { ModificationUtil.DeleteChild(info.Sources[i]); } } return null; }