Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 7 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ ClientBin/
*.build.csdef
csx/

# Temporarily exclude files generated by Script Analyzer build
PSLanguageService/Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll
PSLanguageService/Microsoft.Windows.PowerShell.ScriptAnalyzer.dll
PSLanguageService/PSScriptAnalyzer.psd1
PSLanguageService/ScriptAnalyzer.format.ps1xml
PSLanguageService/ScriptAnalyzer.types.ps1xml
# Don't include ScriptAnalyzer binaries
PowerShellEditorServices/Microsoft.Windows.PowerShell.ScriptAnalyzer.dll
PowerShellEditorServices/Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll
PowerShellEditorServices/PSScriptAnalyzer.psd1
PowerShellEditorServices/ScriptAnalyzer.format.ps1xml
PowerShellEditorServices/ScriptAnalyzer.types.ps1xml

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//


using Microsoft.PowerShell.EditorServices.Utility;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,23 @@
<Compile Include="Message\MessageWriter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Request\ChangeFileRequest.cs" />
<Compile Include="Request\CompletionDetailsRequest.cs" />
<Compile Include="Request\CompletionsRequest.cs" />
<Compile Include="Request\DeclarationRequest.cs" />
<Compile Include="Request\ErrorRequest.cs" />
<Compile Include="Request\FileRequest.cs" />
<Compile Include="Request\OccurrencesRequest.cs" />
<Compile Include="Request\OpenFileRequest.cs" />
<Compile Include="Request\ReferencesRequest.cs" />
<Compile Include="Request\ReplExecuteRequest.cs" />
<Compile Include="Request\RequestBase.cs" />
<Compile Include="Response\CompletionDetailsResponse.cs" />
<Compile Include="Response\DefinitionResponse.cs" />
<Compile Include="Response\LocationResponseElements.cs" />
<Compile Include="Response\OccurrencesResponse.cs" />
<Compile Include="Response\ReferencesResponse.cs" />
<Compile Include="Response\SignatureHelpResponse.cs" />
<Compile Include="Request\SignatureHelpRequest.cs" />
<Compile Include="Response\CompletionsResponse.cs" />
<Compile Include="Response\MessageErrorResponse.cs" />
<Compile Include="Response\ReplPromptChoiceResponse.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

using Microsoft.PowerShell.EditorServices.Language;
using Microsoft.PowerShell.EditorServices.Session;
using Microsoft.PowerShell.EditorServices.Transport.Stdio.Message;
using Microsoft.PowerShell.EditorServices.Transport.Stdio.Response;
using System.Collections.Generic;

namespace Microsoft.PowerShell.EditorServices.Transport.Stdio.Request
{
[MessageTypeName("completionEntryDetails")]
public class CompletionDetailsRequest : FileRequest<CompletionDetailsRequestArgs>
{
public override void ProcessMessage(
EditorSession editorSession,
MessageWriter messageWriter)
{
ScriptFile scriptFile = this.GetScriptFile(editorSession);

CompletionDetails completionDetails =
editorSession.LanguageService.GetCompletionDetailsInFile(
scriptFile,
this.Arguments.Line,
this.Arguments.Offset,
this.Arguments.EntryNames[0]);

var details = new List<CompletionEntryDetails>();
if (completionDetails != null)
{
details.Add(
new CompletionEntryDetails(completionDetails, this.Arguments.EntryNames[0]
));
messageWriter.WriteMessage(
this.PrepareResponse(
new CompletionDetailsResponse
{
Body = details.ToArray()
}));
}
else
{
messageWriter.WriteMessage(
this.PrepareResponse(
new CompletionDetailsResponse{
Body = details.ToArray()
}));
}
}
}

public class CompletionDetailsRequestArgs : FileLocationRequestArgs
{
public string[] EntryNames { get; set; }
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public override void ProcessMessage(
completions)));
}
}

public class CompletionsRequestArgs : FileLocationRequestArgs
{
public string Prefix { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

using Microsoft.PowerShell.EditorServices.Language;
using Microsoft.PowerShell.EditorServices.Session;
using Microsoft.PowerShell.EditorServices.Transport.Stdio.Message;
using Microsoft.PowerShell.EditorServices.Transport.Stdio.Response;

namespace Microsoft.PowerShell.EditorServices.Transport.Stdio.Request
{
[MessageTypeName("definition")]
public class DeclarationRequest : FileRequest<FileLocationRequestArgs>
{
public override void ProcessMessage(
EditorSession editorSession,
MessageWriter messageWriter)
{
ScriptFile scriptFile = this.GetScriptFile(editorSession);

GetDefinitionResult definition =
editorSession.LanguageService.GetDefinitionInFile(
scriptFile,
this.Arguments.Line,
this.Arguments.Offset);

if (definition != null)
{
DefinitionResponse defResponse =
DefinitionResponse.Create(definition.FoundDefinition, this.Arguments.File);

messageWriter.WriteMessage(
this.PrepareResponse(defResponse));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

using Microsoft.PowerShell.EditorServices.Language;
using Microsoft.PowerShell.EditorServices.Session;
using Microsoft.PowerShell.EditorServices.Transport.Stdio.Message;
using Microsoft.PowerShell.EditorServices.Transport.Stdio.Response;

namespace Microsoft.PowerShell.EditorServices.Transport.Stdio.Request
{
[MessageTypeName("occurrences")]
public class OccurrencesRequest : FileRequest<FileLocationRequestArgs>
{
public override void ProcessMessage(
EditorSession editorSession,
MessageWriter messageWriter)
{
ScriptFile scriptFile = this.GetScriptFile(editorSession);

FindOccurrencesResult occurrencesResult =
editorSession.LanguageService.FindOccurrencesInFile(
scriptFile,
this.Arguments.Line,
this.Arguments.Offset);

OccurrencesResponse occurrencesResponce =
OccurrencesResponse.Create(occurrencesResult, this.Arguments.File);

messageWriter.WriteMessage(
this.PrepareResponse(
occurrencesResponce));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using Microsoft.PowerShell.EditorServices.Session;
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

using Microsoft.PowerShell.EditorServices.Session;
using Microsoft.PowerShell.EditorServices.Transport.Stdio.Message;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Microsoft.PowerShell.EditorServices.Transport.Stdio.Request
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

using Microsoft.PowerShell.EditorServices.Language;
using Microsoft.PowerShell.EditorServices.Session;
using Microsoft.PowerShell.EditorServices.Transport.Stdio.Message;
using Microsoft.PowerShell.EditorServices.Transport.Stdio.Response;

namespace Microsoft.PowerShell.EditorServices.Transport.Stdio.Request
{
[MessageTypeName("references")]
public class ReferencesRequest : FileRequest<FileLocationRequestArgs>
{
public override void ProcessMessage(
EditorSession editorSession,
MessageWriter messageWriter)
{
ScriptFile scriptFile = this.GetScriptFile(editorSession);

FindReferencesResult referencesResult =
editorSession.LanguageService.FindReferencesInFile(
scriptFile,
this.Arguments.Line,
this.Arguments.Offset);

ReferencesResponse referencesResponse =
ReferencesResponse.Create(referencesResult, this.Arguments.File);

messageWriter.WriteMessage(
this.PrepareResponse(
referencesResponse));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

using Microsoft.PowerShell.EditorServices.Language;
using Microsoft.PowerShell.EditorServices.Session;
using Microsoft.PowerShell.EditorServices.Transport.Stdio.Message;
using Microsoft.PowerShell.EditorServices.Transport.Stdio.Response;

namespace Microsoft.PowerShell.EditorServices.Transport.Stdio.Request
{
[MessageTypeName("signatureHelp")]
public class SignatureHelpRequest : FileRequest<SignatureHelpRequestArgs>
{
public override void ProcessMessage(
EditorSession editorSession,
MessageWriter messageWriter)
{
ScriptFile scriptFile = this.GetScriptFile(editorSession);

ParameterSetSignatures parameterSetSigs =
editorSession.LanguageService.FindParameterSetsInFile(
scriptFile,
this.Arguments.Line,
this.Arguments.Offset);

SignatureHelpResponse sigHelpResponce =
SignatureHelpResponse.Create(parameterSetSigs);

messageWriter.WriteMessage(
this.PrepareResponse(
sigHelpResponce));
}
}

public class SignatureHelpRequestArgs : FileLocationRequestArgs
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

using Microsoft.PowerShell.EditorServices.Language;
using Microsoft.PowerShell.EditorServices.Transport.Stdio.Message;
using System.Text.RegularExpressions;

namespace Microsoft.PowerShell.EditorServices.Transport.Stdio.Response
{
[MessageTypeName("completionEntryDetails")]
public class CompletionDetailsResponse : ResponseBase<CompletionEntryDetails[]>
{
}

public class CompletionEntryDetails
{
public CompletionEntryDetails(CompletionDetails completionResult, string entryName)
{

Kind = null;
KindModifiers = null;
DisplayParts = null;
Documentation = null;
DocString = null;

// if the result type is a command return null
if (completionResult != null &&
!(completionResult.CompletionType.Equals(CompletionType.Command)))
{
//find matches on square brackets in the the tool tip
var matches =
Regex.Matches(completionResult.ToolTipText, @"^\[(.+)\]");
string strippedEntryName =
Regex.Replace(entryName, @"^[$_-]", "").Replace("{", "").Replace("}", "");

if (matches.Count > 0 && matches[0].Groups.Count > 1)
{
Name = matches[0].Groups[1].Value;
}
// if there are nobracets and the only content is the completion name
else if (completionResult.ToolTipText.Equals(strippedEntryName))
{
Name = null;
}
else
{
Name = null;
DocString = completionResult.ToolTipText;
}
}

else { Name = null; }
}
public string Name { get; set; }

public string Kind { get; set; }

public string KindModifiers { get; set; }

public SymbolDisplayPart[] DisplayParts { get; set; }

public SymbolDisplayPart[] Documentation { get; set; }

public string DocString { get; set; }

}

public class SymbolDisplayPart
{
public string Text { get; set; }

public string Kind { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,15 @@ private static string GetCompletionKind(CompletionType completionType)
}
}
}
public class CompletionEntry
{
public string Name { get; set; }

public string Kind { get; set; }

public string KindModifiers { get; set; }

public string SortText { get; set; }
}

}
Loading