Changeset 11937 for stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures
- Timestamp:
- 02/06/15 12:44:09 (10 years ago)
- Location:
- stable
- Files:
-
- 2 deleted
- 12 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
-
stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CSharpLanguageFeatures.cs
r11700 r11937 25 25 : base(codeEditor, new CSharpCodeFoldingStrategy(codeEditor), new CSharpCodeCompletionStrategy(codeEditor)) { 26 26 } 27 28 public static ILanguageFeatures Apply(CodeEditor codeEditor) { 29 return new CSharpLanguageFeatures(codeEditor); 30 } 27 31 } 28 32 } -
stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CodeCompletion/CSharp/CSharpCodeCompletionContext.cs
r11800 r11937 46 46 this.offset = offset; 47 47 48 var unresolvedFile = CSharp CodeCompletionHelpers.CreateCSharpUnresolvedFile(this.document);48 var unresolvedFile = CSharpParsingHelpers.CreateCSharpUnresolvedFile(this.document); 49 49 this.projectContent = projectContent.AddOrUpdateFiles(unresolvedFile); 50 50 -
stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CodeCompletion/CSharp/CSharpCodeCompletionDataFactory.cs
r11722 r11937 25 25 using ICSharpCode.AvalonEdit.CodeCompletion; 26 26 using ICSharpCode.NRefactory.Completion; 27 using ICSharpCode.NRefactory.CSharp; 27 28 using ICSharpCode.NRefactory.CSharp.Completion; 29 using ICSharpCode.NRefactory.CSharp.Resolver; 28 30 using ICSharpCode.NRefactory.TypeSystem; 29 31 using ICompletionData = ICSharpCode.NRefactory.Completion.ICompletionData; … … 103 105 104 106 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; 107 108 } 108 109 … … 121 122 122 123 #region IParameterCompletionDataFactory Members 123 public IParameterDataProvider CreateConstructorProvider(int startOffset, IType type, ICSharpCode.NRefactory.CSharp.AstNode thisInitializer) {124 return Create MethodDataProvider(startOffset, type.GetConstructors());124 public IParameterDataProvider CreateConstructorProvider(int startOffset, IType type, AstNode thisInitializer) { 125 return CreateConstructorProvider(startOffset, type); 125 126 } 126 127 127 128 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); 129 131 } 130 132 131 133 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); 133 136 } 134 137 … … 138 141 139 142 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))); 141 144 } 142 145 … … 149 152 } 150 153 #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 } 151 161 } 152 162 } -
stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CodeCompletion/CSharp/CSharpCodeCompletionStrategy.cs
r11802 r11937 56 56 completionContext.ProjectContent, 57 57 completionContext.TypeResolveContextAtCaret 58 ) { EolMarker = Environment.NewLine };58 ); 59 59 60 60 char completionChar = completionContext.Document.GetCharAt(completionContext.Offset - 1); … … 119 119 ); 120 120 121 var unresolvedFile = CSharp CodeCompletionHelpers.CreateCSharpUnresolvedFile(document);121 var unresolvedFile = CSharpParsingHelpers.CreateCSharpUnresolvedFile(document); 122 122 projectContent = projectContent.AddOrUpdateFiles(unresolvedFile); 123 123 } -
stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CodeCompletion/CSharp/CSharpOverloadProvider.cs
r11700 r11937 115 115 116 116 int parameterIndex = pce.GetCurrentParameterIndex(startOffset, completionContext.Offset); 117 if (parameterIndex < 0 ) {117 if (parameterIndex < 0 || !items.Any()) { 118 118 RequestClose = true; 119 119 return; … … 161 161 #endregion 162 162 163 164 163 public event PropertyChangedEventHandler PropertyChanged; 165 166 164 private void OnPropertyChanged(string propertyName) { 167 165 var args = new PropertyChangedEventArgs(propertyName); -
stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CodeCompletion/CodeCompletionStrategy.cs
r11800 r11937 40 40 } 41 41 42 public virtual void RunBackgroundParser() { 43 backgroundParser.Start(); 42 public virtual void Initialize() { 43 if (backgroundParser.Status == TaskStatus.Created) 44 backgroundParser.Start(); 44 45 } 45 46 -
stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CodeFolding/CSharp/CSharpCodeFoldingContext.cs
r11700 r11937 25 25 namespace HeuristicLab.CodeEditor { 26 26 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; } } 29 32 30 33 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); 38 36 } 39 37 } -
stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CodeFolding/CSharp/CSharpCodeFoldingStrategy.cs
r11722 r11937 22 22 using System.Linq; 23 23 using CSharpBinding.Parser; 24 using ICSharpCode.NRefactory.CSharp;25 using ICSharpCode.NRefactory.TypeSystem;26 24 27 25 namespace HeuristicLab.CodeEditor { 28 26 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) { } 40 28 41 29 protected override CodeFoldingResult GetCodeFoldingResult(out int firstErrorOffset) { -
stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures/Interfaces/ICodeCompletionStrategy.cs
r11800 r11937 23 23 internal interface ICodeCompletionStrategy { 24 24 void DoCodeCompletion(bool controlSpace); 25 void RunBackgroundParser();25 void Initialize(); 26 26 } 27 27 } -
stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures/LanguageFeatures.cs
r11800 r11937 63 63 64 64 private void LoadedHandler(object sender, EventArgs e) { 65 codeCompletionStrategy. RunBackgroundParser();65 codeCompletionStrategy.Initialize(); 66 66 } 67 67 -
stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures/XmlLanguageFeatures.cs
r11700 r11937 25 25 : base(codeEditor, new XmlCodeFoldingStrategy(codeEditor), null) { 26 26 } 27 28 public static ILanguageFeatures Apply(CodeEditor codeEditor) { 29 return new XmlLanguageFeatures(codeEditor); 30 } 27 31 } 28 32 }
Note: See TracChangeset
for help on using the changeset viewer.