Changeset 11825


Ignore:
Timestamp:
01/26/15 16:33:53 (5 years ago)
Author:
jkarder
Message:

#2077:

  • do not offer completion for inaccessible protected members
  • fixed go to line logic
  • fixed comment in CSharpScriptTemplate
Location:
trunk/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.CodeEditor/3.4/CodeEditor.cs

    r11804 r11825  
    383383          int offset = line.Offset;
    384384          if (TextUtilities.GetLeadingWhitespace(Doc, line).Length > 0)
    385             offset = TextUtilities.GetNextCaretPosition(Doc, offset, LogicalDirection.Forward, CaretPositioningMode.WordStart);
     385            offset = TextUtilities.GetNextCaretPosition(Doc, offset, LogicalDirection.Forward, CaretPositioningMode.WordBorder);
    386386          TextEditor.CaretOffset = offset;
    387387        }
  • trunk/sources/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CodeCompletion/CSharp/CSharpCodeCompletionDataFactory.cs

    r11722 r11825  
    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;
     
    121123
    122124    #region IParameterCompletionDataFactory Members
    123     public IParameterDataProvider CreateConstructorProvider(int startOffset, IType type, ICSharpCode.NRefactory.CSharp.AstNode thisInitializer) {
    124       return CreateMethodDataProvider(startOffset, type.GetConstructors());
     125    public IParameterDataProvider CreateConstructorProvider(int startOffset, IType type, AstNode thisInitializer) {
     126      return CreateConstructorProvider(startOffset, type);
    125127    }
    126128
    127129    public IParameterDataProvider CreateConstructorProvider(int startOffset, IType type) {
    128       return CreateMethodDataProvider(startOffset, type.GetConstructors());
     130      var constructors = FilterMethodsForAccessibility(type, type.GetConstructors());
     131      return CreateMethodDataProvider(startOffset, constructors);
    129132    }
    130133
    131134    public IParameterDataProvider CreateDelegateDataProvider(int startOffset, IType type) {
    132       return CreateMethodDataProvider(startOffset, new[] { type.GetDelegateInvokeMethod() });
     135      var delegates = FilterMethodsForAccessibility(type, new[] { type.GetDelegateInvokeMethod() });
     136      return CreateMethodDataProvider(startOffset, delegates);
    133137    }
    134138
     
    138142
    139143    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));
     144      return new CSharpOverloadProvider(context, startOffset, methods.Where(x => x != null).Select(x => new CSharpInsightItem(x)));
    141145    }
    142146
     
    149153    }
    150154    #endregion
     155
     156    private IEnumerable<IMethod> FilterMethodsForAccessibility(IType type, IEnumerable<IMethod> methods) {
     157      var typeResolveContext = context.TypeResolveContextAtCaret;
     158      var lookup = new MemberLookup(typeResolveContext.CurrentTypeDefinition, typeResolveContext.Compilation.MainAssembly);
     159      bool protectedAccessAllowed = lookup.IsProtectedAccessAllowed(type);
     160      return protectedAccessAllowed ? methods : methods.Where(x => !x.IsProtected);
     161    }
    151162  }
    152163}
  • trunk/sources/HeuristicLab.Scripting/3.3/Scripts/Templates/CSharpScriptTemplate.cs

    r11787 r11825  
    11// use 'vars' to access variables in the script's variable store (e.g. vars.x = 5)
    2 // use 'vars[string]' to access variables via runtime strings (e.g. vars[""x""] = 5)
     2// use 'vars[string]' to access variables via runtime strings (e.g. vars["x"] = 5)
    33// use 'vars.Contains(string)' to check if a variable exists
    44// use 'vars.Clear()' to remove all variables
Note: See TracChangeset for help on using the changeset viewer.