private void OnLoadText(TabInfo tabInfo)
        {
            if (tabInfo.Guid != _fileGuid || _textEditor == null)
            {
                return;
            }

            Reset(() =>
            {
                IsReadOnly   = tabInfo.IsReadOnly;
                IsShowEditor = tabInfo.IsShowEditor;

                _fileGuid        = tabInfo.Guid;
                _textEditor.Text = tabInfo.FileContent;
            });

            if (IsSelected)
            {
                CompileCommand.RaiseCanExecuteChanged();
                RedoCommand.RaiseCanExecuteChanged();
                UndoCommand.RaiseCanExecuteChanged();

                _textEditor.Focus();
                CaretPosChanged();

                if (AutoCompile || IsReadOnly)
                {
                    Compile(tabInfo.FileContent);
                }
            }
        }
示例#2
0
        private bool InvokeCompileOnDependency(ProjectDescription projectDependency)
        {
            var args = new List <string>();

            args.Add("--framework");
            args.Add($"{projectDependency.Framework}");

            args.Add("--configuration");
            args.Add(_args.ConfigValue);
            args.Add(projectDependency.Project.ProjectDirectory);

            if (!string.IsNullOrWhiteSpace(_args.RuntimeValue))
            {
                args.Add("--runtime");
                args.Add(_args.RuntimeValue);
            }

            if (!string.IsNullOrEmpty(_args.VersionSuffixValue))
            {
                args.Add("--version-suffix");
                args.Add(_args.VersionSuffixValue);
            }

            if (!string.IsNullOrWhiteSpace(_args.BuildBasePathValue))
            {
                args.Add("--build-base-path");
                args.Add(_args.BuildBasePathValue);
            }

            var compileResult = CompileCommand.Run(args.ToArray());

            return(compileResult == 0);
        }
示例#3
0
            public void SetUp()
            {
                log      = Substitute.For <ILog>();
                loader   = Substitute.For <ILoader>();
                compiler = Substitute.For <ICompiler>();

                compileCommand = new CompileCommand(log, loader, compiler);
            }
        private void OnIsActiveChanged()
        {
            SaveCommand.RaiseCanExecuteChanged();

            CompileCommand.IsActive = IsActive;
            CompileCommand.RaiseCanExecuteChanged();

            RedoCommand.IsActive = IsActive;
            RedoCommand.RaiseCanExecuteChanged();

            UndoCommand.IsActive = IsActive;
            UndoCommand.RaiseCanExecuteChanged();

            IsActiveChanged?.Invoke(this, new EventArgs());
        }
示例#5
0
        public void TestComparingCompileCommandWithSelfByValueWorks()
        {
            CompileCommand command1 = new CompileCommand();

            command1.File      = "test.cpp";
            command1.Directory = "./";
            command1.Command   = "D test test.cpp";

            CompileCommand command2 = new CompileCommand();

            command2.File      = "test.cpp";
            command2.Directory = "./";
            command2.Command   = "D test test.cpp";

            Assert.IsTrue(command1 == command2);
        }
示例#6
0
        public void TestComparingCompilationDatabaseWithSelfByValueWorks()
        {
            CompileCommand command = new CompileCommand();

            command.File      = "test.cpp";
            command.Directory = "./";
            command.Command   = "D test test.cpp";

            CompilationDatabase cdb1 = new CompilationDatabase();

            cdb1.AddCompileCommand(command);

            CompilationDatabase cdb2 = new CompilationDatabase();

            cdb2.AddCompileCommand(command);

            Assert.IsTrue(cdb1 == cdb2);
        }
示例#7
0
        public void TestCompilationDatabaseRetainsEscapedQuotesWhenDeserializedAfterSerialization()
        {
            CompileCommand command = new CompileCommand();

            command.File      = "test.cpp";
            command.Directory = "./";
            command.Command   = "D DEFINE=\"value\" test.cpp";

            CompilationDatabase originalCompilationDatabase = new CompilationDatabase();

            originalCompilationDatabase.AddCompileCommand(command);
            string serialized = originalCompilationDatabase.SerializeToJson();

            CompilationDatabase deserializedCompilationDatabase = new CompilationDatabase();

            deserializedCompilationDatabase.DeserializeFromJson(serialized);

            Assert.IsTrue(deserializedCompilationDatabase == originalCompilationDatabase);
        }
        //[TestMethod]
        public void TestCompile()
        {
            var compileCommand = new CompileCommand();

            var outputWriter = Console.Out;                                      //new StreamWriter(Console.OpenStandardError());
            var errorWriter  = new ColoredWriter(Console.Out, ConsoleColor.Red); //new StreamWriter(Console.OpenStandardError());

            var commandContext = CommandContext.Parse(new[]
            {
                "/home/amk/Temp/ShellScript/variables.shellscript",
                "/home/amk/Temp/ShellScript/variables.sh",
                "unix-bash",
                "--verbose",
                "--echo-dev",
            });

            Platforms.AddPlatform(new UnixBashPlatform());

            compileCommand.Execute(outputWriter, errorWriter, outputWriter, outputWriter, commandContext);
        }
示例#9
0
        public void PushCommand(CompileCommand command)
        {
            string serializedCommand = "";

            if (!_isFirstCommand)
            {
                serializedCommand += ",\n";
            }
            else
            {
                _isFirstCommand = false;
            }

            foreach (string line in command.SerializeToJson().Split('\n'))
            {
                serializedCommand += "  " + line + "\n";
            }

            serializedCommand = serializedCommand.TrimEnd('\n');

            _fileWriter.PushMessage(serializedCommand);
        }
示例#10
0
        private bool InvokeCompileOnRootProject()
        {
            // todo: add methods to CompilerCommandApp to generate the arg string?
            var args = new List <string>();

            args.Add("--framework");
            args.Add(_rootProject.TargetFramework.ToString());
            args.Add("--configuration");
            args.Add(_args.ConfigValue);

            if (!string.IsNullOrWhiteSpace(_args.RuntimeValue))
            {
                args.Add("--runtime");
                args.Add(_args.RuntimeValue);
            }

            if (!string.IsNullOrEmpty(_args.OutputValue))
            {
                args.Add("--output");
                args.Add(_args.OutputValue);
            }

            if (!string.IsNullOrEmpty(_args.VersionSuffixValue))
            {
                args.Add("--version-suffix");
                args.Add(_args.VersionSuffixValue);
            }

            if (!string.IsNullOrEmpty(_args.BuildBasePathValue))
            {
                args.Add("--build-base-path");
                args.Add(_args.BuildBasePathValue);
            }

            //native args
            if (_args.IsNativeValue)
            {
                args.Add("--native");
            }

            if (_args.IsCppModeValue)
            {
                args.Add("--cpp");
            }

            if (!string.IsNullOrWhiteSpace(_args.CppCompilerFlagsValue))
            {
                args.Add("--cppcompilerflags");
                args.Add(_args.CppCompilerFlagsValue);
            }

            if (!string.IsNullOrWhiteSpace(_args.ArchValue))
            {
                args.Add("--arch");
                args.Add(_args.ArchValue);
            }

            foreach (var ilcArg in _args.IlcArgsValue)
            {
                args.Add("--ilcarg");
                args.Add(ilcArg);
            }

            if (!string.IsNullOrWhiteSpace(_args.IlcPathValue))
            {
                args.Add("--ilcpath");
                args.Add(_args.IlcPathValue);
            }

            if (!string.IsNullOrWhiteSpace(_args.IlcSdkPathValue))
            {
                args.Add("--ilcsdkpath");
                args.Add(_args.IlcSdkPathValue);
            }

            args.Add(_rootProject.ProjectDirectory);

            var compileResult = CompileCommand.Run(args.ToArray());

            var succeeded = compileResult == 0;

            if (succeeded)
            {
                MakeRunnable();
            }

            return(succeeded);
        }