Skip to content

Commit 0a5389b

Browse files
committed
Merge pull request #1053 from zooba/v2.2.3
v2.2.3 fixes
2 parents 75e7eba + 52b1769 commit 0a5389b

15 files changed

+88
-50
lines changed

Python/Product/Django/Django.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@
117117
<When Condition="$(VSMajorVersion) >= 14">
118118
<ItemGroup>
119119
<Reference Include="Microsoft.VisualStudio.InteractiveWindow">
120-
<HintPath>$(DevEnvDir)PrivateAssemblies\Microsoft.VisualStudio.InteractiveWindow.dll</HintPath>
120+
<HintPath>..\PythonTools\Microsoft.VisualStudio.InteractiveWindow.dll</HintPath>
121121
<Private>false</Private>
122122
</Reference>
123123
<Reference Include="Microsoft.VisualStudio.VsInteractiveWindow">
124-
<HintPath>$(DevEnvDir)PrivateAssemblies\Microsoft.VisualStudio.VsInteractiveWindow.dll</HintPath>
124+
<HintPath>..\PythonTools\Microsoft.VisualStudio.VsInteractiveWindow.dll</HintPath>
125125
<Private>false</Private>
126126
</Reference>
127127
</ItemGroup>

Python/Product/Django/Intellisense/DjangoCompletionSource.cs

+8-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using Microsoft.PythonTools.Intellisense;
2222
using Microsoft.VisualStudio.Language.Intellisense;
2323
using Microsoft.VisualStudio.Text;
24+
using Microsoft.VisualStudio.Text.Projection;
2425

2526
#if DEV14_OR_LATER
2627
using Microsoft.Html.Editor.Document;
@@ -37,13 +38,17 @@ public DjangoCompletionSource(IGlyphService glyphService, DjangoAnalyzer analyze
3738
}
3839

3940
public override void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets) {
40-
var doc = HtmlEditorDocument.FromTextBuffer(_buffer);
41+
var doc = TemplateClassifier.HtmlEditorDocumentFromTextBuffer(_buffer);
4142
if (doc == null) {
4243
return;
4344
}
44-
doc.HtmlEditorTree.EnsureTreeReady();
45+
var tree = doc.HtmlEditorTree;
46+
if (tree == null) {
47+
return;
48+
}
49+
tree.EnsureTreeReady();
4550

46-
var primarySnapshot = doc.PrimaryView.TextSnapshot;
51+
var primarySnapshot = tree.TextSnapshot;
4752
var nullableTriggerPoint = session.GetTriggerPoint(primarySnapshot);
4853
if (!nullableTriggerPoint.HasValue) {
4954
return;

Python/Product/Django/TemplateParsing/TemplateClassifier.cs

+58-26
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,28 @@ public TemplateClassifier(TemplateClassifierProviderBase provider, ITextBuffer t
3939

4040
public override event EventHandler<ClassificationChangedEventArgs> ClassificationChanged;
4141

42+
internal static HtmlEditorDocument HtmlEditorDocumentFromTextBuffer(ITextBuffer buffer) {
43+
var doc = HtmlEditorDocument.FromTextBuffer(buffer);
44+
#if DEV14_OR_LATER
45+
if (doc == null) {
46+
var projBuffer = buffer as IProjectionBuffer;
47+
if (projBuffer != null) {
48+
foreach (var b in projBuffer.SourceBuffers) {
49+
if (b.ContentType.IsOfType(TemplateHtmlContentType.ContentTypeName) &&
50+
(doc = HtmlEditorDocument.TryFromTextBuffer(b)) != null) {
51+
return doc;
52+
}
53+
}
54+
}
55+
}
56+
#endif
57+
return doc;
58+
}
59+
4260
public override IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span) {
4361
var spans = new List<ClassificationSpan>();
4462

45-
var htmlDoc = HtmlEditorDocument.TryFromTextBuffer(span.Snapshot.TextBuffer);
63+
var htmlDoc = HtmlEditorDocumentFromTextBuffer(span.Snapshot.TextBuffer);
4664
if (htmlDoc == null) {
4765
return spans;
4866
}
@@ -64,35 +82,49 @@ public override IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan sp
6482
return spans;
6583
}
6684

67-
var projSnapshot = _htmlDoc.PrimaryView.TextSnapshot as IProjectionSnapshot;
68-
if (projSnapshot == null) {
69-
return spans;
70-
}
71-
72-
var primarySpans = projSnapshot.MapFromSourceSnapshot(span);
73-
foreach (var primarySpan in primarySpans) {
74-
var index = _htmlDoc.HtmlEditorTree.ArtifactCollection.GetItemContaining(primarySpan.Start);
75-
if (index < 0) {
76-
continue;
77-
}
78-
79-
var artifact = _htmlDoc.HtmlEditorTree.ArtifactCollection[index] as TemplateArtifact;
80-
if (artifact == null) {
81-
continue;
85+
// The provided span may be in a projection snapshot, so we need to
86+
// map back to the source snapshot to find the correct
87+
// classification. If projSnapshot is null, we are already in the
88+
// correct snapshot.
89+
var projSnapshot = span.Snapshot as IProjectionSnapshot;
90+
var sourceSnapshot = span.Snapshot;
91+
92+
var sourceStartIndex = span.Start.Position;
93+
if (projSnapshot != null) {
94+
var pt = projSnapshot.MapToSourceSnapshot(sourceStartIndex);
95+
sourceStartIndex = pt.Position;
96+
sourceSnapshot = pt.Snapshot;
97+
if (HtmlEditorDocument.TryFromTextBuffer(sourceSnapshot.TextBuffer) != _htmlDoc) {
98+
return spans;
8299
}
100+
}
83101

84-
var artifactStart = projSnapshot.MapToSourceSnapshot(artifact.InnerRange.Start);
85-
if (artifactStart.Snapshot != span.Snapshot) {
86-
continue;
87-
}
102+
var index = _htmlDoc.HtmlEditorTree.ArtifactCollection.GetItemContaining(sourceStartIndex);
103+
if (index < 0) {
104+
return spans;
105+
}
88106

89-
var artifactText = _htmlDoc.HtmlEditorTree.ParseTree.Text.GetText(artifact.InnerRange);
90-
artifact.Parse(artifactText);
107+
var artifact = _htmlDoc.HtmlEditorTree.ArtifactCollection[index] as TemplateArtifact;
108+
if (artifact == null) {
109+
return spans;
110+
}
91111

92-
var classifications = artifact.GetClassifications();
93-
foreach (var classification in classifications) {
94-
var classificationSpan = ToClassificationSpan(classification, span.Snapshot, artifactStart.Position);
95-
spans.Add(classificationSpan);
112+
int artifactStart = artifact.InnerRange.Start;
113+
var artifactText = _htmlDoc.HtmlEditorTree.ParseTree.Text.GetText(artifact.InnerRange);
114+
artifact.Parse(artifactText);
115+
116+
var classifications = artifact.GetClassifications();
117+
foreach (var classification in classifications) {
118+
var cls = GetClassification(classification.Classification);
119+
int clsStart = artifactStart + classification.Span.Start;
120+
int clsLen = Math.Min(sourceSnapshot.Length - clsStart, classification.Span.Length);
121+
var clsSpan = new SnapshotSpan(sourceSnapshot, clsStart, clsLen);
122+
if (projSnapshot != null) {
123+
foreach (var sp in projSnapshot.MapFromSourceSnapshot(clsSpan)) {
124+
spans.Add(new ClassificationSpan(new SnapshotSpan(span.Snapshot, sp), cls));
125+
}
126+
} else {
127+
spans.Add(new ClassificationSpan(clsSpan, cls));
96128
}
97129
}
98130

Python/Product/Django/TemplateParsing/TemplateClassifierBase.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ protected ClassificationSpan ToClassificationSpan(BlockClassification curSpan, I
8989
);
9090
}
9191

92-
private IClassificationType GetClassification(Classification classification) {
92+
protected IClassificationType GetClassification(Classification classification) {
9393
switch (classification) {
9494
case Classification.None: return _classifierProvider._classType;
9595
case Classification.Keyword: return _classifierProvider._keywordType;

Python/Product/EnvironmentsListHost/EnvironmentsListHost.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@
7575
<When Condition="$(VSMajorVersion) >= 14">
7676
<ItemGroup>
7777
<Reference Include="Microsoft.VisualStudio.InteractiveWindow">
78-
<HintPath>$(DevEnvDir)PrivateAssemblies\Microsoft.VisualStudio.InteractiveWindow.dll</HintPath>
78+
<HintPath>..\PythonTools\Microsoft.VisualStudio.InteractiveWindow.dll</HintPath>
7979
<Private>false</Private>
8080
</Reference>
8181
<Reference Include="Microsoft.VisualStudio.VsInteractiveWindow">
82-
<HintPath>$(DevEnvDir)PrivateAssemblies\Microsoft.VisualStudio.VsInteractiveWindow.dll</HintPath>
82+
<HintPath>..\PythonTools\Microsoft.VisualStudio.VsInteractiveWindow.dll</HintPath>
8383
<Private>false</Private>
8484
</Reference>
8585
</ItemGroup>
Binary file not shown.
Binary file not shown.

Python/Product/PythonTools/PythonTools.csproj

+3-2
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
<SpecificVersion>True</SpecificVersion>
127127
<HintPath Condition="Exists('$(DevEnvDir)PrivateAssemblies\Microsoft.VisualStudio.Web.WindowsAzure.Contracts.dll')">$(DevEnvDir)PrivateAssemblies\Microsoft.VisualStudio.Web.WindowsAzure.Contracts.dll</HintPath>
128128
<HintPath Condition="Exists('$(DevEnvDir)Extensions\Microsoft\Web Tools\WindowsAzure\Microsoft.VisualStudio.Web.WindowsAzure.Contracts.dll')">$(DevEnvDir)Extensions\Microsoft\Web Tools\WindowsAzure\Microsoft.VisualStudio.Web.WindowsAzure.Contracts.dll</HintPath>
129+
<HintPath Condition="Exists('$(DevEnvDir)Extensions\Microsoft\Web Tools Azure\Microsoft.VisualStudio.Web.WindowsAzure.Contracts.dll')">$(DevEnvDir)Extensions\Microsoft\Web Tools Azure\Microsoft.VisualStudio.Web.WindowsAzure.Contracts.dll</HintPath>
129130
<Private>false</Private>
130131
</Reference>
131132
</ItemGroup>
@@ -243,11 +244,11 @@
243244
<When Condition="$(VSMajorVersion) &gt;= 14">
244245
<ItemGroup>
245246
<Reference Include="Microsoft.VisualStudio.InteractiveWindow">
246-
<HintPath>$(DevEnvDir)PrivateAssemblies\Microsoft.VisualStudio.InteractiveWindow.dll</HintPath>
247+
<HintPath>Microsoft.VisualStudio.InteractiveWindow.dll</HintPath>
247248
<Private>false</Private>
248249
</Reference>
249250
<Reference Include="Microsoft.VisualStudio.VsInteractiveWindow">
250-
<HintPath>$(DevEnvDir)PrivateAssemblies\Microsoft.VisualStudio.VsInteractiveWindow.dll</HintPath>
251+
<HintPath>Microsoft.VisualStudio.VsInteractiveWindow.dll</HintPath>
251252
<Private>false</Private>
252253
</Reference>
253254
<Reference Include="Microsoft.VisualStudio.ImageCatalog, Version=$(VSTarget).0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />

Python/Tests/AzurePublishingUITests/AzurePublishingUITests.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@
107107
<When Condition="$(VSMajorVersion) >= 14">
108108
<ItemGroup>
109109
<Reference Include="Microsoft.VisualStudio.InteractiveWindow">
110-
<HintPath>$(DevEnvDir)PrivateAssemblies\Microsoft.VisualStudio.InteractiveWindow.dll</HintPath>
110+
<HintPath>$(BuildRoot)Python\Product\PythonTools\Microsoft.VisualStudio.InteractiveWindow.dll</HintPath>
111111
<Private>false</Private>
112112
</Reference>
113113
<Reference Include="Microsoft.VisualStudio.VsInteractiveWindow">
114-
<HintPath>$(DevEnvDir)PrivateAssemblies\Microsoft.VisualStudio.VsInteractiveWindow.dll</HintPath>
114+
<HintPath>$(BuildRoot)Python\Product\PythonTools\Microsoft.VisualStudio.VsInteractiveWindow.dll</HintPath>
115115
<Private>false</Private>
116116
</Reference>
117117
</ItemGroup>

Python/Tests/Core.UI/PythonToolsUITests.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@
107107
<When Condition="$(VSMajorVersion) >= 14">
108108
<ItemGroup>
109109
<Reference Include="Microsoft.VisualStudio.InteractiveWindow">
110-
<HintPath>$(DevEnvDir)PrivateAssemblies\Microsoft.VisualStudio.InteractiveWindow.dll</HintPath>
110+
<HintPath>$(BuildRoot)Python\Product\PythonTools\Microsoft.VisualStudio.InteractiveWindow.dll</HintPath>
111111
<Private>false</Private>
112112
</Reference>
113113
<Reference Include="Microsoft.VisualStudio.VsInteractiveWindow">
114-
<HintPath>$(DevEnvDir)PrivateAssemblies\Microsoft.VisualStudio.VsInteractiveWindow.dll</HintPath>
114+
<HintPath>$(BuildRoot)Python\Product\PythonTools\Microsoft.VisualStudio.VsInteractiveWindow.dll</HintPath>
115115
<Private>false</Private>
116116
</Reference>
117117
</ItemGroup>

Python/Tests/Core/PythonToolsTests.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@
106106
<When Condition="$(VSMajorVersion) &gt;= 14">
107107
<ItemGroup>
108108
<Reference Include="Microsoft.VisualStudio.InteractiveWindow">
109-
<HintPath>$(DevEnvDir)PrivateAssemblies\Microsoft.VisualStudio.InteractiveWindow.dll</HintPath>
109+
<HintPath>$(BuildRoot)Python\Product\PythonTools\Microsoft.VisualStudio.InteractiveWindow.dll</HintPath>
110110
<!-- Need a copy of the correct DLL for non-UI tests -->
111111
<Private>true</Private>
112112
</Reference>
113113
<Reference Include="Microsoft.VisualStudio.VsInteractiveWindow">
114-
<HintPath>$(DevEnvDir)PrivateAssemblies\Microsoft.VisualStudio.VsInteractiveWindow.dll</HintPath>
114+
<HintPath>$(BuildRoot)Python\Product\PythonTools\Microsoft.VisualStudio.VsInteractiveWindow.dll</HintPath>
115115
<!-- Need a copy of the correct DLL for non-UI tests -->
116116
<Private>true</Private>
117117
</Reference>

Python/Tests/IronPython/IronPythonTests.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@
103103
<When Condition="$(VSMajorVersion) >= 14">
104104
<ItemGroup>
105105
<Reference Include="Microsoft.VisualStudio.InteractiveWindow">
106-
<HintPath>$(DevEnvDir)PrivateAssemblies\Microsoft.VisualStudio.InteractiveWindow.dll</HintPath>
106+
<HintPath>$(BuildRoot)Python\Product\PythonTools\Microsoft.VisualStudio.InteractiveWindow.dll</HintPath>
107107
<Private>false</Private>
108108
</Reference>
109109
<Reference Include="Microsoft.VisualStudio.VsInteractiveWindow">
110-
<HintPath>$(DevEnvDir)PrivateAssemblies\Microsoft.VisualStudio.VsInteractiveWindow.dll</HintPath>
110+
<HintPath>$(BuildRoot)Python\Product\PythonTools\Microsoft.VisualStudio.VsInteractiveWindow.dll</HintPath>
111111
<Private>false</Private>
112112
</Reference>
113113
</ItemGroup>

Python/Tests/PythonToolsMockTests/PythonToolsMockTests.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@
115115
<When Condition="$(VSMajorVersion) &gt;= 14">
116116
<ItemGroup>
117117
<Reference Include="Microsoft.VisualStudio.InteractiveWindow">
118-
<HintPath>$(DevEnvDir)PrivateAssemblies\Microsoft.VisualStudio.InteractiveWindow.dll</HintPath>
118+
<HintPath>$(BuildRoot)Python\Product\PythonTools\Microsoft.VisualStudio.InteractiveWindow.dll</HintPath>
119119
<Private>false</Private>
120120
</Reference>
121121
<Reference Include="Microsoft.VisualStudio.VsInteractiveWindow">
122-
<HintPath>$(DevEnvDir)PrivateAssemblies\Microsoft.VisualStudio.VsInteractiveWindow.dll</HintPath>
122+
<HintPath>$(BuildRoot)Python\Product\PythonTools\Microsoft.VisualStudio.VsInteractiveWindow.dll</HintPath>
123123
<Private>false</Private>
124124
</Reference>
125125
</ItemGroup>

Python/Tests/ReplWindowUITests/ReplWindowUITests.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@
9494
<When Condition="$(VSMajorVersion) &gt;= 14">
9595
<ItemGroup>
9696
<Reference Include="Microsoft.VisualStudio.InteractiveWindow">
97-
<HintPath>$(DevEnvDir)PrivateAssemblies\Microsoft.VisualStudio.InteractiveWindow.dll</HintPath>
97+
<HintPath>$(BuildRoot)Python\Product\PythonTools\Microsoft.VisualStudio.InteractiveWindow.dll</HintPath>
9898
<Private>false</Private>
9999
</Reference>
100100
<Reference Include="Microsoft.VisualStudio.VsInteractiveWindow">
101-
<HintPath>$(DevEnvDir)PrivateAssemblies\Microsoft.VisualStudio.VsInteractiveWindow.dll</HintPath>
101+
<HintPath>$(BuildRoot)Python\Product\PythonTools\Microsoft.VisualStudio.VsInteractiveWindow.dll</HintPath>
102102
<Private>false</Private>
103103
</Reference>
104104
</ItemGroup>

Python/Tests/Utilities.Python/TestUtilities.Python.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@
9797
<When Condition="$(VSMajorVersion) &gt;= 14">
9898
<ItemGroup>
9999
<Reference Include="Microsoft.VisualStudio.InteractiveWindow">
100-
<HintPath>$(DevEnvDir)PrivateAssemblies\Microsoft.VisualStudio.InteractiveWindow.dll</HintPath>
100+
<HintPath>$(BuildRoot)Python\Product\PythonTools\Microsoft.VisualStudio.InteractiveWindow.dll</HintPath>
101101
<Private>false</Private>
102102
</Reference>
103103
<Reference Include="Microsoft.VisualStudio.VsInteractiveWindow">
104-
<HintPath>$(DevEnvDir)PrivateAssemblies\Microsoft.VisualStudio.VsInteractiveWindow.dll</HintPath>
104+
<HintPath>$(BuildRoot)Python\Product\PythonTools\Microsoft.VisualStudio.VsInteractiveWindow.dll</HintPath>
105105
<Private>false</Private>
106106
</Reference>
107107
</ItemGroup>

0 commit comments

Comments
 (0)