示例#1
0
        public static Saved_MethodStream map_CodeStreams(this Saved_MethodStream savedMethodStream, O2MappedAstData astData, String file, INode iNode)
        {
            var o2CodeStream = astData.createO2CodeStream(file, iNode);

            //var uniqueStreamPaths = o2CodeStream.getUniqueStreamPaths(100);

            Func <O2CodeStreamNode, CodeStreamPath> map_O2CodeStreamNode = null;

            map_O2CodeStreamNode = (o2CodeStreamNode) =>
            {
                var codeStreamPath = new CodeStreamPath();
                codeStreamPath.Text       = o2CodeStreamNode.Text;
                codeStreamPath.Line       = o2CodeStreamNode.INode.StartLocation.Line;
                codeStreamPath.Column     = o2CodeStreamNode.INode.StartLocation.Column;
                codeStreamPath.Line_End   = o2CodeStreamNode.INode.EndLocation.Line;
                codeStreamPath.Column_End = o2CodeStreamNode.INode.EndLocation.Column;
                foreach (var childNode in o2CodeStreamNode.ChildNodes)
                {
                    codeStreamPath.CodeStreamPaths.add(map_O2CodeStreamNode(childNode));
                }
                return(codeStreamPath);
            };
            foreach (var streamNode in o2CodeStream.StreamNode_First)
            {
                savedMethodStream.CodeStreams.add(map_O2CodeStreamNode(streamNode));
            }
            return(savedMethodStream);
        }
示例#2
0
        public static string codeStreams_CreateInAppDomain(this Saved_MethodStream savedMethodStream)
        {
            //var script = @"C:\O2\_XRules_Local\Ast_Test.cs";
            var script = "Saved_MethodStream.cs".local();

            "Creating new AppDomain".info();
            var appDomainName = 4.randomString();
            var o2AppDomain   = new O2.Kernel.Objects.O2AppDomainFactory(appDomainName);

            o2AppDomain.load("O2_XRules_Database");
            o2AppDomain.load("O2_Kernel");
            o2AppDomain.load("O2_DotNetWrappers");
            var o2Proxy    = (O2Proxy)o2AppDomain.getProxyObject("O2Proxy");
            var parameters = new object[]
            {
                savedMethodStream.Serialized_Saved_MethodStream_FileCache
//						sourceFolder,
//						resultsFolder,
//						methodFilter,
//						useCachedData,
//						references,
//						numberOfItemsToProcess
            };

            var result = (string)o2Proxy.staticInvocation("O2_External_SharpDevelop", "FastCompiler_ExtensionMethods", "executeFirstMethod", new object[] { script, parameters });

            "Result: {0}".info(result);
            o2AppDomain.sleep(2000);
            o2AppDomain.unLoadAppDomain();
            "AppDomain execution completed, Runing GCCollect".info();
            PublicDI.config.gcCollect();
            "GCCollect completed, returning result data: {0}".info(result);
            return(result);
        }
示例#3
0
        public static Saved_MethodStream map_MethodStreamItems(this Saved_MethodStream savedMethodStream, O2MappedAstData astData)
        {
            var methodStreamItems = savedMethodStream.MethodStreamItems;

            foreach (var externalClass in savedMethodStream.o2MethodStream.ExternalClasses.Values)
            {
                methodStreamItems.add(savedMethodStream.methodStreamItem(externalClass));
            }

            foreach (var externalIMethod in savedMethodStream.o2MethodStream.ExternalIMethods.Values)
            {
                methodStreamItems.add(savedMethodStream.methodStreamItem(astData, externalIMethod, MethodStream_ItemType.ExternalMethod));
            }

            foreach (var externalIMethod in savedMethodStream.o2MethodStream.MappedIMethods.Values)
            {
                methodStreamItems.add(savedMethodStream.methodStreamItem(astData, externalIMethod, MethodStream_ItemType.MappedMethod));
            }

            foreach (var iField in savedMethodStream.o2MethodStream.Fields.Values)
            {
                methodStreamItems.add(savedMethodStream.methodStreamItem(astData, iField));
            }

            foreach (var iProperty in savedMethodStream.o2MethodStream.Properties.Values)
            {
                methodStreamItems.add(savedMethodStream.methodStreamItem(astData, iProperty));
            }
            //break;
            return(savedMethodStream);
        }
示例#4
0
        public static Saved_MethodStream createCodeStreams(this Saved_MethodStream savedMethodStream)
        {
            var useAstCachedData = true;
            var methodStreamFile = savedMethodStream.MethodStream_FileCache;

            if (methodStreamFile.fileExists().isFalse())
            {
                "in createCodeStreams there was no MethodStream File to process".error();
                return(savedMethodStream);
            }
            savedMethodStream.CodeStreams = new List <CodeStreamPath>();

            var AstData_MethodStream = methodStreamFile.getAstData(useAstCachedData);
            var methodDeclarations   = AstData_MethodStream.methodDeclarations();

            if (methodDeclarations.size() > 0)
            {
                var iNodes = methodDeclarations[0].iNodes();

                foreach (var iNode in iNodes)
                {
                    savedMethodStream.map_CodeStreams(AstData_MethodStream, methodStreamFile, iNode);
                }
            }
            return(savedMethodStream);
        }
示例#5
0
        public static Saved_MethodStream Create(O2MappedAstData astData, IMethod iMethod, string methodStreams_CacheLocation, bool forceCreate)
        {
            if (methodStreams_CacheLocation.isNull())
            {
                methodStreams_CacheLocation = "_methodStreams_CacheLocation".tempDir();
            }
            var safeFileName = iMethod.fullName().safeFileName();         //240 - methodStreams_CacheLocation.size());
            var pathToSaveSerializedObject = methodStreams_CacheLocation.pathCombine_MaxSize(safeFileName + ".methodStream.xml");

            if (forceCreate.isFalse() && pathToSaveSerializedObject.fileExists())
            {
                "Skipping iMethod '{0}' since serialized object already exists ".debug(iMethod.Name);
                var loaded_SavedMethodStream = pathToSaveSerializedObject.load <Saved_MethodStream>();
                if (loaded_SavedMethodStream.notNull())
                {
                    return(loaded_SavedMethodStream);
                }
            }

            var savedMethodStream = new Saved_MethodStream(astData, iMethod);

            if (savedMethodStream.isNull())
            {
                return(null);
            }
            else
            {
                savedMethodStream.Serialized_Saved_MethodStream_FileCache = pathToSaveSerializedObject;
                savedMethodStream.saveAs(pathToSaveSerializedObject);
                "Serialized method stream object saved to: {0}".debug(pathToSaveSerializedObject);
                return(savedMethodStream);
            }
        }
示例#6
0
        public static Saved_MethodStream createMethodStream(this Saved_MethodStream savedMethodStream, O2MappedAstData astData, IMethod iMethod)
        {
            savedMethodStream.o2MethodStream = astData.createO2MethodStream(iMethod);
            savedMethodStream.MethodStream   = savedMethodStream.o2MethodStream.csharpCode();

            var fileCachePath = "_methodStreams".tempDir(false).pathCombine_MaxSize(savedMethodStream.RootMethod.Signature.safeFileName() + ".cs");

            savedMethodStream.MethodStream_FileCache = savedMethodStream.MethodStream.saveAs(fileCachePath);
            return(savedMethodStream);
        }
示例#7
0
        public static MethodStream_Item methodStreamItem(this Saved_MethodStream savedMethodStream, IEntity iEntity)
        {
            var methodStreamItem = new MethodStream_Item();

            methodStreamItem.Name       = iEntity.Name;
            methodStreamItem.Namespace  = iEntity.Namespace;
            methodStreamItem.DotNetName = iEntity.DotNetName;
            methodStreamItem.Class      = iEntity.DotNetName;
            methodStreamItem.Signature  = iEntity.FullyQualifiedName;
            return(methodStreamItem);
        }
示例#8
0
        public static MethodStream_Item methodStreamItem(this Saved_MethodStream savedMethodStream, IReturnType iReturnType)
        {
            var methodStreamItem = new MethodStream_Item();

            methodStreamItem.ItemType   = MethodStream_ItemType.ExternalClasses;
            methodStreamItem.Name       = iReturnType.Name;
            methodStreamItem.Namespace  = iReturnType.Namespace;
            methodStreamItem.DotNetName = iReturnType.DotNetName;
            methodStreamItem.Class      = iReturnType.DotNetName;
            methodStreamItem.Signature  = iReturnType.FullyQualifiedName;
            return(methodStreamItem);
        }
示例#9
0
        public static MethodStream_Item methodStreamItem(this Saved_MethodStream savedMethodStream, O2MappedAstData astData, IField iField)
        {
            var methodStreamItem = savedMethodStream.methodStreamItem(iField);

            methodStreamItem.ItemType = MethodStream_ItemType.Field;
            var fieldDeclaration = astData.fieldDeclaration(iField);

            if (fieldDeclaration.notNull())
            {
                methodStreamItem.Location = new Location(fieldDeclaration);
            }
            return(methodStreamItem);
        }
示例#10
0
        public static MethodStream_Item methodStreamItem(this Saved_MethodStream savedMethodStream, O2MappedAstData astData, IProperty iProperty)
        {
            var methodStreamItem = savedMethodStream.methodStreamItem(iProperty);

            methodStreamItem.ItemType = MethodStream_ItemType.Property;
            var propertyDeclaration = astData.propertyDeclaration(iProperty);

            if (propertyDeclaration.notNull())
            {
                methodStreamItem.Location = new Location(propertyDeclaration);
            }
            //fieldDeclaration.details();
            return(methodStreamItem);
        }
 public void loadMethodStream(Saved_MethodStream _savedMethodStream)
 {
     if (_savedMethodStream.isNull())
     {
         "provided savedMethodStream object is null".error();
     }
     else
     {
         savedMethodStream = _savedMethodStream;
         codeViewer.set_Text(savedMethodStream.MethodStream);
         //codeViewer.open(savedMethodStream.MethodStream_FileCache );
         refresh_AllCodeStreams_TreeView();
         //codeStreams.selectFirst();
     }
 }
示例#12
0
        public static MethodStream_Item methodStreamItem(this Saved_MethodStream savedMethodStream, O2MappedAstData astData, IMethod iMethod, MethodStream_ItemType itemType)
        {
            var methodStreamItem = new MethodStream_Item();

            methodStreamItem.ItemType = itemType;

            if (iMethod.Parameters.Count > 0)
            {
                methodStreamItem.Parameters = new NameValueItems();
                foreach (var parameter in iMethod.Parameters)
                {
                    methodStreamItem.Parameters.add(parameter.Name.str(), parameter.ReturnType.FullyQualifiedName);
                }
            }
            if (iMethod.Attributes.Count > 0)
            {
                methodStreamItem.Attributes = new NameValueItems();
                foreach (var attribute in iMethod.Attributes)
                {
                    methodStreamItem.Attributes.add(attribute.AttributeTarget.str(), attribute.AttributeType.FullyQualifiedName);
                }
            }

            methodStreamItem.Name  = iMethod.name();
            methodStreamItem.Class = iMethod.DeclaringType.Name;
            if (astData.file(iMethod).notNull())
            {
                methodStreamItem.Location = new Location(astData, iMethod);
            }
            methodStreamItem.Namespace  = iMethod.DeclaringType.Namespace;
            methodStreamItem.Signature  = iMethod.fullName();
            methodStreamItem.ReturnType = iMethod.ReturnType.FullyQualifiedName;
            methodStreamItem.DotNetName = iMethod.DotNetName;

            return(methodStreamItem);
        }
		public void loadMethodStream(Saved_MethodStream _savedMethodStream)
		{
			if (_savedMethodStream.isNull())
				"provided savedMethodStream object is null".error();
			else
			{
				savedMethodStream = _savedMethodStream;
				_codeEditor.set_Text(savedMethodStream.MethodStream , "_.cs");
				//codeViewer.open(savedMethodStream.MethodStream_FileCache );
				refresh_AllCodeStreams_TreeView();				
				//codeStreams.selectFirst();					    				
			}
		}
    	public static Saved_MethodStream Create(O2MappedAstData astData, IMethod iMethod, string methodStreams_CacheLocation, bool forceCreate)
    	{
    		if (methodStreams_CacheLocation.isNull())
    			methodStreams_CacheLocation = "_methodStreams_CacheLocation".tempDir();
    		var safeFileName = 	iMethod.fullName().safeFileName();//240 - methodStreams_CacheLocation.size());
    		var pathToSaveSerializedObject = methodStreams_CacheLocation.pathCombine_MaxSize(safeFileName + ".methodStream.xml");    											
			if (forceCreate.isFalse() && pathToSaveSerializedObject.fileExists())												
			{
				"Skipping iMethod '{0}' since serialized object already exists ".debug(iMethod.Name);
				var loaded_SavedMethodStream = pathToSaveSerializedObject.load<Saved_MethodStream>();
				if (loaded_SavedMethodStream.notNull())
					return loaded_SavedMethodStream;
			}
																			
			var savedMethodStream = new Saved_MethodStream(astData, iMethod);
			if (savedMethodStream.isNull())
				return null;
			else
			{	
				savedMethodStream.Serialized_Saved_MethodStream_FileCache = pathToSaveSerializedObject;
				savedMethodStream.saveAs(pathToSaveSerializedObject);					
				"Serialized method stream object saved to: {0}".debug(pathToSaveSerializedObject);													
				return savedMethodStream;
			}					
    	}
示例#15
0
 public static bool hasCodeStreamsMapped(this Saved_MethodStream savedMethodStream)
 {
     return(savedMethodStream.CodeStreams.isNull().isFalse());
 }
示例#16
0
 public static MethodStream_Item methodStreamItem(this Saved_MethodStream savedMethodStream, O2MappedAstData astData, IMethod iMethod)
 {
     return(savedMethodStream.methodStreamItem(astData, iMethod, MethodStream_ItemType.Method));
 }