Skip to content

Commit

Permalink
When you use Generate Select on entity, Intellisense was not working.…
Browse files Browse the repository at this point in the history
… Fixed. (#62)
  • Loading branch information
nothrow authored and tdanner committed Feb 22, 2017
1 parent 3bde637 commit 11751ad
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
8 changes: 6 additions & 2 deletions Src/SwqlStudio/LexerService.cs
Expand Up @@ -193,11 +193,15 @@ public IEnumerable<string> GetAutoCompletionKeywords(int textPos)
/// <returns></returns>
private IEnumerable<string> FollowNavigationProperties(string proposedEntity)
{
// we haven't got properly filled entities.
if (!_swisEntities.ContainsKey(""))
return Enumerable.Empty<string>();

var ns = _swisEntities[""];

foreach (var dot in ParsePaths(proposedEntity))
{
if (ns.NavigationProperties.ContainsKey(dot.Item2))
if (ns.NavigationProperties.ContainsKey(dot.Item2) && _swisEntities.ContainsKey(ns.NavigationProperties[dot.Item2]))
{
ns = _swisEntities[ns.NavigationProperties[dot.Item2]];
}
Expand All @@ -210,7 +214,7 @@ private IEnumerable<string> FollowNavigationProperties(string proposedEntity)
return ns.ColumnNames;
}

private ExpectedCaretPosition DetectAutoCompletion(string text, int textPos)
private static ExpectedCaretPosition DetectAutoCompletion(string text, int textPos)
{
if (Settings.Default.IntellisenseEnabled)
return new IntellisenseProvider(text).ParseFor(textPos);
Expand Down
5 changes: 4 additions & 1 deletion Src/SwqlStudio/MainForm.ApplicationService.cs
Expand Up @@ -13,7 +13,10 @@ public void AddTextToEditor(string text, ConnectionInfo info)
if (info == null)
info = ActiveConnectionInfo;

CreateQueryTab(info.Title, info);
IMetadataProvider metadataProvider;
_metadataProviders.TryGetValue(info, out metadataProvider);

CreateQueryTab(info.Title, info, metadataProvider);
ActiveQueryTab.QueryText = text;
}

Expand Down
13 changes: 5 additions & 8 deletions Src/SwqlStudio/MainForm.cs
Expand Up @@ -121,7 +121,7 @@ private void AddNewQueryTab()
}
}

private QueryTab CreateQueryTab(string title, ConnectionInfo info, IMetadataProvider provider = null)
private QueryTab CreateQueryTab(string title, ConnectionInfo info, IMetadataProvider provider)
{
var tab = new TabPage(title) { BorderStyle = BorderStyle.None, Padding = new Padding(0) };
var queryTab = new QueryTab { ConnectionInfo = info, Dock = DockStyle.Fill, ApplicationService = this };
Expand All @@ -141,12 +141,6 @@ private QueryTab CreateQueryTab(string title, ConnectionInfo info, IMetadataProv
return queryTab;
}

private void CloneActiveTabWithNewQuery(string query)
{
QueryTab tab = CreateQueryTab(ActiveConnectionTab.ConnectionInfo.Title, ActiveConnectionTab.ConnectionInfo);
tab.QueryText = query;
}

private void menuFileOpen_Click(object sender, EventArgs e)
{
if (openFileDialog.ShowDialog() == DialogResult.OK)
Expand All @@ -170,7 +164,10 @@ private void OpenFiles(string[] fns)
var connectionInfo = ActiveConnectionInfo.Copy();
connectionInfo.Connect();

queryTab = CreateQueryTab(Path.GetFileName(fn), connectionInfo);
IMetadataProvider metadataProvider;
_metadataProviders.TryGetValue(connectionInfo, out metadataProvider);

queryTab = CreateQueryTab(Path.GetFileName(fn), connectionInfo, metadataProvider);
queryTab.QueryText = File.ReadAllText(fn);
// Modified flag is set during loading because the document
// "changes" (from nothing to something). So, clear it again.
Expand Down

0 comments on commit 11751ad

Please sign in to comment.