Skip to content

Commit

Permalink
fix: naming rule violations, source-code headers. some cosmetic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Art-Stea1th committed Dec 10, 2017
1 parent 741cdcc commit 986280d
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 50 deletions.
10 changes: 8 additions & 2 deletions Extension/ASD.ESH/Assets/GettingStartedGuide.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
<!DOCTYPE html>
<!--
Copyright (c) "ESH-Repository" source code contributors. All Rights Reserved.
Licensed under the Microsoft Public License (MS-PL).
See LICENSE.md in the "ESH-Repository" root for license information.
"ESH-Repository" root address: https://github.com/Art-Stea1th/Enhanced-Syntax-Highlighting
-->

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">

<head>
Expand Down Expand Up @@ -43,7 +50,6 @@
and scrolling to properties starting with the prefix
<h>"User Tags - ..."</h>
</li>

<li>
<h>Just select the colors</h> you like, <h>click "ok"</h> and
<h>write code</h> in a little more friendly environment <h>;)<h />
Expand Down
3 changes: 3 additions & 0 deletions Extension/ASD.ESH/Assets/ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
- v 1.2 build **** rev. *****
Fixed: in some cases, the syntax highlighting does not apply completely to the last editing of the code until its next editing.

- v 1.2 build 6551 rev. 38038
Added: support for Visual Basic.

- v 1.1 build 6547 rev. 73
Expand Down
12 changes: 6 additions & 6 deletions Extension/ASD.ESH/Classification/Classifier.SpansConverter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Stanislav Kuzmich. All Rights Reserved.
// Copyright (c) "ESH-Repository" source code contributors. All Rights Reserved.
// Licensed under the Microsoft Public License (MS-PL).
// See License.txt in the project for license information.
// See LICENSE.md in the "ESH-Repository" root for license information.
// "ESH-Repository" root address: https://github.com/Art-Stea1th/Enhanced-Syntax-Highlighting

using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -28,11 +29,10 @@ public SpansConverter(SemanticModel model, SyntaxNode root, ITextSnapshot snapsh
}

public IEnumerable<ClassificationSpan> ConvertAll(IEnumerable<ClassifiedSpan> spans) {

return spans
.Where( s => s.ClassificationType == ClassificationTypeNames.Identifier )
.Select( s => Convert(s) )
.Where( cs => cs != null );
.Where(s => s.ClassificationType == ClassificationTypeNames.Identifier)
.Select(s => Convert(s))
.Where(cs => cs != null);
}

private ClassificationSpan Convert(ClassifiedSpan span) {
Expand Down
38 changes: 20 additions & 18 deletions Extension/ASD.ESH/Classification/Classifier.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Stanislav Kuzmich. All Rights Reserved.
// Copyright (c) "ESH-Repository" source code contributors. All Rights Reserved.
// Licensed under the Microsoft Public License (MS-PL).
// See License.txt in the project for license information.
// See LICENSE.md in the "ESH-Repository" root for license information.
// "ESH-Repository" root address: https://github.com/Art-Stea1th/Enhanced-Syntax-Highlighting

using System;
using System.Collections.Generic;
Expand All @@ -21,48 +22,49 @@ internal sealed partial class Classifier : IClassifier {
public event EventHandler<ClassificationChangedEventArgs> ClassificationChanged;
#pragma warning restore CS0067

private static readonly IList<ClassificationSpan> emptyList = new List<ClassificationSpan>( capacity:0 ).AsReadOnly();
private static readonly IList<ClassificationSpan> emptyList = new List<ClassificationSpan>(capacity: 0).AsReadOnly();

private Document document = null;
private ITextSnapshot snapshot = null;
private IList<ClassificationSpan> lastSpans = emptyList;

public IList<ClassificationSpan> GetClassificationSpans( SnapshotSpan span ) {
public IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span) {

var snapshot = span.Snapshot;
var document = snapshot.GetOpenDocumentInCurrentContextWithChanges();

if ( document == null )
if (document == null) {
return emptyList;

if ( this.document?.Id == document.Id && this.snapshot == snapshot )
}
if (this.document?.Id == document.Id && this.snapshot == snapshot) {
return lastSpans;
}

this.document = document;
this.snapshot = snapshot;

lastSpans = Task.Run( () => getSpansAync(document,snapshot) ).GetAwaiter().GetResult();

return lastSpans;
return lastSpans = Task.Run(() => GetSpansAync(document, snapshot)).GetAwaiter().GetResult();
}

private async Task<IList<ClassificationSpan>> getSpansAync( Document document, ITextSnapshot snapshot ) {
private async Task<IList<ClassificationSpan>> GetSpansAync(Document document, ITextSnapshot snapshot) {

var modelTask = document.GetSemanticModelAsync();
var rootTask = document.GetSyntaxRootAsync();
var spansTask = document.GetClassifiedSpansAsync( new TextSpan(0,snapshot.Length) );
var spansTask = document.GetClassifiedSpansAsync(new TextSpan(0, snapshot.Length));

await Task.WhenAll( modelTask, rootTask, spansTask );
await Task.WhenAll(modelTask, rootTask, spansTask);

var model = modelTask.GetAwaiter().GetResult();
var root = rootTask.GetAwaiter().GetResult();
var spans = spansTask.GetAwaiter().GetResult();

var resultSpans = new List<ClassificationSpan>( spans.Count() );
var converter = new SpansConverter( model, root, snapshot );
var resultSpans = new List<ClassificationSpan>(spans.Count());
var converter = new SpansConverter(model, root, snapshot);

foreach ( var span in converter.ConvertAll(spans) )
resultSpans.Add( span );
foreach (var span in converter.ConvertAll(spans)) {
resultSpans.Add(span);
}
return resultSpans;
}

}
}
13 changes: 7 additions & 6 deletions Extension/ASD.ESH/Classification/ClassifierProvider.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Stanislav Kuzmich. All Rights Reserved.
// Copyright (c) "ESH-Repository" source code contributors. All Rights Reserved.
// Licensed under the Microsoft Public License (MS-PL).
// See License.txt in the project for license information.
// See LICENSE.md in the "ESH-Repository" root for license information.
// "ESH-Repository" root address: https://github.com/Art-Stea1th/Enhanced-Syntax-Highlighting

using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Text;
Expand All @@ -17,13 +18,13 @@ internal sealed class ClassifierProvider : IClassifierProvider {
[Import] private IClassificationTypeRegistryService registryService; // set via MEF
#pragma warning restore CS0649

IClassifier IClassifierProvider.GetClassifier( ITextBuffer textBuffer ) {
IClassifier IClassifierProvider.GetClassifier(ITextBuffer textBuffer) {

return textBuffer.Properties.GetOrCreateSingletonProperty(
creator: () => {
TypesRegistry.InitializeIfNeeded( registryService );
TypesRegistry.InitializeIfNeeded(registryService);
return new Classifier();
}
);
});
}
}
}
6 changes: 3 additions & 3 deletions Extension/ASD.ESH/Classification/TypesRegistry.Definitions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Stanislav Kuzmich. All Rights Reserved.
// Copyright (c) "ESH-Repository" source code contributors. All Rights Reserved.
// Licensed under the Microsoft Public License (MS-PL).
// See License.txt in the project for license information.
// See LICENSE.md in the "ESH-Repository" root for license information.
// "ESH-Repository" root address: https://github.com/Art-Stea1th/Enhanced-Syntax-Highlighting

using System.ComponentModel.Composition;
using System.Windows.Media;
Expand Down Expand Up @@ -142,7 +143,6 @@ public FormatDefinition(string displayName, string defaultForegroundColor) : thi
ForegroundColor = (Color)ColorConverter
.ConvertFromString(defaultForegroundColor);
}

public FormatDefinition(string displayName) {
DisplayName = $"User Tags - {displayName}";
}
Expand Down
19 changes: 11 additions & 8 deletions Extension/ASD.ESH/Classification/TypesRegistry.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Stanislav Kuzmich. All Rights Reserved.
// Copyright (c) "ESH-Repository" source code contributors. All Rights Reserved.
// Licensed under the Microsoft Public License (MS-PL).
// See License.txt in the project for license information.
// See LICENSE.md in the "ESH-Repository" root for license information.
// "ESH-Repository" root address: https://github.com/Art-Stea1th/Enhanced-Syntax-Highlighting

using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Editing;
Expand All @@ -16,14 +17,16 @@ internal static partial class TypesRegistry {
private static readonly object token = new object();
private static IClassificationTypeRegistryService registryService = null;

public static void InitializeIfNeeded( IClassificationTypeRegistryService service ) {
if ( service == null )
throw new System.ArgumentNullException( nameof(service) );
public static void InitializeIfNeeded(IClassificationTypeRegistryService service) {

if ( registryService == null ) {
lock ( token ) {
if ( registryService == null )
if (service == null) {
throw new System.ArgumentNullException(nameof(service));
}
if (registryService == null) {
lock (token) {
if (registryService == null) {
registryService = service;
}
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions Extension/ASD.ESH/Helpers/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Stanislav Kuzmich. All Rights Reserved.
// Copyright (c) "ESH-Repository" source code contributors. All Rights Reserved.
// Licensed under the Microsoft Public License (MS-PL).
// See License.txt in the project for license information.
// See LICENSE.md in the "ESH-Repository" root for license information.
// "ESH-Repository" root address: https://github.com/Art-Stea1th/Enhanced-Syntax-Highlighting

using System.Collections.Generic;
using System.Threading;
Expand All @@ -16,5 +17,6 @@ internal static class Extensions {
public static Task<IEnumerable<ClassifiedSpan>> GetClassifiedSpansAsync(
this Document document, TextSpan textSpan, CancellationToken cancellationToken = default(CancellationToken))
=> Classifier.GetClassifiedSpansAsync(document, textSpan, cancellationToken);

}
}
8 changes: 4 additions & 4 deletions Extension/ASD.ESH/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Stanislav Kuzmich. All Rights Reserved.
// Copyright (c) "ESH-Repository" source code contributors. All Rights Reserved.
// Licensed under the Microsoft Public License (MS-PL).
// See License.txt in the project for license information.
// See LICENSE.md in the "ESH-Repository" root for license information.
// "ESH-Repository" root address: https://github.com/Art-Stea1th/Enhanced-Syntax-Highlighting

using System.Reflection;
using System.Runtime.InteropServices;
Expand All @@ -10,9 +11,8 @@

[assembly: AssemblyCompany("Art of Software Development")]
[assembly: AssemblyProduct("Enhanced Syntax Highlighting")]
[assembly: AssemblyCopyright("Copyright © Stanislav Kuzmich")]
[assembly: AssemblyCopyright("Copyright © \"ESH-Repository\" source code contributors. All Rights Reserved.")]
[assembly: AssemblyTrademark("ASD: Enhanced Syntax Highlighting")]

[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ To change the syntax highlighting settings just go to "**Tools**" > "**Options**

The syntax highlighting options for "**Classes**", "**Delegates**", "**Enums**", "**Interfaces**", "**Modules**", "**Structures**" and "**Type Parameters**" are just below, they have the prefix "**User Types - ...**" and are built-in default.

[![Releases](https://img.shields.io/badge/Releases-All-green.svg?style=flat-square&colorB=9FB861)](https://github.com/Art-Stea1th/Enhanced-Syntax-Highlighting/releases) [![v 1.2 build 6547 rev. 73](https://img.shields.io/badge/v%201.2%20build%206551%20rev.%2038038-Latest-green.svg?style=flat-square&colorB=9FB861)](https://github.com/Art-Stea1th/Enhanced-Syntax-Highlighting/releases/tag/1.2.6551.38038)
[![Releases](https://img.shields.io/badge/Releases-All-green.svg?style=flat-square&colorB=9FB861)](https://github.com/Art-Stea1th/Enhanced-Syntax-Highlighting/releases) [![v 1.2 build 6554 rev. 24807](https://img.shields.io/badge/v%201.2%20build%206554%20rev.%2024807-Latest-green.svg?style=flat-square&colorB=9FB861)](https://github.com/Art-Stea1th/Enhanced-Syntax-Highlighting/releases/tag/1.2.6554.24807)

0 comments on commit 986280d

Please sign in to comment.