예제 #1
0
        /// <summary>
        /// Parses the python code and returns an ICompilationUnit.
        /// </summary>
        public ICompilationUnit Parse(IProjectContent projectContent, string fileName, string fileContent)
        {
            if (fileContent != null)
            {
                try {
                    PythonAst       ast    = CreateAst(fileName, fileContent);
                    PythonAstWalker walker = new PythonAstWalker(projectContent, fileName);
                    walker.Walk(ast);
                    return(walker.CompilationUnit);
                } catch (InvalidCastException) {
                    // Ignore.
                }
            }

            DefaultCompilationUnit compilationUnit = new DefaultCompilationUnit(projectContent);

            compilationUnit.FileName = fileName;
            return(compilationUnit);
        }
예제 #2
0
		/// <summary>
		/// Parses the python code and returns an ICompilationUnit.
		/// </summary>
		public ICompilationUnit Parse(IProjectContent projectContent, string fileName, string fileContent)
		{
			if (fileContent != null) {
				try { 
					PythonAst ast = CreateAst(fileName, fileContent);
					PythonAstWalker walker = new PythonAstWalker(projectContent, fileName);
					walker.Walk(ast);
					return walker.CompilationUnit;
				} catch (InvalidCastException) {
					// Ignore.
				}
			}
			
			DefaultCompilationUnit compilationUnit = new DefaultCompilationUnit(projectContent);
			compilationUnit.FileName = fileName;
			return compilationUnit;
		}