예제 #1
0
 private void CompileDsl(bool confirmedPostgres, bool confirmedOracle)
 {
     TryAction(
         "Compiling DSL ...",
         () => ServerActions.Compile(DTE, Targets, PostgresDb, OracleDb, confirmedPostgres, confirmedOracle))
     .ContinueWith(t =>
     {
         if (t.Exception == null && !t.Result.Success && t.Result.Error.Contains("Objects in database will be removed"))
         {
             Message = "Confirm unsafe migration";
             if (PostgresDb.CompileMigration && (CurrentStep & CompilationStep.ConfirmedPostgres) == 0)
             {
                 CurrentStep = CompilationStep.PostgresConfirmation;
                 DiffDatabase(ServerActions.PostgresDiff, PostgresDb, "Postgres");
             }
             else
             {
                 CurrentStep = CompilationStep.OracleConfirmation;
                 DiffDatabase(ServerActions.OracleDiff, OracleDb, "Oracle");
             }
         }
         else
         {
             CurrentStep = CompilationStep.Done;
             DbChanges   = null;
             Message     = t.Result.Error;
             ChangeMessage();
         }
     });
 }
예제 #2
0
 private void StepThroughCompilation()
 {
     CloseDialog();
     if (CurrentStep == CompilationStep.Starting && PostgresDb.CompileMigration && PostgresDb.DiffBefore)
     {
         CurrentStep = CompilationStep.PostgresDiff;
         DiffDatabase(ServerActions.PostgresDiff, PostgresDb, "Postgres");
     }
     else if ((CurrentStep == CompilationStep.Starting || ((CurrentStep & CompilationStep.PostgresDiff) != 0)) && OracleDb.CompileMigration && OracleDb.DiffBefore)
     {
         CurrentStep = CompilationStep.OracleDiff;
         DiffDatabase(ServerActions.OracleDiff, OracleDb, "Oracle");
     }
     else
     {
         if ((CurrentStep & CompilationStep.PostgresDiff) != 0 ||
             (CurrentStep & CompilationStep.PostgresConfirmation) != 0)
         {
             CurrentStep = CurrentStep | CompilationStep.ConfirmedPostgres;
         }
         if ((CurrentStep & CompilationStep.OracleDiff) != 0 ||
             (CurrentStep & CompilationStep.OracleConfirmation) != 0)
         {
             CurrentStep = CurrentStep | CompilationStep.ConfirmedOracle;
         }
         CompileDsl((CurrentStep & CompilationStep.ConfirmedPostgres) != 0, (CurrentStep & CompilationStep.ConfirmedOracle) != 0);
     }
 }
예제 #3
0
 /// <summary>
 /// A line is freezed after the completion of each compiler step to enable reliable snapshots.
 /// If we need to update the properties of the line later, a new line must be allocated.
 /// This method returns true if the line can be updated in place, false if a new copy of the line must be allocated.
 /// </summary>
 public bool CanStillBeUpdatedBy(CompilationStep updatingStep)
 {
     if (CompilationStep >= updatingStep)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
예제 #4
0
        protected DateTime ProcessFile()
        {
            CompilationStep result = null;

            Assert.DoesNotThrow(() => result = pipeline(input), "Compiling should not result in exception");
            Assert.IsNotNull(result, "Compilation result may not be null");
            Assert.IsTrue(result.Errors == null || !result.Errors.Any(), "Compilation should not result in error");
            Assert.AreEqual(Path.GetFullPath(output_files.Last()), Path.GetFullPath(result.OutputFile), "Unexpected output file");
            foreach (var file in output_files)
            {
                Assert.IsTrue(File.Exists(file), $"Output file or intermediate file {file} should exist");
            }
            return(new FileInfo(output_files.Last()).LastWriteTimeUtc);
        }
예제 #5
0
 internal CodeElementsLine(CodeElementsLine previousLineVersion, CompilationStep compilationStep)
     : base(previousLineVersion.textLine, previousLineVersion.ColumnsLayout)
 {
     switch(compilationStep)
     {
         // In the preprocessor, reuse the previoulsy scanned tokens
         case CompilationStep.Preprocessor:
             CopyTokensLineProperties(previousLineVersion);
             break;
         // In the parser, reuse also the previoulsy processed compiler directives
         case CompilationStep.CodeElementsParser:
             CopyTokensLineProperties(previousLineVersion);
             CopyProcessedTokensLineProperties(previousLineVersion);
             break;
         default:
             // Nothing more to do in the previous steps
             break;
     }
 }
예제 #6
0
        internal CodeElementsLine(CodeElementsLine previousLineVersion, CompilationStep compilationStep) : base(previousLineVersion.textLine, previousLineVersion.ColumnsLayout)
        {
            switch (compilationStep)
            {
            // In the preprocessor, reuse the previoulsy scanned tokens
            case CompilationStep.Preprocessor:
                CopyTokensLineProperties(previousLineVersion);
                break;

            // In the parser, reuse also the previoulsy processed compiler directives
            case CompilationStep.CodeElementsParser:
                CopyTokensLineProperties(previousLineVersion);
                CopyProcessedTokensLineProperties(previousLineVersion);
                break;

            default:
                // Nothing more to do in the previous steps
                break;
            }
        }
예제 #7
0
 /// <summary>
 /// A line is freezed after the completion of each compiler step to enable reliable snapshots.
 /// If we need to update the properties of the line later, a new line must be allocated.
 /// This method returns true if the line can be updated in place, false if a new copy of the line must be allocated.
 /// </summary>
 public bool CanStillBeUpdatedBy(CompilationStep updatingStep)
 {
     if (CompilationStep >= updatingStep)
     {
         return false;
     }
     else
     {
         return true;
     }
 }
예제 #8
0
 public PerfStatsForCompilationStep(CompilationStep compilationStep)
 {
     CompilationStep = compilationStep;
 }
예제 #9
0
        /// <summary>
        /// Document line factory for the compiler processing steps : create new version of a line by copy if necessary before an update
        /// </summary>
        protected object PrepareDocumentLineForUpdate(int index, object previousLineVersion, CompilationStep compilationStep)
        {
            CodeElementsLine originalLine = (CodeElementsLine)previousLineVersion;

            // If the compilation step was not yet applied to this line, we don't need a new version of the line
            if (originalLine.CanStillBeUpdatedBy(compilationStep))
            {
                return(originalLine);
            }
            // If the compilation step was previously applied to this line, we need to create a new version of the line
            else
            {
                CodeElementsLine newLinePreparedForUpdate = new CodeElementsLine(originalLine, compilationStep);
                compilationDocumentLines[index] = newLinePreparedForUpdate;
                return(newLinePreparedForUpdate);
            }
        }
예제 #10
0
 public PerfStatsForParsingStep(CompilationStep compilationStep) : base(compilationStep)
 {
 }
예제 #11
0
 private void CompileAction()
 {
     CurrentStep = CompilationStep.Starting;
     StepThroughCompilation();
 }
 public PerfStatsForCompilationStep(CompilationStep compilationStep)
 {
     CompilationStep = compilationStep;
 }
 /// <summary>
 /// Document line factory for the compiler processing steps : create new version of a line by copy if necessary before an update
 /// </summary>
 protected object PrepareDocumentLineForUpdate(int index, object previousLineVersion, CompilationStep compilationStep)
 {
     CodeElementsLine originalLine = (CodeElementsLine)previousLineVersion;
     // If the compilation step was not yet applied to this line, we don't need a new version of the line
     if (originalLine.CanStillBeUpdatedBy(compilationStep))
     {
         return originalLine;
     }
     // If the compilation step was previously applied to this line, we need to create a new version of the line
     else
     {
         CodeElementsLine newLinePreparedForUpdate = new CodeElementsLine(originalLine, compilationStep);
         compilationDocumentLines[index] = newLinePreparedForUpdate;
         return newLinePreparedForUpdate;
     }
 }