Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Expose IsScript from CompileOps so IVT is not needed
  • Loading branch information
cartermp committed May 24, 2019
commit 65b20d2ce279c76e2db3fa07968ee924d22ce40b
2 changes: 2 additions & 0 deletions src/fsharp/service/service.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3383,3 +3383,5 @@ module PrettyNaming =
let QuoteIdentifierIfNeeded id = Lexhelp.Keywords.QuoteIdentifierIfNeeded id
let KeywordNames = Lexhelp.Keywords.keywordNames

module FSharpFileUtilities =
let isScriptFile (fileName: string) = CompileOps.IsScript fileName
3 changes: 3 additions & 0 deletions src/fsharp/service/service.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -766,3 +766,6 @@ module public PrettyNaming =
/// All the keywords in the F# language
val KeywordNames : string list

/// A set of helpers for dealing with F# files.
module FSharpFileUtilities =
val isScriptFile : string -> bool
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ open System.ComponentModel.Composition
open System.IO
open System.Linq
open Microsoft.CodeAnalysis
open FSharp.Compiler.CompileOps
open FSharp.Compiler.SourceCodeServices
open Microsoft.VisualStudio
open Microsoft.VisualStudio.FSharp.Editor
Expand Down Expand Up @@ -358,7 +357,7 @@ type internal FSharpProjectOptionsManager
let parsingOptions =
match reactor.TryGetCachedOptionsByProjectId(document.Project.Id) with
| Some (_, parsingOptions, _) -> parsingOptions
| _ -> { FSharpParsingOptions.Default with IsInteractive = IsScript document.Name }
| _ -> { FSharpParsingOptions.Default with IsInteractive = FSharpFileUtilities.isScriptFile document.Name }
CompilerEnvironment.GetCompilationDefinesForEditing parsingOptions

member this.TryGetOptionsByProject(project) =
Expand Down
6 changes: 3 additions & 3 deletions vsintegration/src/FSharp.PatternMatcher/SpellChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ internal class SpellChecker
{
private const string SerializationFormat = "2";

public VersionStamp Version { get; }
public PatternMatcherVersionStamp Version { get; }
private readonly BKTree _bkTree;

public SpellChecker(VersionStamp version, BKTree bKTree)
public SpellChecker(PatternMatcherVersionStamp version, BKTree bKTree)
{
Version = version;
_bkTree = bKTree;
}

public SpellChecker(VersionStamp version, IEnumerable<StringSlice> corpus)
public SpellChecker(PatternMatcherVersionStamp version, IEnumerable<StringSlice> corpus)
: this(version, BKTree.Create(corpus))
{
}
Expand Down
48 changes: 24 additions & 24 deletions vsintegration/src/FSharp.PatternMatcher/VersionStamp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ namespace Microsoft.CodeAnalysis
/// <summary>
/// VersionStamp should be only used to compare versions returned by same API.
/// </summary>
internal struct VersionStamp : IEquatable<VersionStamp>, IObjectWritable
internal struct PatternMatcherVersionStamp : IEquatable<PatternMatcherVersionStamp>, IObjectWritable
{
public static VersionStamp Default => default(VersionStamp);
public static PatternMatcherVersionStamp Default => default(PatternMatcherVersionStamp);

private const int GlobalVersionMarker = -1;
private const int InitialGlobalVersion = 10000;
Expand All @@ -36,19 +36,19 @@ internal struct VersionStamp : IEquatable<VersionStamp>, IObjectWritable
/// </summary>
private readonly int _globalIncrement;

private VersionStamp(DateTime utcLastModified)
private PatternMatcherVersionStamp(DateTime utcLastModified)
: this(utcLastModified, 0)
{
}

private VersionStamp(DateTime utcLastModified, int localIncrement)
private PatternMatcherVersionStamp(DateTime utcLastModified, int localIncrement)
{
_utcLastModified = utcLastModified;
_localIncrement = localIncrement;
_globalIncrement = GetNextGlobalVersion();
}

private VersionStamp(DateTime utcLastModified, int localIncrement, int globalIncrement)
private PatternMatcherVersionStamp(DateTime utcLastModified, int localIncrement, int globalIncrement)
{
_utcLastModified = utcLastModified;
_localIncrement = localIncrement;
Expand All @@ -58,24 +58,24 @@ private VersionStamp(DateTime utcLastModified, int localIncrement, int globalInc
/// <summary>
/// Creates a new instance of a VersionStamp.
/// </summary>
public static VersionStamp Create()
public static PatternMatcherVersionStamp Create()
{
return new VersionStamp(DateTime.UtcNow);
return new PatternMatcherVersionStamp(DateTime.UtcNow);
}

/// <summary>
/// Creates a new instance of a version stamp based on the specified DateTime.
/// </summary>
public static VersionStamp Create(DateTime utcTimeLastModified)
public static PatternMatcherVersionStamp Create(DateTime utcTimeLastModified)
{
return new VersionStamp(utcTimeLastModified);
return new PatternMatcherVersionStamp(utcTimeLastModified);
}

/// <summary>
/// compare two different versions and return either one of the versions if there is no collision, otherwise, create a new version
/// that can be used later to compare versions between different items
/// </summary>
public VersionStamp GetNewerVersion(VersionStamp version)
public PatternMatcherVersionStamp GetNewerVersion(PatternMatcherVersionStamp version)
{
// * NOTE *
// in current design/implementation, there are 4 possible ways for a version to be created.
Expand Down Expand Up @@ -106,7 +106,7 @@ public VersionStamp GetNewerVersion(VersionStamp version)

// mark it as global version
// global version can't be moved to newer version.
return new VersionStamp(_utcLastModified, (thisGlobalVersion > thatGlobalVersion) ? thisGlobalVersion : thatGlobalVersion, GlobalVersionMarker);
return new PatternMatcherVersionStamp(_utcLastModified, (thisGlobalVersion > thatGlobalVersion) ? thisGlobalVersion : thatGlobalVersion, GlobalVersionMarker);
}

return version;
Expand All @@ -116,15 +116,15 @@ public VersionStamp GetNewerVersion(VersionStamp version)
/// Gets a new VersionStamp that is guaranteed to be newer than its base one
/// this should only be used for same item to move it to newer version
/// </summary>
public VersionStamp GetNewerVersion()
public PatternMatcherVersionStamp GetNewerVersion()
{
// global version can't be moved to newer version
Contract.Requires(_globalIncrement != GlobalVersionMarker);

var now = DateTime.UtcNow;
var incr = (now == _utcLastModified) ? _localIncrement + 1 : 0;

return new VersionStamp(now, incr);
return new PatternMatcherVersionStamp(now, incr);
}

/// <summary>
Expand All @@ -143,15 +143,15 @@ public override int GetHashCode()

public override bool Equals(object obj)
{
if (obj is VersionStamp)
if (obj is PatternMatcherVersionStamp)
{
return this.Equals((VersionStamp)obj);
return this.Equals((PatternMatcherVersionStamp)obj);
}

return false;
}

public bool Equals(VersionStamp version)
public bool Equals(PatternMatcherVersionStamp version)
{
if (_utcLastModified == version._utcLastModified)
{
Expand All @@ -161,20 +161,20 @@ public bool Equals(VersionStamp version)
return false;
}

public static bool operator ==(VersionStamp left, VersionStamp right)
public static bool operator ==(PatternMatcherVersionStamp left, PatternMatcherVersionStamp right)
{
return left.Equals(right);
}

public static bool operator !=(VersionStamp left, VersionStamp right)
public static bool operator !=(PatternMatcherVersionStamp left, PatternMatcherVersionStamp right)
{
return !left.Equals(right);
}

/// <summary>
/// check whether given persisted version is re-usable
/// </summary>
internal static bool CanReusePersistedVersion(VersionStamp baseVersion, VersionStamp persistedVersion)
internal static bool CanReusePersistedVersion(PatternMatcherVersionStamp baseVersion, PatternMatcherVersionStamp persistedVersion)
{
if (baseVersion == persistedVersion)
{
Expand Down Expand Up @@ -202,16 +202,16 @@ internal void WriteTo(ObjectWriter writer)
writer.WriteInt32(_globalIncrement);
}

internal static VersionStamp ReadFrom(ObjectReader reader)
internal static PatternMatcherVersionStamp ReadFrom(ObjectReader reader)
{
var raw = reader.ReadInt64();
var localIncrement = reader.ReadInt32();
var globalIncrement = reader.ReadInt32();

return new VersionStamp(DateTime.FromBinary(raw), localIncrement, globalIncrement);
return new PatternMatcherVersionStamp(DateTime.FromBinary(raw), localIncrement, globalIncrement);
}

private static int GetGlobalVersion(VersionStamp version)
private static int GetGlobalVersion(PatternMatcherVersionStamp version)
{
// global increment < 0 means it is a global version which has its global increment in local increment
return version._globalIncrement >= 0 ? version._globalIncrement : version._localIncrement;
Expand All @@ -227,15 +227,15 @@ private static int GetNextGlobalVersion()

// this will let versions to be compared safely between multiple items
// without worrying about collision within same session
var globalVersion = Interlocked.Increment(ref VersionStamp.s_globalVersion);
var globalVersion = Interlocked.Increment(ref PatternMatcherVersionStamp.s_globalVersion);

return globalVersion;
}

/// <summary>
/// True if this VersionStamp is newer than the specified one.
/// </summary>
internal bool TestOnly_IsNewerThan(VersionStamp version)
internal bool TestOnly_IsNewerThan(PatternMatcherVersionStamp version)
{
if (_utcLastModified > version._utcLastModified)
{
Expand Down