Free cookie consent management tool by TermsFeed Policy Generator

source: branches/CodeEditor/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CodeCompletion/CSharp/CompletionData/CodeCompletionData.cs @ 11700

Last change on this file since 11700 was 11700, checked in by jkarder, 9 years ago

#2077: created branch and added first version

File size: 2.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Windows.Media;
25using ICSharpCode.AvalonEdit.Editing;
26using ICSharpCode.NRefactory.Editor;
27using ACC = ICSharpCode.AvalonEdit.CodeCompletion;
28using NCC = ICSharpCode.NRefactory.Completion;
29
30namespace HeuristicLab.CodeEditor {
31  internal class CompletionData : NCC.ICompletionData, ACC.ICompletionData {
32    public string TriggerWord { get; set; }
33    public int TriggerWordLength { get; set; }
34
35    #region Constructors
36    protected CompletionData() { }
37
38    public CompletionData(string text) {
39      DisplayText = CompletionText = Description = text;
40    }
41    #endregion
42
43    #region ICSharpCode.NRefactory.Completion.ICompletionData Members
44    public NCC.CompletionCategory CompletionCategory { get; set; }
45    public string DisplayText { get; set; }
46    public virtual string Description { get; set; }
47    public string CompletionText { get; set; }
48    public NCC.DisplayFlags DisplayFlags { get; set; }
49    public bool HasOverloads { get { return overloadedData.Count > 0; } }
50
51    private readonly List<NCC.ICompletionData> overloadedData = new List<NCC.ICompletionData>();
52    public IEnumerable<NCC.ICompletionData> OverloadedData {
53      get { return overloadedData; }
54      set { throw new InvalidOperationException(); }
55    }
56
57    public void AddOverload(NCC.ICompletionData data) {
58      if (overloadedData.Count == 0)
59        overloadedData.Add(this);
60      overloadedData.Add(data);
61    }
62    #endregion
63
64    #region ICSharpCode.AvalonEdit.CodeCompletion.ICompletionData Members
65    public object Content { get { return DisplayText; } }
66    object ACC.ICompletionData.Description { get { return Description; } }
67    public virtual ImageSource Image { get; set; }
68    public double Priority { get; set; }
69    public string Text { get { return CompletionText; } }
70
71    public void Complete(TextArea textArea, ISegment completionSegment, EventArgs insertionRequestEventArgs) {
72      textArea.Document.Replace(completionSegment, CompletionText);
73    }
74    #endregion
75  }
76}
Note: See TracBrowser for help on using the repository browser.