Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/04/14 17:14:01 (10 years ago)
Author:
jkarder
Message:

#2262: applied some of the changes suggested by swagner in comment:17:ticket:2262

  • added highlighting of current line
  • added error markers and bookmarks
  • fixed <Ctrl> + <Backspace> bug
  • minor code changes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Scripting/3.3/Script.cs

    r11477 r11657  
    2424using System.CodeDom.Compiler;
    2525using System.Collections.Generic;
    26 using System.Diagnostics;
    2726using System.Drawing;
    2827using System.IO;
     
    8079    public Script()
    8180      : base("Script", "An empty script.") {
    82       code = string.Empty;
     81      code = CodeTemplate;
    8382    }
    8483    public Script(string code)
     
    109108        WarningLevel = 4
    110109      };
     110
    111111      parameters.ReferencedAssemblies.AddRange(
    112112        GetAssemblies()
    113113        .Select(a => a.Location)
    114114        .ToArray());
    115       var unit = CreateCompilationUnit();
    116       var writer = new StringWriter();
    117       CodeProvider.GenerateCodeFromCompileUnit(
    118         unit,
    119         writer,
    120         new CodeGeneratorOptions {
    121           ElseOnClosing = true,
    122           IndentString = "  ",
    123         });
    124       return CodeProvider.CompileAssemblyFromDom(parameters, unit);
     115
     116      return CodeProvider.CompileAssemblyFromSource(parameters, code);
    125117    }
    126118
     
    135127            .AppendLine(error.ErrorText);
    136128        }
    137         throw new Exception(string.Format("Compilation of \"{0}\" failed:{1}{2}",
     129        throw new InvalidOperationException(string.Format("Compilation of \"{0}\" failed:{1}{2}",
    138130          Name, Environment.NewLine, sb.ToString()));
    139131      } else {
     
    143135
    144136    public virtual IEnumerable<Assembly> GetAssemblies() {
    145       var assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => !a.IsDynamic && File.Exists(a.Location)).ToList();   
     137      var assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => !a.IsDynamic && File.Exists(a.Location)).ToList();
    146138      assemblies.Add(typeof(Microsoft.CSharp.RuntimeBinder.Binder).Assembly); // for dlr functionality
    147139      return assemblies;
Note: See TracChangeset for help on using the changeset viewer.