diff --git a/VisualStudioPlugin/Gui/ServerActions.cs b/VisualStudioPlugin/Gui/ServerActions.cs index e9b2630..6b0a5bd 100644 --- a/VisualStudioPlugin/Gui/ServerActions.cs +++ b/VisualStudioPlugin/Gui/ServerActions.cs @@ -186,6 +186,9 @@ private static void GatherCurrentDsl(ProjectItems items, Dictionary dsls) } if (pi.ProjectItems != null) LocateCurrentDsl(pi.ProjectItems, dsls); + var subproject = pi.SubProject; + if (subproject != null && subproject.ProjectItems != null) + LocateCurrentDsl(subproject.ProjectItems, dsls); } } diff --git a/VisualStudioPlugin/Outlining/DddOutliningTagger.cs b/VisualStudioPlugin/Outlining/DddOutliningTagger.cs index 583afa6..eff0ea3 100644 --- a/VisualStudioPlugin/Outlining/DddOutliningTagger.cs +++ b/VisualStudioPlugin/Outlining/DddOutliningTagger.cs @@ -69,7 +69,7 @@ public IEnumerable> GetTags(NormalizedSnapshotSpanCollec var innerText = currentSnapshot.GetText(startPosition + 1, len); yield return new TagSpan( new SnapshotSpan(startLine.Start + region.StartOffset, endLine.End), - new DddOutlineTag(innerText, len, region.Rule, endLine.Start.Position + region.EndOffset + 1)); + new DddOutlineTag(region.IsNested, innerText, len, region.Rule, endLine.Start.Position + region.EndOffset + 1)); } } } @@ -130,18 +130,16 @@ private void ParseAndCache() if (lastInfo.Level >= 0) continue; currentLevel--; - if (lastInfo.IsNested) + newRegions.Add(new Region { - newRegions.Add(new Region - { - Rule = t.Value, - Level = currentLevel, - StartLine = currentRegion.StartLine, - StartOffset = currentRegion.StartOffset, - EndLine = t.Line - 1, - EndOffset = t.Column - 1 - }); - } + Rule = t.Value, + IsNested = lastInfo.IsNested, + Level = currentLevel, + StartLine = currentRegion.StartLine, + StartOffset = currentRegion.StartOffset, + EndLine = t.Line - 1, + EndOffset = t.Column - 1 + }); lastInfo = currentLevel > 0 ? levelInfo[currentLevel - 1] : null; if (lastInfo != null) lastInfo.Level--; diff --git a/VisualStudioPlugin/Outlining/Region.cs b/VisualStudioPlugin/Outlining/Region.cs index 2e7e205..c9ae0ce 100644 --- a/VisualStudioPlugin/Outlining/Region.cs +++ b/VisualStudioPlugin/Outlining/Region.cs @@ -13,5 +13,6 @@ internal class Region : PartialRegion { public int EndLine; public int EndOffset; + public bool IsNested; } } diff --git a/VisualStudioPlugin/Token/DddOutlineTag.cs b/VisualStudioPlugin/Token/DddOutlineTag.cs index f7bd811..3a612b7 100644 --- a/VisualStudioPlugin/Token/DddOutlineTag.cs +++ b/VisualStudioPlugin/Token/DddOutlineTag.cs @@ -6,29 +6,38 @@ namespace DDDLanguage { internal class DddOutlineTag : IOutliningRegionTag { + public readonly bool IsNested; private readonly string Lines; private readonly int Len; internal readonly string Rule; internal readonly int End; private string Text; - public DddOutlineTag(string lines, int len, string rule, int end) + public DddOutlineTag(bool isNested, string lines, int len, string rule, int end) { + this.IsNested = isNested; this.Lines = lines; this.Len = len; this.Rule = rule; this.End = end; } - public object CollapsedForm { get { return "{ ... }"; } } + public object CollapsedForm { get { return IsNested ? "{ ... }" : "{}"; } } public object CollapsedHintForm { get { + if (!IsNested) return string.Empty; if (Text == null) { var innerLines = Lines.Split('\n'); - var maxSpace = innerLines.Take(10).Where(it => !string.IsNullOrWhiteSpace(it)).Min(it => it.Length - it.TrimStart().Length); + var nonEmpty = innerLines.Take(10).Where(it => !string.IsNullOrWhiteSpace(it)).ToList(); + if (nonEmpty.Count == 0) + { + Text = string.Empty; + return Text; + } + var maxSpace = nonEmpty.Min(it => it.Length - it.TrimStart().Length); Text = string.Join("\n", innerLines.Take(10).Select(it => string.IsNullOrWhiteSpace(it) ? string.Empty : it.Substring(maxSpace))) + (Len > 999 || innerLines.Where(it => it.Length > 0).Count() > 10 ? Environment.NewLine + "..." : string.Empty);