Skip to content

Commit

Permalink
Add IndexedProperties bundle to the zzz solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Fitzchak Yitzchaki committed May 22, 2012
1 parent aeef148 commit 845bbc0
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 68 deletions.
136 changes: 68 additions & 68 deletions Raven.Studio/Controls/Editors/QueryEditor.cs
@@ -1,31 +1,31 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Input;
using ActiproSoftware.Text;
using ActiproSoftware.Windows.Controls.SyntaxEditor.IntelliPrompt;
using Raven.Studio.Features.Query;

namespace Raven.Studio.Controls.Editors
{
public class QueryEditor : EditorBase
{
private static readonly ISyntaxLanguage DefaultLanguage;

static QueryEditor()
{
DefaultLanguage = SyntaxEditorHelper.LoadLanguageDefinitionFromResourceStream("RavenQuery.langdef");
}

public QueryEditor()
{
Document.Language = DefaultLanguage;
AreLineModificationMarksVisible = false;

foreach (var key in InputBindings.Where(x => x.Key == Key.Enter && x.Modifiers == ModifierKeys.Control).ToList())
{
InputBindings.Remove(key);
}
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Input;
using ActiproSoftware.Text;
using ActiproSoftware.Windows.Controls.SyntaxEditor.IntelliPrompt;
using Raven.Studio.Features.Query;

namespace Raven.Studio.Controls.Editors
{
public class QueryEditor : EditorBase
{
private static readonly ISyntaxLanguage DefaultLanguage;

static QueryEditor()
{
DefaultLanguage = SyntaxEditorHelper.LoadLanguageDefinitionFromResourceStream("RavenQuery.langdef");
}

public QueryEditor()
{
Document.Language = DefaultLanguage;
AreLineModificationMarksVisible = false;

foreach (var key in InputBindings.Where(x => x.Key == Key.Enter && x.Modifiers == ModifierKeys.Control).ToList())
{
InputBindings.Remove(key);
}
}

public ICompletionProvider CompletionProvider
Expand All @@ -34,46 +34,46 @@ public ICompletionProvider CompletionProvider
set { SetValue(CompletionProviderProperty, value); }
}

public static readonly DependencyProperty CompletionProviderProperty =
DependencyProperty.Register("CompletionProvider", typeof(ICompletionProvider), typeof(QueryEditor), new PropertyMetadata(null, PropertyChangedCallback));

private static void PropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
{
public static readonly DependencyProperty CompletionProviderProperty =
DependencyProperty.Register("CompletionProvider", typeof(ICompletionProvider), typeof(QueryEditor), new PropertyMetadata(null, PropertyChangedCallback));

private static void PropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
{
var editor = (QueryEditor)dependencyObject;
editor.Document.Language.RegisterService((ICompletionProvider) args.NewValue);
}

public static IEnumerable<FieldAndTerm> GetCurrentFieldsAndTerms(string text)
{
var editor = new QueryEditor {Text = text};
var textSnapshotReader = editor.ActiveView.GetReader();
string currentField = null;
while (!textSnapshotReader.IsAtSnapshotEnd)
{
var token = textSnapshotReader.ReadToken();
if (token == null)
break;

var txt = textSnapshotReader.ReadTextReverse(token.Length);
textSnapshotReader.ReadToken();
if(string.IsNullOrWhiteSpace(txt))
continue;

string currentVal = null;
if (txt.EndsWith(":"))
{
currentField = txt.Substring(0, txt.Length - 1);
}
else
{
currentVal = txt;
}
if (currentField == null || currentVal == null)
continue;

yield return new FieldAndTerm(currentField, currentVal);
currentField = null;
}
}
}
}

public static IEnumerable<FieldAndTerm> GetCurrentFieldsAndTerms(string text)
{
var editor = new QueryEditor {Text = text};
var textSnapshotReader = editor.ActiveView.GetReader();
string currentField = null;
while (!textSnapshotReader.IsAtSnapshotEnd)
{
var token = textSnapshotReader.ReadToken();
if (token == null)
break;

var txt = textSnapshotReader.ReadTextReverse(token.Length);
textSnapshotReader.ReadToken();
if(string.IsNullOrWhiteSpace(txt))
continue;

string currentVal = null;
if (txt.EndsWith(":"))
{
currentField = txt.Substring(0, txt.Length - 1);
}
else
{
currentVal = txt;
}
if (currentField == null || currentVal == null)
continue;

yield return new FieldAndTerm(currentField, currentVal);
currentField = null;
}
}
}
}
26 changes: 26 additions & 0 deletions zzz_RavenDB_Release.sln
Expand Up @@ -120,6 +120,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raven.Client.MoreLikeThis",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raven.Database", "Raven.Database\Raven.Database.csproj", "{212823CD-25E1-41AC-92D1-D6DF4D53FC85}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raven.Bundles.IndexedProperties", "Bundles\Raven.Bundles.IndexedProperties\Raven.Bundles.IndexedProperties.csproj", "{012F5E7B-DDC3-4B8C-BA39-1394536D58BE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raven.Client.IndexedProperties", "Bundles\Raven.Client.IndexedProperties\Raven.Client.IndexedProperties.csproj", "{F41C7F7E-A287-449A-A545-E7152937EF77}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -700,6 +704,26 @@ Global
{212823CD-25E1-41AC-92D1-D6DF4D53FC85}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{212823CD-25E1-41AC-92D1-D6DF4D53FC85}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{212823CD-25E1-41AC-92D1-D6DF4D53FC85}.Release|x86.ActiveCfg = Release|Any CPU
{012F5E7B-DDC3-4B8C-BA39-1394536D58BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{012F5E7B-DDC3-4B8C-BA39-1394536D58BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{012F5E7B-DDC3-4B8C-BA39-1394536D58BE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{012F5E7B-DDC3-4B8C-BA39-1394536D58BE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{012F5E7B-DDC3-4B8C-BA39-1394536D58BE}.Debug|x86.ActiveCfg = Debug|Any CPU
{012F5E7B-DDC3-4B8C-BA39-1394536D58BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{012F5E7B-DDC3-4B8C-BA39-1394536D58BE}.Release|Any CPU.Build.0 = Release|Any CPU
{012F5E7B-DDC3-4B8C-BA39-1394536D58BE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{012F5E7B-DDC3-4B8C-BA39-1394536D58BE}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{012F5E7B-DDC3-4B8C-BA39-1394536D58BE}.Release|x86.ActiveCfg = Release|Any CPU
{F41C7F7E-A287-449A-A545-E7152937EF77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F41C7F7E-A287-449A-A545-E7152937EF77}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F41C7F7E-A287-449A-A545-E7152937EF77}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{F41C7F7E-A287-449A-A545-E7152937EF77}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{F41C7F7E-A287-449A-A545-E7152937EF77}.Debug|x86.ActiveCfg = Debug|Any CPU
{F41C7F7E-A287-449A-A545-E7152937EF77}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F41C7F7E-A287-449A-A545-E7152937EF77}.Release|Any CPU.Build.0 = Release|Any CPU
{F41C7F7E-A287-449A-A545-E7152937EF77}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{F41C7F7E-A287-449A-A545-E7152937EF77}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{F41C7F7E-A287-449A-A545-E7152937EF77}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -728,6 +752,8 @@ Global
{35CFAB1C-7934-4481-AC0D-7102F7DEE7F8} = {F2B14D1C-4B20-4DA0-9CE6-C169773B0493}
{2EA316E8-629A-45C2-80B8-48F9CDB5BF57} = {F2B14D1C-4B20-4DA0-9CE6-C169773B0493}
{039CB1C3-C4F3-4D87-A2C0-7531E386E6A3} = {F2B14D1C-4B20-4DA0-9CE6-C169773B0493}
{012F5E7B-DDC3-4B8C-BA39-1394536D58BE} = {F2B14D1C-4B20-4DA0-9CE6-C169773B0493}
{F41C7F7E-A287-449A-A545-E7152937EF77} = {F2B14D1C-4B20-4DA0-9CE6-C169773B0493}
{B09A78D9-B609-459F-9AE1-319799330C6B} = {135E8994-55C0-4353-B31A-24778CB727B5}
{C9D466E0-346D-4C68-8F2F-1391C498E07F} = {135E8994-55C0-4353-B31A-24778CB727B5}
{76989E08-049F-4938-9E17-9A0EB69F70ED} = {135E8994-55C0-4353-B31A-24778CB727B5}
Expand Down

0 comments on commit 845bbc0

Please sign in to comment.