Skip to content

Commit 3bee295

Browse files
Merge pull request #1375 from am11/master
WEIgnore: Alow compilation just for preview.
2 parents 1bcfa11 + 548f845 commit 3bee295

File tree

8 files changed

+32
-18
lines changed

8 files changed

+32
-18
lines changed

EditorExtensions/CoffeeScript/Compilers/CoffeeScriptCompiler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace MadsKristensen.EditorExtensions.CoffeeScript
88
[ContentType("CoffeeScript")]
99
public class CoffeeScriptCompiler : JsCompilerBase
1010
{
11+
protected override bool Previewing { get { return WESettings.Instance.CoffeeScript.ShowPreviewPane; } }
1112
public override string ServiceName { get { return "CoffeeScript"; } }
1213
public override bool MinifyInPlace { get { return WESettings.Instance.CoffeeScript.MinifyInPlace; } }
1314
public override bool GenerateSourceMap { get { return WESettings.Instance.CoffeeScript.GenerateSourceMaps && !MinifyInPlace; } }

EditorExtensions/HTML/Completion/HtmlLabelForAttributeCompletion.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Linq;
33
using Microsoft.Html.Core;
44
using Microsoft.Html.Editor.Intellisense;
5-
using Microsoft.VisualStudio.Language.Intellisense;
65
using Microsoft.VisualStudio.Utilities;
76
using Microsoft.Web.Editor;
87

@@ -21,7 +20,6 @@ public CompletionType CompletionType
2120
public IList<HtmlCompletion> GetEntries(HtmlCompletionContext context)
2221
{
2322
var list = new HashSet<string>();
24-
var glyph = GlyphService.GetGlyph(StandardGlyphGroup.GlyphGroupVariable, StandardGlyphItem.GlyphItemPublic);
2523

2624
context.Document.HtmlEditorTree.RootNode.Accept(this, list);
2725

EditorExtensions/HTML/Completion/InputIdAttributeCompletion.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
using System.Collections.Generic;
22
using System.Linq;
3-
using System.Windows.Media;
43
using Microsoft.Html.Core;
54
using Microsoft.Html.Editor.Intellisense;
6-
using Microsoft.VisualStudio.Language.Intellisense;
75
using Microsoft.VisualStudio.Utilities;
86
using Microsoft.Web.Editor;
97

@@ -14,7 +12,6 @@ namespace MadsKristensen.EditorExtensions.Html
1412
public class InputIdAttributeCompletion : IHtmlCompletionListProvider, IHtmlTreeVisitor
1513
{
1614
private static readonly HashSet<string> _inputTypes = new HashSet<string>() { "input", "textarea", "select" };
17-
private static ImageSource _glyph = GlyphService.GetGlyph(StandardGlyphGroup.GlyphGroupVariable, StandardGlyphItem.GlyphItemPublic);
1815

1916
public CompletionType CompletionType
2017
{

EditorExtensions/LESS/Compilers/LessCompiler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace MadsKristensen.EditorExtensions.Less
88
[ContentType("LESS")]
99
public class LessCompiler : CssCompilerBase
1010
{
11+
protected override bool Previewing { get { return WESettings.Instance.Less.ShowPreviewPane; } }
1112
public override string TargetExtension { get { return ".css"; } }
1213
public override string ServiceName { get { return "LESS"; } }
1314
public override bool MinifyInPlace { get { return WESettings.Instance.Less.MinifyInPlace; } }

EditorExtensions/LiveScript/Compilers/LiveScriptCompiler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace MadsKristensen.EditorExtensions.LiveScript
88
[ContentType(LiveScriptContentTypeDefinition.LiveScriptContentType)]
99
public class LiveScriptCompiler : JsCompilerBase
1010
{
11+
protected override bool Previewing { get { return WESettings.Instance.LiveScript.ShowPreviewPane; } }
1112
public override string ServiceName { get { return "LiveScript"; } }
1213
public override bool MinifyInPlace { get { return WESettings.Instance.SweetJs.MinifyInPlace; } }
1314
public override bool GenerateSourceMap { get { return false; /*WESettings.Instance.LiveScript.GenerateSourceMaps && !WESettings.Instance.LiveScript.MinifyInPlace;*/ } }

EditorExtensions/SCSS/Compilers/ScssCompiler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace MadsKristensen.EditorExtensions.Scss
1010
[ContentType(ScssContentTypeDefinition.ScssContentType)]
1111
public class ScssCompiler : CssCompilerBase
1212
{
13+
protected override bool Previewing { get { return WESettings.Instance.Scss.ShowPreviewPane; } }
1314
public override string ServiceName { get { return "SCSS"; } }
1415
public override string TargetExtension { get { return ".css"; } }
1516
public override bool MinifyInPlace { get { return WESettings.Instance.Scss.MinifyInPlace; } }

EditorExtensions/Shared/Compilers/NodeExecutorBase.cs

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ namespace MadsKristensen.EditorExtensions
1010
{
1111
public abstract class NodeExecutorBase
1212
{
13+
protected virtual bool Previewing { get { return false; } }
14+
1315
///<summary>Indicates whether this compiler will emit a source map file. Will only return true if supported and enabled in user settings.</summary>
1416
public abstract bool MinifyInPlace { get; }
1517
public abstract bool GenerateSourceMap { get; }
@@ -18,20 +20,26 @@ public abstract class NodeExecutorBase
1820

1921
public async Task<CompilerResult> CompileAsync(string sourceFileName, string targetFileName)
2022
{
23+
bool onlyPreview = false;
24+
2125
if (WEIgnore.TestWEIgnore(sourceFileName, this is ILintCompiler ? "linter" : "compiler", ServiceName.ToLowerInvariant()))
2226
{
2327
Logger.Log(String.Format(CultureInfo.CurrentCulture, "{0}: The file {1} is ignored by .weignore. Skipping..", ServiceName, Path.GetFileName(sourceFileName)));
24-
return await CompilerResultFactory.GenerateResult(sourceFileName, targetFileName, string.Empty, false, string.Empty, string.Empty, Enumerable.Empty<CompilerError>(), true);
28+
29+
if (!Previewing)
30+
return await CompilerResultFactory.GenerateResult(sourceFileName, targetFileName, string.Empty, false, string.Empty, string.Empty, Enumerable.Empty<CompilerError>(), true);
31+
32+
onlyPreview = true;
2533
}
2634

2735
CompilerResult response = await NodeServer.CallServiceAsync(GetPath(sourceFileName, targetFileName));
2836

29-
return await ProcessResult(response, sourceFileName, targetFileName);
37+
return await ProcessResult(response, onlyPreview, sourceFileName, targetFileName);
3038
}
3139

3240
// Don't try-catch this method: We need to "address" all the bugs,
3341
// which may occur as the (node.js-based) service implement changes.
34-
private async Task<CompilerResult> ProcessResult(CompilerResult result, string sourceFileName, string targetFileName)
42+
private async Task<CompilerResult> ProcessResult(CompilerResult result, bool onlyPreview, string sourceFileName, string targetFileName)
3543
{
3644
if (result == null)
3745
{
@@ -50,17 +58,23 @@ private async Task<CompilerResult> ProcessResult(CompilerResult result, string s
5058

5159
string resultString = PostProcessResult(result);
5260

53-
if (result.TargetFileName != null && (MinifyInPlace || !File.Exists(result.TargetFileName) ||
54-
resultString != await FileHelpers.ReadAllTextRetry(result.TargetFileName)))
61+
if (!onlyPreview)
5562
{
56-
ProjectHelpers.CheckOutFileFromSourceControl(result.TargetFileName);
57-
await FileHelpers.WriteAllTextRetry(result.TargetFileName, resultString);
58-
}
59-
if (GenerateSourceMap && (!File.Exists(result.MapFileName) ||
60-
result.ResultMap != await FileHelpers.ReadAllTextRetry(result.MapFileName)))
61-
{
62-
ProjectHelpers.CheckOutFileFromSourceControl(result.MapFileName);
63-
await FileHelpers.WriteAllTextRetry(result.MapFileName, result.ResultMap);
63+
// Write output file
64+
if (result.TargetFileName != null && (MinifyInPlace || !File.Exists(result.TargetFileName) ||
65+
resultString != await FileHelpers.ReadAllTextRetry(result.TargetFileName)))
66+
{
67+
ProjectHelpers.CheckOutFileFromSourceControl(result.TargetFileName);
68+
await FileHelpers.WriteAllTextRetry(result.TargetFileName, resultString);
69+
}
70+
71+
// Write map file
72+
if (GenerateSourceMap && (!File.Exists(result.MapFileName) ||
73+
result.ResultMap != await FileHelpers.ReadAllTextRetry(result.MapFileName)))
74+
{
75+
ProjectHelpers.CheckOutFileFromSourceControl(result.MapFileName);
76+
await FileHelpers.WriteAllTextRetry(result.MapFileName, result.ResultMap);
77+
}
6478
}
6579

6680
return CompilerResult.UpdateResult(result, resultString);

EditorExtensions/SweetJs/Compilers/SweetJsCompiler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace MadsKristensen.EditorExtensions.SweetJs
88
[ContentType(SweetJsContentTypeDefinition.SweetJsContentType)]
99
public class SweetJsCompiler : JsCompilerBase
1010
{
11+
protected override bool Previewing { get { return WESettings.Instance.SweetJs.ShowPreviewPane; } }
1112
public override string ServiceName { get { return SweetJsContentTypeDefinition.SweetJsContentType; } }
1213
public override bool MinifyInPlace { get { return WESettings.Instance.SweetJs.MinifyInPlace; } }
1314
public override bool GenerateSourceMap { get { return WESettings.Instance.SweetJs.GenerateSourceMaps && !MinifyInPlace; } }

0 commit comments

Comments
 (0)