[11700] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[17181] | 3 | * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[11700] | 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 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Collections.Generic;
|
---|
| 24 | using System.Windows.Media;
|
---|
| 25 | using ICSharpCode.AvalonEdit.Editing;
|
---|
| 26 | using ICSharpCode.NRefactory.Editor;
|
---|
| 27 | using ACC = ICSharpCode.AvalonEdit.CodeCompletion;
|
---|
| 28 | using NCC = ICSharpCode.NRefactory.Completion;
|
---|
| 29 |
|
---|
| 30 | namespace 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; } }
|
---|
[11804] | 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 |
|
---|
[11700] | 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
|
---|
[11804] | 85 |
|
---|
| 86 | protected virtual object CreateFancyDescription() {
|
---|
| 87 | return Description;
|
---|
| 88 | }
|
---|
[11700] | 89 | }
|
---|
| 90 | }
|
---|