void CreateTypeScriptContextIfProjectHasTypeScriptFiles(IProject project)
		{
			var typeScriptProject = new TypeScriptProject(project);
			if (typeScriptProject.HasTypeScriptFiles()) {
				contextProvider.CreateProjectContext(typeScriptProject);
			}
		}
 void AddTypeScriptFileToContext(IProject project, FileName fileName)
 {
     if (TypeScriptParser.IsTypeScriptFileName(fileName)) {
         var typeScriptProject = new TypeScriptProject(project);
         TypeScriptService.ContextProvider.AddFileToProjectContext(typeScriptProject, fileName);
     }
 }
        public bool IsValid(object caller, Condition condition)
        {
            if (ProjectService.CurrentProject == null)
                return false;

            var project = new TypeScriptProject(ProjectService.CurrentProject);
            return project.HasTypeScriptFiles();
        }
		void CompileFiles(TypeScriptProject project)
		{
			FileName[] fileNames = project.GetTypeScriptFileNames().ToArray();
			if (fileNames.Length == 0)
				return;
			
			CompileFiles(project, fileNames);
		}
		public bool IsValid(object caller, Condition condition)
		{
			var currentProject = ProjectService.CurrentProject as MSBuildBasedProject;
			if (currentProject == null)
				return false;
			
			var project = new TypeScriptProject(currentProject);
			return project.HasTypeScriptFiles();
		}
        void CompileFiles(TypeScriptProject project, FileName[] fileNames)
        {
            ReportCompileStarting(project);

            var compiler = new TypeScriptCompiler();
            compiler.AddFiles(fileNames);

            Report(compiler.GetCommandLine());

            TypeScriptCompilerResult result = compiler.Compile();
            UpdateProject(project, result.GeneratedFiles);

            ReportCompileFinished(result.HasErrors);
        }
		public void Compile(FileName fileName, TypeScriptProject project, TypeScriptContext context)
		{
			ReportCompileStarting(fileName);
			
			project.CreateOutputDirectory();
			
			var compiler = new LanguageServiceCompiler(context);
			UpdateFile(context, fileName);
			LanguageServiceCompilerResult result = compiler.Compile(fileName, project);
			
			if (result.HasErrors) {
				Report(result.GetError());
			}
			ReportCompileFinished(result.HasErrors);
		}
        protected override bool Save(MSBuildBasedProject project, string configuration, string platform)
        {
            var buildConfig = new BuildConfiguration(configuration, platform);

            var typeScriptProject = new TypeScriptProject(project);

            typeScriptProject.SetCompileOnSave(buildConfig, CompileOnSave);
            typeScriptProject.SetCompileOnBuild(buildConfig, CompileOnBuild);
            typeScriptProject.SetRemoveComments(buildConfig, !IncludeComments);
            typeScriptProject.SetGenerateSourceMap(buildConfig, GenerateSourceMap);
            typeScriptProject.SetNoImplicitAny(buildConfig, !AllowImplicitAnyTypes);
            typeScriptProject.SetEcmaScriptVersion(buildConfig, SelectedEcmaScriptTargetVersion.Id);
            typeScriptProject.SetModuleKind(buildConfig, SelectedModuleKind.Id);

            typeScriptProject.SetOutputFileName(buildConfig, GetOutputFileName());
            typeScriptProject.SetOutputDirectory(buildConfig, GetOutputDirectory());

            return(base.Save(project, configuration, platform));
        }
		void CompileFiles(TypeScriptProject project, FileName[] fileNames)
		{
			ReportCompileStarting(project);
			
			bool errors = false;
			TypeScriptContext context = TypeScriptService.ContextProvider.GetContext(fileNames.First());
			var compiler = new LanguageServiceCompiler(context);
			
			project.CreateOutputDirectory();
			
			foreach (FileName fileName in fileNames) {
				UpdateFile(context, fileName);
				LanguageServiceCompilerResult result = compiler.Compile(fileName, project);
				
				if (result.HasErrors) {
					errors = true;
					Report(result.GetError());
				}
			}
			ReportCompileFinished(errors);
		}
        void FileSaved(object sender, FileNameEventArgs e)
        {
            if (!TypeScriptFileExtensions.IsTypeScriptFileName(e.FileName))
            {
                return;
            }

            TypeScriptProject project = TypeScriptService.GetProjectForFile(e.FileName);

            if (project == null)
            {
                return;
            }

            if (project.CompileOnSave)
            {
                var action = new CompileTypeScriptOnSaveFileAction();
                TypeScriptContext context = TypeScriptService.ContextProvider.GetContext(e.FileName);
                action.Compile(e.FileName, project, context);
            }
        }
        void CompileFiles(TypeScriptProject project, FileName[] fileNames)
        {
            ReportCompileStarting(project);

            bool errors = false;
            TypeScriptContext context = TypeScriptService.ContextProvider.GetContext(fileNames.First());
            var compiler = new LanguageServiceCompiler(context);

            project.CreateOutputDirectory();

            foreach (FileName fileName in fileNames)
            {
                UpdateFile(context, fileName);
                LanguageServiceCompilerResult result = compiler.Compile(fileName, project);

                if (result.HasErrors)
                {
                    errors = true;
                    Report(result.GetError());
                }
            }
            ReportCompileFinished(errors);
        }
        ParseInformation ParseTypeScriptFile(string fileName, ITextBuffer fileContent, TypeScriptProject project)
        {
            var parser                  = new TypeScriptParser(new LanguageServiceNullLogger());
            var projectContent          = new TypeScriptProjectContent(project);
            List <TypeScriptFile> files = project.GetTypeScriptFiles().ToList();
            ICompilationUnit      unit  = parser.Parse(projectContent, fileName, fileContent, files);

            return(new ParseInformation(unit));
        }
		ParseInformation ParseTypeScriptFile(FileName fileName, ITextSource fileContent, TypeScriptProject project)
		{
			var parser = new TypeScriptParser(new LanguageServiceNullLogger());
			List<TypeScriptFile> files = project.GetTypeScriptFiles().ToList();
			return parser.Parse(fileName, fileContent, project, files);
		}
		void ReportCompileStarting(TypeScriptProject project)
		{
			Report("Compiling TypeScript files for project: {0}", project.Name);
		}
 void UpdateProject(TypeScriptProject project, IEnumerable<GeneratedTypeScriptFile> generatedFiles)
 {
     using (var updater = new ProjectBrowserUpdater()) {
         project.AddMissingFiles(generatedFiles);
     }
 }
 public TypeScriptProjectContent(TypeScriptProject project)
 {
     Options = project.GetOptions();
 }
Ejemplo n.º 17
0
		public ParseInformation Parse(
			FileName fileName,
			ITextSource fileContent,
			TypeScriptProject project,
			IEnumerable<TypeScriptFile> files)
		{
			try {
				using (TypeScriptContext context = contextFactory.CreateContext()) {
					context.AddFile(fileName, fileContent.Text);
					context.RunInitialisationScript();
					
					NavigationBarItem[] navigation = context.GetNavigationInfo(fileName);
					var unresolvedFile = new TypeScriptUnresolvedFile(fileName);
					unresolvedFile.AddNavigation(navigation, fileContent);
					
					if (project != null) {
						context.AddFiles(files);
						var document = new TextDocument(fileContent);
						Diagnostic[] diagnostics = context.GetDiagnostics(fileName, project.GetOptions());
						TypeScriptService.TaskService.Update(diagnostics, fileName);
					}
					
					return new ParseInformation(unresolvedFile, fileContent.Version, true);
				}
			} catch (Exception ex) {
				Console.WriteLine(ex.ToString());
				LoggingService.Debug(ex.ToString());
			}
			
			return new ParseInformation(
				new TypeScriptUnresolvedFile(fileName),
				fileContent.Version,
				true);
		}
 void ReportCompileStarting(TypeScriptProject project)
 {
     Report("Compiling TypeScript files for project: {0}", project.Name);
 }
Ejemplo n.º 19
0
        ParseInformation ParseTypeScriptFile(FileName fileName, ITextSource fileContent, TypeScriptProject project)
        {
            var parser = new TypeScriptParser(new LanguageServiceNullLogger());
            List <TypeScriptFile> files = project.GetTypeScriptFiles().ToList();

            return(parser.Parse(fileName, fileContent, project, files));
        }
Ejemplo n.º 20
0
 public TypeScriptProjectContent(TypeScriptProject project)
 {
     Options = project.GetOptions();
 }
 ParseInformation ParseTypeScriptFile(string fileName, ITextBuffer fileContent, TypeScriptProject project)
 {
     var parser = new TypeScriptParser(new LanguageServiceNullLogger());
     var projectContent = new TypeScriptProjectContent(project);
     List<TypeScriptFile> files = project.GetTypeScriptFiles().ToList();
     ICompilationUnit unit = parser.Parse(projectContent, fileName, fileContent, files);
     return new ParseInformation(unit);
 }