Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CodeCompletion/CSharp/CompletionData/CodeCompletionData.cs @ 13791

Last change on this file since 13791 was 12012, checked in by ascheibe, 10 years ago

#2212 merged r12008, r12009, r12010 back into trunk

File size: 3.1 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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
67    object fancyDescription;
68    object ACC.ICompletionData.Description {
69      get {
70        if (fancyDescription == null) {
71          fancyDescription = CreateFancyDescription();
72        }
73        return fancyDescription;
74      }
75    }
76
77    public virtual ImageSource Image { get; set; }
78    public double Priority { get; set; }
79    public string Text { get { return CompletionText; } }
80
81    public void Complete(TextArea textArea, ISegment completionSegment, EventArgs insertionRequestEventArgs) {
82      textArea.Document.Replace(completionSegment, CompletionText);
83    }
84    #endregion
85
86    protected virtual object CreateFancyDescription() {
87      return Description;
88    }
89  }
90}
Note: See TracBrowser for help on using the repository browser.