Free cookie consent management tool by TermsFeed Policy Generator

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

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

Location:
stable
Files:
2 deleted
12 edited
2 copied

Legend:

Unmodified
Added
Removed
  • stable

  • 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.