Ignore:
Timestamp:
02/06/15 12:44:09 (5 years ago)
Author:
jkarder
Message:

#2077: merged r11807:11811, r11816, r11819, r11822, r11825, r11834, r11835, r11836, r11933 and r11936 into stable

Location:
stable
Files:
3 deleted
15 edited
2 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.CodeEditor/3.4/AssemblyLoader.cs

    r11700 r11937  
    7878    private IUnresolvedAssembly Load(Assembly assembly) {
    7979      var loader = new CecilLoader {
    80         IncludeInternalMembers = true,
    8180        DocumentationProvider = GetXmlDocumentation(assembly.Location)
    8281      };
  • stable/HeuristicLab.CodeEditor/3.4/CodeEditor.cs

    r11804 r11937  
    6161
    6262    private AssemblyLoader assemblyLoader;
    63     private ILanguageFeatures languageFeatures;
    6463    private TextMarkerService textMarkerService;
    6564
     
    7978        if (value == null) value = string.Empty;
    8079        if (prefix == value) return;
    81         if (prefixMarker != null) textMarkerService.Remove(prefixMarker);
     80        if (prefixMarker != null) prefixMarker.Delete();
    8281        Doc.Remove(0, prefix.Length);
    8382        prefix = value;
     
    9796        if (value == null) value = string.Empty;
    9897        if (suffix == value) return;
    99         if (suffixMarker != null) textMarkerService.Remove(suffixMarker);
     98        if (suffixMarker != null) suffixMarker.Delete();
    10099        Doc.Remove(Doc.TextLength - suffix.Length, suffix.Length);
    101100        suffix = value;
     
    191190      TextEditor.TextArea.TextView.LineTransformers.Add(textMarkerService);
    192191      TextEditor.TextArea.TextView.Services.AddService(typeof(ITextMarkerService), textMarkerService);
    193 
    194192      #endregion
    195193
     
    244242
    245243      TextEditor.TextChanged += (sender, args) => {
    246         textMarkerService.RemoveAll(x => x != prefixMarker && x != suffixMarker);
     244        foreach (var marker in textMarkerService.TextMarkers) {
     245          if (marker == prefixMarker || marker == suffixMarker) continue;
     246          if (marker.Length != (int)marker.Tag)
     247            marker.Delete();
     248          else {
     249            int caretOffset = TextEditor.CaretOffset;
     250            var line = Doc.GetLineByOffset(marker.StartOffset);
     251            int lineEndOffset = line.EndOffset;
     252            if (caretOffset == lineEndOffset) // special case for markers beyond line length
     253              marker.Delete();
     254          }
     255        }
    247256        OnTextEditorTextChanged();
    248257      };
     
    383392          int offset = line.Offset;
    384393          if (TextUtilities.GetLeadingWhitespace(Doc, line).Length > 0)
    385             offset = TextUtilities.GetNextCaretPosition(Doc, offset, LogicalDirection.Forward, CaretPositioningMode.WordStart);
     394            offset = TextUtilities.GetNextCaretPosition(Doc, offset, LogicalDirection.Forward, CaretPositioningMode.WordBorder);
    386395          TextEditor.CaretOffset = offset;
    387396        }
     
    408417      marker.MarkerTypes = TextMarkerTypes.SquigglyUnderline;
    409418      marker.MarkerColor = error.IsWarning ? WarningColor : ErrorColor;
     419      marker.Tag = segment.Length;
    410420    }
    411421
     
    429439      switch (TextEditorSyntaxHighlighting) {
    430440        case "XML":
    431           languageFeatures = new XmlLanguageFeatures(this);
     441          XmlLanguageFeatures.Apply(this);
    432442          break;
    433443        default:
    434           languageFeatures = new CSharpLanguageFeatures(this);
     444          CSharpLanguageFeatures.Apply(this);
    435445          break;
    436446      }
  • stable/HeuristicLab.CodeEditor/3.4/HeuristicLab.CodeEditor-3.4.csproj

    r11804 r11937  
    156156    <Compile Include="LanguageFeatures\CodeCompletion\CSharp\CSharpCodeCompletionContext.cs" />
    157157    <Compile Include="LanguageFeatures\CodeCompletion\CSharp\CSharpCodeCompletionDataFactory.cs" />
    158     <Compile Include="LanguageFeatures\CodeCompletion\CSharp\CSharpCodeCompletionHelpers.cs" />
     158    <Compile Include="LanguageFeatures\Helpers\CSharpParsingHelpers.cs" />
    159159    <Compile Include="LanguageFeatures\CodeCompletion\CSharp\CompletionData\EntityCompletionData.cs" />
    160     <Compile Include="LanguageFeatures\CodeCompletion\CSharp\CompletionData\ImportCompletionData.cs" />
    161160    <Compile Include="LanguageFeatures\CodeCompletion\CSharp\CompletionData\VariableCompletionData.cs" />
    162161    <Compile Include="LanguageFeatures\Interfaces\ICodeFoldingStrategy.cs" />
  • stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CSharpLanguageFeatures.cs

    r11700 r11937  
    2525      : base(codeEditor, new CSharpCodeFoldingStrategy(codeEditor), new CSharpCodeCompletionStrategy(codeEditor)) {
    2626    }
     27
     28    public static ILanguageFeatures Apply(CodeEditor codeEditor) {
     29      return new CSharpLanguageFeatures(codeEditor);
     30    }
    2731  }
    2832}
  • stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CodeCompletion/CSharp/CSharpCodeCompletionContext.cs

    r11800 r11937  
    4646      this.offset = offset;
    4747
    48       var unresolvedFile = CSharpCodeCompletionHelpers.CreateCSharpUnresolvedFile(this.document);
     48      var unresolvedFile = CSharpParsingHelpers.CreateCSharpUnresolvedFile(this.document);
    4949      this.projectContent = projectContent.AddOrUpdateFiles(unresolvedFile);
    5050
  • stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CodeCompletion/CSharp/CSharpCodeCompletionDataFactory.cs

    r11722 r11937  
    2525using ICSharpCode.AvalonEdit.CodeCompletion;
    2626using ICSharpCode.NRefactory.Completion;
     27using ICSharpCode.NRefactory.CSharp;
    2728using ICSharpCode.NRefactory.CSharp.Completion;
     29using ICSharpCode.NRefactory.CSharp.Resolver;
    2830using ICSharpCode.NRefactory.TypeSystem;
    2931using ICompletionData = ICSharpCode.NRefactory.Completion.ICompletionData;
     
    103105
    104106    public ICompletionData CreateImportCompletionData(IType type, bool useFullName, bool addForTypeCreation) {
    105       var typeDef = type.GetDefinition();
    106       return new ImportCompletionData(typeDef, context.TypeResolveContextAtCaret, useFullName);
     107      return null;
    107108    }
    108109
     
    121122
    122123    #region IParameterCompletionDataFactory Members
    123     public IParameterDataProvider CreateConstructorProvider(int startOffset, IType type, ICSharpCode.NRefactory.CSharp.AstNode thisInitializer) {
    124       return CreateMethodDataProvider(startOffset, type.GetConstructors());
     124    public IParameterDataProvider CreateConstructorProvider(int startOffset, IType type, AstNode thisInitializer) {
     125      return CreateConstructorProvider(startOffset, type);
    125126    }
    126127
    127128    public IParameterDataProvider CreateConstructorProvider(int startOffset, IType type) {
    128       return CreateMethodDataProvider(startOffset, type.GetConstructors());
     129      var constructors = FilterMethodsForAccessibility(type, type.GetConstructors());
     130      return CreateMethodDataProvider(startOffset, constructors);
    129131    }
    130132
    131133    public IParameterDataProvider CreateDelegateDataProvider(int startOffset, IType type) {
    132       return CreateMethodDataProvider(startOffset, new[] { type.GetDelegateInvokeMethod() });
     134      var delegates = FilterMethodsForAccessibility(type, new[] { type.GetDelegateInvokeMethod() });
     135      return CreateMethodDataProvider(startOffset, delegates);
    133136    }
    134137
     
    138141
    139142    public IParameterDataProvider CreateMethodDataProvider(int startOffset, IEnumerable<IMethod> methods) {
    140       return new CSharpOverloadProvider(context, startOffset, from m in methods where m != null select new CSharpInsightItem(m));
     143      return new CSharpOverloadProvider(context, startOffset, methods.Where(x => x != null).Select(x => new CSharpInsightItem(x)));
    141144    }
    142145
     
    149152    }
    150153    #endregion
     154
     155    private IEnumerable<IMethod> FilterMethodsForAccessibility(IType type, IEnumerable<IMethod> methods) {
     156      var typeResolveContext = context.TypeResolveContextAtCaret;
     157      var lookup = new MemberLookup(typeResolveContext.CurrentTypeDefinition, typeResolveContext.Compilation.MainAssembly);
     158      bool protectedAccessAllowed = lookup.IsProtectedAccessAllowed(type);
     159      return protectedAccessAllowed ? methods : methods.Where(x => !x.IsProtected);
     160    }
    151161  }
    152162}
  • stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CodeCompletion/CSharp/CSharpCodeCompletionStrategy.cs

    r11802 r11937  
    5656        completionContext.ProjectContent,
    5757        completionContext.TypeResolveContextAtCaret
    58       ) { EolMarker = Environment.NewLine };
     58        );
    5959
    6060      char completionChar = completionContext.Document.GetCharAt(completionContext.Offset - 1);
     
    119119      );
    120120
    121       var unresolvedFile = CSharpCodeCompletionHelpers.CreateCSharpUnresolvedFile(document);
     121      var unresolvedFile = CSharpParsingHelpers.CreateCSharpUnresolvedFile(document);
    122122      projectContent = projectContent.AddOrUpdateFiles(unresolvedFile);
    123123    }
  • stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CodeCompletion/CSharp/CSharpOverloadProvider.cs

    r11700 r11937  
    115115
    116116      int parameterIndex = pce.GetCurrentParameterIndex(startOffset, completionContext.Offset);
    117       if (parameterIndex < 0) {
     117      if (parameterIndex < 0 || !items.Any()) {
    118118        RequestClose = true;
    119119        return;
     
    161161    #endregion
    162162
    163 
    164163    public event PropertyChangedEventHandler PropertyChanged;
    165 
    166164    private void OnPropertyChanged(string propertyName) {
    167165      var args = new PropertyChangedEventArgs(propertyName);
  • stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CodeCompletion/CodeCompletionStrategy.cs

    r11800 r11937  
    4040    }
    4141
    42     public virtual void RunBackgroundParser() {
    43       backgroundParser.Start();
     42    public virtual void Initialize() {
     43      if (backgroundParser.Status == TaskStatus.Created)
     44        backgroundParser.Start();
    4445    }
    4546
  • stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CodeFolding/CSharp/CSharpCodeFoldingContext.cs

    r11700 r11937  
    2525namespace HeuristicLab.CodeEditor {
    2626  internal class CSharpCodeFoldingContext {
    27     public readonly IDocument Document;
    28     public readonly SyntaxTree SyntaxTree;
     27    private readonly IDocument document;
     28    public IDocument Document { get { return document; } }
     29
     30    private readonly SyntaxTree syntaxTree;
     31    public SyntaxTree SyntaxTree { get { return syntaxTree; } }
    2932
    3033    public CSharpCodeFoldingContext(IDocument document) {
    31       Document = new ReadOnlyDocument(document, document.FileName);
    32 
    33       var parser = new CSharpParser();
    34       var syntaxTree = parser.Parse(document, document.FileName);
    35       syntaxTree.Freeze();
    36 
    37       SyntaxTree = syntaxTree;
     34      this.document = new ReadOnlyDocument(document, document.FileName);
     35      syntaxTree = CSharpParsingHelpers.CreateSyntaxTree(this.document);
    3836    }
    3937  }
  • stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CodeFolding/CSharp/CSharpCodeFoldingStrategy.cs

    r11722 r11937  
    2222using System.Linq;
    2323using CSharpBinding.Parser;
    24 using ICSharpCode.NRefactory.CSharp;
    25 using ICSharpCode.NRefactory.TypeSystem;
    2624
    2725namespace HeuristicLab.CodeEditor {
    2826  internal class CSharpCodeFoldingStrategy : CodeFoldingStrategy {
    29     private IProjectContent projectContent = new CSharpProjectContent();
    30 
    31     public CSharpCodeFoldingStrategy(CodeEditor codeEditor)
    32       : base(codeEditor) {
    33       codeEditor.InternalAssembliesLoaded += (sender, args) => {
    34         projectContent = projectContent.AddAssemblyReferences(args.Value);
    35       };
    36       codeEditor.InternalAssembliesUnloaded += (sender, args) => {
    37         projectContent = projectContent.RemoveAssemblyReferences(args.Value);
    38       };
    39     }
     27    public CSharpCodeFoldingStrategy(CodeEditor codeEditor) : base(codeEditor) { }
    4028
    4129    protected override CodeFoldingResult GetCodeFoldingResult(out int firstErrorOffset) {
  • stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures/Interfaces/ICodeCompletionStrategy.cs

    r11800 r11937  
    2323  internal interface ICodeCompletionStrategy {
    2424    void DoCodeCompletion(bool controlSpace);
    25     void RunBackgroundParser();
     25    void Initialize();
    2626  }
    2727}
  • stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures/LanguageFeatures.cs

    r11800 r11937  
    6363
    6464    private void LoadedHandler(object sender, EventArgs e) {
    65       codeCompletionStrategy.RunBackgroundParser();
     65      codeCompletionStrategy.Initialize();
    6666    }
    6767
  • stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures/XmlLanguageFeatures.cs

    r11700 r11937  
    2525      : base(codeEditor, new XmlCodeFoldingStrategy(codeEditor), null) {
    2626    }
     27
     28    public static ILanguageFeatures Apply(CodeEditor codeEditor) {
     29      return new XmlLanguageFeatures(codeEditor);
     30    }
    2731  }
    2832}
Note: See TracChangeset for help on using the changeset viewer.