51 changed files with 779 additions and 4950 deletions
@ -0,0 +1,7 @@ |
|||||||
|
' Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) |
||||||
|
' This code is distributed under the GNU LGPL (for details please see \doc\license.txt) |
||||||
|
|
||||||
|
Public Enum CompareKind |
||||||
|
Binary |
||||||
|
Text |
||||||
|
End Enum |
||||||
@ -1,18 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System.Reflection; |
|
||||||
using System.Runtime.CompilerServices; |
|
||||||
|
|
||||||
// Information about this assembly is defined by the following
|
|
||||||
// attributes.
|
|
||||||
//
|
|
||||||
// change them to the information which is associated with the assembly
|
|
||||||
// you compile.
|
|
||||||
|
|
||||||
[assembly: AssemblyTitle("VB.NET Binding")] |
|
||||||
[assembly: AssemblyDescription("VB.NET language binding for #develop")] |
|
||||||
[assembly: AssemblyConfiguration("")] |
|
||||||
[assembly: AssemblyTrademark("")] |
|
||||||
[assembly: AssemblyCulture("")] |
|
||||||
[assembly: InternalsVisibleTo("ICSharpCode.VBNetBinding.Tests")] |
|
||||||
@ -0,0 +1,18 @@ |
|||||||
|
' Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) |
||||||
|
' This code is distributed under the GNU LGPL (for details please see \doc\license.txt) |
||||||
|
|
||||||
|
Imports System.Reflection |
||||||
|
Imports System.Runtime.CompilerServices |
||||||
|
|
||||||
|
' Information about this assembly is defined by the following |
||||||
|
' attributes. |
||||||
|
' |
||||||
|
' change them to the information which is associated with the assembly |
||||||
|
' you compile. |
||||||
|
|
||||||
|
<Assembly: AssemblyTitle("VB.NET Binding")> |
||||||
|
<Assembly: AssemblyDescription("VB.NET language binding for #develop")> |
||||||
|
<Assembly: AssemblyConfiguration("")> |
||||||
|
<Assembly: AssemblyTrademark("")> |
||||||
|
<Assembly: AssemblyCulture("")> |
||||||
|
<Assembly: InternalsVisibleTo("ICSharpCode.VBNetBinding.Tests")> |
||||||
@ -0,0 +1,153 @@ |
|||||||
|
' Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) |
||||||
|
' This code is distributed under the GNU LGPL (for details please see \doc\license.txt) |
||||||
|
|
||||||
|
Imports System.Collections.Generic |
||||||
|
Imports ICSharpCode.SharpDevelop.Gui.OptionPanels |
||||||
|
Imports ICSharpCode.SharpDevelop.Project |
||||||
|
|
||||||
|
Namespace OptionPanels |
||||||
|
''' <summary> |
||||||
|
''' Interaction logic for BuildOptionsXaml.xaml |
||||||
|
''' </summary> |
||||||
|
Public Partial Class BuildOptions |
||||||
|
Inherits ProjectOptionPanel |
||||||
|
Public Sub New() |
||||||
|
InitializeComponent() |
||||||
|
DataContext = Me |
||||||
|
|
||||||
|
|
||||||
|
m_optionExplicitItems = New List(Of KeyItemPair)() |
||||||
|
m_optionExplicitItems.Add(New KeyItemPair("Off", "Explicit Off")) |
||||||
|
m_optionExplicitItems.Add(New KeyItemPair("On", "Explicit On")) |
||||||
|
OptionExplicitItems = m_optionExplicitItems |
||||||
|
|
||||||
|
m_optionStrictItems = New List(Of KeyItemPair)() |
||||||
|
m_optionStrictItems.Add(New KeyItemPair("Off", "Strict Off")) |
||||||
|
m_optionStrictItems.Add(New KeyItemPair("On", "Strict On")) |
||||||
|
OptionStrictItems = m_optionStrictItems |
||||||
|
|
||||||
|
|
||||||
|
m_optionCompareItems = New List(Of KeyItemPair)() |
||||||
|
m_optionCompareItems.Add(New KeyItemPair("Binary", "Compare Binary")) |
||||||
|
m_optionCompareItems.Add(New KeyItemPair("Text", "Compare Text")) |
||||||
|
OptionCompareItems = m_optionCompareItems |
||||||
|
|
||||||
|
m_optionInferItems = New List(Of KeyItemPair)() |
||||||
|
m_optionInferItems.Add(New KeyItemPair("Off", "Infer Off")) |
||||||
|
m_optionInferItems.Add(New KeyItemPair("On", "Infer On")) |
||||||
|
OptionInferItems = m_optionInferItems |
||||||
|
End Sub |
||||||
|
|
||||||
|
|
||||||
|
Public ReadOnly Property DefineConstants() As ProjectProperty(Of String) |
||||||
|
Get |
||||||
|
Return GetProperty("DefineConstants", "", TextBoxEditMode.EditRawProperty) |
||||||
|
End Get |
||||||
|
End Property |
||||||
|
|
||||||
|
Public ReadOnly Property Optimize() As ProjectProperty(Of Boolean) |
||||||
|
Get |
||||||
|
Return GetProperty("Optimize", False, PropertyStorageLocations.ConfigurationSpecific) |
||||||
|
End Get |
||||||
|
End Property |
||||||
|
|
||||||
|
Public ReadOnly Property RemoveIntegerChecks() As ProjectProperty(Of String) |
||||||
|
Get |
||||||
|
Return GetProperty("RemoveIntegerChecks", "", TextBoxEditMode.EditRawProperty) |
||||||
|
End Get |
||||||
|
End Property |
||||||
|
|
||||||
|
Public ReadOnly Property OptionExplicit() As ProjectProperty(Of String) |
||||||
|
Get |
||||||
|
Return GetProperty("OptionExplicit", "", TextBoxEditMode.EditRawProperty) |
||||||
|
End Get |
||||||
|
End Property |
||||||
|
|
||||||
|
Public ReadOnly Property OptionStrict() As ProjectProperty(Of String) |
||||||
|
Get |
||||||
|
Return GetProperty("OptionStrict", "Off", TextBoxEditMode.EditRawProperty) |
||||||
|
End Get |
||||||
|
End Property |
||||||
|
|
||||||
|
Public ReadOnly Property OptionCompare() As ProjectProperty(Of String) |
||||||
|
Get |
||||||
|
Return GetProperty("OptionCompare", "Binary", TextBoxEditMode.EditRawProperty) |
||||||
|
End Get |
||||||
|
End Property |
||||||
|
|
||||||
|
Public ReadOnly Property OptionInfer() As ProjectProperty(Of String) |
||||||
|
Get |
||||||
|
Return GetProperty("OptionInfer", "Off", TextBoxEditMode.EditRawProperty) |
||||||
|
End Get |
||||||
|
End Property |
||||||
|
|
||||||
|
|
||||||
|
#Region "OptionItems" |
||||||
|
|
||||||
|
Private m_optionExplicitItems As List(Of KeyItemPair) |
||||||
|
|
||||||
|
Public Property OptionExplicitItems() As List(Of KeyItemPair) |
||||||
|
Get |
||||||
|
Return m_optionExplicitItems |
||||||
|
End Get |
||||||
|
Set |
||||||
|
m_optionExplicitItems = value |
||||||
|
MyBase.RaisePropertyChanged(Function() OptionExplicitItems) |
||||||
|
End Set |
||||||
|
End Property |
||||||
|
|
||||||
|
|
||||||
|
Private m_optionStrictItems As List(Of KeyItemPair) |
||||||
|
|
||||||
|
Public Property OptionStrictItems() As List(Of KeyItemPair) |
||||||
|
Get |
||||||
|
Return m_optionStrictItems |
||||||
|
End Get |
||||||
|
Set |
||||||
|
m_optionStrictItems = value |
||||||
|
MyBase.RaisePropertyChanged(Function() OptionStrictItems) |
||||||
|
End Set |
||||||
|
End Property |
||||||
|
|
||||||
|
|
||||||
|
Private m_optionCompareItems As List(Of KeyItemPair) |
||||||
|
|
||||||
|
Public Property OptionCompareItems() As List(Of KeyItemPair) |
||||||
|
Get |
||||||
|
Return m_optionCompareItems |
||||||
|
End Get |
||||||
|
Set |
||||||
|
m_optionCompareItems = value |
||||||
|
MyBase.RaisePropertyChanged(Function() OptionCompareItems) |
||||||
|
End Set |
||||||
|
End Property |
||||||
|
|
||||||
|
|
||||||
|
Private m_optionInferItems As List(Of KeyItemPair) |
||||||
|
|
||||||
|
Public Property OptionInferItems() As List(Of KeyItemPair) |
||||||
|
Get |
||||||
|
Return m_optionInferItems |
||||||
|
End Get |
||||||
|
Set |
||||||
|
m_optionInferItems = value |
||||||
|
MyBase.RaisePropertyChanged(Function() OptionInferItems) |
||||||
|
End Set |
||||||
|
End Property |
||||||
|
|
||||||
|
|
||||||
|
#End Region |
||||||
|
|
||||||
|
#Region "overrides" |
||||||
|
|
||||||
|
|
||||||
|
Protected Overrides Sub Initialize() |
||||||
|
MyBase.Initialize() |
||||||
|
buildOutput.Initialize(Me) |
||||||
|
Me.buildAdvanced.Initialize(Me) |
||||||
|
Me.errorsAndWarnings.Initialize(Me) |
||||||
|
Me.treatErrorsAndWarnings.Initialize(Me) |
||||||
|
End Sub |
||||||
|
#End Region |
||||||
|
End Class |
||||||
|
End Namespace |
||||||
@ -1,6 +1,6 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
<?xml version="1.0" encoding="utf-8"?> |
||||||
<optionpanels:ProjectOptionPanel |
<optionpanels:ProjectOptionPanel |
||||||
x:Class="ICSharpCode.VBNetBinding.OptionPanels.ProjectImports" |
x:Class="ProjectImports" |
||||||
xmlns:optionpanels="clr-namespace:ICSharpCode.SharpDevelop.Gui.OptionPanels;assembly=ICSharpCode.SharpDevelop" |
xmlns:optionpanels="clr-namespace:ICSharpCode.SharpDevelop.Gui.OptionPanels;assembly=ICSharpCode.SharpDevelop" |
||||||
xmlns:core="http://icsharpcode.net/sharpdevelop/core" |
xmlns:core="http://icsharpcode.net/sharpdevelop/core" |
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||||
@ -0,0 +1,177 @@ |
|||||||
|
' Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) |
||||||
|
' This code is distributed under the GNU LGPL (for details please see \doc\license.txt) |
||||||
|
|
||||||
|
Imports System.Collections.Generic |
||||||
|
Imports System.Collections.ObjectModel |
||||||
|
Imports System.Text |
||||||
|
Imports System.Windows |
||||||
|
Imports System.Windows.Controls |
||||||
|
Imports System.Windows.Data |
||||||
|
Imports System.Windows.Documents |
||||||
|
Imports System.Windows.Input |
||||||
|
Imports System.Windows.Media |
||||||
|
Imports System.Linq |
||||||
|
Imports ICSharpCode.SharpDevelop |
||||||
|
Imports ICSharpCode.SharpDevelop.Dom |
||||||
|
Imports ICSharpCode.SharpDevelop.Gui |
||||||
|
Imports ICSharpCode.SharpDevelop.Gui.OptionPanels |
||||||
|
Imports ICSharpCode.SharpDevelop.Project |
||||||
|
|
||||||
|
Namespace OptionPanels |
||||||
|
''' <summary> |
||||||
|
''' Interaction logic for ProjectImportsOptions.xaml |
||||||
|
''' </summary> |
||||||
|
Public Partial Class ProjectImports |
||||||
|
Inherits ProjectOptionPanel |
||||||
|
|
||||||
|
Public Sub New() |
||||||
|
InitializeComponent() |
||||||
|
End Sub |
||||||
|
|
||||||
|
#Region "override" |
||||||
|
|
||||||
|
Protected Overrides Sub Initialize() |
||||||
|
ProjectItems = New ObservableCollection(Of String)() |
||||||
|
NameSpaceItems = New ObservableCollection(Of String)() |
||||||
|
|
||||||
|
For Each item As ProjectItem In MyBase.Project.Items |
||||||
|
If item.ItemType = ItemType.Import Then |
||||||
|
ProjectItems.Add(item.Include) |
||||||
|
End If |
||||||
|
Next |
||||||
|
|
||||||
|
|
||||||
|
Dim projectContent As IProjectContent = ParserService.GetProjectContent(MyBase.Project) |
||||||
|
For Each refProjectContent As IProjectContent In projectContent.ThreadSafeGetReferencedContents() |
||||||
|
AddNamespaces(refProjectContent) |
||||||
|
Next |
||||||
|
AddNamespaces(projectContent) |
||||||
|
End Sub |
||||||
|
|
||||||
|
|
||||||
|
Protected Overrides Function Save(project As MSBuildBasedProject, configuration As String, platform As String) As Boolean |
||||||
|
Dim [imports] As New List(Of ProjectItem)() |
||||||
|
For Each item As ProjectItem In project.Items |
||||||
|
If item.ItemType = ItemType.Import Then |
||||||
|
[imports].Add(item) |
||||||
|
End If |
||||||
|
Next |
||||||
|
|
||||||
|
For Each item As ImportProjectItem In [imports] |
||||||
|
ProjectService.RemoveProjectItem(project, item) |
||||||
|
Next |
||||||
|
|
||||||
|
For Each importedNamespace As String In ProjectItems |
||||||
|
ProjectService.AddProjectItem(project, New ImportProjectItem(project, importedNamespace)) |
||||||
|
Next |
||||||
|
|
||||||
|
Return MyBase.Save(project, configuration, platform) |
||||||
|
End Function |
||||||
|
|
||||||
|
#End Region |
||||||
|
|
||||||
|
|
||||||
|
Private m_projectItems As ObservableCollection(Of String) |
||||||
|
|
||||||
|
Public Property ProjectItems() As ObservableCollection(Of String) |
||||||
|
Get |
||||||
|
Return m_projectItems |
||||||
|
End Get |
||||||
|
Set |
||||||
|
m_projectItems = value |
||||||
|
MyBase.RaisePropertyChanged(Function() ProjectItems) |
||||||
|
End Set |
||||||
|
End Property |
||||||
|
|
||||||
|
Private m_selectedProjectItem As String |
||||||
|
|
||||||
|
Public Property SelectedProjectItem() As String |
||||||
|
Get |
||||||
|
Return m_selectedProjectItem |
||||||
|
End Get |
||||||
|
Set |
||||||
|
m_selectedProjectItem = value |
||||||
|
MyBase.RaisePropertyChanged(Function() SelectedProjectItem) |
||||||
|
RemoveButtonEnable = True |
||||||
|
AddButtonEnable = False |
||||||
|
End Set |
||||||
|
End Property |
||||||
|
|
||||||
|
Private m_nameSpaceItems As ObservableCollection(Of String) |
||||||
|
|
||||||
|
Public Property NameSpaceItems() As ObservableCollection(Of String) |
||||||
|
Get |
||||||
|
Return m_nameSpaceItems |
||||||
|
End Get |
||||||
|
Set |
||||||
|
m_nameSpaceItems = value |
||||||
|
MyBase.RaisePropertyChanged(Function() NameSpaceItems) |
||||||
|
End Set |
||||||
|
End Property |
||||||
|
|
||||||
|
|
||||||
|
Private m_selectedNameSpace As String |
||||||
|
|
||||||
|
Public Property SelectedNameSpace() As String |
||||||
|
Get |
||||||
|
Return m_selectedNameSpace |
||||||
|
End Get |
||||||
|
Set |
||||||
|
m_selectedNameSpace = value |
||||||
|
MyBase.RaisePropertyChanged(Function() SelectedNameSpace) |
||||||
|
AddButtonEnable = True |
||||||
|
End Set |
||||||
|
End Property |
||||||
|
|
||||||
|
|
||||||
|
Private m_addButtonEnable As Boolean |
||||||
|
|
||||||
|
Public Property AddButtonEnable() As Boolean |
||||||
|
Get |
||||||
|
Return m_addButtonEnable |
||||||
|
End Get |
||||||
|
Set |
||||||
|
m_addButtonEnable = value |
||||||
|
MyBase.RaisePropertyChanged(Function() AddButtonEnable) |
||||||
|
End Set |
||||||
|
End Property |
||||||
|
|
||||||
|
Private m_removeButtonEnable As Boolean |
||||||
|
|
||||||
|
Public Property RemoveButtonEnable() As Boolean |
||||||
|
Get |
||||||
|
Return m_removeButtonEnable |
||||||
|
End Get |
||||||
|
Set |
||||||
|
m_removeButtonEnable = value |
||||||
|
MyBase.RaisePropertyChanged(Function() RemoveButtonEnable) |
||||||
|
End Set |
||||||
|
End Property |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Private Sub AddNamespaces(projectContent As IProjectContent) |
||||||
|
For Each projectNamespace As String In projectContent.NamespaceNames |
||||||
|
If Not String.IsNullOrEmpty(projectNamespace) Then |
||||||
|
|
||||||
|
If Not NameSpaceItems.Contains(projectNamespace) Then |
||||||
|
NameSpaceItems.Add(projectNamespace) |
||||||
|
End If |
||||||
|
End If |
||||||
|
Next |
||||||
|
End Sub |
||||||
|
|
||||||
|
Private Sub AddButton_Click(sender As Object, e As RoutedEventArgs) |
||||||
|
ProjectItems.Add(SelectedNameSpace) |
||||||
|
IsDirty = True |
||||||
|
End Sub |
||||||
|
|
||||||
|
Private Sub RemoveButton_Click(sender As Object, e As RoutedEventArgs) |
||||||
|
ProjectItems.Remove(SelectedProjectItem) |
||||||
|
SelectedProjectItem = Nothing |
||||||
|
RemoveButtonEnable = False |
||||||
|
AddButtonEnable = False |
||||||
|
IsDirty = True |
||||||
|
End Sub |
||||||
|
End Class |
||||||
|
End Namespace |
||||||
@ -1,4 +1,4 @@ |
|||||||
<gui:OptionPanel x:Class="ICSharpCode.VBNetBinding.OptionPanels.TextEditorOptions" |
<gui:OptionPanel x:Class="TextEditorOptions" |
||||||
xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop" |
xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop" |
||||||
xmlns:addin="clr-namespace:ICSharpCode.VBNetBinding.OptionPanels" |
xmlns:addin="clr-namespace:ICSharpCode.VBNetBinding.OptionPanels" |
||||||
xmlns:sd="http://icsharpcode.net/sharpdevelop/core" |
xmlns:sd="http://icsharpcode.net/sharpdevelop/core" |
||||||
@ -0,0 +1,41 @@ |
|||||||
|
' Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) |
||||||
|
' This code is distributed under the GNU LGPL (for details please see \doc\license.txt) |
||||||
|
|
||||||
|
Imports System.Collections.Generic |
||||||
|
Imports System.Text |
||||||
|
Imports System.Windows |
||||||
|
Imports System.Windows.Controls |
||||||
|
Imports System.Windows.Data |
||||||
|
Imports System.Windows.Documents |
||||||
|
Imports System.Windows.Input |
||||||
|
Imports System.Windows.Media |
||||||
|
Imports ICSharpCode.Core |
||||||
|
|
||||||
|
Namespace OptionPanels |
||||||
|
''' <summary> |
||||||
|
''' Interaction logic for TextEditorOptions.xaml |
||||||
|
''' </summary> |
||||||
|
Public Partial Class TextEditorOptions |
||||||
|
Public Sub New() |
||||||
|
InitializeComponent() |
||||||
|
End Sub |
||||||
|
|
||||||
|
Public Shared Property EnableEndConstructs() As Boolean |
||||||
|
Get |
||||||
|
Return PropertyService.[Get]("VBBinding.TextEditor.EnableEndConstructs", True) |
||||||
|
End Get |
||||||
|
Set |
||||||
|
PropertyService.[Set]("VBBinding.TextEditor.EnableEndConstructs", value) |
||||||
|
End Set |
||||||
|
End Property |
||||||
|
|
||||||
|
Public Shared Property EnableCasing() As Boolean |
||||||
|
Get |
||||||
|
Return PropertyService.[Get]("VBBinding.TextEditor.EnableCasing", True) |
||||||
|
End Get |
||||||
|
Set |
||||||
|
PropertyService.[Set]("VBBinding.TextEditor.EnableCasing", value) |
||||||
|
End Set |
||||||
|
End Property |
||||||
|
End Class |
||||||
|
End Namespace |
||||||
@ -0,0 +1,11 @@ |
|||||||
|
This version of the VB binding contains following features: |
||||||
|
|
||||||
|
- Basic support for compilation and the project format |
||||||
|
|
||||||
|
If you want to help us with VB support, please contact us in our community |
||||||
|
forums on http://community.sharpdevelop.net/ or submit pull requests to our |
||||||
|
github repository on https://github.com/icsharpcode/SharpDevelop/. |
||||||
|
|
||||||
|
Skills required for future development: |
||||||
|
- Knowledge of VB |
||||||
|
- Knowledge of parsers, internals of IDEs and debuggers |
||||||
@ -1,256 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Linq; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.NRefactory.Parser.VB; |
|
||||||
using ICSharpCode.SharpDevelop; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver; |
|
||||||
using ICSharpCode.SharpDevelop.Editor; |
|
||||||
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding |
|
||||||
{ |
|
||||||
public static class CompletionDataHelper |
|
||||||
{ |
|
||||||
public static VBNetCompletionItemList GenerateCompletionData(this ExpressionResult expressionResult, ITextEditor editor, char pressedKey) |
|
||||||
{ |
|
||||||
VBNetCompletionItemList result = new VBNetCompletionItemList(); |
|
||||||
|
|
||||||
IResolver resolver = ParserService.CreateResolver(editor.FileName); |
|
||||||
ParseInformation info = ParserService.GetParseInformation(editor.FileName); |
|
||||||
|
|
||||||
if (info == null) |
|
||||||
return result; |
|
||||||
|
|
||||||
List<ICompletionEntry> data = new List<ICompletionEntry>(); |
|
||||||
|
|
||||||
bool completingDotExpression = false; |
|
||||||
IReturnType resolvedType = null; |
|
||||||
|
|
||||||
if (expressionResult.Context != ExpressionContext.Global && expressionResult.Context != ExpressionContext.TypeDeclaration) { |
|
||||||
if (expressionResult.Context == ExpressionContext.Importable |
|
||||||
&& string.IsNullOrWhiteSpace(expressionResult.Expression)) { |
|
||||||
expressionResult.Expression = "Global"; |
|
||||||
} else if (pressedKey == '\0') { |
|
||||||
int idx = string.IsNullOrWhiteSpace(expressionResult.Expression) |
|
||||||
? -1 |
|
||||||
: expressionResult.Expression.LastIndexOf('.'); |
|
||||||
|
|
||||||
if (idx > -1) { |
|
||||||
expressionResult.Expression = expressionResult.Expression.Substring(0, idx); |
|
||||||
// its the same as if . was pressed
|
|
||||||
completingDotExpression = true; |
|
||||||
} else { |
|
||||||
expressionResult.Expression = ""; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
var rr = resolver.Resolve(expressionResult, info, editor.Document.Text); |
|
||||||
|
|
||||||
if (rr == null || !rr.IsValid || (pressedKey != '.' && !completingDotExpression)) { |
|
||||||
if (((BitArray)expressionResult.Tag)[Tokens.Identifier]) |
|
||||||
data = new NRefactoryResolver(LanguageProperties.VBNet) |
|
||||||
.CtrlSpace(editor.Caret.Line, editor.Caret.Column, info, editor.Document.Text, expressionResult.Context, |
|
||||||
((NRefactoryCompletionItemList)result).ContainsItemsFromAllNamespaces); |
|
||||||
} else { |
|
||||||
if (rr is MethodGroupResolveResult) { |
|
||||||
IMethod singleMethod = ((MethodGroupResolveResult)rr).GetMethodWithEmptyParameterList(); |
|
||||||
if (singleMethod != null) |
|
||||||
rr = new MemberResolveResult(rr.CallingClass, rr.CallingMember, singleMethod); |
|
||||||
} |
|
||||||
|
|
||||||
if (rr is IntegerLiteralResolveResult && pressedKey == '.') |
|
||||||
return result; |
|
||||||
|
|
||||||
data = rr.GetCompletionData(info.CompilationUnit.ProjectContent, ((NRefactoryCompletionItemList)result).ContainsItemsFromAllNamespaces) ?? new List<ICompletionEntry>(); |
|
||||||
|
|
||||||
resolvedType = rr.ResolvedType; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
bool addedKeywords = false; |
|
||||||
|
|
||||||
if (expressionResult.Tag != null && (expressionResult.Context != ExpressionContext.Importable) && pressedKey != '.' && !completingDotExpression) { |
|
||||||
AddVBNetKeywords(data, (BitArray)expressionResult.Tag); |
|
||||||
addedKeywords = true; |
|
||||||
} |
|
||||||
|
|
||||||
CodeCompletionItemProvider.ConvertCompletionData(result, data, expressionResult.Context); |
|
||||||
|
|
||||||
if (addedKeywords && result.Items.Any()) |
|
||||||
AddTemplates(editor, result); |
|
||||||
|
|
||||||
string word = editor.GetWordBeforeCaret().Trim(); |
|
||||||
|
|
||||||
IClass c = GetCurrentClass(editor); |
|
||||||
IMember m = GetCurrentMember(editor); |
|
||||||
|
|
||||||
HandleKeyword(ref result, resolvedType, word, c, m, editor, pressedKey); |
|
||||||
|
|
||||||
AddSpecialItems(ref result, info, resolvedType, m, expressionResult, editor); |
|
||||||
|
|
||||||
char prevChar; |
|
||||||
|
|
||||||
if (pressedKey == '\0') { // ctrl+space
|
|
||||||
prevChar = editor.Caret.Offset > 0 ? editor.Document.GetCharAt(editor.Caret.Offset - 1) : '\0'; |
|
||||||
word = char.IsLetterOrDigit(prevChar) || prevChar == '_' ? editor.GetWordBeforeCaret() : ""; |
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(word)) |
|
||||||
result.PreselectionLength = word.Length; |
|
||||||
} |
|
||||||
|
|
||||||
prevChar = editor.Caret.Offset > 0 ? editor.Document.GetCharAt(editor.Caret.Offset - 1) : '\0'; |
|
||||||
|
|
||||||
if (prevChar == '_') |
|
||||||
result.PreselectionLength++; |
|
||||||
|
|
||||||
result.SortItems(); |
|
||||||
|
|
||||||
return result; |
|
||||||
} |
|
||||||
|
|
||||||
static void HandleKeyword(ref VBNetCompletionItemList result, IReturnType resolvedType, string word, IClass c, IMember m, ITextEditor editor, char pressedKey) |
|
||||||
{ |
|
||||||
if (pressedKey == ' ') { |
|
||||||
if (word.Equals("return", StringComparison.OrdinalIgnoreCase) && m != null) { |
|
||||||
c = m.ReturnType != null ? m.ReturnType.GetUnderlyingClass() : null; |
|
||||||
if (c != null) { |
|
||||||
foreach (CodeCompletionItem item in result.Items.OfType<CodeCompletionItem>()) { |
|
||||||
IClass itemClass = item.Entity as IClass; |
|
||||||
if (itemClass != null && c.FullyQualifiedName == itemClass.FullyQualifiedName && c.TypeParameters.Count == itemClass.TypeParameters.Count) { |
|
||||||
result.SuggestedItem = item; |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
if (word.Equals("overrides", StringComparison.OrdinalIgnoreCase) && c != null) { |
|
||||||
result = new OverrideCompletionItemProvider().GenerateCompletionList(editor).ToVBCCList(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
static void AddSpecialItems(ref VBNetCompletionItemList result, ParseInformation info, IReturnType resolvedType, IMember m, ExpressionResult expressionResult, ITextEditor editor) |
|
||||||
{ |
|
||||||
if (expressionResult.Context == ExpressionContext.Type && m != null && m.BodyRegion.IsInside(editor.Caret.Line, editor.Caret.Column)) { |
|
||||||
result.Items.Add(new DefaultCompletionItem("? =") { |
|
||||||
Image = ClassBrowserIconService.GotoArrow, |
|
||||||
Description = StringParser.Parse("${res:AddIns.VBNetBinding.CodeCompletion.QuestionmarkEqualsItem.Description}") |
|
||||||
}); |
|
||||||
} |
|
||||||
if (resolvedType != null && AllowsDescendentAccess(resolvedType, info.CompilationUnit.ProjectContent)) |
|
||||||
result.Items.Add(new DefaultCompletionItem("..") { Image = ClassBrowserIconService.GotoArrow }); |
|
||||||
if (resolvedType != null && AllowsAttributeValueAccess(resolvedType, info.CompilationUnit.ProjectContent)) |
|
||||||
result.Items.Add(new DefaultCompletionItem("@") { Image = ClassBrowserIconService.GotoArrow }); |
|
||||||
} |
|
||||||
|
|
||||||
static bool AllowsAttributeValueAccess(IReturnType resolvedType, IProjectContent content) |
|
||||||
{ |
|
||||||
/* See VB 10 Spec, pg. 282: |
|
||||||
* If an attribute access, System.Xml.Linq.XElement or a derived type, or |
|
||||||
* System.Collections.Generic.IEnumerable(Of T) or a derived type, where T is |
|
||||||
* System.Xml.Linq.XElement or a derived type. |
|
||||||
**/ |
|
||||||
|
|
||||||
string baseClass = "System.Xml.Linq.XElement"; |
|
||||||
string methodName = "Attributes"; |
|
||||||
|
|
||||||
return AllowsHelper(baseClass, methodName, resolvedType, content); |
|
||||||
} |
|
||||||
|
|
||||||
static bool AllowsDescendentAccess(IReturnType resolvedType, IProjectContent content) |
|
||||||
{ |
|
||||||
/* See VB 10 Spec, pg. 282: |
|
||||||
* If an element or descendents access, System.Xml.Linq.XContainer or a |
|
||||||
* derived type, or System.Collections.Generic.IEnumerable(Of T) or a derived |
|
||||||
* type, where T is System.Xml.Linq.XContainer or a derived type. |
|
||||||
**/ |
|
||||||
|
|
||||||
string baseClass = "System.Xml.Linq.XContainer"; |
|
||||||
string methodName = "Descendants"; |
|
||||||
|
|
||||||
return AllowsHelper(baseClass, methodName, resolvedType, content); |
|
||||||
} |
|
||||||
|
|
||||||
static bool AllowsHelper(string baseClass, string methodName, IReturnType resolvedType, IProjectContent content) |
|
||||||
{ |
|
||||||
IClass extensions = content.GetClass("System.Xml.Linq.Extensions", 0); |
|
||||||
if (extensions == null) |
|
||||||
return false; |
|
||||||
IMethod descendents = extensions.Methods.FirstOrDefault(m => m.Name == methodName); |
|
||||||
if (descendents == null) |
|
||||||
return false; |
|
||||||
IParameter param = descendents.Parameters.FirstOrDefault(); |
|
||||||
if (param == null) |
|
||||||
return false; |
|
||||||
IClass resolvedTypeClass = resolvedType.GetUnderlyingClass(); |
|
||||||
if (resolvedTypeClass == null) |
|
||||||
return false; |
|
||||||
return MemberLookupHelper.IsApplicable(resolvedType, param, descendents) |
|
||||||
|| resolvedTypeClass.IsTypeInInheritanceTree(content.GetClass(baseClass, 0)); |
|
||||||
} |
|
||||||
|
|
||||||
static void AddVBNetKeywords(List<ICompletionEntry> ar, BitArray keywords) |
|
||||||
{ |
|
||||||
for (int i = 0; i < keywords.Length; i++) { |
|
||||||
if (keywords[i] && i >= Tokens.AddHandler && i < Tokens.MaxToken) { |
|
||||||
ar.Add(new KeywordEntry(Tokens.GetTokenString(i))); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
static void AddTemplates(ITextEditor editor, DefaultCompletionItemList list) |
|
||||||
{ |
|
||||||
if (list == null) |
|
||||||
return; |
|
||||||
List<ICompletionItem> snippets = editor.GetSnippets().ToList(); |
|
||||||
snippets.RemoveAll(item => !FitsToContext(item, list.Items)); |
|
||||||
list.Items.RemoveAll(item => item.Image == ClassBrowserIconService.Keyword && snippets.Exists(i => i.Text == item.Text)); |
|
||||||
list.Items.AddRange(snippets); |
|
||||||
list.SortItems(); |
|
||||||
} |
|
||||||
|
|
||||||
static bool FitsToContext(ICompletionItem item, List<ICompletionItem> list) |
|
||||||
{ |
|
||||||
var snippetItem = item as ISnippetCompletionItem; |
|
||||||
|
|
||||||
if (snippetItem == null) |
|
||||||
return false; |
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(snippetItem.Keyword)) |
|
||||||
return true; |
|
||||||
|
|
||||||
return list.Any(x => x.Image == ClassBrowserIconService.Keyword |
|
||||||
&& x.Text == snippetItem.Keyword); |
|
||||||
} |
|
||||||
|
|
||||||
static IMember GetCurrentMember(ITextEditor editor) |
|
||||||
{ |
|
||||||
var caret = editor.Caret; |
|
||||||
NRefactoryResolver r = new NRefactoryResolver(LanguageProperties.VBNet); |
|
||||||
if (r.Initialize(ParserService.GetParseInformation(editor.FileName), caret.Line, caret.Column)) { |
|
||||||
return r.CallingMember; |
|
||||||
} else { |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
static IClass GetCurrentClass(ITextEditor editor) |
|
||||||
{ |
|
||||||
var caret = editor.Caret; |
|
||||||
NRefactoryResolver r = new NRefactoryResolver(LanguageProperties.VBNet); |
|
||||||
if (r.Initialize(ParserService.GetParseInformation(editor.FileName), caret.Line, caret.Column)) { |
|
||||||
return r.CallingClass; |
|
||||||
} else { |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,40 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding |
|
||||||
{ |
|
||||||
public static class Extensions |
|
||||||
{ |
|
||||||
public static T PeekOrDefault<T>(this Stack<T> stack) |
|
||||||
{ |
|
||||||
if (stack.Count > 0) |
|
||||||
return stack.Peek(); |
|
||||||
|
|
||||||
return default(T); |
|
||||||
} |
|
||||||
|
|
||||||
public static T PopOrDefault<T>(this Stack<T> stack) |
|
||||||
{ |
|
||||||
if (stack.Count > 0) |
|
||||||
return stack.Pop(); |
|
||||||
|
|
||||||
return default(T); |
|
||||||
} |
|
||||||
|
|
||||||
internal static VBNetCompletionItemList ToVBCCList(this ICompletionItemList list) |
|
||||||
{ |
|
||||||
var result = new VBNetCompletionItemList() { |
|
||||||
SuggestedItem = list.SuggestedItem, |
|
||||||
PreselectionLength = list.PreselectionLength |
|
||||||
}; |
|
||||||
|
|
||||||
result.Items.AddRange(list.Items); |
|
||||||
|
|
||||||
return result; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,918 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.IO; |
|
||||||
using System.Text; |
|
||||||
using System.Text.RegularExpressions; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.NRefactory; |
|
||||||
using ICSharpCode.NRefactory.Parser; |
|
||||||
using ICSharpCode.NRefactory.Parser.VB; |
|
||||||
using ICSharpCode.SharpDevelop; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.SharpDevelop.Editor; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// This class handles the auto and smart indenting in the textbuffer while
|
|
||||||
/// you type.
|
|
||||||
/// </summary>
|
|
||||||
public class VBNetFormattingStrategy : DefaultFormattingStrategy |
|
||||||
{ |
|
||||||
#region VB Statements
|
|
||||||
static readonly List<VBStatement> statements; |
|
||||||
|
|
||||||
internal static List<VBStatement> Statements { |
|
||||||
get { return statements; } |
|
||||||
} |
|
||||||
|
|
||||||
static readonly string[] keywords = new string[] { |
|
||||||
"AddHandler", "AddressOf", "Alias", "And", |
|
||||||
"AndAlso", "As", "Boolean", "ByRef", |
|
||||||
"Byte", "ByVal", "Call", "Case", |
|
||||||
"Catch", "CBool", "CByte", "CChar", |
|
||||||
"CDate", "CDbl", "CDec", "Char", |
|
||||||
"CInt", "Class", "CLng", "CObj", |
|
||||||
"Const", "Continue", "CSByte", "CShort", |
|
||||||
"CSng", "CStr", "CType", "CUInt", |
|
||||||
"CULng", "CUShort", "Date", "Decimal", |
|
||||||
"Declare", "Default", "Delegate", "Dim", |
|
||||||
"DirectCast", "Do", "Double", "Each", |
|
||||||
"Else", "ElseIf", "End", "EndIf", // EndIf special case: converted to "End If"
|
|
||||||
"Enum", "Erase", "Error", "Event", |
|
||||||
"Exit", "False", "Finally", "For", |
|
||||||
"Friend", "Function", "Get", "GetType", |
|
||||||
"Global", "GoSub", "GoTo", "Handles", |
|
||||||
"If", "Implements", "Imports", "In", |
|
||||||
"Inherits", "Integer", "Interface", "Is", |
|
||||||
"IsNot", "Let", "Lib", "Like", |
|
||||||
"Long", "Loop", "Me", "Mod", |
|
||||||
"Module", "MustInherit", "MustOverride", "MyBase", |
|
||||||
"MyClass", "Namespace", "Narrowing", "New", |
|
||||||
"Next", "Not", "Nothing", "NotInheritable", |
|
||||||
"NotOverridable", "Object", "Of", "On", |
|
||||||
"Operator", "Option", "Optional", "Or", |
|
||||||
"OrElse", "Overloads", "Overridable", "Overrides", |
|
||||||
"ParamArray", "Partial", "Private", "Property", |
|
||||||
"Protected", "Public", "RaiseEvent", "ReadOnly", |
|
||||||
"ReDim", "REM", "RemoveHandler", "Resume", |
|
||||||
"Return", "SByte", "Select", "Set", |
|
||||||
"Shadows", "Shared", "Short", "Single", |
|
||||||
"Static", "Step", "Stop", "String", |
|
||||||
"Structure", "Sub", "SyncLock", "Then", |
|
||||||
"Throw", "To", "True", "Try", |
|
||||||
"TryCast", "TypeOf", "UInteger", "ULong", |
|
||||||
"UShort", "Using", "Variant", "Wend", |
|
||||||
"When", "While", "Widening", "With", |
|
||||||
"WithEvents", "WriteOnly", "Xor", |
|
||||||
// these are not keywords, but context dependend
|
|
||||||
"Until", "Ansi", "Unicode", "Region", "Preserve" |
|
||||||
}; |
|
||||||
|
|
||||||
internal static IList<string> Keywords { |
|
||||||
get { return keywords; } |
|
||||||
} |
|
||||||
|
|
||||||
static VBStatement interfaceStatement; |
|
||||||
|
|
||||||
static List<int> blockTokens = new List<int>( |
|
||||||
new int[] { |
|
||||||
Tokens.Class, Tokens.Module, Tokens.Namespace, Tokens.Interface, Tokens.Structure, |
|
||||||
Tokens.Sub, Tokens.Function, Tokens.Operator, Tokens.Enum, |
|
||||||
Tokens.If, Tokens.For, Tokens.Do, Tokens.While, Tokens.With, Tokens.Select, Tokens.Try, Tokens.Using, Tokens.SyncLock, |
|
||||||
Tokens.Property, Tokens.Get, Tokens.Set |
|
||||||
}); |
|
||||||
#endregion
|
|
||||||
|
|
||||||
bool doCasing; |
|
||||||
bool doInsertion; |
|
||||||
|
|
||||||
static VBNetFormattingStrategy() |
|
||||||
{ |
|
||||||
statements = new List<VBStatement>(); |
|
||||||
statements.Add(new VBStatement(@"^if.*?(then|\s+_)$", "^end ?if$", "End If", 1, Tokens.If)); |
|
||||||
statements.Add(new VBStatement(@"\bclass\s+\w+\s*($|\(\s*Of)", "^end class$", "End Class", 1, Tokens.Class)); |
|
||||||
statements.Add(new VBStatement(@"\bnamespace\s+\w+(\.\w+)*$", "^end namespace$", "End Namespace", 1, Tokens.Namespace)); |
|
||||||
statements.Add(new VBStatement(@"\bmodule\s+\w+$", "^end module$", "End Module", 1, Tokens.Module)); |
|
||||||
statements.Add(new VBStatement(@"\bstructure\s+\w+\s*($|\(\s*Of)", "^end structure$", "End Structure", 1, Tokens.Structure)); |
|
||||||
statements.Add(new VBStatement(@"^while\s+", "^end while$", "End While", 1, Tokens.While)); |
|
||||||
statements.Add(new VBStatement(@"^select case", "^end select$", "End Select", 1, Tokens.Select)); |
|
||||||
statements.Add(new VBStatement(@"(?<!\b(delegate|mustoverride|declare(\s+(unicode|ansi|auto))?)\s+)\bsub\s+\w+", @"^end\s+sub$", "End Sub", 1, Tokens.Sub)); |
|
||||||
statements.Add(new VBStatement(@"(?<!\bmustoverride (readonly |writeonly )?)\bproperty\s+\w+", @"^end\s+property$", "End Property", 1, Tokens.Property)); |
|
||||||
statements.Add(new VBStatement(@"(?<!\b(delegate|mustoverride|declare(\s+(unicode|ansi|auto))?)\s+)\bfunction\s+\w+", @"^end\s+function$", "End Function", 1, Tokens.Function)); |
|
||||||
statements.Add(new VBStatement(@"\boperator(\s*[\+\-\*\/\&\^\>\<\=\\]+\s*|\s+\w+\s*)\(", @"^end\s+operator$", "End Operator", 1, Tokens.Operator)); |
|
||||||
statements.Add(new VBStatement(@"\bfor\s+.*?$", "^next( \\w+)?$", "Next", 1, Tokens.For)); |
|
||||||
statements.Add(new VBStatement(@"^synclock\s+.*?$", "^end synclock$", "End SyncLock", 1, Tokens.SyncLock)); |
|
||||||
statements.Add(new VBStatement(@"^get$", "^end get$", "End Get", 1, Tokens.Get)); |
|
||||||
statements.Add(new VBStatement(@"^with\s+.*?$", "^end with$", "End With", 1, Tokens.With)); |
|
||||||
statements.Add(new VBStatement(@"^set(\s*\(.*?\))?$", "^end set$", "End Set", 1, Tokens.Set)); |
|
||||||
statements.Add(new VBStatement(@"^try$", "^end try$", "End Try", 1, Tokens.Try)); |
|
||||||
statements.Add(new VBStatement(@"^do\s+.+?$", "^loop$", "Loop", 1, Tokens.Do)); |
|
||||||
statements.Add(new VBStatement(@"^do$", "^loop .+?$", "Loop While ", 1, Tokens.Do)); |
|
||||||
statements.Add(new VBStatement(@"\benum\s+\w+$", "^end enum$", "End Enum", 1, Tokens.Enum)); |
|
||||||
interfaceStatement = new VBStatement(@"\binterface\s+\w+\s*($|\(\s*Of)", "^end interface$", "End Interface", 1, Tokens.Interface); |
|
||||||
statements.Add(interfaceStatement); |
|
||||||
statements.Add(new VBStatement(@"\busing\s+", "^end using$", "End Using", 1, Tokens.Using)); |
|
||||||
statements.Add(new VBStatement(@"^#region\s+", "^#end region$", "#End Region", 0, -1)); |
|
||||||
} |
|
||||||
|
|
||||||
public override void FormatLine(ITextEditor editor, char charTyped) |
|
||||||
{ |
|
||||||
using (editor.Document.OpenUndoGroup()) { |
|
||||||
FormatLineInternal(editor, editor.Caret.Line, editor.Caret.Offset, charTyped); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void FormatLineInternal(ITextEditor editor, int lineNr, int cursorOffset, char ch) |
|
||||||
{ |
|
||||||
string terminator = DocumentUtilitites.GetLineTerminator(editor.Document, lineNr); |
|
||||||
doCasing = PropertyService.Get("VBBinding.TextEditor.EnableCasing", true); |
|
||||||
doInsertion = PropertyService.Get("VBBinding.TextEditor.EnableEndConstructs", true); |
|
||||||
|
|
||||||
IDocumentLine currentLine = editor.Document.GetLine(lineNr); |
|
||||||
IDocumentLine lineAbove = lineNr > 1 ? editor.Document.GetLine(lineNr - 1) : null; |
|
||||||
|
|
||||||
string curLineText = currentLine == null ? "" : currentLine.Text; |
|
||||||
string lineAboveText = lineAbove == null ? "" : lineAbove.Text; |
|
||||||
|
|
||||||
if (ch == '\'') { |
|
||||||
InsertDocumentationComments(editor, lineNr, cursorOffset); |
|
||||||
} |
|
||||||
|
|
||||||
if (ch == '\n' && lineAbove != null) { |
|
||||||
if (LanguageUtils.IsInsideDocumentationComment(editor, lineAbove, lineAbove.EndOffset)) { |
|
||||||
editor.Document.Insert(cursorOffset, "''' "); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
string textToReplace = lineAboveText.TrimLine(); |
|
||||||
|
|
||||||
if (doCasing) |
|
||||||
DoCasingOnLine(lineAbove, textToReplace, editor); |
|
||||||
|
|
||||||
if (doInsertion) |
|
||||||
DoInsertionOnLine(terminator, currentLine, lineAbove, textToReplace, editor, lineNr); |
|
||||||
|
|
||||||
if (IsInString(lineAboveText)) { |
|
||||||
if (IsFinishedString(curLineText)) { |
|
||||||
editor.Document.Insert(lineAbove.EndOffset, "\" & _"); |
|
||||||
editor.Document.Insert(currentLine.Offset, "\""); |
|
||||||
} else { |
|
||||||
editor.Document.Insert(lineAbove.EndOffset, "\""); |
|
||||||
} |
|
||||||
} else { |
|
||||||
string indent = DocumentUtilitites.GetWhitespaceAfter(editor.Document, lineAbove.Offset); |
|
||||||
if (indent.Length > 0) { |
|
||||||
string newLineText = indent + currentLine.Text.Trim(); |
|
||||||
editor.Document.Replace(currentLine.Offset, currentLine.Length, newLineText); |
|
||||||
} |
|
||||||
editor.Caret.Column = indent.Length + 1; |
|
||||||
} |
|
||||||
|
|
||||||
IndentLines(editor, lineNr - 1, lineNr); |
|
||||||
} else if(ch == '>') { |
|
||||||
if (LanguageUtils.IsInsideDocumentationComment(editor, currentLine, cursorOffset)) { |
|
||||||
int column = editor.Caret.Offset - currentLine.Offset; |
|
||||||
int index = Math.Min(column - 1, curLineText.Length - 1); |
|
||||||
|
|
||||||
while (index > 0 && curLineText[index] != '<') { |
|
||||||
--index; |
|
||||||
if(curLineText[index] == '/') |
|
||||||
return; // the tag was an end tag or already
|
|
||||||
} |
|
||||||
|
|
||||||
if (index > 0) { |
|
||||||
StringBuilder commentBuilder = new StringBuilder(""); |
|
||||||
for (int i = index; i < curLineText.Length && i < column && !Char.IsWhiteSpace(curLineText[i]); ++i) { |
|
||||||
commentBuilder.Append(curLineText[i]); |
|
||||||
} |
|
||||||
string tag = commentBuilder.ToString().Trim(); |
|
||||||
if (!tag.EndsWith(">", StringComparison.OrdinalIgnoreCase)) { |
|
||||||
tag += ">"; |
|
||||||
} |
|
||||||
if (!tag.StartsWith("/", StringComparison.OrdinalIgnoreCase)) { |
|
||||||
string endTag = "</" + tag.Substring(1); |
|
||||||
editor.Document.Insert(editor.Caret.Offset, endTag); |
|
||||||
editor.Caret.Offset -= endTag.Length; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void DoInsertionOnLine(string terminator, IDocumentLine currentLine, IDocumentLine lineAbove, string textToReplace, ITextEditor editor, int lineNr) |
|
||||||
{ |
|
||||||
string curLineText = currentLine.Text; |
|
||||||
|
|
||||||
if (Regex.IsMatch(textToReplace.Trim(), "^If .*[^_]$", RegexOptions.IgnoreCase)) { |
|
||||||
if (!Regex.IsMatch(textToReplace, "\\bthen\\b", RegexOptions.IgnoreCase)) { |
|
||||||
string specialThen = "Then"; // do special check in cases like If t = True' comment
|
|
||||||
if (editor.Document.GetCharAt(lineAbove.Offset + textToReplace.Length) == '\'') |
|
||||||
specialThen += " "; |
|
||||||
if (editor.Document.GetCharAt(lineAbove.Offset + textToReplace.Length - 1) != ' ') |
|
||||||
specialThen = " " + specialThen; |
|
||||||
editor.Document.Insert(lineAbove.Offset + textToReplace.Length, specialThen); |
|
||||||
textToReplace += specialThen; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// check #Region statements
|
|
||||||
if (Regex.IsMatch(textToReplace.Trim(), "^#Region", RegexOptions.IgnoreCase) && LookForEndRegion(editor)) { |
|
||||||
string indentation = DocumentUtilitites.GetWhitespaceAfter(editor.Document, lineAbove.Offset); |
|
||||||
textToReplace += indentation + "\r\n" + indentation + "#End Region"; |
|
||||||
editor.Document.Replace(currentLine.Offset, currentLine.Length, textToReplace); |
|
||||||
} |
|
||||||
|
|
||||||
foreach (VBStatement statement_ in statements) { |
|
||||||
VBStatement statement = statement_; // allow passing statement byref
|
|
||||||
if (Regex.IsMatch(textToReplace.Trim(), statement.StartRegex, RegexOptions.IgnoreCase)) { |
|
||||||
string indentation = DocumentUtilitites.GetWhitespaceAfter(editor.Document, lineAbove.Offset); |
|
||||||
if (IsEndStatementNeeded(editor, ref statement, lineNr)) { |
|
||||||
editor.Document.Replace(currentLine.Offset, currentLine.Length, terminator + indentation + statement.EndStatement); |
|
||||||
} |
|
||||||
if (!IsInsideInterface(editor, lineNr) || statement == interfaceStatement) { |
|
||||||
for (int i = 0; i < statement.IndentPlus; i++) { |
|
||||||
indentation += editor.Options.IndentationString; |
|
||||||
} |
|
||||||
} |
|
||||||
editor.Document.Replace(currentLine.Offset, currentLine.Length, indentation + curLineText.Trim()); |
|
||||||
editor.Caret.Line = currentLine.LineNumber; |
|
||||||
editor.Caret.Column = indentation.Length; |
|
||||||
return; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
static void DoCasingOnLine(IDocumentLine lineAbove, string textToReplace, ITextEditor editor) |
|
||||||
{ |
|
||||||
foreach (string keyword in keywords) { |
|
||||||
string regex = "\\b" + keyword + "\\b"; // \b = word border
|
|
||||||
MatchCollection matches = Regex.Matches(textToReplace, regex, RegexOptions.IgnoreCase | RegexOptions.Singleline); |
|
||||||
foreach (Match match in matches) { |
|
||||||
if (keyword == "EndIf") // special case
|
|
||||||
editor.Document.Replace(lineAbove.Offset + match.Index, match.Length, "End If"); |
|
||||||
else |
|
||||||
editor.Document.Replace(lineAbove.Offset + match.Index, match.Length, keyword); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
static void InsertDocumentationComments(ITextEditor editor, int lineNr, int cursorOffset) |
|
||||||
{ |
|
||||||
string terminator = DocumentUtilitites.GetLineTerminator(editor.Document, lineNr); |
|
||||||
|
|
||||||
IDocumentLine currentLine = editor.Document.GetLine(lineNr); |
|
||||||
IDocumentLine previousLine = (lineNr > 1) ? editor.Document.GetLine(lineNr - 1) : null; |
|
||||||
|
|
||||||
string curLineText = currentLine.Text; |
|
||||||
string lineAboveText = previousLine == null ? null : previousLine.Text; |
|
||||||
|
|
||||||
if (curLineText != null && curLineText.EndsWith("'''", StringComparison.OrdinalIgnoreCase) && (lineAboveText == null || !lineAboveText.Trim().StartsWith("'''", StringComparison.OrdinalIgnoreCase))) { |
|
||||||
string indentation = DocumentUtilitites.GetWhitespaceAfter(editor.Document, currentLine.Offset); |
|
||||||
object member = GetMemberAfter(editor, lineNr); |
|
||||||
if (member != null) { |
|
||||||
StringBuilder sb = new StringBuilder(); |
|
||||||
sb.Append(" <summary>"); |
|
||||||
sb.Append(terminator); |
|
||||||
sb.Append(indentation); |
|
||||||
sb.Append("''' "); |
|
||||||
sb.Append(terminator); |
|
||||||
sb.Append(indentation); |
|
||||||
sb.Append("''' </summary>"); |
|
||||||
if (member is IMethod) { |
|
||||||
IMethod method = (IMethod)member; |
|
||||||
if (method.Parameters != null && method.Parameters.Count > 0) { |
|
||||||
for (int i = 0; i < method.Parameters.Count; ++i) { |
|
||||||
sb.Append(terminator); |
|
||||||
sb.Append(indentation); |
|
||||||
sb.Append("''' <param name=\""); |
|
||||||
sb.Append(method.Parameters[i].Name); |
|
||||||
sb.Append("\"></param>"); |
|
||||||
} |
|
||||||
} |
|
||||||
if (method.ReturnType != null && !method.IsConstructor && method.ReturnType.FullyQualifiedName != "System.Void") { |
|
||||||
sb.Append(terminator); |
|
||||||
sb.Append(indentation); |
|
||||||
sb.Append("''' <returns></returns>"); |
|
||||||
} |
|
||||||
} |
|
||||||
editor.Document.Insert(cursorOffset, sb.ToString()); |
|
||||||
editor.Caret.Position = editor.Document.OffsetToPosition(cursorOffset + indentation.Length + "/// ".Length + " <summary>".Length + terminator.Length); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
static bool LookForEndRegion(ITextEditor editor) |
|
||||||
{ |
|
||||||
string lineText = editor.Document.GetLine(1).Text; |
|
||||||
int count = 0; |
|
||||||
int lineNr = 0; |
|
||||||
while ((!Regex.IsMatch(lineText, @"^\s*#End\s+Region", RegexOptions.IgnoreCase) || count >= 0) && (lineNr < editor.Document.TotalNumberOfLines)) { |
|
||||||
if (Regex.IsMatch(lineText, @"^\s*#Region", RegexOptions.IgnoreCase)) |
|
||||||
count++; |
|
||||||
if (Regex.IsMatch(lineText, @"^\s*#End\s+Region", RegexOptions.IgnoreCase)) |
|
||||||
count--; |
|
||||||
lineNr++; |
|
||||||
if (lineNr < editor.Document.TotalNumberOfLines) |
|
||||||
lineText = editor.Document.GetLine(1).Text; |
|
||||||
} |
|
||||||
|
|
||||||
return (count > 0); |
|
||||||
} |
|
||||||
|
|
||||||
static bool IsInsideInterface(ITextEditor editor, int lineNr) |
|
||||||
{ |
|
||||||
ILexer lexer = ParserFactory.CreateLexer(SupportedLanguage.VBNet, new StringReader(editor.Document.Text)); |
|
||||||
|
|
||||||
Stack<Token> tokens = new Stack<Token>(); |
|
||||||
|
|
||||||
Token currentToken = null; |
|
||||||
Token prevToken = null; |
|
||||||
|
|
||||||
while ((currentToken = lexer.NextToken()).Kind != Tokens.EOF) { |
|
||||||
if (prevToken == null) |
|
||||||
prevToken = currentToken; |
|
||||||
|
|
||||||
if (currentToken.EndLocation.Line <= lineNr && |
|
||||||
IsDeclaration(currentToken.Kind) && |
|
||||||
IsBlockStart(lexer, currentToken, prevToken)) { |
|
||||||
|
|
||||||
tokens.Push(currentToken); |
|
||||||
} |
|
||||||
|
|
||||||
if (currentToken.EndLocation.Line <= lineNr && |
|
||||||
IsDeclaration(currentToken.Kind) && |
|
||||||
IsBlockEnd(currentToken, prevToken)) { |
|
||||||
|
|
||||||
if (tokens.Count > 0) |
|
||||||
tokens.Pop(); |
|
||||||
} |
|
||||||
|
|
||||||
if (currentToken.EndLocation.Line > lineNr) |
|
||||||
break; |
|
||||||
|
|
||||||
prevToken = currentToken; |
|
||||||
} |
|
||||||
|
|
||||||
if (tokens.Count > 0) |
|
||||||
return tokens.Pop().Kind == Tokens.Interface; |
|
||||||
|
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
static bool IsInString(string start) |
|
||||||
{ |
|
||||||
bool inString = false; |
|
||||||
for (int i = 0; i < start.Length; i++) { |
|
||||||
if (start[i] == '"') |
|
||||||
inString = !inString; |
|
||||||
if (!inString && start[i] == '\'') |
|
||||||
return false; |
|
||||||
} |
|
||||||
return inString; |
|
||||||
} |
|
||||||
|
|
||||||
static bool IsFinishedString(string end) |
|
||||||
{ |
|
||||||
bool inString = true; |
|
||||||
for (int i = 0; i < end.Length; i++) { |
|
||||||
if (end[i] == '"') |
|
||||||
inString = !inString; |
|
||||||
if (!inString && end[i] == '\'') |
|
||||||
break; |
|
||||||
} |
|
||||||
return !inString; |
|
||||||
} |
|
||||||
|
|
||||||
internal static bool IsDeclaration(int type) |
|
||||||
{ |
|
||||||
return (type == Tokens.Class) || |
|
||||||
(type == Tokens.Module) || |
|
||||||
(type == Tokens.Structure) || |
|
||||||
(type == Tokens.Enum) || |
|
||||||
(type == Tokens.Interface); |
|
||||||
} |
|
||||||
|
|
||||||
bool IsEndStatementNeeded(ITextEditor editor, ref VBStatement statement, int lineNr) |
|
||||||
{ |
|
||||||
Stack<Token> tokens = new Stack<Token>(); |
|
||||||
List<Token> missingEnds = new List<Token>(); |
|
||||||
|
|
||||||
ILexer lexer = ParserFactory.CreateLexer(SupportedLanguage.VBNet, new StringReader(editor.Document.Text)); |
|
||||||
|
|
||||||
Token currentToken = null; |
|
||||||
Token prevToken = null; |
|
||||||
|
|
||||||
while ((currentToken = lexer.NextToken()).Kind != Tokens.EOF) { |
|
||||||
if (prevToken == null) |
|
||||||
prevToken = currentToken; |
|
||||||
if (IsBlockStart(lexer, currentToken, prevToken) && !IsAutomaticPropertyWithDefaultValue(lexer, currentToken, prevToken)) { |
|
||||||
if ((tokens.Count > 0 && tokens.Peek().Kind != Tokens.Interface) || IsDeclaration(currentToken.Kind)) |
|
||||||
tokens.Push(currentToken); |
|
||||||
} |
|
||||||
|
|
||||||
if (IsBlockEnd(currentToken, prevToken)) { |
|
||||||
while (tokens.Count > 0 && !IsMatchingEnd(tokens.Peek(), currentToken)) { |
|
||||||
missingEnds.Add(tokens.Pop()); |
|
||||||
} |
|
||||||
|
|
||||||
if (tokens.Count > 0) { |
|
||||||
if (IsMatchingEnd(tokens.Peek(), currentToken)) |
|
||||||
tokens.Pop(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
prevToken = currentToken; |
|
||||||
} |
|
||||||
|
|
||||||
while (tokens.Count > 0) |
|
||||||
missingEnds.Add(tokens.Pop()); |
|
||||||
|
|
||||||
if (missingEnds.Count > 0) |
|
||||||
return GetClosestMissing(missingEnds, statement, editor, lineNr) != null; |
|
||||||
else |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
static bool IsAutomaticPropertyWithDefaultValue(ILexer lexer, Token currentToken, Token prevToken) |
|
||||||
{ |
|
||||||
if (currentToken.Kind != Tokens.Property) |
|
||||||
return false; |
|
||||||
lexer.StartPeek(); |
|
||||||
|
|
||||||
int parenthesesNesting = 0; |
|
||||||
|
|
||||||
// look for parameter list, = or EOL
|
|
||||||
Token t; |
|
||||||
while ((t = lexer.Peek()).Kind != Tokens.EOF) { |
|
||||||
if (t.Kind == Tokens.OpenParenthesis) |
|
||||||
parenthesesNesting++; |
|
||||||
if (t.Kind == Tokens.CloseParenthesis) |
|
||||||
parenthesesNesting--; |
|
||||||
if (parenthesesNesting == 0 && t.Kind == Tokens.Assign) |
|
||||||
return true; |
|
||||||
if (t.Kind == Tokens.EOL) |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
static Token GetClosestMissing(List<Token> missingEnds, VBStatement statement, ITextEditor editor, int lineNr) |
|
||||||
{ |
|
||||||
Token closest = null; |
|
||||||
int diff = 0; |
|
||||||
|
|
||||||
foreach (Token t in missingEnds) { |
|
||||||
if (!IsSingleLine(t.Location.Line, editor)) { |
|
||||||
if (IsMatchingStatement(t, statement) && ((diff = lineNr - t.Location.Line) > 0)) { |
|
||||||
if (closest == null) { |
|
||||||
closest = t; |
|
||||||
} else { |
|
||||||
if (diff < lineNr - closest.Location.Line) |
|
||||||
closest = t; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
return closest; |
|
||||||
} |
|
||||||
|
|
||||||
static bool IsSingleLine(int line, ITextEditor editor) |
|
||||||
{ |
|
||||||
if (line < 1) |
|
||||||
return false; |
|
||||||
|
|
||||||
IDocumentLine lineSeg = editor.Document.GetLine(line); |
|
||||||
|
|
||||||
if (lineSeg == null) |
|
||||||
return false; |
|
||||||
|
|
||||||
string text = lineSeg.Text; |
|
||||||
|
|
||||||
if (text.TrimComments().Trim(' ', '\t', '\r', '\n').EndsWith("_", StringComparison.OrdinalIgnoreCase)) |
|
||||||
return true; |
|
||||||
else |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
internal static bool IsMatchingEnd(Token begin, Token end) |
|
||||||
{ |
|
||||||
if (begin.Kind == end.Kind) |
|
||||||
return true; |
|
||||||
|
|
||||||
if (begin.Kind == Tokens.For && end.Kind == Tokens.Next) |
|
||||||
return true; |
|
||||||
|
|
||||||
if (begin.Kind == Tokens.Do && end.Kind == Tokens.Loop) |
|
||||||
return true; |
|
||||||
|
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
static bool IsMatchingStatement(Token token, VBStatement statement) |
|
||||||
{ |
|
||||||
if (token.Kind == Tokens.For && statement.EndStatement == "Next") |
|
||||||
return true; |
|
||||||
|
|
||||||
if (token.Kind == Tokens.Do && statement.EndStatement.StartsWith("Loop", StringComparison.OrdinalIgnoreCase)) |
|
||||||
return true; |
|
||||||
|
|
||||||
bool empty = !string.IsNullOrEmpty(token.Value); |
|
||||||
bool match = statement.EndStatement.IndexOf(token.Value, StringComparison.OrdinalIgnoreCase) != -1; |
|
||||||
|
|
||||||
return empty && match; |
|
||||||
} |
|
||||||
|
|
||||||
public override void IndentLines(ITextEditor editor, int begin, int end) |
|
||||||
{ |
|
||||||
SmartIndentInternal(editor, begin, end); |
|
||||||
} |
|
||||||
|
|
||||||
static int SmartIndentInternal(ITextEditor editor, int begin, int end) |
|
||||||
{ |
|
||||||
ILexer lexer = ParserFactory.CreateLexer(SupportedLanguage.VBNet, new StringReader(editor.Document.Text)); |
|
||||||
|
|
||||||
ExpressionFinder context = new ExpressionFinder(); |
|
||||||
|
|
||||||
Stack<string> indentation = new Stack<string>(); |
|
||||||
indentation.Push(string.Empty); |
|
||||||
|
|
||||||
List<int> eols = new List<int>(); |
|
||||||
|
|
||||||
bool inInterface = false; |
|
||||||
bool isMustOverride = false; |
|
||||||
bool isDeclare = false; |
|
||||||
bool isDelegate = false; |
|
||||||
|
|
||||||
Token currentToken = null; |
|
||||||
Token prevToken = null; |
|
||||||
|
|
||||||
int blockStart = 1; |
|
||||||
int lambdaNesting = 0; |
|
||||||
|
|
||||||
bool sawAttribute = false; |
|
||||||
|
|
||||||
while ((currentToken = lexer.NextToken()).Kind != Tokens.EOF) { |
|
||||||
if (context.InContext(Context.Attribute) && currentToken.Kind == Tokens.GreaterThan) |
|
||||||
sawAttribute = true; |
|
||||||
|
|
||||||
context.InformToken(currentToken); |
|
||||||
|
|
||||||
if (prevToken == null) |
|
||||||
prevToken = currentToken; |
|
||||||
|
|
||||||
if (currentToken.Kind == Tokens.MustOverride) |
|
||||||
isMustOverride = true; |
|
||||||
|
|
||||||
if (currentToken.Kind == Tokens.Delegate) |
|
||||||
isDelegate = true; |
|
||||||
|
|
||||||
if (currentToken.Kind == Tokens.Declare) |
|
||||||
isDeclare = true; |
|
||||||
|
|
||||||
if (currentToken.Kind == Tokens.EOL) { |
|
||||||
isDelegate = isDeclare = isMustOverride = sawAttribute = false; |
|
||||||
eols.Add(currentToken.Location.Line); |
|
||||||
} |
|
||||||
|
|
||||||
if (IsBlockEnd(currentToken, prevToken)) { |
|
||||||
// indent the lines inside the block
|
|
||||||
// this is an End-statement
|
|
||||||
// hence we indent from blockStart to the previous line
|
|
||||||
int blockEnd = currentToken.Location.Line - 1; |
|
||||||
|
|
||||||
// if this is a lambda end include End-Statement in block
|
|
||||||
// if (lambdaNesting > 0 && (currentToken.Kind == Tokens.Function || currentToken.Kind == Tokens.Sub)) {
|
|
||||||
// blockEnd++;
|
|
||||||
// }
|
|
||||||
|
|
||||||
ApplyToRange(editor, indentation, eols, blockStart, blockEnd, begin, end, sawAttribute); |
|
||||||
|
|
||||||
if (lambdaNesting > 0 && (currentToken.Kind == Tokens.Function || currentToken.Kind == Tokens.Sub)) { |
|
||||||
Unindent(indentation); |
|
||||||
|
|
||||||
ApplyToRange(editor, indentation, eols, currentToken.Location.Line, currentToken.Location.Line, begin, end, sawAttribute); |
|
||||||
} |
|
||||||
|
|
||||||
if (currentToken.Kind == Tokens.Interface) |
|
||||||
inInterface = false; |
|
||||||
|
|
||||||
if (!inInterface && !isMustOverride && !isDeclare && !isDelegate) { |
|
||||||
Unindent(indentation); |
|
||||||
|
|
||||||
if (currentToken.Kind == Tokens.Select) |
|
||||||
Unindent(indentation); |
|
||||||
} |
|
||||||
|
|
||||||
// block start is this line (for the lines between two blocks)
|
|
||||||
blockStart = currentToken.Location.Line; |
|
||||||
|
|
||||||
if (lambdaNesting > 0 && (currentToken.Kind == Tokens.Function || currentToken.Kind == Tokens.Sub)) { |
|
||||||
blockStart++; |
|
||||||
lambdaNesting--; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
bool isMultiLineLambda; |
|
||||||
if (IsBlockStart(lexer, currentToken, prevToken, out isMultiLineLambda)) { |
|
||||||
// indent the lines between the last and this block
|
|
||||||
// this is a Begin-statement
|
|
||||||
// hence we indent from blockStart to the this line
|
|
||||||
int lastVisualLine = FindNextEol(lexer); |
|
||||||
eols.Add(lastVisualLine); |
|
||||||
ApplyToRange(editor, indentation, eols, blockStart, lastVisualLine, begin, end, sawAttribute); |
|
||||||
|
|
||||||
if (isMultiLineLambda && (currentToken.Kind == Tokens.Function || currentToken.Kind == Tokens.Sub)) { |
|
||||||
lambdaNesting++; |
|
||||||
int endColumn = currentToken.Location.Column; |
|
||||||
if (prevToken.Kind == Tokens.Iterator || prevToken.Kind == Tokens.Async) |
|
||||||
endColumn = prevToken.Location.Column; |
|
||||||
int startColumn = DocumentUtilitites.GetWhitespaceAfter(editor.Document, editor.Document.GetLine(lastVisualLine).Offset).Length; |
|
||||||
if (startColumn < endColumn) |
|
||||||
Indent(editor, indentation, new string(' ', endColumn - startColumn - 1)); |
|
||||||
} |
|
||||||
|
|
||||||
if (!inInterface && !isMustOverride && !isDeclare && !isDelegate && !IsAutomaticPropertyWithDefaultValue(lexer, currentToken, prevToken)) { |
|
||||||
Indent(editor, indentation); |
|
||||||
|
|
||||||
if (currentToken.Kind == Tokens.Select) |
|
||||||
Indent(editor, indentation); |
|
||||||
} |
|
||||||
|
|
||||||
if (currentToken.Kind == Tokens.Interface) |
|
||||||
inInterface = true; |
|
||||||
|
|
||||||
// block start is the following line (for the lines inside a block)
|
|
||||||
blockStart = lastVisualLine + 1; |
|
||||||
} |
|
||||||
|
|
||||||
prevToken = currentToken; |
|
||||||
} |
|
||||||
|
|
||||||
ApplyToRange(editor, indentation, eols, blockStart, editor.Document.TotalNumberOfLines, begin, end, sawAttribute); |
|
||||||
|
|
||||||
return (indentation.PeekOrDefault() ?? string.Empty).Length; |
|
||||||
} |
|
||||||
|
|
||||||
static int FindNextEol(ILexer lexer) |
|
||||||
{ |
|
||||||
lexer.StartPeek(); |
|
||||||
|
|
||||||
Token t = lexer.Peek(); |
|
||||||
|
|
||||||
while (t.Kind > Tokens.EOL) // break on EOF(0) or EOL(1)
|
|
||||||
t = lexer.Peek(); |
|
||||||
|
|
||||||
return t.Location.Line; |
|
||||||
} |
|
||||||
|
|
||||||
static void ApplyToRange(ITextEditor editor, Stack<string> indentation, List<int> eols, int blockStart, int blockEnd, int selectionStart, int selectionEnd, bool sawAttribute) { |
|
||||||
LoggingService.InfoFormatted("indenting line {0} to {1} with {2}", blockStart, blockEnd, (indentation.PeekOrDefault() ?? "").Length); |
|
||||||
|
|
||||||
int nextEol = -1; |
|
||||||
bool wasMultiLine = false; |
|
||||||
|
|
||||||
for (int i = blockStart; i <= blockEnd; i++) { |
|
||||||
IDocumentLine curLine = editor.Document.GetLine(i); |
|
||||||
string lineText = curLine.Text.TrimStart(); |
|
||||||
// preprocessor directives cannot be multiline (just as comments)
|
|
||||||
// and they are not included in normal block indentation ->
|
|
||||||
// treat preprocessor directives as comments -> remove them
|
|
||||||
string noComments = lineText.TrimComments().TrimPreprocessorDirectives().TrimEnd().TrimEnd('_').TrimEnd(); |
|
||||||
|
|
||||||
// adjust indentation if the current line is not selected
|
|
||||||
// lines between the selection will be aligned to the selected level
|
|
||||||
if (i < selectionStart || i > selectionEnd) { |
|
||||||
indentation.PopOrDefault(); |
|
||||||
indentation.Push(DocumentUtilitites.GetWhitespaceAfter(editor.Document, curLine.Offset)); |
|
||||||
} |
|
||||||
|
|
||||||
// look for next eol if line is not empty
|
|
||||||
// (the lexer does not produce eols for empty lines)
|
|
||||||
if (!string.IsNullOrEmpty(noComments) && i >= nextEol) { |
|
||||||
int search = eols.BinarySearch(i); |
|
||||||
if (search < 0) |
|
||||||
search = ~search; |
|
||||||
nextEol = search < eols.Count ? eols[search] : i; |
|
||||||
} |
|
||||||
|
|
||||||
// remove indentation in last line of multiline array(, collection, object) initializers
|
|
||||||
if (i == nextEol && wasMultiLine && (noComments == "}" || sawAttribute)) { |
|
||||||
wasMultiLine = false; |
|
||||||
Unindent(indentation); |
|
||||||
} |
|
||||||
|
|
||||||
// apply the indentation
|
|
||||||
editor.Document.SmartReplaceLine(curLine, (indentation.PeekOrDefault() ?? "") + lineText); |
|
||||||
|
|
||||||
// indent line if it is ended by (implicit) line continuation
|
|
||||||
if (i < nextEol && !wasMultiLine) { |
|
||||||
wasMultiLine = true; |
|
||||||
Indent(editor, indentation); |
|
||||||
} |
|
||||||
|
|
||||||
// unindent if this is the last line of a multiline statement
|
|
||||||
if (i == nextEol && wasMultiLine) { |
|
||||||
wasMultiLine = false; |
|
||||||
Unindent(indentation); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
static void Unindent(Stack<string> indentation) |
|
||||||
{ |
|
||||||
indentation.PopOrDefault(); |
|
||||||
} |
|
||||||
|
|
||||||
static void Indent(ITextEditor editor, Stack<string> indentation, string indent = null) |
|
||||||
{ |
|
||||||
indentation.Push((indentation.PeekOrDefault() ?? string.Empty) + (indent ?? editor.Options.IndentationString)); |
|
||||||
} |
|
||||||
|
|
||||||
internal static bool IsBlockStart(ILexer lexer, Token current, Token prev) |
|
||||||
{ |
|
||||||
bool tmp; |
|
||||||
return IsBlockStart(lexer, current, prev, out tmp); |
|
||||||
} |
|
||||||
|
|
||||||
static bool IsBlockStart(ILexer lexer, Token current, Token prev, out bool isMultiLineLambda) |
|
||||||
{ |
|
||||||
isMultiLineLambda = false; |
|
||||||
|
|
||||||
if (blockTokens.Contains(current.Kind)) { |
|
||||||
if (current.Kind == Tokens.If) { |
|
||||||
if (prev.Kind != Tokens.EOL) |
|
||||||
return false; |
|
||||||
|
|
||||||
lexer.StartPeek(); |
|
||||||
|
|
||||||
Token currentToken = null; |
|
||||||
|
|
||||||
while ((currentToken = lexer.Peek()).Kind > Tokens.EOL) { |
|
||||||
if (currentToken.Kind == Tokens.Then) |
|
||||||
return lexer.Peek().Kind == Tokens.EOL; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// check if it is a lambda
|
|
||||||
if (current.Kind == Tokens.Function || current.Kind == Tokens.Sub) { |
|
||||||
lexer.StartPeek(); |
|
||||||
|
|
||||||
bool isSingleLineLambda = false; |
|
||||||
|
|
||||||
if (lexer.Peek().Kind == Tokens.OpenParenthesis) { |
|
||||||
isSingleLineLambda = true; |
|
||||||
|
|
||||||
int brackets = 1; |
|
||||||
|
|
||||||
// look for end of parameter list
|
|
||||||
while (brackets > 0) { |
|
||||||
var t = lexer.Peek(); |
|
||||||
if (t.Kind == Tokens.OpenParenthesis) |
|
||||||
brackets++; |
|
||||||
if (t.Kind == Tokens.CloseParenthesis) |
|
||||||
brackets--; |
|
||||||
} |
|
||||||
|
|
||||||
// expression is multi-line lambda if next Token is EOL
|
|
||||||
if (brackets == 0) |
|
||||||
return isMultiLineLambda = (lexer.Peek().Kind == Tokens.EOL); |
|
||||||
} |
|
||||||
|
|
||||||
// do not indent if current token is start of single-line lambda
|
|
||||||
if (isSingleLineLambda) |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
if (current.Kind == Tokens.With && prev.Kind > Tokens.EOL) |
|
||||||
return false; |
|
||||||
|
|
||||||
if (current.Kind == Tokens.While && (prev.Kind == Tokens.Skip || prev.Kind == Tokens.Take)) |
|
||||||
return false; |
|
||||||
|
|
||||||
if (current.Kind == Tokens.Select && prev.Kind > Tokens.EOL) |
|
||||||
return false; |
|
||||||
|
|
||||||
if (current.Kind == Tokens.Class || current.Kind == Tokens.Structure) { |
|
||||||
lexer.StartPeek(); |
|
||||||
|
|
||||||
Token t = lexer.Peek(); |
|
||||||
|
|
||||||
if (t.Kind == Tokens.CloseParenthesis || t.Kind == Tokens.CloseCurlyBrace || t.Kind == Tokens.Comma) |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
if (current.Kind == Tokens.Module) { |
|
||||||
lexer.StartPeek(); |
|
||||||
|
|
||||||
Token t = lexer.Peek(); |
|
||||||
|
|
||||||
if (t.Kind == Tokens.Colon) |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
if (prev.Kind == Tokens.End || |
|
||||||
prev.Kind == Tokens.Loop || |
|
||||||
prev.Kind == Tokens.Exit || |
|
||||||
prev.Kind == Tokens.Continue || |
|
||||||
prev.Kind == Tokens.Resume || |
|
||||||
prev.Kind == Tokens.GoTo || |
|
||||||
prev.Kind == Tokens.Do) |
|
||||||
return false; |
|
||||||
else |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
return IsSpecialCase(current, prev); |
|
||||||
} |
|
||||||
|
|
||||||
internal static bool IsBlockEnd(Token current, Token prev) |
|
||||||
{ |
|
||||||
if (current.Kind == Tokens.Next) |
|
||||||
return prev.Kind == Tokens.EOL || prev.Kind == Tokens.Colon; |
|
||||||
|
|
||||||
if (current.Kind == Tokens.Loop) |
|
||||||
return prev.Kind == Tokens.EOL || prev.Kind == Tokens.Colon; |
|
||||||
|
|
||||||
if (blockTokens.Contains(current.Kind)) |
|
||||||
return prev.Kind == Tokens.End; |
|
||||||
|
|
||||||
return IsSpecialCase(current, prev); |
|
||||||
} |
|
||||||
|
|
||||||
static bool IsSpecialCase(Token current, Token prev) |
|
||||||
{ |
|
||||||
switch (current.Kind) { |
|
||||||
case Tokens.Else: |
|
||||||
return true; |
|
||||||
case Tokens.Case: |
|
||||||
return prev.Kind != Tokens.Select; |
|
||||||
case Tokens.ElseIf: |
|
||||||
return true; |
|
||||||
case Tokens.Catch: |
|
||||||
return true; |
|
||||||
case Tokens.Finally: |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the next member after the specified caret position.
|
|
||||||
/// </summary>
|
|
||||||
static object GetMemberAfter(ITextEditor editor, int caretLine) |
|
||||||
{ |
|
||||||
string fileName = editor.FileName; |
|
||||||
object nextElement = null; |
|
||||||
if (fileName != null && fileName.Length > 0 ) { |
|
||||||
ParseInformation parseInfo = ParserService.ParseFile(fileName, editor.Document); |
|
||||||
if (parseInfo != null) { |
|
||||||
ICompilationUnit currentCompilationUnit = parseInfo.CompilationUnit; |
|
||||||
if (currentCompilationUnit != null) { |
|
||||||
IClass currentClass = currentCompilationUnit.GetInnermostClass(caretLine, 0); |
|
||||||
int nextElementLine = int.MaxValue; |
|
||||||
if (currentClass == null) { |
|
||||||
foreach (IClass c in currentCompilationUnit.Classes) { |
|
||||||
if (c.Region.BeginLine < nextElementLine && c.Region.BeginLine > caretLine) { |
|
||||||
nextElementLine = c.Region.BeginLine; |
|
||||||
nextElement = c; |
|
||||||
} |
|
||||||
} |
|
||||||
} else { |
|
||||||
foreach (IClass c in currentClass.InnerClasses) { |
|
||||||
if (c.Region.BeginLine < nextElementLine && c.Region.BeginLine > caretLine) { |
|
||||||
nextElementLine = c.Region.BeginLine; |
|
||||||
nextElement = c; |
|
||||||
} |
|
||||||
} |
|
||||||
foreach (IMember m in currentClass.AllMembers) { |
|
||||||
if (m.Region.BeginLine < nextElementLine && m.Region.BeginLine > caretLine) { |
|
||||||
nextElementLine = m.Region.BeginLine; |
|
||||||
nextElement = m; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
return nextElement; |
|
||||||
} |
|
||||||
|
|
||||||
public override void IndentLine(ITextEditor editor, IDocumentLine line) |
|
||||||
{ |
|
||||||
IndentLines(editor, line.LineNumber, line.LineNumber); |
|
||||||
} |
|
||||||
|
|
||||||
public override void SurroundSelectionWithComment(ITextEditor editor) |
|
||||||
{ |
|
||||||
SurroundSelectionWithSingleLineComment(editor, "'"); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,55 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using ICSharpCode.NRefactory.Parser; |
|
||||||
using ICSharpCode.NRefactory.Parser.VB; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding |
|
||||||
{ |
|
||||||
public class VBStatement |
|
||||||
{ |
|
||||||
string startRegex = ""; |
|
||||||
|
|
||||||
public string StartRegex { |
|
||||||
get { return startRegex; } |
|
||||||
} |
|
||||||
|
|
||||||
string endRegex = ""; |
|
||||||
|
|
||||||
public string EndRegex { |
|
||||||
get { return endRegex; } |
|
||||||
} |
|
||||||
|
|
||||||
string endStatement = ""; |
|
||||||
|
|
||||||
public string EndStatement { |
|
||||||
get { return endStatement; } |
|
||||||
} |
|
||||||
|
|
||||||
int statementToken = 0; |
|
||||||
|
|
||||||
public int StatementToken { |
|
||||||
get { return statementToken; } |
|
||||||
} |
|
||||||
|
|
||||||
int indentPlus = 0; |
|
||||||
|
|
||||||
public int IndentPlus { |
|
||||||
get { return indentPlus; } |
|
||||||
} |
|
||||||
|
|
||||||
public VBStatement() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public VBStatement(string startRegex, string endRegex, string endStatement, int indentPlus, int statementToken) |
|
||||||
{ |
|
||||||
this.startRegex = startRegex; |
|
||||||
this.endRegex = endRegex; |
|
||||||
this.endStatement = endStatement; |
|
||||||
this.indentPlus = indentPlus; |
|
||||||
this.statementToken = statementToken; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,82 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Text.RegularExpressions; |
|
||||||
using ICSharpCode.SharpDevelop.Editor; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding |
|
||||||
{ |
|
||||||
public static class LanguageUtils |
|
||||||
{ |
|
||||||
public static string TrimComments(this string line) |
|
||||||
{ |
|
||||||
if (string.IsNullOrEmpty(line)) |
|
||||||
return string.Empty; |
|
||||||
|
|
||||||
bool inStr = false; |
|
||||||
|
|
||||||
for (int i = 0; i < line.Length; i++) { |
|
||||||
if (line[i] == '"') |
|
||||||
inStr = !inStr; |
|
||||||
if (line[i] == '\'' && !inStr) |
|
||||||
return line.Substring(0, i); |
|
||||||
} |
|
||||||
|
|
||||||
return line; |
|
||||||
} |
|
||||||
|
|
||||||
public static string TrimPreprocessorDirectives(this string line) |
|
||||||
{ |
|
||||||
if (string.IsNullOrEmpty(line)) |
|
||||||
return string.Empty; |
|
||||||
|
|
||||||
bool wsOnly = true; |
|
||||||
|
|
||||||
for (int i = 0; i < line.Length; i++) { |
|
||||||
if (line[i] == '#' && wsOnly) { |
|
||||||
if (i < line.Length - 1) { |
|
||||||
if (char.IsLetter(line[i + 1])) |
|
||||||
return line.Substring(0, i); |
|
||||||
} else |
|
||||||
return line.Substring(0, i); |
|
||||||
} |
|
||||||
if (!char.IsWhiteSpace(line[i])) |
|
||||||
wsOnly = false; |
|
||||||
} |
|
||||||
|
|
||||||
return line; |
|
||||||
} |
|
||||||
|
|
||||||
public static string TrimLine(this string line) |
|
||||||
{ |
|
||||||
if (string.IsNullOrEmpty(line)) |
|
||||||
return string.Empty; |
|
||||||
// remove string content
|
|
||||||
MatchCollection matches = Regex.Matches(line, "\"[^\"]*?\"", RegexOptions.Singleline); |
|
||||||
foreach (Match match in matches) { |
|
||||||
line = line.Remove(match.Index, match.Length).Insert(match.Index, new string('-', match.Length)); |
|
||||||
} |
|
||||||
// remove comments
|
|
||||||
return TrimComments(line); |
|
||||||
} |
|
||||||
|
|
||||||
public static bool IsInsideDocumentationComment(ITextEditor editor) |
|
||||||
{ |
|
||||||
return IsInsideDocumentationComment(editor, editor.Document.GetLineForOffset(editor.Caret.Offset), editor.Caret.Offset); |
|
||||||
} |
|
||||||
|
|
||||||
public static bool IsInsideDocumentationComment(ITextEditor editor, IDocumentLine curLine, int cursorOffset) |
|
||||||
{ |
|
||||||
for (int i = curLine.Offset; i < cursorOffset; ++i) { |
|
||||||
char ch = editor.Document.GetCharAt(i); |
|
||||||
if (ch == '"') |
|
||||||
return false; |
|
||||||
if (ch == '\'' && i + 2 < cursorOffset && editor.Document.GetCharAt(i + 1) == '\'' && |
|
||||||
editor.Document.GetCharAt(i + 2) == '\'') |
|
||||||
return true; |
|
||||||
} |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,151 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.SharpDevelop.Project; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding |
|
||||||
{ |
|
||||||
public static class MyNamespaceBuilder |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Builds Visual Basic's "My" namespace for the specified project.
|
|
||||||
/// </summary>
|
|
||||||
public static void BuildNamespace(VBNetProject project, IProjectContent pc) |
|
||||||
{ |
|
||||||
if ("custom".Equals(project.GetEvaluatedProperty("MyType"), StringComparison.OrdinalIgnoreCase)) |
|
||||||
return; |
|
||||||
|
|
||||||
ICompilationUnit cu = new DefaultCompilationUnit(pc); |
|
||||||
//cu.FileName = "GeneratedMyNamespace.vb"; // leave FileName null - fixes SD2-854
|
|
||||||
string ns; |
|
||||||
if (project.RootNamespace == null || project.RootNamespace.Length == 0) |
|
||||||
ns = "My"; |
|
||||||
else |
|
||||||
ns = project.RootNamespace + ".My"; |
|
||||||
IClass myApp = CreateMyApplication(cu, project, ns); |
|
||||||
IClass myComp = CreateMyComputer(cu, ns); |
|
||||||
|
|
||||||
cu.Classes.Add(myApp); |
|
||||||
cu.Classes.Add(myComp); |
|
||||||
|
|
||||||
IClass myForms = null; |
|
||||||
if (project.OutputType == OutputType.WinExe) { |
|
||||||
myForms = CreateMyForms(cu, ns); |
|
||||||
cu.Classes.Add(myForms); |
|
||||||
} |
|
||||||
DefaultClass c = new DefaultClass(cu, ns + ".MyProject"); |
|
||||||
c.ClassType = ClassType.Module; |
|
||||||
c.Modifiers = ModifierEnum.Internal | ModifierEnum.Partial | ModifierEnum.Sealed | ModifierEnum.Synthetic; |
|
||||||
c.Attributes.Add(new DefaultAttribute(CreateTypeRef(cu, "Microsoft.VisualBasic.HideModuleNameAttribute"))); |
|
||||||
|
|
||||||
// we need to use GetClassReturnType instead of DefaultReturnType because we need
|
|
||||||
// a reference to the compound class.
|
|
||||||
c.Properties.Add(new DefaultProperty("Application", |
|
||||||
new GetClassReturnType(pc, myApp.FullyQualifiedName, 0), |
|
||||||
ModifierEnum.Public | ModifierEnum.Static, |
|
||||||
DomRegion.Empty, DomRegion.Empty, c)); |
|
||||||
c.Properties.Add(new DefaultProperty("Computer", |
|
||||||
new GetClassReturnType(pc, myComp.FullyQualifiedName, 0), |
|
||||||
ModifierEnum.Public | ModifierEnum.Static, |
|
||||||
DomRegion.Empty, DomRegion.Empty, c)); |
|
||||||
if (myForms != null) { |
|
||||||
c.Properties.Add(new DefaultProperty("Forms", |
|
||||||
new GetClassReturnType(pc, myForms.FullyQualifiedName, 0), |
|
||||||
ModifierEnum.Public | ModifierEnum.Static, |
|
||||||
DomRegion.Empty, DomRegion.Empty, c)); |
|
||||||
} |
|
||||||
c.Properties.Add(new DefaultProperty("User", |
|
||||||
new GetClassReturnType(pc, "Microsoft.VisualBasic.ApplicationServices.User", 0), |
|
||||||
ModifierEnum.Public | ModifierEnum.Static, |
|
||||||
DomRegion.Empty, DomRegion.Empty, c)); |
|
||||||
cu.Classes.Add(c); |
|
||||||
pc.UpdateCompilationUnit(null, cu, cu.FileName); |
|
||||||
} |
|
||||||
|
|
||||||
static IClass CreateMyApplication(ICompilationUnit cu, VBNetProject project, string ns) |
|
||||||
{ |
|
||||||
DefaultClass c = new DefaultClass(cu, ns + ".MyApplication"); |
|
||||||
c.ClassType = ClassType.Class; |
|
||||||
c.Modifiers = ModifierEnum.Internal | ModifierEnum.Sealed | ModifierEnum.Partial | ModifierEnum.Synthetic; |
|
||||||
c.Attributes.Add(new DefaultAttribute(CreateTypeRef(cu, "Microsoft.VisualBasic.HideModuleNameAttribute"))); |
|
||||||
switch (project.OutputType) { |
|
||||||
case OutputType.WinExe: |
|
||||||
c.BaseTypes.Add(CreateTypeRef(cu, "Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase")); |
|
||||||
if (project.GetEvaluatedProperty("MyType") == "WindowsForms") { |
|
||||||
c.Methods.Add( |
|
||||||
new DefaultMethod(c, "Main") { |
|
||||||
Modifiers = ModifierEnum.Internal | ModifierEnum.Static, |
|
||||||
ReturnType = c.ProjectContent.SystemTypes.Void, |
|
||||||
Parameters = new[] { |
|
||||||
new DefaultParameter( |
|
||||||
"args", |
|
||||||
new ArrayReturnType(c.ProjectContent, c.ProjectContent.SystemTypes.String, 1), |
|
||||||
DomRegion.Empty |
|
||||||
) |
|
||||||
} |
|
||||||
}); |
|
||||||
} |
|
||||||
break; |
|
||||||
case OutputType.Exe: |
|
||||||
c.BaseTypes.Add(CreateTypeRef(cu, "Microsoft.VisualBasic.ApplicationServices.ConsoleApplicationBase")); |
|
||||||
break; |
|
||||||
default: |
|
||||||
c.BaseTypes.Add(CreateTypeRef(cu, "Microsoft.VisualBasic.ApplicationServices.ApplicationBase")); |
|
||||||
break; |
|
||||||
} |
|
||||||
return c; |
|
||||||
} |
|
||||||
|
|
||||||
static IReturnType CreateTypeRef(ICompilationUnit cu, string fullName) |
|
||||||
{ |
|
||||||
return new GetClassReturnType(cu.ProjectContent, fullName, 0); |
|
||||||
} |
|
||||||
|
|
||||||
static IClass CreateMyComputer(ICompilationUnit cu, string ns) |
|
||||||
{ |
|
||||||
DefaultClass c = new DefaultClass(cu, ns + ".MyComputer"); |
|
||||||
c.ClassType = ClassType.Class; |
|
||||||
c.Modifiers = ModifierEnum.Internal | ModifierEnum.Sealed | ModifierEnum.Partial | ModifierEnum.Synthetic; |
|
||||||
c.Attributes.Add(new DefaultAttribute(CreateTypeRef(cu, "Microsoft.VisualBasic.HideModuleNameAttribute"))); |
|
||||||
c.BaseTypes.Add(CreateTypeRef(cu, "Microsoft.VisualBasic.Devices.Computer")); |
|
||||||
return c; |
|
||||||
} |
|
||||||
|
|
||||||
static IClass CreateMyForms(ICompilationUnit cu, string ns) |
|
||||||
{ |
|
||||||
DefaultClass c = new MyFormsClass(cu, ns + ".MyForms"); |
|
||||||
c.ClassType = ClassType.Class; |
|
||||||
c.Modifiers = ModifierEnum.Internal | ModifierEnum.Sealed | ModifierEnum.Synthetic; |
|
||||||
c.Attributes.Add(new DefaultAttribute(CreateTypeRef(cu, "Microsoft.VisualBasic.HideModuleNameAttribute"))); |
|
||||||
return c; |
|
||||||
} |
|
||||||
|
|
||||||
class MyFormsClass : DefaultClass |
|
||||||
{ |
|
||||||
public MyFormsClass(ICompilationUnit cu, string fullName) : base(cu, fullName) {} |
|
||||||
|
|
||||||
public override IList<IProperty> Properties { |
|
||||||
get { |
|
||||||
// TODO: This class must be immutable when frozen, we cannot change the properties!
|
|
||||||
|
|
||||||
List<IProperty> properties = new List<IProperty>(); |
|
||||||
IClass formClass = this.ProjectContent.GetClass("System.Windows.Forms.Form", 0); |
|
||||||
if (formClass == null) |
|
||||||
return properties; |
|
||||||
foreach (IClass c in this.ProjectContent.Classes) { |
|
||||||
if (c.IsTypeInInheritanceTree(formClass)) { |
|
||||||
properties.Add(new DefaultProperty(c.Name, |
|
||||||
new GetClassReturnType(this.ProjectContent, c.FullyQualifiedName, 0), |
|
||||||
ModifierEnum.Public | ModifierEnum.Static, |
|
||||||
DomRegion.Empty, DomRegion.Empty, c)); |
|
||||||
} |
|
||||||
} |
|
||||||
return properties; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,135 +0,0 @@ |
|||||||
/* |
|
||||||
* Created by SharpDevelop. |
|
||||||
* User: Peter Forstmeier |
|
||||||
* Date: 06.08.2012 |
|
||||||
* Time: 19:43 |
|
||||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
|
||||||
*/ |
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using ICSharpCode.SharpDevelop.Gui.OptionPanels; |
|
||||||
using ICSharpCode.SharpDevelop.Project; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding.OptionPanels |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Interaction logic for BuildOptionsXaml.xaml
|
|
||||||
/// </summary>
|
|
||||||
public partial class BuildOptions : ProjectOptionPanel |
|
||||||
{ |
|
||||||
public BuildOptions() |
|
||||||
{ |
|
||||||
InitializeComponent(); |
|
||||||
DataContext = this; |
|
||||||
|
|
||||||
|
|
||||||
optionExplicitItems = new List<KeyItemPair>(); |
|
||||||
optionExplicitItems.Add(new KeyItemPair("Off","Explicit Off")); |
|
||||||
optionExplicitItems.Add(new KeyItemPair("On","Explicit On")); |
|
||||||
OptionExplicitItems = optionExplicitItems; |
|
||||||
|
|
||||||
optionStrictItems = new List<KeyItemPair>(); |
|
||||||
optionStrictItems.Add(new KeyItemPair("Off", "Strict Off")); |
|
||||||
optionStrictItems.Add(new KeyItemPair("On", "Strict On")); |
|
||||||
OptionStrictItems = optionStrictItems; |
|
||||||
|
|
||||||
|
|
||||||
optionCompareItems = new List<KeyItemPair>(); |
|
||||||
optionCompareItems.Add(new KeyItemPair("Binary", "Compare Binary")); |
|
||||||
optionCompareItems.Add(new KeyItemPair("Text", "Compare Text")); |
|
||||||
OptionCompareItems = optionCompareItems; |
|
||||||
|
|
||||||
optionInferItems = new List<KeyItemPair>(); |
|
||||||
optionInferItems.Add(new KeyItemPair("Off", "Infer Off")); |
|
||||||
optionInferItems.Add(new KeyItemPair("On", "Infer On")); |
|
||||||
OptionInferItems = optionInferItems; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
public ProjectProperty<string> DefineConstants { |
|
||||||
get { return GetProperty("DefineConstants", "", TextBoxEditMode.EditRawProperty); } |
|
||||||
} |
|
||||||
|
|
||||||
public ProjectProperty<bool> Optimize { |
|
||||||
get { return GetProperty("Optimize", false, PropertyStorageLocations.ConfigurationSpecific); } |
|
||||||
} |
|
||||||
|
|
||||||
public ProjectProperty<string> RemoveIntegerChecks { |
|
||||||
get { return GetProperty("RemoveIntegerChecks", "", TextBoxEditMode.EditRawProperty); } |
|
||||||
} |
|
||||||
|
|
||||||
public ProjectProperty<string> OptionExplicit { |
|
||||||
get {return GetProperty("OptionExplicit", "", TextBoxEditMode.EditRawProperty); } |
|
||||||
} |
|
||||||
|
|
||||||
public ProjectProperty<string> OptionStrict { |
|
||||||
get { return GetProperty("OptionStrict", "Off", TextBoxEditMode.EditRawProperty); } |
|
||||||
} |
|
||||||
|
|
||||||
public ProjectProperty<string> OptionCompare { |
|
||||||
get { return GetProperty("OptionCompare", "Binary", TextBoxEditMode.EditRawProperty); } |
|
||||||
} |
|
||||||
|
|
||||||
public ProjectProperty<string> OptionInfer { |
|
||||||
get { return GetProperty("OptionInfer", "Off", TextBoxEditMode.EditRawProperty); } |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
#region OptionItems
|
|
||||||
|
|
||||||
List<KeyItemPair> optionExplicitItems; |
|
||||||
|
|
||||||
public List<KeyItemPair> OptionExplicitItems { |
|
||||||
get { return optionExplicitItems; } |
|
||||||
set { optionExplicitItems = value; |
|
||||||
base.RaisePropertyChanged(() => OptionExplicitItems); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
List<KeyItemPair> optionStrictItems; |
|
||||||
|
|
||||||
public List<KeyItemPair> OptionStrictItems { |
|
||||||
get { return optionStrictItems; } |
|
||||||
set { optionStrictItems = value; |
|
||||||
base.RaisePropertyChanged(() => OptionStrictItems); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
private List<KeyItemPair> optionCompareItems; |
|
||||||
|
|
||||||
public List<KeyItemPair> OptionCompareItems { |
|
||||||
get { return optionCompareItems; } |
|
||||||
set { optionCompareItems = value; |
|
||||||
base.RaisePropertyChanged(() => OptionCompareItems); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
List<KeyItemPair> optionInferItems; |
|
||||||
|
|
||||||
public List<KeyItemPair> OptionInferItems { |
|
||||||
get { return optionInferItems; } |
|
||||||
set { optionInferItems = value; |
|
||||||
base.RaisePropertyChanged(()=>OptionInferItems); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region overrides
|
|
||||||
|
|
||||||
|
|
||||||
protected override void Initialize() |
|
||||||
{ |
|
||||||
base.Initialize(); |
|
||||||
buildOutput.Initialize(this); |
|
||||||
this.buildAdvanced.Initialize(this); |
|
||||||
this.errorsAndWarnings.Initialize(this); |
|
||||||
this.treatErrorsAndWarnings.Initialize(this); |
|
||||||
} |
|
||||||
#endregion
|
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,172 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Collections.ObjectModel; |
|
||||||
using System.Text; |
|
||||||
using System.Windows; |
|
||||||
using System.Windows.Controls; |
|
||||||
using System.Windows.Data; |
|
||||||
using System.Windows.Documents; |
|
||||||
using System.Windows.Input; |
|
||||||
using System.Windows.Media; |
|
||||||
using System.Linq; |
|
||||||
using ICSharpCode.SharpDevelop; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.SharpDevelop.Gui; |
|
||||||
using ICSharpCode.SharpDevelop.Gui.OptionPanels; |
|
||||||
using ICSharpCode.SharpDevelop.Project; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding.OptionPanels |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Interaction logic for ProjectImportsOptions.xaml
|
|
||||||
/// </summary>
|
|
||||||
public partial class ProjectImports : ProjectOptionPanel |
|
||||||
{ |
|
||||||
|
|
||||||
public ProjectImports() |
|
||||||
{ |
|
||||||
InitializeComponent(); |
|
||||||
} |
|
||||||
|
|
||||||
#region override
|
|
||||||
|
|
||||||
protected override void Initialize() |
|
||||||
{ |
|
||||||
ProjectItems = new ObservableCollection<string>(); |
|
||||||
NameSpaceItems = new ObservableCollection<string> (); |
|
||||||
|
|
||||||
foreach(ProjectItem item in base.Project.Items) |
|
||||||
{ |
|
||||||
if(item.ItemType == ItemType.Import) { |
|
||||||
ProjectItems.Add(item.Include); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
IProjectContent projectContent = ParserService.GetProjectContent(base.Project); |
|
||||||
foreach(IProjectContent refProjectContent in projectContent.ThreadSafeGetReferencedContents()) { |
|
||||||
AddNamespaces(refProjectContent); |
|
||||||
} |
|
||||||
AddNamespaces(projectContent); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
protected override bool Save(MSBuildBasedProject project, string configuration, string platform) |
|
||||||
{ |
|
||||||
List<ProjectItem> imports = new List<ProjectItem>(); |
|
||||||
foreach(ProjectItem item in project.Items) |
|
||||||
{ |
|
||||||
if(item.ItemType == ItemType.Import) |
|
||||||
{ |
|
||||||
imports.Add(item); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
foreach(ImportProjectItem item in imports) |
|
||||||
{ |
|
||||||
ProjectService.RemoveProjectItem(project, item); |
|
||||||
} |
|
||||||
|
|
||||||
foreach(string importedNamespace in ProjectItems) |
|
||||||
{ |
|
||||||
ProjectService.AddProjectItem(project, new ImportProjectItem(project, importedNamespace)); |
|
||||||
} |
|
||||||
|
|
||||||
return base.Save(project, configuration, platform); |
|
||||||
} |
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
private ObservableCollection<string> projectItems; |
|
||||||
|
|
||||||
public ObservableCollection<string> ProjectItems { |
|
||||||
get { return projectItems; } |
|
||||||
set { projectItems = value; |
|
||||||
base.RaisePropertyChanged(() => ProjectItems); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private string selectedProjectItem; |
|
||||||
|
|
||||||
public string SelectedProjectItem { |
|
||||||
get { return selectedProjectItem; } |
|
||||||
set { selectedProjectItem = value; |
|
||||||
base.RaisePropertyChanged(() => SelectedProjectItem); |
|
||||||
RemoveButtonEnable = true; |
|
||||||
AddButtonEnable = false; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private ObservableCollection <string> nameSpaceItems; |
|
||||||
|
|
||||||
public ObservableCollection<string> NameSpaceItems { |
|
||||||
get { return nameSpaceItems; } |
|
||||||
set { nameSpaceItems = value; |
|
||||||
base.RaisePropertyChanged(() => NameSpaceItems); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
private string selectedNameSpace; |
|
||||||
|
|
||||||
public string SelectedNameSpace { |
|
||||||
get { return selectedNameSpace; } |
|
||||||
set { selectedNameSpace = value; |
|
||||||
base.RaisePropertyChanged(()=>SelectedNameSpace); |
|
||||||
AddButtonEnable = true; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
private bool addButtonEnable; |
|
||||||
|
|
||||||
public bool AddButtonEnable { |
|
||||||
get { return addButtonEnable; } |
|
||||||
set { addButtonEnable = value; |
|
||||||
base.RaisePropertyChanged(() => AddButtonEnable); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private bool removeButtonEnable; |
|
||||||
|
|
||||||
public bool RemoveButtonEnable { |
|
||||||
get { return removeButtonEnable; } |
|
||||||
set { removeButtonEnable = value; |
|
||||||
base.RaisePropertyChanged(() => RemoveButtonEnable); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void AddNamespaces(IProjectContent projectContent) |
|
||||||
{ |
|
||||||
foreach(string projectNamespace in projectContent.NamespaceNames) { |
|
||||||
if (!string.IsNullOrEmpty(projectNamespace)) { |
|
||||||
|
|
||||||
if (!NameSpaceItems.Contains(projectNamespace)) { |
|
||||||
NameSpaceItems.Add(projectNamespace); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void AddButton_Click(object sender, RoutedEventArgs e) |
|
||||||
{ |
|
||||||
ProjectItems.Add(SelectedNameSpace); |
|
||||||
IsDirty = true; |
|
||||||
} |
|
||||||
|
|
||||||
void RemoveButton_Click(object sender, RoutedEventArgs e) |
|
||||||
{ |
|
||||||
ProjectItems.Remove(SelectedProjectItem); |
|
||||||
SelectedProjectItem = null; |
|
||||||
RemoveButtonEnable = false; |
|
||||||
AddButtonEnable = false; |
|
||||||
IsDirty = true; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,37 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Text; |
|
||||||
using System.Windows; |
|
||||||
using System.Windows.Controls; |
|
||||||
using System.Windows.Data; |
|
||||||
using System.Windows.Documents; |
|
||||||
using System.Windows.Input; |
|
||||||
using System.Windows.Media; |
|
||||||
using ICSharpCode.Core; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding.OptionPanels |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Interaction logic for TextEditorOptions.xaml
|
|
||||||
/// </summary>
|
|
||||||
public partial class TextEditorOptions |
|
||||||
{ |
|
||||||
public TextEditorOptions() |
|
||||||
{ |
|
||||||
InitializeComponent(); |
|
||||||
} |
|
||||||
|
|
||||||
public static bool EnableEndConstructs { |
|
||||||
get { return PropertyService.Get("VBBinding.TextEditor.EnableEndConstructs", true); } |
|
||||||
set { PropertyService.Set("VBBinding.TextEditor.EnableEndConstructs", value); } |
|
||||||
} |
|
||||||
|
|
||||||
public static bool EnableCasing { |
|
||||||
get { return PropertyService.Get("VBBinding.TextEditor.EnableCasing", true); } |
|
||||||
set { PropertyService.Set("VBBinding.TextEditor.EnableCasing", value); } |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,107 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.IO; |
|
||||||
using System.Linq; |
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver; |
|
||||||
using ICSharpCode.SharpDevelop.Dom.VBNet; |
|
||||||
using ICSharpCode.SharpDevelop.Project; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding |
|
||||||
{ |
|
||||||
public class TParser : IParser |
|
||||||
{ |
|
||||||
///<summary>IParser Interface</summary>
|
|
||||||
string[] lexerTags; |
|
||||||
|
|
||||||
public string[] LexerTags { |
|
||||||
get { return lexerTags; } |
|
||||||
set { lexerTags = value; } |
|
||||||
} |
|
||||||
|
|
||||||
public LanguageProperties Language { |
|
||||||
get { return LanguageProperties.VBNet; } |
|
||||||
} |
|
||||||
|
|
||||||
public IExpressionFinder CreateExpressionFinder(string fileName) |
|
||||||
{ |
|
||||||
return new VBNetExpressionFinder(ParserService.GetParseInformation(fileName)); |
|
||||||
} |
|
||||||
|
|
||||||
public bool CanParse(string fileName) |
|
||||||
{ |
|
||||||
return Path.GetExtension(fileName).Equals(".VB", StringComparison.OrdinalIgnoreCase); |
|
||||||
} |
|
||||||
|
|
||||||
public bool CanParse(IProject project) |
|
||||||
{ |
|
||||||
return project.Language == "VBNet"; |
|
||||||
} |
|
||||||
|
|
||||||
static void RetrieveRegions(ICompilationUnit cu, ICSharpCode.NRefactory.Parser.SpecialTracker tracker) |
|
||||||
{ |
|
||||||
Stack<ICSharpCode.NRefactory.PreprocessingDirective> regionStartDirectives = new Stack<ICSharpCode.NRefactory.PreprocessingDirective>(); |
|
||||||
|
|
||||||
foreach (ICSharpCode.NRefactory.PreprocessingDirective directive in tracker.CurrentSpecials.OfType<ICSharpCode.NRefactory.PreprocessingDirective>()) { |
|
||||||
if (directive.Cmd.Equals("#region", StringComparison.OrdinalIgnoreCase)) |
|
||||||
regionStartDirectives.Push(directive); |
|
||||||
if (directive.Cmd.Equals("#end", StringComparison.OrdinalIgnoreCase) |
|
||||||
// using StartsWith allows comments at end of line
|
|
||||||
// fixes http://community.sharpdevelop.net/forums/t/12252.aspx
|
|
||||||
&& directive.Arg.StartsWith("region", StringComparison.OrdinalIgnoreCase) |
|
||||||
&& regionStartDirectives.Any()) { |
|
||||||
ICSharpCode.NRefactory.PreprocessingDirective start = regionStartDirectives.Pop(); |
|
||||||
cu.FoldingRegions.Add(new FoldingRegion(start.Arg.TrimComments().Trim().Trim('"'), DomRegion.FromLocation(start.StartPosition, directive.EndPosition))); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public ICompilationUnit Parse(IProjectContent projectContent, string fileName, ICSharpCode.SharpDevelop.ITextBuffer fileContent) |
|
||||||
{ |
|
||||||
using (ICSharpCode.NRefactory.IParser p = ICSharpCode.NRefactory.ParserFactory.CreateParser(ICSharpCode.NRefactory.SupportedLanguage.VBNet, fileContent.CreateReader())) { |
|
||||||
return Parse(p, fileName, projectContent); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
ICompilationUnit Parse(ICSharpCode.NRefactory.IParser p, string fileName, IProjectContent projectContent) |
|
||||||
{ |
|
||||||
p.Lexer.SpecialCommentTags = lexerTags; |
|
||||||
p.ParseMethodBodies = false; |
|
||||||
p.Parse(); |
|
||||||
|
|
||||||
NRefactoryASTConvertVisitor visitor = new NRefactoryASTConvertVisitor(projectContent, ICSharpCode.NRefactory.SupportedLanguage.VBNet); |
|
||||||
if (projectContent.Project != null) { |
|
||||||
visitor.VBRootNamespace = ((IProject)projectContent.Project).RootNamespace; |
|
||||||
} |
|
||||||
visitor.Specials = p.Lexer.SpecialTracker.CurrentSpecials; |
|
||||||
visitor.VisitCompilationUnit(p.CompilationUnit, null); |
|
||||||
visitor.Cu.FileName = fileName; |
|
||||||
visitor.Cu.ErrorsDuringCompile = p.Errors.Count > 0; |
|
||||||
RetrieveRegions(visitor.Cu, p.Lexer.SpecialTracker); |
|
||||||
AddCommentTags(visitor.Cu, p.Lexer.TagComments); |
|
||||||
|
|
||||||
return visitor.Cu; |
|
||||||
} |
|
||||||
|
|
||||||
static void AddCommentTags(ICompilationUnit cu, System.Collections.Generic.List<ICSharpCode.NRefactory.Parser.TagComment> tagComments) |
|
||||||
{ |
|
||||||
foreach (ICSharpCode.NRefactory.Parser.TagComment tagComment in tagComments) |
|
||||||
{ |
|
||||||
DomRegion tagRegion = new DomRegion(tagComment.StartPosition.Y, tagComment.StartPosition.X); |
|
||||||
var tag = new ICSharpCode.SharpDevelop.Dom.TagComment(tagComment.Tag, tagRegion, tagComment.CommentText); |
|
||||||
cu.TagComments.Add(tag); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public IResolver CreateResolver() |
|
||||||
{ |
|
||||||
return new NRefactoryResolver(LanguageProperties.VBNet); |
|
||||||
} |
|
||||||
///////// IParser Interface END
|
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,78 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using ICSharpCode.NRefactory; |
|
||||||
using ICSharpCode.NRefactory.Ast; |
|
||||||
using ICSharpCode.NRefactory.PrettyPrinter; |
|
||||||
using ICSharpCode.SharpDevelop; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver; |
|
||||||
using ICSharpCode.SharpDevelop.Project; |
|
||||||
using ICSharpCode.SharpDevelop.Project.Converter; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding |
|
||||||
{ |
|
||||||
public class CSharpToVBNetConverter : NRefactoryLanguageConverter |
|
||||||
{ |
|
||||||
public override string TargetLanguageName { |
|
||||||
get { |
|
||||||
return VBNetProjectBinding.LanguageName; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
IList<string> defaultImports = new[] { "Microsoft.VisualBasic", "System" }; |
|
||||||
|
|
||||||
protected override IProject CreateProject(string targetProjectDirectory, IProject sourceProject) |
|
||||||
{ |
|
||||||
VBNetProject project = (VBNetProject)base.CreateProject(targetProjectDirectory, sourceProject); |
|
||||||
IProjectItemListProvider provider = (IProjectItemListProvider)project; |
|
||||||
foreach (string import in defaultImports) { |
|
||||||
provider.AddProjectItem(new ImportProjectItem(project, import)); |
|
||||||
} |
|
||||||
return project; |
|
||||||
} |
|
||||||
|
|
||||||
protected override void ConvertFile(FileProjectItem sourceItem, FileProjectItem targetItem) |
|
||||||
{ |
|
||||||
ConvertFile(sourceItem, targetItem, ".cs", ".vb", SupportedLanguage.CSharp, new VBNetOutputVisitor()); |
|
||||||
} |
|
||||||
|
|
||||||
string startupObject; |
|
||||||
|
|
||||||
protected override void ConvertAst(CompilationUnit compilationUnit, List<ISpecial> specials, FileProjectItem sourceItem) |
|
||||||
{ |
|
||||||
PreprocessingDirective.CSharpToVB(specials); |
|
||||||
IProjectContent pc = ParserService.GetProjectContent(sourceItem.Project) ?? ParserService.CurrentProjectContent; |
|
||||||
CSharpToVBNetConvertVisitor visitor = new CSharpToVBNetConvertVisitor(pc, ParserService.GetParseInformation(sourceItem.FileName)); |
|
||||||
visitor.RootNamespaceToRemove = sourceItem.Project.RootNamespace; |
|
||||||
visitor.DefaultImportsToRemove = defaultImports; |
|
||||||
visitor.StartupObjectToMakePublic = startupObject; |
|
||||||
compilationUnit.AcceptVisitor(visitor, null); |
|
||||||
} |
|
||||||
|
|
||||||
protected override void CopyProperties(IProject sourceProject, IProject targetProject) |
|
||||||
{ |
|
||||||
VBNetProject vbProject = (VBNetProject)targetProject; |
|
||||||
base.CopyProperties(sourceProject, targetProject); |
|
||||||
vbProject.ChangeProperty("DefineConstants", v => v.Replace(';', ',')); |
|
||||||
vbProject.ChangeProperty("ProjectTypeGuids", |
|
||||||
v => v.Replace(ProjectTypeGuids.CSharp, ProjectTypeGuids.VBNet, StringComparison.OrdinalIgnoreCase)); |
|
||||||
|
|
||||||
// determine the StartupObject
|
|
||||||
startupObject = vbProject.GetEvaluatedProperty("StartupObject"); |
|
||||||
if (string.IsNullOrEmpty(startupObject)) { |
|
||||||
IList<IClass> startupObjects = ICSharpCode.SharpDevelop.Gui.OptionPanels.ApplicationSettings.GetPossibleStartupObjects(sourceProject); |
|
||||||
if (startupObjects.Count == 1) { |
|
||||||
startupObject = startupObjects[0].FullyQualifiedName; |
|
||||||
if (vbProject.OutputType == OutputType.WinExe) { |
|
||||||
// we have to set StartupObject to prevent the VB compiler from choosing
|
|
||||||
// the generated Main method.
|
|
||||||
vbProject.SetProperty("StartupObject", startupObject); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,198 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.CodeDom; |
|
||||||
using System.ComponentModel; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.IO; |
|
||||||
using System.Linq; |
|
||||||
using System.Threading; |
|
||||||
using ICSharpCode.SharpDevelop; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.SharpDevelop.Dom.VBNet; |
|
||||||
using ICSharpCode.SharpDevelop.Internal.Templates; |
|
||||||
using ICSharpCode.SharpDevelop.Project; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding |
|
||||||
{ |
|
||||||
public class VBNetProject : CompilableProject, IVBNetOptionProvider |
|
||||||
{ |
|
||||||
protected override void OnPropertyChanged(ProjectPropertyChangedEventArgs e) |
|
||||||
{ |
|
||||||
base.OnPropertyChanged(e); |
|
||||||
if (e.PropertyName == "OutputType") { |
|
||||||
switch (this.OutputType) { |
|
||||||
case OutputType.WinExe: |
|
||||||
SetProperty(e.Configuration, e.Platform, |
|
||||||
"MyType", "WindowsForms", e.NewLocation, true); |
|
||||||
break; |
|
||||||
case OutputType.Exe: |
|
||||||
SetProperty(e.Configuration, e.Platform, |
|
||||||
"MyType", "Console", e.NewLocation, true); |
|
||||||
break; |
|
||||||
default: |
|
||||||
SetProperty(e.Configuration, e.Platform, |
|
||||||
"MyType", "Windows", e.NewLocation, true); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override IAmbience GetAmbience() |
|
||||||
{ |
|
||||||
return new VBNetAmbience(); |
|
||||||
} |
|
||||||
|
|
||||||
public VBNetProject(ProjectLoadInformation info) |
|
||||||
: base(info) |
|
||||||
{ |
|
||||||
InitVB(); |
|
||||||
} |
|
||||||
|
|
||||||
public const string DefaultTargetsFile = @"$(MSBuildToolsPath)\Microsoft.VisualBasic.targets"; |
|
||||||
|
|
||||||
public VBNetProject(ProjectCreateInformation info) |
|
||||||
: base(info) |
|
||||||
{ |
|
||||||
InitVB(); |
|
||||||
|
|
||||||
this.AddImport(DefaultTargetsFile, null); |
|
||||||
|
|
||||||
SetProperty("Debug", null, "DefineConstants", "DEBUG=1,TRACE=1", |
|
||||||
PropertyStorageLocations.ConfigurationSpecific, true); |
|
||||||
SetProperty("Release", null, "DefineConstants", "TRACE=1", |
|
||||||
PropertyStorageLocations.ConfigurationSpecific, true); |
|
||||||
} |
|
||||||
|
|
||||||
protected override ParseProjectContent CreateProjectContent() |
|
||||||
{ |
|
||||||
ParseProjectContent pc = base.CreateProjectContent(); |
|
||||||
MyNamespaceBuilder.BuildNamespace(this, pc); |
|
||||||
return pc; |
|
||||||
} |
|
||||||
|
|
||||||
public override IEnumerable<ReferenceProjectItem> ResolveAssemblyReferences(CancellationToken cancellationToken) |
|
||||||
{ |
|
||||||
ReferenceProjectItem[] additionalItems = { |
|
||||||
new ReferenceProjectItem(this, "mscorlib"), |
|
||||||
new ReferenceProjectItem(this, "Microsoft.VisualBasic"), |
|
||||||
}; |
|
||||||
return MSBuildInternals.ResolveAssemblyReferences(this, additionalItems); |
|
||||||
} |
|
||||||
|
|
||||||
void InitVB() |
|
||||||
{ |
|
||||||
reparseReferencesSensitiveProperties.Add("TargetFrameworkVersion"); |
|
||||||
reparseCodeSensitiveProperties.Add("DefineConstants"); |
|
||||||
} |
|
||||||
|
|
||||||
public override string Language { |
|
||||||
get { return VBNetProjectBinding.LanguageName; } |
|
||||||
} |
|
||||||
|
|
||||||
public override LanguageProperties LanguageProperties { |
|
||||||
get { return LanguageProperties.VBNet; } |
|
||||||
} |
|
||||||
|
|
||||||
public override void StartBuild(ProjectBuildOptions options, IBuildFeedbackSink feedbackSink) |
|
||||||
{ |
|
||||||
if (this.MinimumSolutionVersion == Solution.SolutionVersionVS2005) { |
|
||||||
MSBuildEngine.StartBuild(this, |
|
||||||
options, |
|
||||||
feedbackSink, |
|
||||||
MSBuildEngine.AdditionalTargetFiles.Concat( |
|
||||||
new [] { Path.Combine(MSBuildEngine.SharpDevelopBinPath, "SharpDevelop.CheckMSBuild35Features.targets") })); |
|
||||||
} else { |
|
||||||
base.StartBuild(options, feedbackSink); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public Nullable<bool> OptionInfer { |
|
||||||
get { return GetValue("OptionInfer", false); } |
|
||||||
} |
|
||||||
|
|
||||||
public Nullable<bool> OptionStrict { |
|
||||||
get { return GetValue("OptionStrict", false); } |
|
||||||
} |
|
||||||
|
|
||||||
public Nullable<bool> OptionExplicit { |
|
||||||
get { return GetValue("OptionExplicit", true); } |
|
||||||
} |
|
||||||
|
|
||||||
public Nullable<CompareKind> OptionCompare { |
|
||||||
get { |
|
||||||
string val = GetEvaluatedProperty("OptionCompare"); |
|
||||||
|
|
||||||
if ("Text".Equals(val, StringComparison.OrdinalIgnoreCase)) |
|
||||||
return CompareKind.Text; |
|
||||||
|
|
||||||
return CompareKind.Binary; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
bool? GetValue(string name, bool defaultVal) |
|
||||||
{ |
|
||||||
string val; |
|
||||||
try { |
|
||||||
val = GetEvaluatedProperty(name); |
|
||||||
} catch (ObjectDisposedException) { |
|
||||||
// This can happen when the project is disposed but the resolver still tries
|
|
||||||
// to access Option Infer (or similar).
|
|
||||||
val = null; |
|
||||||
} |
|
||||||
|
|
||||||
if (val == null) |
|
||||||
return defaultVal; |
|
||||||
|
|
||||||
return "On".Equals(val, StringComparison.OrdinalIgnoreCase); |
|
||||||
} |
|
||||||
|
|
||||||
public override string GetDefaultNamespace(string fileName) |
|
||||||
{ |
|
||||||
// use root namespace everywhere, ignore the folder name
|
|
||||||
return this.RootNamespace; |
|
||||||
} |
|
||||||
|
|
||||||
public override System.CodeDom.Compiler.CodeDomProvider CreateCodeDomProvider() |
|
||||||
{ |
|
||||||
return new Microsoft.VisualBasic.VBCodeProvider(); |
|
||||||
} |
|
||||||
|
|
||||||
public override void GenerateCodeFromCodeDom(CodeCompileUnit compileUnit, TextWriter writer) |
|
||||||
{ |
|
||||||
// the root namespace is implicit in VB
|
|
||||||
string rootNamespace = this.RootNamespace; |
|
||||||
foreach (CodeNamespace ns in ccu.Namespaces) { |
|
||||||
if (string.Equals(ns.Name, rootNamespace, StringComparison.OrdinalIgnoreCase)) { |
|
||||||
ns.Name = string.Empty; |
|
||||||
} else if (ns.Name.StartsWith(rootNamespace + ".", StringComparison.OrdinalIgnoreCase)) { |
|
||||||
ns.Name = ns.Name.Substring(rootNamespace.Length + 1); |
|
||||||
} |
|
||||||
} |
|
||||||
base.GenerateCodeFromCodeDom(compileUnit, writer); |
|
||||||
} |
|
||||||
|
|
||||||
protected override ProjectBehavior CreateDefaultBehavior() |
|
||||||
{ |
|
||||||
return new VBProjectBehavior(this, base.CreateDefaultBehavior()); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public class VBProjectBehavior : ProjectBehavior |
|
||||||
{ |
|
||||||
public VBProjectBehavior(VBNetProject project, ProjectBehavior next = null) |
|
||||||
: base(project, next) |
|
||||||
{ |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public override ItemType GetDefaultItemType(string fileName) |
|
||||||
{ |
|
||||||
if (string.Equals(Path.GetExtension(fileName), ".vb", StringComparison.OrdinalIgnoreCase)) |
|
||||||
return ItemType.Compile; |
|
||||||
else |
|
||||||
return base.GetDefaultItemType(fileName); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,234 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Linq; |
|
||||||
using System.Text.RegularExpressions; |
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.NRefactory; |
|
||||||
using ICSharpCode.NRefactory.Parser; |
|
||||||
using ICSharpCode.NRefactory.Parser.VB; |
|
||||||
using ICSharpCode.SharpDevelop.Editor; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding |
|
||||||
{ |
|
||||||
public class VBNetBracketSearcher : IBracketSearcher |
|
||||||
{ |
|
||||||
string openingBrackets = "([{"; |
|
||||||
string closingBrackets = ")]}"; |
|
||||||
|
|
||||||
public BracketSearchResult SearchBracket(IDocument document, int offset) |
|
||||||
{ |
|
||||||
if (offset > 0) { |
|
||||||
char c = document.GetCharAt(offset - 1); |
|
||||||
int index = openingBrackets.IndexOf(c); |
|
||||||
int otherOffset = -1; |
|
||||||
if (index > -1) |
|
||||||
otherOffset = SearchBracketForward(document, offset, openingBrackets[index], closingBrackets[index]); |
|
||||||
|
|
||||||
index = closingBrackets.IndexOf(c); |
|
||||||
if (index > -1) |
|
||||||
otherOffset = SearchBracketBackward(document, offset - 2, openingBrackets[index], closingBrackets[index]); |
|
||||||
|
|
||||||
if (otherOffset > -1) |
|
||||||
return new BracketSearchResult(Math.Min(offset - 1, otherOffset), 1, |
|
||||||
Math.Max(offset - 1, otherOffset), 1); |
|
||||||
|
|
||||||
int length; |
|
||||||
VBStatement statement; |
|
||||||
|
|
||||||
int startIndex = FindBeginStatementAroundOffset(document, offset, out statement, out length); |
|
||||||
int endIndex = 0; |
|
||||||
|
|
||||||
if (statement != null) |
|
||||||
endIndex = FindEndStatement(document, statement); |
|
||||||
else { |
|
||||||
endIndex = FindEndStatementAroundOffset(document, offset, out statement); |
|
||||||
|
|
||||||
if (statement != null) |
|
||||||
startIndex = FindBeginStatement(document, statement, document.OffsetToPosition(endIndex), out length); |
|
||||||
} |
|
||||||
|
|
||||||
if (startIndex > -1 && endIndex > -1) |
|
||||||
return new BracketSearchResult(startIndex, length, endIndex, |
|
||||||
statement.EndStatement.Length); |
|
||||||
} |
|
||||||
|
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
#region bracket search
|
|
||||||
static int SearchBracketBackward(IDocument document, int offset, char openBracket, char closingBracket) |
|
||||||
{ |
|
||||||
bool inString = false; |
|
||||||
char ch; |
|
||||||
int brackets = -1; |
|
||||||
for (int i = offset; i > 0; --i) { |
|
||||||
ch = document.GetCharAt(i); |
|
||||||
if (ch == openBracket && !inString) { |
|
||||||
++brackets; |
|
||||||
if (brackets == 0) return i; |
|
||||||
} else if (ch == closingBracket && !inString) { |
|
||||||
--brackets; |
|
||||||
} else if (ch == '"') { |
|
||||||
inString = !inString; |
|
||||||
} else if (ch == '\n') { |
|
||||||
int lineStart = ScanLineStart(document, i); |
|
||||||
if (lineStart >= 0) { // line could have a comment
|
|
||||||
inString = false; |
|
||||||
for (int j = lineStart; j < i; ++j) { |
|
||||||
ch = document.GetCharAt(j); |
|
||||||
if (ch == '"') inString = !inString; |
|
||||||
if (ch == '\'' && !inString) { |
|
||||||
// comment found!
|
|
||||||
// Skip searching in the comment:
|
|
||||||
i = j; |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
inString = false; |
|
||||||
} |
|
||||||
} |
|
||||||
return -1; |
|
||||||
} |
|
||||||
|
|
||||||
static int ScanLineStart(IDocument document, int offset) |
|
||||||
{ |
|
||||||
bool hasComment = false; |
|
||||||
for (int i = offset - 1; i > 0; --i) { |
|
||||||
char ch = document.GetCharAt(i); |
|
||||||
if (ch == '\n') { |
|
||||||
if (!hasComment) return -1; |
|
||||||
return i + 1; |
|
||||||
} else if (ch == '\'') { |
|
||||||
hasComment = true; |
|
||||||
} |
|
||||||
} |
|
||||||
return 0; |
|
||||||
} |
|
||||||
|
|
||||||
static int SearchBracketForward(IDocument document, int offset, char openBracket, char closingBracket) |
|
||||||
{ |
|
||||||
bool inString = false; |
|
||||||
bool inComment = false; |
|
||||||
int brackets = 1; |
|
||||||
for (int i = offset; i < document.TextLength; ++i) { |
|
||||||
char ch = document.GetCharAt(i); |
|
||||||
if (ch == '\n') { |
|
||||||
inString = false; |
|
||||||
inComment = false; |
|
||||||
} |
|
||||||
if (inComment) continue; |
|
||||||
if (ch == '"') inString = !inString; |
|
||||||
if (inString) continue; |
|
||||||
if (ch == '\'') { |
|
||||||
inComment = true; |
|
||||||
} else if (ch == openBracket) { |
|
||||||
++brackets; |
|
||||||
} else if (ch == closingBracket) { |
|
||||||
--brackets; |
|
||||||
if (brackets == 0) return i; |
|
||||||
} |
|
||||||
} |
|
||||||
return -1; |
|
||||||
} |
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region statement search
|
|
||||||
static int FindBeginStatementAroundOffset(IDocument document, int offset, out VBStatement statement, out int length) |
|
||||||
{ |
|
||||||
length = 0; |
|
||||||
statement = null; |
|
||||||
return -1; |
|
||||||
} |
|
||||||
|
|
||||||
static int FindEndStatementAroundOffset(IDocument document, int offset, out VBStatement statement) |
|
||||||
{ |
|
||||||
IDocumentLine line = document.GetLineForOffset(offset); |
|
||||||
|
|
||||||
string interestingText = line.Text.TrimLine().Trim(' ', '\t'); |
|
||||||
|
|
||||||
//LoggingService.Debug("text: '" + interestingText + "'");
|
|
||||||
|
|
||||||
foreach (VBStatement s in VBNetFormattingStrategy.Statements) { |
|
||||||
Match match = Regex.Matches(interestingText, s.EndRegex, RegexOptions.Singleline | RegexOptions.IgnoreCase).OfType<Match>().FirstOrDefault(); |
|
||||||
if (match != null) { |
|
||||||
//LoggingService.DebugFormatted("Found end statement at offset {1}: {0}", s, offset);
|
|
||||||
statement = s; |
|
||||||
int result = match.Index + (line.Length - line.Text.TrimStart(' ', '\t').Length) + line.Offset; |
|
||||||
if (offset >= result && offset <= (result + match.Length)) |
|
||||||
return result; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
statement = null; |
|
||||||
return -1; |
|
||||||
} |
|
||||||
|
|
||||||
static int FindBeginStatement(IDocument document, VBStatement statement, Location endLocation, out int length) |
|
||||||
{ |
|
||||||
ILexer lexer = ParserFactory.CreateLexer(SupportedLanguage.VBNet, document.CreateReader()); |
|
||||||
|
|
||||||
Token currentToken = null; |
|
||||||
Token prevToken = null; |
|
||||||
|
|
||||||
int lookFor = statement.StatementToken; |
|
||||||
Stack<Token> tokens = new Stack<Token>(); |
|
||||||
|
|
||||||
if (statement.EndStatement == "Next") { |
|
||||||
lookFor = Tokens.For; |
|
||||||
} |
|
||||||
|
|
||||||
Token result = null; |
|
||||||
// Token firstModifier = null;
|
|
||||||
|
|
||||||
while ((currentToken = lexer.NextToken()).Kind != Tokens.EOF) { |
|
||||||
if (prevToken == null) |
|
||||||
prevToken = currentToken; |
|
||||||
|
|
||||||
// if (IsModifier(currentToken)) {
|
|
||||||
// if (firstModifier == null)
|
|
||||||
// firstModifier = currentToken;
|
|
||||||
// } else
|
|
||||||
// firstModifier = null;
|
|
||||||
|
|
||||||
|
|
||||||
if (VBNetFormattingStrategy.IsBlockStart(lexer, currentToken, prevToken)) { |
|
||||||
tokens.Push(currentToken); |
|
||||||
} |
|
||||||
if (VBNetFormattingStrategy.IsBlockEnd(currentToken, prevToken)) { |
|
||||||
while (tokens.Count > 0 && !VBNetFormattingStrategy.IsMatchingEnd(tokens.Peek(), currentToken)) |
|
||||||
tokens.Pop(); |
|
||||||
if (tokens.Count > 0) { |
|
||||||
Token t = tokens.Pop(); |
|
||||||
if (currentToken.Location.Line == endLocation.Line) { |
|
||||||
result = t; |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
prevToken = currentToken; |
|
||||||
} |
|
||||||
|
|
||||||
if (result != null) { |
|
||||||
int endOffset = document.PositionToOffset(result.EndLocation.Line, result.EndLocation.Column); |
|
||||||
int offset = document.PositionToOffset(result.Location.Line, result.Location.Column); |
|
||||||
length = endOffset - offset; |
|
||||||
return offset; |
|
||||||
} |
|
||||||
|
|
||||||
length = 0; |
|
||||||
|
|
||||||
return -1; |
|
||||||
} |
|
||||||
|
|
||||||
static int FindEndStatement(IDocument document, VBStatement statement) |
|
||||||
{ |
|
||||||
return -1; |
|
||||||
} |
|
||||||
#endregion
|
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,314 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.IO; |
|
||||||
using System.Linq; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.NRefactory; |
|
||||||
using ICSharpCode.NRefactory.Parser; |
|
||||||
using ICSharpCode.NRefactory.Parser.VB; |
|
||||||
using ICSharpCode.SharpDevelop; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using Dom = ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver; |
|
||||||
using ICSharpCode.SharpDevelop.Dom.Refactoring; |
|
||||||
using ICSharpCode.SharpDevelop.Dom.VBNet; |
|
||||||
using ICSharpCode.SharpDevelop.Editor; |
|
||||||
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding |
|
||||||
{ |
|
||||||
public class VBNetCompletionBinding : ICodeCompletionBinding |
|
||||||
{ |
|
||||||
static VBNetCompletionBinding instance; |
|
||||||
|
|
||||||
public static VBNetCompletionBinding Instance { |
|
||||||
get { |
|
||||||
if (instance == null) |
|
||||||
instance = new VBNetCompletionBinding(); |
|
||||||
return instance; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
NRefactoryInsightWindowHandler insightHandler = new NRefactoryInsightWindowHandler(SupportedLanguage.VBNet); |
|
||||||
|
|
||||||
public CodeCompletionKeyPressResult HandleKeyPress(ITextEditor editor, char ch) |
|
||||||
{ |
|
||||||
if (LanguageUtils.IsInsideDocumentationComment(editor) && ch == '<') { |
|
||||||
new CommentCompletionItemProvider().ShowCompletion(editor); |
|
||||||
return CodeCompletionKeyPressResult.Completed; |
|
||||||
} |
|
||||||
|
|
||||||
if (IsInComment(editor) || IsInString(editor)) |
|
||||||
return CodeCompletionKeyPressResult.None; |
|
||||||
|
|
||||||
if (editor.SelectionLength > 0) { |
|
||||||
// allow code completion when overwriting an identifier
|
|
||||||
int endOffset = editor.SelectionStart + editor.SelectionLength; |
|
||||||
// but block code completion when overwriting only part of an identifier
|
|
||||||
if (endOffset < editor.Document.TextLength && char.IsLetterOrDigit(editor.Document.GetCharAt(endOffset))) |
|
||||||
return CodeCompletionKeyPressResult.None; |
|
||||||
|
|
||||||
editor.Document.Remove(editor.SelectionStart, editor.SelectionLength); |
|
||||||
} |
|
||||||
|
|
||||||
VBNetExpressionFinder ef = new VBNetExpressionFinder(ParserService.GetParseInformation(editor.FileName)); |
|
||||||
|
|
||||||
ExpressionResult result; |
|
||||||
|
|
||||||
switch (ch) { |
|
||||||
case '(': |
|
||||||
if (CodeCompletionOptions.InsightEnabled) { |
|
||||||
IInsightWindow insightWindow = editor.ShowInsightWindow(new MethodInsightProvider().ProvideInsight(editor)); |
|
||||||
if (insightWindow != null) { |
|
||||||
insightHandler.InitializeOpenedInsightWindow(editor, insightWindow); |
|
||||||
insightHandler.HighlightParameter(insightWindow, 0); |
|
||||||
} |
|
||||||
return CodeCompletionKeyPressResult.Completed; |
|
||||||
} |
|
||||||
break; |
|
||||||
case ',': |
|
||||||
if (CodeCompletionOptions.InsightRefreshOnComma && CodeCompletionOptions.InsightEnabled) { |
|
||||||
IInsightWindow insightWindow; |
|
||||||
if (insightHandler.InsightRefreshOnComma(editor, ch, out insightWindow)) |
|
||||||
return CodeCompletionKeyPressResult.Completed; |
|
||||||
} |
|
||||||
break; |
|
||||||
case '\n': |
|
||||||
TryDeclarationTypeInference(editor, editor.Document.GetLineForOffset(editor.Caret.Offset)); |
|
||||||
break; |
|
||||||
case '.': |
|
||||||
string w = editor.GetWordBeforeCaret(); int index = w.IndexOf('.'); |
|
||||||
|
|
||||||
if (index > -1 && w.Length - index == 2) |
|
||||||
index = editor.Caret.Offset - 2; |
|
||||||
else |
|
||||||
index = editor.Caret.Offset; |
|
||||||
|
|
||||||
result = ef.FindExpression(editor.Document.Text, index); |
|
||||||
LoggingService.Debug("CC: After dot, result=" + result + ", context=" + result.Context); |
|
||||||
if (ShowCompletion(result, editor, ch)) |
|
||||||
return CodeCompletionKeyPressResult.Completed; |
|
||||||
else |
|
||||||
return CodeCompletionKeyPressResult.None; |
|
||||||
case '@': |
|
||||||
if (editor.Caret.Offset > 0 && editor.Document.GetCharAt(editor.Caret.Offset - 1) == '.') |
|
||||||
return CodeCompletionKeyPressResult.None; |
|
||||||
goto default; |
|
||||||
case ' ': |
|
||||||
editor.Document.Insert(editor.Caret.Offset, " "); |
|
||||||
result = ef.FindExpression(editor.Document.Text, editor.Caret.Offset); |
|
||||||
|
|
||||||
string word = editor.GetWordBeforeCaret().Trim(); |
|
||||||
if (word.Equals("overrides", StringComparison.OrdinalIgnoreCase) || word.Equals("return", StringComparison.OrdinalIgnoreCase) || !LiteralMayFollow((BitArray)result.Tag) && !OperatorMayFollow((BitArray)result.Tag) && ExpressionContext.IdentifierExpected != result.Context) { |
|
||||||
LoggingService.Debug("CC: After space, result=" + result + ", context=" + result.Context); |
|
||||||
ShowCompletion(result, editor, ch); |
|
||||||
} |
|
||||||
return CodeCompletionKeyPressResult.EatKey; |
|
||||||
default: |
|
||||||
if (CodeCompletionOptions.CompleteWhenTyping) { |
|
||||||
int cursor = editor.Caret.Offset; |
|
||||||
char prevChar = cursor > 1 ? editor.Document.GetCharAt(cursor - 1) : ' '; |
|
||||||
char ppChar = cursor > 2 ? editor.Document.GetCharAt(cursor - 2) : ' '; |
|
||||||
|
|
||||||
result = ef.FindExpression(editor.Document.Text, cursor); |
|
||||||
|
|
||||||
if ((result.Context != ExpressionContext.IdentifierExpected && char.IsLetter(ch)) && |
|
||||||
(!char.IsLetterOrDigit(prevChar) && prevChar != '.')) { |
|
||||||
if (prevChar == '@' && ppChar == '.') |
|
||||||
return CodeCompletionKeyPressResult.None; |
|
||||||
if (IsTypeCharacter(ch, prevChar)) |
|
||||||
return CodeCompletionKeyPressResult.None; |
|
||||||
if (prevChar == '_') { |
|
||||||
result.Expression = '_' + result.Expression; |
|
||||||
result.Region = new DomRegion(result.Region.BeginLine, result.Region.BeginColumn - 1, result.Region.EndLine, result.Region.EndColumn); |
|
||||||
} |
|
||||||
LoggingService.Debug("CC: Beginning to type a word, result=" + result + ", context=" + result.Context); |
|
||||||
ShowCompletion(result, editor, ch); |
|
||||||
return CodeCompletionKeyPressResult.CompletedIncludeKeyInCompletion; |
|
||||||
} |
|
||||||
} |
|
||||||
break; |
|
||||||
} |
|
||||||
|
|
||||||
return CodeCompletionKeyPressResult.None; |
|
||||||
} |
|
||||||
|
|
||||||
static bool IsTypeCharacter(char ch, char prevChar) |
|
||||||
{ |
|
||||||
ch = char.ToUpperInvariant(ch); |
|
||||||
|
|
||||||
// char type character
|
|
||||||
if (ch == 'C' && prevChar == '"') |
|
||||||
return true; |
|
||||||
|
|
||||||
// start of hex or octal literal
|
|
||||||
if (prevChar == '&' && (ch == 'H' || ch == 'O')) |
|
||||||
return true; |
|
||||||
|
|
||||||
if (char.IsDigit(prevChar)) |
|
||||||
return true; |
|
||||||
|
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
static bool ShowCompletion(ExpressionResult result, ITextEditor editor, char ch) |
|
||||||
{ |
|
||||||
VBNetCompletionItemList list = CompletionDataHelper.GenerateCompletionData(result, editor, ch); |
|
||||||
list.Editor = editor; |
|
||||||
list.Window = editor.ShowCompletionWindow(list); |
|
||||||
return list.Items.Any(); |
|
||||||
} |
|
||||||
|
|
||||||
#region Helpers
|
|
||||||
static bool OperatorMayFollow(BitArray array) |
|
||||||
{ |
|
||||||
if (array == null) |
|
||||||
return false; |
|
||||||
|
|
||||||
return array[Tokens.Xor]; |
|
||||||
} |
|
||||||
|
|
||||||
static bool LiteralMayFollow(BitArray array) |
|
||||||
{ |
|
||||||
if (array == null) |
|
||||||
return false; |
|
||||||
|
|
||||||
for (int i = 0; i < array.Length; i++) { |
|
||||||
if (array[i] && i >= Tokens.LiteralString && i <= Tokens.LiteralDate) |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
static void GetCommentOrStringState(ITextEditor editor, out bool inString, out bool inComment) |
|
||||||
{ |
|
||||||
ILexer lexer = ParserFactory.CreateLexer(SupportedLanguage.VBNet, editor.Document.CreateReader()); |
|
||||||
|
|
||||||
Token t = lexer.NextToken(); |
|
||||||
bool inXml = false; |
|
||||||
|
|
||||||
inString = false; |
|
||||||
inComment = false; |
|
||||||
|
|
||||||
while (t.Location < editor.Caret.Position) { |
|
||||||
t = lexer.NextToken(); |
|
||||||
|
|
||||||
if (inXml && (t.Kind != Tokens.Identifier && t.Kind != Tokens.LiteralString && !(t.Kind > Tokens.LiteralDate && t.Kind < Tokens.Colon))) { |
|
||||||
inXml = false; |
|
||||||
continue; |
|
||||||
} |
|
||||||
|
|
||||||
if (t.Kind > Tokens.LiteralDate && t.Kind < Tokens.Assign) |
|
||||||
inXml = true; |
|
||||||
} |
|
||||||
|
|
||||||
if (inXml) { |
|
||||||
// TODO
|
|
||||||
} else { |
|
||||||
string lineText = editor.Document.GetLine(editor.Caret.Line).Text; |
|
||||||
|
|
||||||
for (int i = 0; i < editor.Caret.Column - 1; i++) { |
|
||||||
char ch = lineText[i]; |
|
||||||
|
|
||||||
if (!inComment && ch == '"') |
|
||||||
inString = !inString; |
|
||||||
if (!inString && ch == '\'') |
|
||||||
inComment = true; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
static bool IsInString(ITextEditor editor) |
|
||||||
{ |
|
||||||
bool inString, inComment; |
|
||||||
GetCommentOrStringState(editor, out inString, out inComment); |
|
||||||
return inString; |
|
||||||
} |
|
||||||
|
|
||||||
static bool IsInComment(ITextEditor editor) |
|
||||||
{ |
|
||||||
bool inString, inComment; |
|
||||||
GetCommentOrStringState(editor, out inString, out inComment); |
|
||||||
return inComment; |
|
||||||
} |
|
||||||
#endregion
|
|
||||||
|
|
||||||
public bool CtrlSpace(ITextEditor editor) |
|
||||||
{ |
|
||||||
if (IsInComment(editor)) |
|
||||||
return false; |
|
||||||
|
|
||||||
if (editor.SelectionLength > 0) { |
|
||||||
// allow code completion when overwriting an identifier
|
|
||||||
int endOffset = editor.SelectionStart + editor.SelectionLength; |
|
||||||
// but block code completion when overwriting only part of an identifier
|
|
||||||
if (endOffset < editor.Document.TextLength && char.IsLetterOrDigit(editor.Document.GetCharAt(endOffset))) |
|
||||||
return false; |
|
||||||
|
|
||||||
editor.Document.Remove(editor.SelectionStart, editor.SelectionLength); |
|
||||||
} |
|
||||||
|
|
||||||
int cursor = editor.Caret.Offset; |
|
||||||
char prevChar = cursor > 1 ? editor.Document.GetCharAt(cursor - 1) : ' '; |
|
||||||
bool afterUnderscore = prevChar == '_'; |
|
||||||
|
|
||||||
if (afterUnderscore) { |
|
||||||
cursor--; |
|
||||||
prevChar = cursor > 1 ? editor.Document.GetCharAt(cursor - 1) : ' '; |
|
||||||
} |
|
||||||
|
|
||||||
VBNetExpressionFinder ef = new VBNetExpressionFinder(ParserService.GetParseInformation(editor.FileName)); |
|
||||||
ExpressionResult result = ef.FindExpression(editor.Document.Text, cursor); |
|
||||||
LoggingService.Debug("CC: Beginning to type a word, result=" + result + ", context=" + result.Context); |
|
||||||
ShowCompletion(result, editor, '\0'); |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
static bool TryDeclarationTypeInference(ITextEditor editor, IDocumentLine curLine) |
|
||||||
{ |
|
||||||
string lineText = editor.Document.GetText(curLine.Offset, curLine.Length); |
|
||||||
ILexer lexer = ParserFactory.CreateLexer(SupportedLanguage.VBNet, new System.IO.StringReader(lineText)); |
|
||||||
if (lexer.NextToken().Kind != Tokens.Dim) |
|
||||||
return false; |
|
||||||
if (lexer.NextToken().Kind != Tokens.Identifier) |
|
||||||
return false; |
|
||||||
if (lexer.NextToken().Kind != Tokens.As) |
|
||||||
return false; |
|
||||||
Token t1 = lexer.NextToken(); |
|
||||||
if (t1.Kind != Tokens.QuestionMark) |
|
||||||
return false; |
|
||||||
Token t2 = lexer.NextToken(); |
|
||||||
if (t2.Kind != Tokens.Assign) |
|
||||||
return false; |
|
||||||
string expr = lineText.Substring(t2.Location.Column); |
|
||||||
LoggingService.Debug("DeclarationTypeInference: >" + expr + "<"); |
|
||||||
ResolveResult rr = ParserService.Resolve(new ExpressionResult(expr), |
|
||||||
editor.Caret.Line, |
|
||||||
t2.Location.Column, editor.FileName, |
|
||||||
editor.Document.Text); |
|
||||||
if (rr != null && rr.ResolvedType != null) { |
|
||||||
ClassFinder context = new ClassFinder(ParserService.GetParseInformation(editor.FileName), editor.Caret.Line, t1.Location.Column); |
|
||||||
VBNetAmbience ambience = new VBNetAmbience(); |
|
||||||
if (CodeGenerator.CanUseShortTypeName(rr.ResolvedType, context)) |
|
||||||
ambience.ConversionFlags = ConversionFlags.None; |
|
||||||
else |
|
||||||
ambience.ConversionFlags = ConversionFlags.UseFullyQualifiedTypeNames; |
|
||||||
string typeName = ambience.Convert(rr.ResolvedType); |
|
||||||
using (editor.Document.OpenUndoGroup()) { |
|
||||||
int offset = curLine.Offset + t1.Location.Column - 1; |
|
||||||
editor.Document.Remove(offset, 1); |
|
||||||
editor.Document.Insert(offset, typeName); |
|
||||||
} |
|
||||||
editor.Caret.Column += typeName.Length - 1; |
|
||||||
return true; |
|
||||||
} |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,45 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Linq; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.NRefactory.Parser.VB; |
|
||||||
using ICSharpCode.SharpDevelop; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver; |
|
||||||
using ICSharpCode.SharpDevelop.Editor; |
|
||||||
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding |
|
||||||
{ |
|
||||||
public class VBNetCompletionItemList : NRefactoryCompletionItemList |
|
||||||
{ |
|
||||||
public ITextEditor Editor { get; set; } |
|
||||||
|
|
||||||
public ICompletionListWindow Window { get; set; } |
|
||||||
|
|
||||||
public override CompletionItemListKeyResult ProcessInput(char key) |
|
||||||
{ |
|
||||||
if (key == '?' && string.IsNullOrWhiteSpace(Editor.Document.GetText(Window.StartOffset, Window.EndOffset - Window.StartOffset))) |
|
||||||
return CompletionItemListKeyResult.NormalKey; |
|
||||||
|
|
||||||
if (key == '@' && Window.StartOffset > 0 && Editor.Document.GetCharAt(Window.StartOffset - 1) == '.') |
|
||||||
return CompletionItemListKeyResult.NormalKey; |
|
||||||
|
|
||||||
return base.ProcessInput(key); |
|
||||||
} |
|
||||||
|
|
||||||
public override void Complete(CompletionContext context, ICompletionItem item) |
|
||||||
{ |
|
||||||
base.Complete(context, item); |
|
||||||
|
|
||||||
if (item.Text == "..") { |
|
||||||
VBNetCompletionBinding.Instance.CtrlSpace(context.Editor); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,28 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using ICSharpCode.SharpDevelop; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.SharpDevelop.Editor; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Description of VBNetLanguageBinding.
|
|
||||||
/// </summary>
|
|
||||||
public class VBNetLanguageBinding : DefaultLanguageBinding |
|
||||||
{ |
|
||||||
public override IFormattingStrategy FormattingStrategy { |
|
||||||
get { return new VBNetFormattingStrategy(); } |
|
||||||
} |
|
||||||
|
|
||||||
public override IBracketSearcher BracketSearcher { |
|
||||||
get { return new VBNetBracketSearcher(); } |
|
||||||
} |
|
||||||
|
|
||||||
public override LanguageProperties Properties { |
|
||||||
get { return LanguageProperties.VBNet; } |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,38 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Xml; |
|
||||||
using ICSharpCode.SharpDevelop.Internal.Templates; |
|
||||||
using ICSharpCode.SharpDevelop.Project; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding |
|
||||||
{ |
|
||||||
public class VBNetProjectBinding : IProjectBinding |
|
||||||
{ |
|
||||||
public const string LanguageName = "VBNet"; |
|
||||||
|
|
||||||
public string Language |
|
||||||
{ |
|
||||||
get { |
|
||||||
return LanguageName; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public IProject LoadProject(ProjectLoadInformation info) |
|
||||||
{ |
|
||||||
return new VBNetProject(info); |
|
||||||
} |
|
||||||
|
|
||||||
public IProject CreateProject(ProjectCreateInformation info) |
|
||||||
{ |
|
||||||
return new VBNetProject(info); |
|
||||||
} |
|
||||||
|
|
||||||
public bool HandlingMissingProject { |
|
||||||
get { |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,92 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Text; |
|
||||||
using ICSharpCode.SharpDevelop.Project; |
|
||||||
using Microsoft.Build.Framework; |
|
||||||
using System.IO; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Fixes SD2-995 : Special characters not correctly encoded for languages others than English
|
|
||||||
/// </summary>
|
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Vbc")] |
|
||||||
public sealed class VbcEncodingFixingLogger : IMSBuildLoggerFilter |
|
||||||
{ |
|
||||||
public IMSBuildChainedLoggerFilter CreateFilter(MSBuildEngine engine, IMSBuildChainedLoggerFilter nextFilter) |
|
||||||
{ |
|
||||||
return new VbcLoggerImpl(nextFilter); |
|
||||||
} |
|
||||||
|
|
||||||
sealed class VbcLoggerImpl : IMSBuildChainedLoggerFilter |
|
||||||
{ |
|
||||||
readonly IMSBuildChainedLoggerFilter nextFilter; |
|
||||||
|
|
||||||
public VbcLoggerImpl(IMSBuildChainedLoggerFilter nextFilter) |
|
||||||
{ |
|
||||||
this.nextFilter = nextFilter; |
|
||||||
} |
|
||||||
|
|
||||||
static string FixEncoding(string text) |
|
||||||
{ |
|
||||||
if (text == null) |
|
||||||
return text; |
|
||||||
return Encoding.Default.GetString(ICSharpCode.SharpDevelop.Util.ProcessRunner.OemEncoding.GetBytes(text)); |
|
||||||
} |
|
||||||
|
|
||||||
public void HandleError(BuildError error) |
|
||||||
{ |
|
||||||
error.ErrorText = FixEncoding(error.ErrorText); |
|
||||||
error.FileName = FixEncoding(error.FileName); |
|
||||||
error.Column = FixColumn(error.FileName, error.Line, error.Column); |
|
||||||
nextFilter.HandleError(error); |
|
||||||
} |
|
||||||
|
|
||||||
public void HandleBuildEvent(Microsoft.Build.Framework.BuildEventArgs e) |
|
||||||
{ |
|
||||||
nextFilter.HandleBuildEvent(e); |
|
||||||
if (e is TaskFinishedEventArgs && lastFile != null) { |
|
||||||
lastFile.Close(); |
|
||||||
lastFile = null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
string lastFileName, lastLineText; |
|
||||||
StreamReader lastFile; |
|
||||||
int lastLine; |
|
||||||
|
|
||||||
// fixes SD-1746 - VB compiler errors are shown in incorrect column if the line contains tabs
|
|
||||||
// (http://bugtracker.sharpdevelop.net/issue/ViewIssue.aspx?id=1746&PROJID=4)
|
|
||||||
int FixColumn(string fileName, int line, int column) |
|
||||||
{ |
|
||||||
if (!File.Exists(fileName) || line < 1 || column < 1) |
|
||||||
return column; |
|
||||||
|
|
||||||
if (fileName != lastFileName || line < lastLine || lastFile == null) { |
|
||||||
if (lastFile != null) |
|
||||||
lastFile.Close(); |
|
||||||
lastFile = new StreamReader(fileName); |
|
||||||
lastFileName = fileName; |
|
||||||
lastLineText = ""; |
|
||||||
lastLine = 0; |
|
||||||
} |
|
||||||
|
|
||||||
while (lastLine < line && lastLineText != null) { |
|
||||||
lastLineText = lastFile.ReadLine(); |
|
||||||
lastLine++; |
|
||||||
} |
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(lastLineText)) { |
|
||||||
for (int i = 0; i < column && i < lastLineText.Length; i++) { |
|
||||||
if (lastLineText[i] == '\t') |
|
||||||
column -= 3; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
return column; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,10 +0,0 @@ |
|||||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|
||||||
<PropertyGroup> |
|
||||||
<LastOpenVersion>8.0.50215</LastOpenVersion> |
|
||||||
<ProjectView>ShowAllFiles</ProjectView> |
|
||||||
<ProjectTrust>0</ProjectTrust> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|
||||||
<StartProgram>..\..\..\..\..\bin\SharpDevelop.exe</StartProgram> |
|
||||||
</PropertyGroup> |
|
||||||
</Project> |
|
||||||
@ -0,0 +1,152 @@ |
|||||||
|
' Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) |
||||||
|
' This code is distributed under the GNU LGPL (for details please see \doc\license.txt) |
||||||
|
|
||||||
|
Imports System.CodeDom |
||||||
|
Imports System.ComponentModel |
||||||
|
Imports System.Collections.Generic |
||||||
|
Imports System.IO |
||||||
|
Imports System.Linq |
||||||
|
Imports System.Threading.Tasks |
||||||
|
Imports System.Threading |
||||||
|
|
||||||
|
Imports ICSharpCode.Core |
||||||
|
Imports ICSharpCode.SharpDevelop |
||||||
|
Imports ICSharpCode.SharpDevelop.Project |
||||||
|
|
||||||
|
Public Class VBNetProject |
||||||
|
Inherits CompilableProject |
||||||
|
|
||||||
|
Protected Overrides Sub OnPropertyChanged(e As ProjectPropertyChangedEventArgs) |
||||||
|
MyBase.OnPropertyChanged(e) |
||||||
|
If e.PropertyName = "OutputType" Then |
||||||
|
Select Case Me.OutputType |
||||||
|
Case OutputType.WinExe |
||||||
|
SetProperty(e.Configuration, e.Platform, "MyType", "WindowsForms", e.NewLocation, True) |
||||||
|
Exit Select |
||||||
|
Case OutputType.Exe |
||||||
|
SetProperty(e.Configuration, e.Platform, "MyType", "Console", e.NewLocation, True) |
||||||
|
Exit Select |
||||||
|
Case Else |
||||||
|
SetProperty(e.Configuration, e.Platform, "MyType", "Windows", e.NewLocation, True) |
||||||
|
Exit Select |
||||||
|
End Select |
||||||
|
End If |
||||||
|
End Sub |
||||||
|
|
||||||
|
Public Sub New(info As ProjectLoadInformation) |
||||||
|
MyBase.New(info) |
||||||
|
InitVB() |
||||||
|
End Sub |
||||||
|
|
||||||
|
Public Const DefaultTargetsFile As String = "$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" |
||||||
|
|
||||||
|
Public Sub New(info As ProjectCreateInformation) |
||||||
|
MyBase.New(info) |
||||||
|
InitVB() |
||||||
|
|
||||||
|
Me.AddImport(DefaultTargetsFile, Nothing) |
||||||
|
|
||||||
|
SetProperty("Debug", Nothing, "DefineConstants", "DEBUG=1,TRACE=1", PropertyStorageLocations.ConfigurationSpecific, True) |
||||||
|
SetProperty("Release", Nothing, "DefineConstants", "TRACE=1", PropertyStorageLocations.ConfigurationSpecific, True) |
||||||
|
End Sub |
||||||
|
|
||||||
|
Public Overrides Function ResolveAssemblyReferences(cancellationToken As CancellationToken) As IEnumerable(Of ReferenceProjectItem) |
||||||
|
Dim additionalItems As ReferenceProjectItem() = {New ReferenceProjectItem(Me, "mscorlib"), New ReferenceProjectItem(Me, "Microsoft.VisualBasic")} |
||||||
|
Return SD.MSBuildEngine.ResolveAssemblyReferences(Me, additionalItems) |
||||||
|
End Function |
||||||
|
|
||||||
|
Private Sub InitVB() |
||||||
|
reparseReferencesSensitiveProperties.Add("TargetFrameworkVersion") |
||||||
|
reparseCodeSensitiveProperties.Add("DefineConstants") |
||||||
|
End Sub |
||||||
|
|
||||||
|
Public Overrides ReadOnly Property Language() As String |
||||||
|
Get |
||||||
|
Return VBNetProjectBinding.LanguageName |
||||||
|
End Get |
||||||
|
End Property |
||||||
|
|
||||||
|
Public Overrides Function BuildAsync(options As ProjectBuildOptions, feedbackSink As IBuildFeedbackSink, progressMonitor As IProgressMonitor) As Task(Of Boolean) |
||||||
|
If Me.MinimumSolutionVersion = SolutionFormatVersion.VS2005 Then |
||||||
|
Return SD.MSBuildEngine.BuildAsync(Me, options, feedbackSink, progressMonitor.CancellationToken, { Path.Combine(FileUtility.ApplicationRootPath, "bin\SharpDevelop.CheckMSBuild35Features.targets") }) |
||||||
|
End If |
||||||
|
|
||||||
|
Return MyBase.BuildAsync(options, feedbackSink, progressMonitor) |
||||||
|
End Function |
||||||
|
|
||||||
|
Public ReadOnly Property OptionInfer() As Nullable(Of Boolean) |
||||||
|
Get |
||||||
|
Return GetValue("OptionInfer", False) |
||||||
|
End Get |
||||||
|
End Property |
||||||
|
|
||||||
|
Public ReadOnly Property OptionStrict() As Nullable(Of Boolean) |
||||||
|
Get |
||||||
|
Return GetValue("OptionStrict", False) |
||||||
|
End Get |
||||||
|
End Property |
||||||
|
|
||||||
|
Public ReadOnly Property OptionExplicit() As Nullable(Of Boolean) |
||||||
|
Get |
||||||
|
Return GetValue("OptionExplicit", True) |
||||||
|
End Get |
||||||
|
End Property |
||||||
|
|
||||||
|
Public ReadOnly Property OptionCompare() As Nullable(Of CompareKind) |
||||||
|
Get |
||||||
|
Dim val As String = GetEvaluatedProperty("OptionCompare") |
||||||
|
|
||||||
|
If "Text".Equals(val, StringComparison.OrdinalIgnoreCase) Then |
||||||
|
Return CompareKind.Text |
||||||
|
End If |
||||||
|
|
||||||
|
Return CompareKind.Binary |
||||||
|
End Get |
||||||
|
End Property |
||||||
|
|
||||||
|
Private Function GetValue(name As String, defaultVal As Boolean) As System.Nullable(Of Boolean) |
||||||
|
Dim val As String |
||||||
|
Try |
||||||
|
val = GetEvaluatedProperty(name) |
||||||
|
Catch generatedExceptionName As ObjectDisposedException |
||||||
|
' This can happen when the project is disposed but the resolver still tries |
||||||
|
' to access Option Infer (or similar). |
||||||
|
val = Nothing |
||||||
|
End Try |
||||||
|
|
||||||
|
If val Is Nothing Then |
||||||
|
Return defaultVal |
||||||
|
End If |
||||||
|
|
||||||
|
Return "On".Equals(val, StringComparison.OrdinalIgnoreCase) |
||||||
|
End Function |
||||||
|
|
||||||
|
Public Overrides Function GetDefaultNamespace(fileName As String) As String |
||||||
|
' use root namespace everywhere, ignore the folder name |
||||||
|
Return Me.RootNamespace |
||||||
|
End Function |
||||||
|
|
||||||
|
Public Overrides Function CreateCodeDomProvider() As System.CodeDom.Compiler.CodeDomProvider |
||||||
|
Return New Microsoft.VisualBasic.VBCodeProvider() |
||||||
|
End Function |
||||||
|
|
||||||
|
Protected Overrides Function CreateDefaultBehavior() As ProjectBehavior |
||||||
|
Return New VBProjectBehavior(Me, MyBase.CreateDefaultBehavior()) |
||||||
|
End Function |
||||||
|
End Class |
||||||
|
|
||||||
|
Public Class VBProjectBehavior |
||||||
|
Inherits ProjectBehavior |
||||||
|
Public Sub New(project As VBNetProject, Optional [next] As ProjectBehavior = Nothing) |
||||||
|
|
||||||
|
MyBase.New(project, [next]) |
||||||
|
End Sub |
||||||
|
|
||||||
|
Public Overrides Function GetDefaultItemType(fileName As String) As ItemType |
||||||
|
If String.Equals(Path.GetExtension(fileName), ".vb", StringComparison.OrdinalIgnoreCase) Then |
||||||
|
Return ItemType.Compile |
||||||
|
Else |
||||||
|
Return MyBase.GetDefaultItemType(fileName) |
||||||
|
End If |
||||||
|
End Function |
||||||
|
End Class |
||||||
@ -0,0 +1,30 @@ |
|||||||
|
' Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) |
||||||
|
' This code is distributed under the GNU LGPL (for details please see \doc\license.txt) |
||||||
|
|
||||||
|
Imports System.Xml |
||||||
|
Imports ICSharpCode.SharpDevelop.Project |
||||||
|
|
||||||
|
Public Class VBNetProjectBinding |
||||||
|
Implements IProjectBinding |
||||||
|
Public Const LanguageName As String = "VBNet" |
||||||
|
|
||||||
|
Public ReadOnly Property Language() As String Implements IProjectBinding.Language |
||||||
|
Get |
||||||
|
Return LanguageName |
||||||
|
End Get |
||||||
|
End Property |
||||||
|
|
||||||
|
Public Function LoadProject(info As ProjectLoadInformation) As IProject Implements IProjectBinding.LoadProject |
||||||
|
Return New VBNetProject(info) |
||||||
|
End Function |
||||||
|
|
||||||
|
Public Function CreateProject(info As ProjectCreateInformation) As IProject Implements IProjectBinding.CreateProject |
||||||
|
Return New VBNetProject(info) |
||||||
|
End Function |
||||||
|
|
||||||
|
Public ReadOnly Property HandlingMissingProject() As Boolean Implements IProjectBinding.HandlingMissingProject |
||||||
|
Get |
||||||
|
Return False |
||||||
|
End Get |
||||||
|
End Property |
||||||
|
End Class |
||||||
@ -0,0 +1,88 @@ |
|||||||
|
' Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) |
||||||
|
' This code is distributed under the GNU LGPL (for details please see \doc\license.txt) |
||||||
|
|
||||||
|
Imports System.Text |
||||||
|
Imports ICSharpCode.SharpDevelop.Project |
||||||
|
Imports Microsoft.Build.Framework |
||||||
|
Imports System.IO |
||||||
|
|
||||||
|
''' <summary> |
||||||
|
''' Fixes SD2-995 : Special characters not correctly encoded for languages others than English |
||||||
|
''' </summary> |
||||||
|
<System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId := "Vbc")> _ |
||||||
|
Public NotInheritable Class VbcEncodingFixingLogger |
||||||
|
Implements IMSBuildLoggerFilter |
||||||
|
Public Function CreateFilter(context As IMSBuildLoggerContext, nextFilter As IMSBuildChainedLoggerFilter) As IMSBuildChainedLoggerFilter Implements IMSBuildLoggerFilter.CreateFilter |
||||||
|
Return New VbcLoggerImpl(nextFilter) |
||||||
|
End Function |
||||||
|
|
||||||
|
Private NotInheritable Class VbcLoggerImpl |
||||||
|
Implements IMSBuildChainedLoggerFilter |
||||||
|
ReadOnly nextFilter As IMSBuildChainedLoggerFilter |
||||||
|
|
||||||
|
Public Sub New(nextFilter As IMSBuildChainedLoggerFilter) |
||||||
|
Me.nextFilter = nextFilter |
||||||
|
End Sub |
||||||
|
|
||||||
|
Private Shared Function FixEncoding(text As String) As String |
||||||
|
If text Is Nothing Then |
||||||
|
Return text |
||||||
|
End If |
||||||
|
Return Encoding.[Default].GetString(ICSharpCode.SharpDevelop.ProcessRunner.OemEncoding.GetBytes(text)) |
||||||
|
End Function |
||||||
|
|
||||||
|
Public Sub HandleError([error] As BuildError) Implements IMSBuildChainedLoggerFilter.HandleError |
||||||
|
[error].ErrorText = FixEncoding([error].ErrorText) |
||||||
|
[error].FileName = FixEncoding([error].FileName) |
||||||
|
[error].Column = FixColumn([error].FileName, [error].Line, [error].Column) |
||||||
|
nextFilter.HandleError([error]) |
||||||
|
End Sub |
||||||
|
|
||||||
|
Public Sub HandleBuildEvent(e As Microsoft.Build.Framework.BuildEventArgs) Implements IMSBuildChainedLoggerFilter.HandleBuildEvent |
||||||
|
nextFilter.HandleBuildEvent(e) |
||||||
|
If TypeOf e Is TaskFinishedEventArgs AndAlso lastFile IsNot Nothing Then |
||||||
|
lastFile.Close() |
||||||
|
lastFile = Nothing |
||||||
|
End If |
||||||
|
End Sub |
||||||
|
|
||||||
|
Private lastFileName As String, lastLineText As String |
||||||
|
Private lastFile As StreamReader |
||||||
|
Private lastLine As Integer |
||||||
|
|
||||||
|
' fixes SD-1746 - VB compiler errors are shown in incorrect column if the line contains tabs |
||||||
|
' (http://bugtracker.sharpdevelop.net/issue/ViewIssue.aspx?id=1746&PROJID=4) |
||||||
|
Private Function FixColumn(fileName As String, line As Integer, column As Integer) As Integer |
||||||
|
If Not File.Exists(fileName) OrElse line < 1 OrElse column < 1 Then |
||||||
|
Return column |
||||||
|
End If |
||||||
|
|
||||||
|
If fileName <> lastFileName OrElse line < lastLine OrElse lastFile Is Nothing Then |
||||||
|
If lastFile IsNot Nothing Then |
||||||
|
lastFile.Close() |
||||||
|
End If |
||||||
|
lastFile = New StreamReader(fileName) |
||||||
|
lastFileName = fileName |
||||||
|
lastLineText = "" |
||||||
|
lastLine = 0 |
||||||
|
End If |
||||||
|
|
||||||
|
While lastLine < line AndAlso lastLineText IsNot Nothing |
||||||
|
lastLineText = lastFile.ReadLine() |
||||||
|
lastLine += 1 |
||||||
|
End While |
||||||
|
|
||||||
|
If Not String.IsNullOrEmpty(lastLineText) Then |
||||||
|
Dim i As Integer = 0 |
||||||
|
While i < column AndAlso i < lastLineText.Length |
||||||
|
If lastLineText(i) = ControlChars.Tab Then |
||||||
|
column -= 3 |
||||||
|
End If |
||||||
|
i += 1 |
||||||
|
End While |
||||||
|
End If |
||||||
|
|
||||||
|
Return column |
||||||
|
End Function |
||||||
|
End Class |
||||||
|
End Class |
||||||
@ -1,139 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Linq; |
|
||||||
using ICSharpCode.SharpDevelop; |
|
||||||
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; |
|
||||||
using NUnit.Framework; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding.Tests |
|
||||||
{ |
|
||||||
[TestFixture] |
|
||||||
public class CodeCompletionTests : TextEditorBasedTests |
|
||||||
{ |
|
||||||
[Test] |
|
||||||
public void TestEmptyFile() |
|
||||||
{ |
|
||||||
TestKeyPress("|", 'o', CodeCompletionKeyPressResult.CompletedIncludeKeyInCompletion, |
|
||||||
list => { |
|
||||||
Assert.IsTrue(list.Items.Any()); |
|
||||||
Assert.IsTrue(list.Items.All(item => item.Image == ClassBrowserIconService.Keyword)); |
|
||||||
ContainsAll(list.Items.Select(item => item.Text).ToArray(), |
|
||||||
"Class", "Delegate", "Friend", "Imports", "Module", |
|
||||||
"Namespace", "Option", "Private", "Protected", "Public", |
|
||||||
"Shadows", "Structure", "Interface", "Enum", "Partial", "NotInheritable"); |
|
||||||
} |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void TestOptions() |
|
||||||
{ |
|
||||||
TestKeyPress("Option|\n", ' ', CodeCompletionKeyPressResult.EatKey, |
|
||||||
list => { |
|
||||||
Assert.IsTrue(list.Items.Any()); |
|
||||||
Assert.IsTrue(list.Items.All(item => item.Image == ClassBrowserIconService.Keyword)); |
|
||||||
ContainsAll(list.Items.Select(item => item.Text).ToArray(), |
|
||||||
"Explicit", "Infer", "Compare", "Strict"); |
|
||||||
} |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void TestOptionCompare() |
|
||||||
{ |
|
||||||
TestKeyPress("Option Compare|\n", ' ', CodeCompletionKeyPressResult.EatKey, |
|
||||||
list => { |
|
||||||
Assert.IsTrue(list.Items.Any()); |
|
||||||
Assert.IsTrue(list.Items.All(item => item.Image == ClassBrowserIconService.Keyword)); |
|
||||||
ContainsAll(list.Items.Select(item => item.Text).ToArray(), |
|
||||||
"Text", "Binary"); |
|
||||||
} |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void TestOnOffOptions() |
|
||||||
{ |
|
||||||
foreach (string option in new[] { "Infer", "Strict", "Explicit" }) { |
|
||||||
TestKeyPress(string.Format("Option {0} |\n", option), 'o', CodeCompletionKeyPressResult.CompletedIncludeKeyInCompletion, |
|
||||||
list => { |
|
||||||
Assert.IsTrue(list.Items.Any()); |
|
||||||
Assert.IsTrue(list.Items.All(item => item.Image == ClassBrowserIconService.Keyword)); |
|
||||||
ContainsAll(list.Items.Select(item => item.Text).ToArray(), |
|
||||||
"On", "Off"); |
|
||||||
} |
|
||||||
); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void ContainsAll(ICollection items, params string[] expected) |
|
||||||
{ |
|
||||||
// Assert.AreEqual(expected.Length, items.Count);
|
|
||||||
|
|
||||||
foreach (string element in expected) |
|
||||||
Assert.Contains(element, items); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void TestDotAfterDigit() |
|
||||||
{ |
|
||||||
string text = @"Module Test
|
|
||||||
Public Function fn() As Double |
|
||||||
Dim f As Double |
|
||||||
f = 1| |
|
||||||
End Function |
|
||||||
End Module";
|
|
||||||
|
|
||||||
TestKeyPress(text, '.', CodeCompletionKeyPressResult.None, list => Assert.IsFalse(list.Items.Any())); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void TestDotAfterIdentifier() |
|
||||||
{ |
|
||||||
string text = @"Module Test
|
|
||||||
Public Function fn(x As Double) As Double |
|
||||||
Dim f As Double |
|
||||||
f = x| |
|
||||||
End Function |
|
||||||
End Module";
|
|
||||||
|
|
||||||
TestKeyPress(text, '.', CodeCompletionKeyPressResult.Completed, list => Assert.IsTrue(list.Items.Any())); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void TestWithBlockCtrlSpace() |
|
||||||
{ |
|
||||||
string text = @"Module Test
|
|
||||||
Sub Test2(a As Exception) |
|
||||||
With a |
|
||||||
| |
|
||||||
End With |
|
||||||
End Sub |
|
||||||
End Module";
|
|
||||||
|
|
||||||
// TODO seems to be wrong!
|
|
||||||
|
|
||||||
TestCtrlSpace(text, true, list => Assert.IsFalse(list.Items.Any(i => i.Text == "InnerException"))); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void TestLocalVariablesAvailableAtEndOfForLoop() |
|
||||||
{ |
|
||||||
string text = @"Module Test
|
|
||||||
Public Sub f() |
|
||||||
Dim cheeses = { ""cheddar"", ""brie"", ""edam"" } |
|
||||||
For Each cheese As String In cheeses |
|
||||||
Dim gouda = ""is tasty"" |
|
||||||
| |
|
||||||
Next |
|
||||||
End Sub |
|
||||||
End Module";
|
|
||||||
|
|
||||||
TestKeyPress(text, 'g', CodeCompletionKeyPressResult.CompletedIncludeKeyInCompletion, list => Assert.IsTrue(list.Items.Any(i => i.Text == "gouda"))); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,20 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System.Reflection; |
|
||||||
using NUnit.Framework; |
|
||||||
|
|
||||||
// Information about this assembly is defined by the following
|
|
||||||
// attributes.
|
|
||||||
//
|
|
||||||
// change them to the information which is associated with the assembly
|
|
||||||
// you compile.
|
|
||||||
|
|
||||||
[assembly: AssemblyTitle("VBNetBinding.Tests")] |
|
||||||
[assembly: AssemblyDescription("VB.NET language binding for #develop")] |
|
||||||
[assembly: AssemblyConfiguration("")] |
|
||||||
[assembly: AssemblyTrademark("")] |
|
||||||
[assembly: AssemblyCulture("")] |
|
||||||
|
|
||||||
// Run unit tests on STA thread.
|
|
||||||
[assembly: RequiresSTA] |
|
||||||
@ -1,406 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; |
|
||||||
using System; |
|
||||||
using ICSharpCode.AvalonEdit; |
|
||||||
using ICSharpCode.Core; |
|
||||||
using NUnit.Framework; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding.Tests |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Tests that Operator overrides have "End Operator" added after the user presses the return key.
|
|
||||||
/// </summary>
|
|
||||||
[TestFixture] |
|
||||||
public class EndOperatorTests |
|
||||||
{ |
|
||||||
[TestFixtureSetUp] |
|
||||||
public void SetUpFixture() |
|
||||||
{ |
|
||||||
if (!PropertyService.Initialized) { |
|
||||||
PropertyService.InitializeService(String.Empty, String.Empty, "VBNetBindingTests"); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Checks that when the user presses the return key after the Operator line that the
|
|
||||||
/// expected code is generated.
|
|
||||||
/// </summary>
|
|
||||||
void RunFormatLineTest(string code, string expectedCode, int expectedOffset) |
|
||||||
{ |
|
||||||
string foo = "As Foo\r\n"; |
|
||||||
int cursorOffset = code.IndexOf(foo) + foo.Length; |
|
||||||
|
|
||||||
AvalonEditTextEditorAdapter editor = new AvalonEditTextEditorAdapter(new TextEditor()); |
|
||||||
editor.Document.Text = code; |
|
||||||
editor.Caret.Offset = cursorOffset; |
|
||||||
VBNetFormattingStrategy formattingStrategy = new VBNetFormattingStrategy(); |
|
||||||
formattingStrategy.FormatLine(editor, '\n'); |
|
||||||
|
|
||||||
Assert.AreEqual(expectedCode, editor.Document.Text); |
|
||||||
Assert.AreEqual(expectedOffset, editor.Caret.Offset); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void AdditionOperator() |
|
||||||
{ |
|
||||||
string code = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator +(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"End Class"; |
|
||||||
|
|
||||||
string expectedCode = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator +(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t\r\n" + |
|
||||||
"\tEnd Operator\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator +(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t").Length; |
|
||||||
|
|
||||||
RunFormatLineTest(code, expectedCode, expectedOffset); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void AdditionOperatorWithExistingEndOperator() |
|
||||||
{ |
|
||||||
string code = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator +(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"\tEnd Operator\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
string expectedCode = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator +(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t\r\n" + |
|
||||||
"\tEnd Operator\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator +(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t").Length; |
|
||||||
|
|
||||||
RunFormatLineTest(code, expectedCode, expectedOffset); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ExistingEndOperatorHasWhitespaceInbetween() |
|
||||||
{ |
|
||||||
string code = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator +(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"\tEnd Operator\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
string expectedCode = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator +(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t\r\n" + |
|
||||||
"\tEnd Operator\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator +(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t").Length; |
|
||||||
|
|
||||||
RunFormatLineTest(code, expectedCode, expectedOffset); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void AdditionOperatorHasWhitespaceAfterOperator() |
|
||||||
{ |
|
||||||
string code = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator + (ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"End Class"; |
|
||||||
|
|
||||||
string expectedCode = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator + (ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t\r\n" + |
|
||||||
"\tEnd Operator\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator + (ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t").Length; |
|
||||||
|
|
||||||
RunFormatLineTest(code, expectedCode, expectedOffset); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void AdditionOperatorWithNoWhitespace() |
|
||||||
{ |
|
||||||
string code = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator+(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"End Class"; |
|
||||||
|
|
||||||
string expectedCode = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator+(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t\r\n" + |
|
||||||
"\tEnd Operator\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator+(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t").Length; |
|
||||||
|
|
||||||
RunFormatLineTest(code, expectedCode, expectedOffset); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void SubtractionOperator() |
|
||||||
{ |
|
||||||
string code = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator -(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"End Class"; |
|
||||||
|
|
||||||
string expectedCode = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator -(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t\r\n" + |
|
||||||
"\tEnd Operator\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator -(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t").Length; |
|
||||||
|
|
||||||
RunFormatLineTest(code, expectedCode, expectedOffset); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void IsTrueOperator() |
|
||||||
{ |
|
||||||
string code = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator IsTrue(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"End Class"; |
|
||||||
|
|
||||||
string expectedCode = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator IsTrue(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t\r\n" + |
|
||||||
"\tEnd Operator\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator IsTrue(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t").Length; |
|
||||||
|
|
||||||
RunFormatLineTest(code, expectedCode, expectedOffset); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void MultiplicationOperator() |
|
||||||
{ |
|
||||||
string code = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator *(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"End Class"; |
|
||||||
|
|
||||||
string expectedCode = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator *(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t\r\n" + |
|
||||||
"\tEnd Operator\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator *(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t").Length; |
|
||||||
|
|
||||||
RunFormatLineTest(code, expectedCode, expectedOffset); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void DivisionOperator() |
|
||||||
{ |
|
||||||
string code = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator /(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"End Class"; |
|
||||||
|
|
||||||
string expectedCode = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator /(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t\r\n" + |
|
||||||
"\tEnd Operator\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator /(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t").Length; |
|
||||||
|
|
||||||
RunFormatLineTest(code, expectedCode, expectedOffset); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void IntegerDivisionOperator() |
|
||||||
{ |
|
||||||
string code = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator \\(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"End Class"; |
|
||||||
|
|
||||||
string expectedCode = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator \\(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t\r\n" + |
|
||||||
"\tEnd Operator\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator \\(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t").Length; |
|
||||||
|
|
||||||
RunFormatLineTest(code, expectedCode, expectedOffset); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void StringConcatenationOperator() |
|
||||||
{ |
|
||||||
string code = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator &(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"End Class"; |
|
||||||
|
|
||||||
string expectedCode = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator &(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t\r\n" + |
|
||||||
"\tEnd Operator\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator &(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t").Length; |
|
||||||
|
|
||||||
RunFormatLineTest(code, expectedCode, expectedOffset); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ExponentationcationOperator() |
|
||||||
{ |
|
||||||
string code = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator ^(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"End Class"; |
|
||||||
|
|
||||||
string expectedCode = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator ^(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t\r\n" + |
|
||||||
"\tEnd Operator\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator ^(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t").Length; |
|
||||||
|
|
||||||
RunFormatLineTest(code, expectedCode, expectedOffset); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void EqualityOperator() |
|
||||||
{ |
|
||||||
string code = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator =(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"End Class"; |
|
||||||
|
|
||||||
string expectedCode = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator =(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t\r\n" + |
|
||||||
"\tEnd Operator\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator =(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t").Length; |
|
||||||
|
|
||||||
RunFormatLineTest(code, expectedCode, expectedOffset); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void GreaterThanOperator() |
|
||||||
{ |
|
||||||
string code = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator >(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"End Class"; |
|
||||||
|
|
||||||
string expectedCode = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator >(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t\r\n" + |
|
||||||
"\tEnd Operator\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator >(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t").Length; |
|
||||||
|
|
||||||
RunFormatLineTest(code, expectedCode, expectedOffset); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void LessThanOperator() |
|
||||||
{ |
|
||||||
string code = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator <(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"End Class"; |
|
||||||
|
|
||||||
string expectedCode = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator <(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t\r\n" + |
|
||||||
"\tEnd Operator\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator <(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t").Length; |
|
||||||
|
|
||||||
RunFormatLineTest(code, expectedCode, expectedOffset); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void InequalityOperator() |
|
||||||
{ |
|
||||||
string code = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator <>(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"End Class"; |
|
||||||
|
|
||||||
string expectedCode = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator <>(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t\r\n" + |
|
||||||
"\tEnd Operator\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared Operator <>(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\t").Length; |
|
||||||
|
|
||||||
RunFormatLineTest(code, expectedCode, expectedOffset); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Check that a method that starts with "Operator" is ignored.
|
|
||||||
/// </summary>
|
|
||||||
[Test] |
|
||||||
public void MethodStartsWithOperatorString() |
|
||||||
{ |
|
||||||
string code = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared OperatorIgnore(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"End Class"; |
|
||||||
|
|
||||||
string expectedCode = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared OperatorIgnore(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Class Foo\r\n" + |
|
||||||
"\tPublic Shared OperatorIgnore(ByVal lhs As Foo, ByVal rhs As Foo) As Foo\r\n" + |
|
||||||
"\t").Length; |
|
||||||
|
|
||||||
RunFormatLineTest(code, expectedCode, expectedOffset); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,224 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using ICSharpCode.AvalonEdit; |
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; |
|
||||||
using NUnit.Framework; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding.Tests |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Tests that Operator overrides have "End Operator" added after the user presses the return key.
|
|
||||||
/// </summary>
|
|
||||||
[TestFixture] |
|
||||||
public class EndInsertionTests |
|
||||||
{ |
|
||||||
[TestFixtureSetUp] |
|
||||||
public void SetUpFixture() |
|
||||||
{ |
|
||||||
if (!PropertyService.Initialized) { |
|
||||||
PropertyService.InitializeService(String.Empty, String.Empty, "VBNetBindingTests"); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void EndSub() |
|
||||||
{ |
|
||||||
string code = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Sub Bar\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"End Class"; |
|
||||||
|
|
||||||
string bar = "Bar\r\n"; |
|
||||||
int cursorOffset = code.IndexOf(bar) + bar.Length; |
|
||||||
|
|
||||||
string expectedCode = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Sub Bar\r\n" + |
|
||||||
"\t\t\r\n" + |
|
||||||
"\tEnd Sub\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Class Foo\r\n" + |
|
||||||
"\tPublic Sub Bar\r\n" + |
|
||||||
"\t\t").Length; |
|
||||||
|
|
||||||
RunTest(code, cursorOffset, expectedCode, expectedOffset, '\n'); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void RunTest(string code, int cursorOffset, string expectedCode, int expectedOffset, char keyPressed) |
|
||||||
{ |
|
||||||
AvalonEditTextEditorAdapter editor = new AvalonEditTextEditorAdapter(new TextEditor()); |
|
||||||
editor.Document.Text = code; |
|
||||||
editor.Caret.Offset = cursorOffset; |
|
||||||
VBNetFormattingStrategy formattingStrategy = new VBNetFormattingStrategy(); |
|
||||||
formattingStrategy.FormatLine(editor, keyPressed); |
|
||||||
Assert.AreEqual(expectedCode, editor.Document.Text); |
|
||||||
Assert.AreEqual(expectedOffset, editor.Caret.Offset); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void EndIf() |
|
||||||
{ |
|
||||||
string code = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Sub Bar\r\n" + |
|
||||||
"\t\tIf True Then\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"\tEnd Sub\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
string bar = "Then\r\n"; |
|
||||||
int cursorOffset = code.IndexOf(bar) + bar.Length; |
|
||||||
|
|
||||||
string expectedCode = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Sub Bar\r\n" + |
|
||||||
"\t\tIf True Then\r\n" + |
|
||||||
"\t\t\t\r\n" + |
|
||||||
"\t\tEnd If\r\n" + |
|
||||||
"\tEnd Sub\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Class Foo\r\n" + |
|
||||||
"\tPublic Sub Bar\r\n" + |
|
||||||
"\t\tIf True Then\r\n" + |
|
||||||
"\t\t\t").Length; |
|
||||||
|
|
||||||
RunTest(code, cursorOffset, expectedCode, expectedOffset, '\n'); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void EndUsing() |
|
||||||
{ |
|
||||||
string code = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Sub Bar\r\n" + |
|
||||||
"\t\tUsing a As New StreamReader()\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"\tEnd Sub\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
string bar = "Using a As New StreamReader()\r\n"; |
|
||||||
int cursorOffset = code.IndexOf(bar) + bar.Length; |
|
||||||
|
|
||||||
string expectedCode = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Sub Bar\r\n" + |
|
||||||
"\t\tUsing a As New StreamReader()\r\n" + |
|
||||||
"\t\t\t\r\n" + |
|
||||||
"\t\tEnd Using\r\n" + |
|
||||||
"\tEnd Sub\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Class Foo\r\n" + |
|
||||||
"\tPublic Sub Bar\r\n" + |
|
||||||
"\t\tUsing a As New StreamReader()\r\n" + |
|
||||||
"\t\t\t").Length; |
|
||||||
|
|
||||||
RunTest(code, cursorOffset, expectedCode, expectedOffset, '\n'); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void EndSyncLock() |
|
||||||
{ |
|
||||||
string code = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Sub Bar\r\n" + |
|
||||||
"\t\tSyncLock a\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"\tEnd Sub\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
string bar = "SyncLock a\r\n"; |
|
||||||
int cursorOffset = code.IndexOf(bar) + bar.Length; |
|
||||||
|
|
||||||
string expectedCode = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Sub Bar\r\n" + |
|
||||||
"\t\tSyncLock a\r\n" + |
|
||||||
"\t\t\t\r\n" + |
|
||||||
"\t\tEnd SyncLock\r\n" + |
|
||||||
"\tEnd Sub\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Class Foo\r\n" + |
|
||||||
"\tPublic Sub Bar\r\n" + |
|
||||||
"\t\tSyncLock a\r\n" + |
|
||||||
"\t\t\t").Length; |
|
||||||
|
|
||||||
RunTest(code, cursorOffset, expectedCode, expectedOffset, '\n'); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void SingleLineIf() |
|
||||||
{ |
|
||||||
string code = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Sub Bar\r\n" + |
|
||||||
"\t\tIf True Then _\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"\tEnd Sub\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
string bar = "Then _\r\n"; |
|
||||||
int cursorOffset = code.IndexOf(bar) + bar.Length; |
|
||||||
|
|
||||||
string expectedCode = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Sub Bar\r\n" + |
|
||||||
"\t\tIf True Then _\r\n" + |
|
||||||
"\t\t\t\r\n" + |
|
||||||
"\tEnd Sub\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Class Foo\r\n" + |
|
||||||
"\tPublic Sub Bar\r\n" + |
|
||||||
"\t\tIf True Then _\r\n" + |
|
||||||
"\t\t\t").Length; |
|
||||||
|
|
||||||
RunTest(code, cursorOffset, expectedCode, expectedOffset, '\n'); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void AutomaticPropertyWithInitializer() |
|
||||||
{ |
|
||||||
string code = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Property Bar As Boolean = True\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"End Class"; |
|
||||||
|
|
||||||
string bar = "= True\r\n"; |
|
||||||
int cursorOffset = code.IndexOf(bar) + bar.Length; |
|
||||||
|
|
||||||
string expectedCode = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Property Bar As Boolean = True\r\n" + |
|
||||||
"\t\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Class Foo\r\n" + |
|
||||||
"\tPublic Property Bar As Boolean = True\r\n" + |
|
||||||
"\t").Length; |
|
||||||
|
|
||||||
RunTest(code, cursorOffset, expectedCode, expectedOffset, '\n'); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void StandardProperty() |
|
||||||
{ |
|
||||||
string code = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Property Bar As Boolean\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"End Class"; |
|
||||||
|
|
||||||
string bar = "As Boolean\r\n"; |
|
||||||
int cursorOffset = code.IndexOf(bar) + bar.Length; |
|
||||||
|
|
||||||
string expectedCode = "Public Class Foo\r\n" + |
|
||||||
"\tPublic Property Bar As Boolean\r\n" + |
|
||||||
"\t\t\r\n" + |
|
||||||
"\tEnd Property\r\n" + |
|
||||||
"End Class"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Class Foo\r\n" + |
|
||||||
"\tPublic Property Bar As Boolean\r\n" + |
|
||||||
"\t\t").Length; |
|
||||||
|
|
||||||
RunTest(code, cursorOffset, expectedCode, expectedOffset, '\n'); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,595 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; |
|
||||||
using System; |
|
||||||
using ICSharpCode.AvalonEdit; |
|
||||||
using ICSharpCode.Core; |
|
||||||
using NUnit.Framework; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding.Tests |
|
||||||
{ |
|
||||||
[TestFixture] |
|
||||||
public class IndentationTests |
|
||||||
{ |
|
||||||
[Test] |
|
||||||
public void SimpleInterfaceTest() |
|
||||||
{ |
|
||||||
string code = @"Interface t
|
|
||||||
Sub Test() |
|
||||||
Sub Test2() |
|
||||||
End Interface";
|
|
||||||
|
|
||||||
string expectedCode = @"Interface t
|
|
||||||
Sub Test() |
|
||||||
Sub Test2() |
|
||||||
End Interface";
|
|
||||||
|
|
||||||
RunFormatTest(code, expectedCode); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void SimpleInterfaceWithModifierTest() |
|
||||||
{ |
|
||||||
string code = @"Public Interface t
|
|
||||||
Sub Test() |
|
||||||
Sub Test2() |
|
||||||
End Interface";
|
|
||||||
|
|
||||||
string expectedCode = @"Public Interface t
|
|
||||||
Sub Test() |
|
||||||
Sub Test2() |
|
||||||
End Interface";
|
|
||||||
|
|
||||||
RunFormatTest(code, expectedCode); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void InterfaceWithNewLineAtEndTest() |
|
||||||
{ |
|
||||||
string code = @"Interface t
|
|
||||||
Sub Test() |
|
||||||
Sub Test2() |
|
||||||
|
|
||||||
End Interface";
|
|
||||||
|
|
||||||
string expectedCode = @"Interface t
|
|
||||||
Sub Test() |
|
||||||
Sub Test2() |
|
||||||
|
|
||||||
End Interface";
|
|
||||||
|
|
||||||
RunFormatTest(code, expectedCode); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void SD1775_Fix() |
|
||||||
{ |
|
||||||
string expected = @"Public Class Test
|
|
||||||
Private Sub Tester() |
|
||||||
B = New Burger With {Cheese = True, _ |
|
||||||
Lettuce = True, _ |
|
||||||
Tomato = True, _ |
|
||||||
CookLevel = MeatCookLevel.WellDone} |
|
||||||
End Sub |
|
||||||
End Class";
|
|
||||||
|
|
||||||
string code = @"Public Class Test
|
|
||||||
Private Sub Tester() |
|
||||||
B = New Burger With {Cheese = True, _ |
|
||||||
Lettuce = True, _ |
|
||||||
Tomato = True, _ |
|
||||||
CookLevel = MeatCookLevel.WellDone} |
|
||||||
End Sub |
|
||||||
End Class";
|
|
||||||
|
|
||||||
RunFormatTest(code, expected); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Simple() |
|
||||||
{ |
|
||||||
string expected = @"'
|
|
||||||
' Created by SharpDevelop. |
|
||||||
' User: Siegfried |
|
||||||
' Date: 25.02.2011 |
|
||||||
' Time: 14:41 |
|
||||||
' |
|
||||||
' To change this template use Tools | Options | Coding | Edit Standard Headers. |
|
||||||
' |
|
||||||
Imports Microsoft.VisualBasic.ApplicationServices |
|
||||||
|
|
||||||
Namespace My |
|
||||||
' This file controls the behaviour of the application. |
|
||||||
Partial Class MyApplication |
|
||||||
Public Sub New() |
|
||||||
MyBase.New(AuthenticationMode.Windows) |
|
||||||
Me.IsSingleInstance = False |
|
||||||
Me.EnableVisualStyles = True |
|
||||||
Me.SaveMySettingsOnExit = True |
|
||||||
Me.ShutDownStyle = ShutdownMode.AfterMainFormCloses |
|
||||||
End Sub |
|
||||||
|
|
||||||
Protected Overrides Sub OnCreateMainForm() |
|
||||||
Me.MainForm = My.Forms.MainForm |
|
||||||
End Sub |
|
||||||
End Class |
|
||||||
End Namespace";
|
|
||||||
|
|
||||||
string code = @"'
|
|
||||||
' Created by SharpDevelop. |
|
||||||
' User: Siegfried |
|
||||||
' Date: 25.02.2011 |
|
||||||
' Time: 14:41 |
|
||||||
' |
|
||||||
' To change this template use Tools | Options | Coding | Edit Standard Headers. |
|
||||||
' |
|
||||||
Imports Microsoft.VisualBasic.ApplicationServices |
|
||||||
|
|
||||||
Namespace My |
|
||||||
' This file controls the behaviour of the application. |
|
||||||
Partial Class MyApplication |
|
||||||
Public Sub New() |
|
||||||
MyBase.New(AuthenticationMode.Windows) |
|
||||||
Me.IsSingleInstance = False |
|
||||||
Me.EnableVisualStyles = True |
|
||||||
Me.SaveMySettingsOnExit = True |
|
||||||
Me.ShutDownStyle = ShutdownMode.AfterMainFormCloses |
|
||||||
End Sub |
|
||||||
|
|
||||||
Protected Overrides Sub OnCreateMainForm() |
|
||||||
Me.MainForm = My.Forms.MainForm |
|
||||||
End Sub |
|
||||||
End Class |
|
||||||
End Namespace";
|
|
||||||
|
|
||||||
RunFormatTest(code, expected); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ArrayInitializerTest() |
|
||||||
{ |
|
||||||
string expected = @"Public Class Test
|
|
||||||
Private Sub Tester() |
|
||||||
test(asdf, _ |
|
||||||
asdf, _ |
|
||||||
asdf, _ |
|
||||||
asdf) |
|
||||||
|
|
||||||
Dim test As Integer() = { _ |
|
||||||
2,2,3,34,4,5 _ |
|
||||||
} |
|
||||||
End Sub |
|
||||||
End Class";
|
|
||||||
|
|
||||||
string code = @"Public Class Test
|
|
||||||
Private Sub Tester() |
|
||||||
test(asdf, _ |
|
||||||
asdf, _ |
|
||||||
asdf, _ |
|
||||||
asdf) |
|
||||||
|
|
||||||
Dim test As Integer() = { _ |
|
||||||
2,2,3,34,4,5 _ |
|
||||||
} |
|
||||||
End Sub |
|
||||||
End Class";
|
|
||||||
|
|
||||||
RunFormatTest(code, expected); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void IfLineContinuationTest() |
|
||||||
{ |
|
||||||
string expected = @"Public Class Test
|
|
||||||
Private Sub Tester() |
|
||||||
If True _ |
|
||||||
Then |
|
||||||
test() |
|
||||||
End If |
|
||||||
End Sub |
|
||||||
End Class";
|
|
||||||
|
|
||||||
string code = @"Public Class Test
|
|
||||||
Private Sub Tester() |
|
||||||
If True _ |
|
||||||
Then |
|
||||||
test() |
|
||||||
End If |
|
||||||
End Sub |
|
||||||
End Class";
|
|
||||||
|
|
||||||
RunFormatTest(code, expected); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void IfMultiLineContinuationTest() |
|
||||||
{ |
|
||||||
string expected = @"Public Class Test
|
|
||||||
Private Sub Tester() |
|
||||||
If IsCorrect(i) _ |
|
||||||
And _ |
|
||||||
IsHIgherThan(i, 5) _ |
|
||||||
Then |
|
||||||
test() |
|
||||||
End If |
|
||||||
End Sub |
|
||||||
End Class";
|
|
||||||
|
|
||||||
string code = @"Public Class Test
|
|
||||||
Private Sub Tester() |
|
||||||
If IsCorrect(i) _ |
|
||||||
And _ |
|
||||||
IsHIgherThan(i, 5) _ |
|
||||||
Then |
|
||||||
test() |
|
||||||
End If |
|
||||||
End Sub |
|
||||||
End Class";
|
|
||||||
|
|
||||||
RunFormatTest(code, expected); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ElseIfMultiLineContinuationTest() |
|
||||||
{ |
|
||||||
string expected = @"Public Class Test
|
|
||||||
Private Sub Tester() |
|
||||||
If True Then |
|
||||||
'CODE HERE |
|
||||||
Else If False And _ |
|
||||||
False Then |
|
||||||
'CODE HERE1 |
|
||||||
End If |
|
||||||
End Sub |
|
||||||
End Class";
|
|
||||||
|
|
||||||
string code = @"Public Class Test
|
|
||||||
Private Sub Tester() |
|
||||||
If True Then |
|
||||||
'CODE HERE |
|
||||||
Else If False And _ |
|
||||||
False Then |
|
||||||
'CODE HERE1 |
|
||||||
End If |
|
||||||
End Sub |
|
||||||
End Class";
|
|
||||||
|
|
||||||
RunFormatTest(code, expected); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void SelectCaseTest() |
|
||||||
{ |
|
||||||
string expected = @"Public Class Test
|
|
||||||
Private Sub Tester() |
|
||||||
Select Case a |
|
||||||
Case 0 |
|
||||||
DoSomething() |
|
||||||
' TEST CASE 0 |
|
||||||
Case 1 |
|
||||||
'TEST CASE 1 |
|
||||||
Case 2 |
|
||||||
'TEST CASE 2 |
|
||||||
Case Else |
|
||||||
DoElse() |
|
||||||
End Select |
|
||||||
End Sub |
|
||||||
End Class";
|
|
||||||
|
|
||||||
string code = @"Public Class Test
|
|
||||||
Private Sub Tester() |
|
||||||
Select Case a |
|
||||||
Case 0 |
|
||||||
DoSomething() |
|
||||||
' TEST CASE 0 |
|
||||||
Case 1 |
|
||||||
'TEST CASE 1 |
|
||||||
Case 2 |
|
||||||
'TEST CASE 2 |
|
||||||
Case Else |
|
||||||
DoElse() |
|
||||||
End Select |
|
||||||
End Sub |
|
||||||
End Class";
|
|
||||||
|
|
||||||
RunFormatTest(code, expected); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void SelectCaseTest2() |
|
||||||
{ |
|
||||||
string expected = @"Public Class Test
|
|
||||||
Private Sub Tester() |
|
||||||
Select Case a |
|
||||||
Case 0 |
|
||||||
DoSomething() |
|
||||||
Case 1 |
|
||||||
Case 2 |
|
||||||
Case Else |
|
||||||
DoElse() |
|
||||||
End Select |
|
||||||
End Sub |
|
||||||
End Class";
|
|
||||||
|
|
||||||
string code = @"Public Class Test
|
|
||||||
Private Sub Tester() |
|
||||||
Select Case a |
|
||||||
Case 0 |
|
||||||
DoSomething() |
|
||||||
Case 1 |
|
||||||
Case 2 |
|
||||||
Case Else |
|
||||||
DoElse() |
|
||||||
End Select |
|
||||||
End Sub |
|
||||||
End Class";
|
|
||||||
|
|
||||||
RunFormatTest(code, expected); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void WithTest() |
|
||||||
{ |
|
||||||
string expected = @"Public Class Test
|
|
||||||
Private Sub Tester() |
|
||||||
With a |
|
||||||
If True Then |
|
||||||
' Test |
|
||||||
ElseIf False Then |
|
||||||
' Test3 |
|
||||||
Else |
|
||||||
' Test2 |
|
||||||
End If |
|
||||||
End With |
|
||||||
End Sub |
|
||||||
End Class";
|
|
||||||
|
|
||||||
string code = @"Public Class Test
|
|
||||||
Private Sub Tester() |
|
||||||
With a |
|
||||||
If True Then |
|
||||||
' Test |
|
||||||
ElseIf False Then |
|
||||||
' Test3 |
|
||||||
Else |
|
||||||
' Test2 |
|
||||||
End If |
|
||||||
End With |
|
||||||
End Sub |
|
||||||
End Class";
|
|
||||||
|
|
||||||
RunFormatTest(code, expected); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void WithTest2() |
|
||||||
{ |
|
||||||
string expected = @"Public Class Test
|
|
||||||
Private Sub Tester() |
|
||||||
With a |
|
||||||
If True Then |
|
||||||
' Test |
|
||||||
ElseIf False Then |
|
||||||
' Test3 |
|
||||||
Else |
|
||||||
Try |
|
||||||
DoSomething() |
|
||||||
Catch ex As Exception |
|
||||||
'Handle |
|
||||||
End Try |
|
||||||
End If |
|
||||||
End With |
|
||||||
End Sub |
|
||||||
End Class";
|
|
||||||
|
|
||||||
string code = @"Public Class Test
|
|
||||||
Private Sub Tester() |
|
||||||
With a |
|
||||||
If True Then |
|
||||||
' Test |
|
||||||
ElseIf False Then |
|
||||||
' Test3 |
|
||||||
Else |
|
||||||
Try |
|
||||||
DoSomething() |
|
||||||
Catch ex As Exception |
|
||||||
'Handle |
|
||||||
End Try |
|
||||||
End If |
|
||||||
End With |
|
||||||
End Sub |
|
||||||
End Class";
|
|
||||||
|
|
||||||
RunFormatTest(code, expected); |
|
||||||
} |
|
||||||
|
|
||||||
[Test, Ignore] |
|
||||||
// TODO : find out why unit test does not work, but normal run works
|
|
||||||
public void FunctionLambda() |
|
||||||
{ |
|
||||||
string expected = @"Public Class Test
|
|
||||||
Private Sub Tester() |
|
||||||
Dim increment1 = Function(x) x + 1 |
|
||||||
Dim increment2 = Function(x) |
|
||||||
Return x + 2 |
|
||||||
End Function |
|
||||||
End Sub |
|
||||||
End Class";
|
|
||||||
|
|
||||||
string code = @"Public Class Test
|
|
||||||
Private Sub Tester() |
|
||||||
Dim increment1 = Function(x) x + 1 |
|
||||||
Dim increment2 = Function(x) |
|
||||||
Return x + 2 |
|
||||||
End Function |
|
||||||
End Sub |
|
||||||
End Class";
|
|
||||||
|
|
||||||
RunFormatTest(code, expected); |
|
||||||
} |
|
||||||
|
|
||||||
[Test, Ignore] |
|
||||||
// TODO : find out why unit test does not work, but normal run works
|
|
||||||
public void SubLambda() |
|
||||||
{ |
|
||||||
string expected = @"Public Class Test
|
|
||||||
Private Sub Tester() |
|
||||||
Dim writeline1 = Sub(x) Console.WriteLine(x) |
|
||||||
Dim writeline2 = Sub(x) |
|
||||||
Console.WriteLine(x) |
|
||||||
End Sub |
|
||||||
End Sub |
|
||||||
End Class";
|
|
||||||
|
|
||||||
string code = @"Public Class Test
|
|
||||||
Private Sub Tester() |
|
||||||
Dim writeline1 = Sub(x) Console.WriteLine(x) |
|
||||||
Dim writeline2 = Sub(x) |
|
||||||
Console.WriteLine(x) |
|
||||||
End Sub |
|
||||||
End Sub |
|
||||||
End Class";
|
|
||||||
|
|
||||||
RunFormatTest(code, expected); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Region() |
|
||||||
{ |
|
||||||
string expected = @"Module Program
|
|
||||||
#Region Test |
|
||||||
|
|
||||||
#End Region |
|
||||||
|
|
||||||
Sub asdf() |
|
||||||
|
|
||||||
End Sub |
|
||||||
End Module";
|
|
||||||
|
|
||||||
string code = @"Module Program
|
|
||||||
#Region Test |
|
||||||
|
|
||||||
#End Region |
|
||||||
|
|
||||||
Sub asdf() |
|
||||||
|
|
||||||
End Sub |
|
||||||
End Module";
|
|
||||||
|
|
||||||
RunFormatTest(code, expected); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Attribute() |
|
||||||
{ |
|
||||||
string expected = @"Module Core
|
|
||||||
<STAThreadAttribute> _ |
|
||||||
Sub Main |
|
||||||
|
|
||||||
End Sub |
|
||||||
End Module";
|
|
||||||
|
|
||||||
string code = @"Module Core
|
|
||||||
<STAThreadAttribute> _ |
|
||||||
Sub Main |
|
||||||
|
|
||||||
End Sub |
|
||||||
End Module";
|
|
||||||
|
|
||||||
RunFormatTest(code, expected); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Attribute2() |
|
||||||
{ |
|
||||||
string expected = @"Module Core
|
|
||||||
<AttributeUsage( |
|
||||||
bla.bla |
|
||||||
)> _ |
|
||||||
Sub Main |
|
||||||
|
|
||||||
End Sub |
|
||||||
End Module";
|
|
||||||
|
|
||||||
string code = @"Module Core
|
|
||||||
<AttributeUsage( |
|
||||||
bla.bla |
|
||||||
)> _ |
|
||||||
Sub Main |
|
||||||
|
|
||||||
End Sub |
|
||||||
End Module";
|
|
||||||
|
|
||||||
RunFormatTest(code, expected); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ForNextOneLine() |
|
||||||
{ |
|
||||||
string expected = @"Module Core
|
|
||||||
Sub Main |
|
||||||
Dim a = 1 |
|
||||||
For i = 0 To 10 : Console.WriteLine(i) : Next |
|
||||||
Dim b = 2 |
|
||||||
End Sub |
|
||||||
End Module";
|
|
||||||
|
|
||||||
string code = @"Module Core
|
|
||||||
Sub Main |
|
||||||
Dim a = 1 |
|
||||||
For i = 0 To 10 : Console.WriteLine(i) : Next |
|
||||||
Dim b = 2 |
|
||||||
End Sub |
|
||||||
End Module";
|
|
||||||
|
|
||||||
RunFormatTest(code, expected); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void RandomNext() |
|
||||||
{ |
|
||||||
string expected = @"Module Core
|
|
||||||
Public Function GetRandomNumber( _ |
|
||||||
Optional ByVal Low As Integer = 1, _ |
|
||||||
Optional ByVal High As Integer = 100) As Integer |
|
||||||
' Returns a random number, |
|
||||||
' between the optional Low and High parameters |
|
||||||
Return objRandom.Next(Low, High + 1) |
|
||||||
End Function |
|
||||||
End Module";
|
|
||||||
|
|
||||||
string code = @"Module Core
|
|
||||||
Public Function GetRandomNumber( _ |
|
||||||
Optional ByVal Low As Integer = 1, _ |
|
||||||
Optional ByVal High As Integer = 100) As Integer |
|
||||||
' Returns a random number, |
|
||||||
' between the optional Low and High parameters |
|
||||||
Return objRandom.Next(Low, High + 1) |
|
||||||
End Function |
|
||||||
End Module";
|
|
||||||
|
|
||||||
RunFormatTest(code, expected); |
|
||||||
} |
|
||||||
|
|
||||||
void RunFormatTest(string code, string expectedCode) |
|
||||||
{ |
|
||||||
AvalonEditTextEditorAdapter editor = new AvalonEditTextEditorAdapter(new TextEditor()); |
|
||||||
editor.Document.Text = code; |
|
||||||
VBNetFormattingStrategy formattingStrategy = new VBNetFormattingStrategy(); |
|
||||||
formattingStrategy.IndentLines(editor, 1, editor.Document.TotalNumberOfLines); |
|
||||||
|
|
||||||
Console.WriteLine(editor.Document.Text); |
|
||||||
|
|
||||||
Assert.AreEqual(expectedCode, editor.Document.Text); |
|
||||||
} |
|
||||||
|
|
||||||
[TestFixtureSetUp] |
|
||||||
public void Init() |
|
||||||
{ |
|
||||||
if (!PropertyService.Initialized) { |
|
||||||
PropertyService.InitializeService(String.Empty, String.Empty, "VBNetBindingTests"); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,56 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using ICSharpCode.AvalonEdit; |
|
||||||
using System; |
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; |
|
||||||
using NUnit.Framework; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding.Tests |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Tests the special case of an interface. for ex. no insertion of End-Tags etc.
|
|
||||||
/// </summary>
|
|
||||||
[TestFixture] |
|
||||||
public class InterfaceTests |
|
||||||
{ |
|
||||||
[TestFixtureSetUp] |
|
||||||
public void SetUpFixture() |
|
||||||
{ |
|
||||||
if (!PropertyService.Initialized) { |
|
||||||
PropertyService.InitializeService(String.Empty, String.Empty, "VBNetBindingTests"); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void InterfaceEndSub() |
|
||||||
{ |
|
||||||
string code = "Public Interface Foo\r\n" + |
|
||||||
"\tPublic Sub Bar\r\n" + |
|
||||||
"\r\n" + // This extra new line is required. This is the new line just entered by the user.
|
|
||||||
"End Interface"; |
|
||||||
|
|
||||||
string bar = "Sub Bar\r\n"; |
|
||||||
int cursorOffset = code.IndexOf(bar) + bar.Length; |
|
||||||
|
|
||||||
string expectedCode = "Public Interface Foo\r\n" + |
|
||||||
"\tPublic Sub Bar\r\n" + |
|
||||||
"\t\r\n" + |
|
||||||
"End Interface"; |
|
||||||
|
|
||||||
int expectedOffset = ("Public Interface Foo\r\n" + |
|
||||||
"\tPublic Sub Bar\r\n" + |
|
||||||
"\t").Length; |
|
||||||
|
|
||||||
AvalonEditTextEditorAdapter editor = new AvalonEditTextEditorAdapter(new TextEditor()); |
|
||||||
editor.Document.Text = code; |
|
||||||
editor.Caret.Offset = cursorOffset; |
|
||||||
VBNetFormattingStrategy formattingStrategy = new VBNetFormattingStrategy(); |
|
||||||
formattingStrategy.FormatLine(editor, '\n'); |
|
||||||
|
|
||||||
Assert.AreEqual(expectedCode, editor.Document.Text); |
|
||||||
Assert.AreEqual(expectedOffset, editor.Caret.Offset); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,72 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using NUnit.Framework; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding.Tests |
|
||||||
{ |
|
||||||
[TestFixture] |
|
||||||
public class LanguageUtilsTests |
|
||||||
{ |
|
||||||
[Test] |
|
||||||
public void TrimPreprocessorDirectives1() |
|
||||||
{ |
|
||||||
string input = " #Region Test"; |
|
||||||
string expectedOutput = " "; |
|
||||||
|
|
||||||
TestTrimPreprocessorDirectives(input, expectedOutput); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void TrimPreprocessorDirectives2() |
|
||||||
{ |
|
||||||
string input = "Dim a# = 12.0"; |
|
||||||
string expectedOutput = "Dim a# = 12.0"; |
|
||||||
|
|
||||||
TestTrimPreprocessorDirectives(input, expectedOutput); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void TrimPreprocessorDirectives3() |
|
||||||
{ |
|
||||||
string input = "Dim a = 12.0#"; |
|
||||||
string expectedOutput = "Dim a = 12.0#"; |
|
||||||
|
|
||||||
TestTrimPreprocessorDirectives(input, expectedOutput); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void TrimPreprocessorDirectives4() |
|
||||||
{ |
|
||||||
string input = " #10/10/2010#"; |
|
||||||
string expectedOutput = " #10/10/2010#"; |
|
||||||
|
|
||||||
TestTrimPreprocessorDirectives(input, expectedOutput); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void TrimPreprocessorDirectives5() |
|
||||||
{ |
|
||||||
string input = "Dim a = 12.0# "; |
|
||||||
string expectedOutput = "Dim a = 12.0# "; |
|
||||||
|
|
||||||
TestTrimPreprocessorDirectives(input, expectedOutput); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void TrimPreprocessorDirectives6() |
|
||||||
{ |
|
||||||
string input = " #10/10/2010# "; |
|
||||||
string expectedOutput = " #10/10/2010# "; |
|
||||||
|
|
||||||
TestTrimPreprocessorDirectives(input, expectedOutput); |
|
||||||
} |
|
||||||
|
|
||||||
void TestTrimPreprocessorDirectives(string input, string expectedOutput) |
|
||||||
{ |
|
||||||
string output = LanguageUtils.TrimPreprocessorDirectives(input); |
|
||||||
Assert.AreEqual(expectedOutput, output); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,97 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Diagnostics; |
|
||||||
using System.Linq; |
|
||||||
using ICSharpCode.AvalonEdit; |
|
||||||
using ICSharpCode.AvalonEdit.Highlighting; |
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.SharpDevelop; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.SharpDevelop.Editor; |
|
||||||
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; |
|
||||||
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding.Tests |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Text editor for unit tests.
|
|
||||||
/// Because the tested code completion has complex requirements for the ITextEditor
|
|
||||||
/// implementation, we use a real AvalonEdit instead of mocking everything.
|
|
||||||
/// However, we override UI-displaying
|
|
||||||
/// </summary>
|
|
||||||
public class MockTextEditor : AvalonEditTextEditorAdapter |
|
||||||
{ |
|
||||||
DefaultProjectContent pc; |
|
||||||
|
|
||||||
public MockTextEditor() |
|
||||||
: base(new TextEditor()) |
|
||||||
{ |
|
||||||
PropertyService.InitializeServiceForUnitTests(); |
|
||||||
pc = new DefaultProjectContent(); |
|
||||||
pc.Language = LanguageProperties.VBNet; |
|
||||||
pc.ReferencedContents.Add(AssemblyParserService.DefaultProjectContentRegistry.Mscorlib); |
|
||||||
|
|
||||||
Dictionary<string, string> referencedAssemblies = new Dictionary<string, string>() { |
|
||||||
{ "System", typeof(Uri).Module.FullyQualifiedName }, |
|
||||||
{ "System.Core", typeof(Enumerable).Module.FullyQualifiedName }, |
|
||||||
{ "Microsoft.VisualBasic", typeof(Microsoft.VisualBasic.Constants).Module.FullyQualifiedName } |
|
||||||
}; |
|
||||||
foreach (var assembly in referencedAssemblies) { |
|
||||||
IProjectContent referenceProjectContent = AssemblyParserService.DefaultProjectContentRegistry.GetProjectContentForReference(assembly.Key, assembly.Value ?? assembly.Key); |
|
||||||
if (referenceProjectContent == null) |
|
||||||
throw new Exception("Error loading " + assembly.Key); |
|
||||||
pc.ReferencedContents.Add(referenceProjectContent); |
|
||||||
if (referenceProjectContent is ReflectionProjectContent) { |
|
||||||
(referenceProjectContent as ReflectionProjectContent).InitializeReferences(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// this.TextEditor.TextArea.TextView.Services.AddService(typeof(ISyntaxHighlighter), new AvalonEditSyntaxHighlighterAdapter(this.TextEditor));
|
|
||||||
this.TextEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("VBNet"); |
|
||||||
|
|
||||||
new VBNetLanguageBinding().Attach(this); |
|
||||||
} |
|
||||||
|
|
||||||
public override FileName FileName { |
|
||||||
get { return new FileName("mockFileName.vb"); } |
|
||||||
} |
|
||||||
|
|
||||||
public void CreateParseInformation() |
|
||||||
{ |
|
||||||
ParserService.RegisterAvailableParsers(new ParserDescriptor(typeof(TParser), "VBNet", new string[] { ".vb" })); |
|
||||||
var parser = new VBNetBinding.TParser(); |
|
||||||
parser.LexerTags = new string[0]; |
|
||||||
var cu = parser.Parse(pc, this.FileName, this.Document); |
|
||||||
ParserService.RegisterParseInformation(this.FileName, cu); |
|
||||||
pc.UpdateCompilationUnit(null, cu, this.FileName); |
|
||||||
} |
|
||||||
|
|
||||||
ICompletionItemList lastCompletionItemList; |
|
||||||
|
|
||||||
public ICompletionItemList LastCompletionItemList { |
|
||||||
get { return lastCompletionItemList; } |
|
||||||
} |
|
||||||
|
|
||||||
public override ICompletionListWindow ShowCompletionWindow(ICompletionItemList data) |
|
||||||
{ |
|
||||||
this.lastCompletionItemList = data; |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
IEnumerable<IInsightItem> lastInsightItems; |
|
||||||
|
|
||||||
public IEnumerable<IInsightItem> LastInsightItems { |
|
||||||
get { return lastInsightItems; } |
|
||||||
} |
|
||||||
|
|
||||||
public override IInsightWindow ShowInsightWindow(IEnumerable<IInsightItem> items) |
|
||||||
{ |
|
||||||
this.lastInsightItems = items; |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,90 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; |
|
||||||
using System; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using NUnit.Framework; |
|
||||||
|
|
||||||
namespace ICSharpCode.VBNetBinding.Tests |
|
||||||
{ |
|
||||||
public class TextEditorBasedTests |
|
||||||
{ |
|
||||||
protected MockTextEditor textEditor; |
|
||||||
|
|
||||||
[SetUp] |
|
||||||
public void SetupTest() |
|
||||||
{ |
|
||||||
this.textEditor = new MockTextEditor(); |
|
||||||
} |
|
||||||
|
|
||||||
protected void TestCtrlSpace(string file, bool expected, Action<ICompletionItemList> constraint) |
|
||||||
{ |
|
||||||
int insertionPoint = file.IndexOf('|'); |
|
||||||
|
|
||||||
if (insertionPoint < 0) |
|
||||||
Assert.Fail("insertionPoint not found in text!"); |
|
||||||
|
|
||||||
this.textEditor.Document.Text = file.Replace("|", ""); |
|
||||||
this.textEditor.Caret.Offset = insertionPoint; |
|
||||||
this.textEditor.CreateParseInformation(); |
|
||||||
|
|
||||||
bool invoked = new VBNetCompletionBinding().CtrlSpace(textEditor); |
|
||||||
|
|
||||||
Assert.AreEqual(expected, invoked); |
|
||||||
|
|
||||||
ICompletionItemList list = this.textEditor.LastCompletionItemList; |
|
||||||
|
|
||||||
constraint(list); |
|
||||||
} |
|
||||||
|
|
||||||
protected void TestKeyPress(string file, char keyPressed, CodeCompletionKeyPressResult keyPressResult, Action<ICompletionItemList> constraint) |
|
||||||
{ |
|
||||||
int insertionPoint = file.IndexOf('|'); |
|
||||||
|
|
||||||
if (insertionPoint < 0) |
|
||||||
Assert.Fail("insertionPoint not found in text!"); |
|
||||||
|
|
||||||
this.textEditor.Document.Text = file.Replace("|", ""); |
|
||||||
this.textEditor.Caret.Offset = insertionPoint; |
|
||||||
this.textEditor.CreateParseInformation(); |
|
||||||
|
|
||||||
CodeCompletionKeyPressResult result = new VBNetCompletionBinding().HandleKeyPress(textEditor, keyPressed); |
|
||||||
|
|
||||||
Assert.AreEqual(keyPressResult, result); |
|
||||||
|
|
||||||
ICompletionItemList list = this.textEditor.LastCompletionItemList; |
|
||||||
|
|
||||||
constraint(list); |
|
||||||
} |
|
||||||
|
|
||||||
protected void TestTextInsert(string file, char completionChar, ICompletionItemList list, ICompletionItem item, string expectedOutput, int expectedOffset) |
|
||||||
{ |
|
||||||
int insertionPoint = file.IndexOf('|'); |
|
||||||
|
|
||||||
if (insertionPoint < 0) |
|
||||||
Assert.Fail("insertionPoint not found in text!"); |
|
||||||
|
|
||||||
this.textEditor.Document.Text = file.Replace("|", ""); |
|
||||||
this.textEditor.Caret.Offset = insertionPoint; |
|
||||||
this.textEditor.CreateParseInformation(); |
|
||||||
|
|
||||||
CompletionContext context = new CompletionContext() { |
|
||||||
Editor = this.textEditor, |
|
||||||
CompletionChar = completionChar, |
|
||||||
StartOffset = textEditor.Caret.Offset, |
|
||||||
EndOffset = textEditor.Caret.Offset |
|
||||||
}; |
|
||||||
|
|
||||||
list.Complete(context, item); |
|
||||||
|
|
||||||
if (!context.CompletionCharHandled && context.CompletionChar != '\n') |
|
||||||
this.textEditor.Document.Insert(this.textEditor.Caret.Offset, completionChar + ""); |
|
||||||
|
|
||||||
string insertedText = this.textEditor.Document.GetText(insertionPoint, this.textEditor.Document.TextLength - file.Length + 1); |
|
||||||
|
|
||||||
Assert.AreEqual(expectedOutput, insertedText); |
|
||||||
Assert.AreEqual(insertionPoint + expectedOffset, textEditor.Caret.Offset); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,96 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> |
|
||||||
<PropertyGroup> |
|
||||||
<OutputType>Library</OutputType> |
|
||||||
<RootNamespace>ICSharpCode.VBNetBinding.Tests</RootNamespace> |
|
||||||
<AssemblyName>ICSharpCode.VBNetBinding.Tests</AssemblyName> |
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|
||||||
<ProjectGuid>{50A89267-A28B-4DF3-8E62-912E005143B8}</ProjectGuid> |
|
||||||
<OutputPath>..\..\..\..\..\bin\UnitTests\</OutputPath> |
|
||||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
|
||||||
<NoStdLib>False</NoStdLib> |
|
||||||
<RegisterForComInterop>False</RegisterForComInterop> |
|
||||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
|
||||||
<BaseAddress>4194304</BaseAddress> |
|
||||||
<PlatformTarget>x86</PlatformTarget> |
|
||||||
<FileAlignment>4096</FileAlignment> |
|
||||||
<WarningLevel>4</WarningLevel> |
|
||||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
|
||||||
<Optimize>False</Optimize> |
|
||||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
|
||||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|
||||||
<DebugSymbols>true</DebugSymbols> |
|
||||||
<DebugType>Full</DebugType> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
|
||||||
<DefineConstants>TRACE</DefineConstants> |
|
||||||
<DebugSymbols>False</DebugSymbols> |
|
||||||
<DebugType>None</DebugType> |
|
||||||
</PropertyGroup> |
|
||||||
<ItemGroup> |
|
||||||
<Reference Include="Microsoft.VisualBasic" /> |
|
||||||
<Reference Include="PresentationCore"> |
|
||||||
<RequiredTargetFramework>3.0</RequiredTargetFramework> |
|
||||||
</Reference> |
|
||||||
<Reference Include="PresentationFramework"> |
|
||||||
<RequiredTargetFramework>3.0</RequiredTargetFramework> |
|
||||||
</Reference> |
|
||||||
<Reference Include="System" /> |
|
||||||
<Reference Include="System.Core"> |
|
||||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
|
||||||
</Reference> |
|
||||||
<Reference Include="System.Data" /> |
|
||||||
<Reference Include="System.Xaml"> |
|
||||||
<RequiredTargetFramework>4.0</RequiredTargetFramework> |
|
||||||
</Reference> |
|
||||||
<Reference Include="System.Xml" /> |
|
||||||
<Reference Include="nunit.framework"> |
|
||||||
<HintPath>..\..\..\..\Tools\NUnit\nunit.framework.dll</HintPath> |
|
||||||
<SpecificVersion>False</SpecificVersion> |
|
||||||
</Reference> |
|
||||||
<Reference Include="WindowsBase"> |
|
||||||
<RequiredTargetFramework>3.0</RequiredTargetFramework> |
|
||||||
</Reference> |
|
||||||
</ItemGroup> |
|
||||||
<ItemGroup> |
|
||||||
<Compile Include="..\..\..\..\Main\GlobalAssemblyInfo.cs"> |
|
||||||
<Link>Configuration\GlobalAssemblyInfo.cs</Link> |
|
||||||
</Compile> |
|
||||||
<Compile Include="Configuration\AssemblyInfo.cs" /> |
|
||||||
<Compile Include="LanguageUtilsTests.cs" /> |
|
||||||
<Compile Include="MockTextEditor.cs" /> |
|
||||||
<Compile Include="TextEditorBasedTests.cs" /> |
|
||||||
<Folder Include="Configuration" /> |
|
||||||
<ProjectReference Include="..\..\..\..\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj"> |
|
||||||
<Project>{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}</Project> |
|
||||||
<Name>ICSharpCode.AvalonEdit</Name> |
|
||||||
</ProjectReference> |
|
||||||
<ProjectReference Include="..\..\..\..\Main\Core\Project\ICSharpCode.Core.csproj"> |
|
||||||
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project> |
|
||||||
<Name>ICSharpCode.Core</Name> |
|
||||||
</ProjectReference> |
|
||||||
<ProjectReference Include="..\Project\VBNetBinding.csproj"> |
|
||||||
<Project>{BF38FB72-B380-4196-AF8C-95749D726C61}</Project> |
|
||||||
<Name>VBNetBinding</Name> |
|
||||||
</ProjectReference> |
|
||||||
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> |
|
||||||
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> |
|
||||||
<Name>ICSharpCode.SharpDevelop</Name> |
|
||||||
</ProjectReference> |
|
||||||
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj"> |
|
||||||
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project> |
|
||||||
<Name>ICSharpCode.SharpDevelop.Dom</Name> |
|
||||||
</ProjectReference> |
|
||||||
<Folder Include="FormattingStrategy" /> |
|
||||||
<Compile Include="CodeCompletionTests.cs" /> |
|
||||||
<Compile Include="FormattingStrategy\EndOperatorTests.cs" /> |
|
||||||
<Compile Include="FormattingStrategy\EndSubTests.cs" /> |
|
||||||
<Compile Include="FormattingStrategy\IndentationTests.cs" /> |
|
||||||
<Compile Include="FormattingStrategy\InterfaceTests.cs" /> |
|
||||||
</ItemGroup> |
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
|
||||||
</Project> |
|
||||||
@ -1,54 +0,0 @@ |
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 10.00 |
|
||||||
# Visual Studio 2008 |
|
||||||
# SharpDevelop 3.0.0.2993 |
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VBNetBinding.Tests", "VBNetBinding.Tests.csproj", "{50A89267-A28B-4DF3-8E62-912E005143B8}" |
|
||||||
EndProject |
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VBNetBinding", "..\Project\VBNetBinding.csproj", "{BF38FB72-B380-4196-AF8C-95749D726C61}" |
|
||||||
EndProject |
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core", "..\..\..\..\Main\Core\Project\ICSharpCode.Core.csproj", "{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}" |
|
||||||
EndProject |
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop", "..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj", "{2748AD25-9C63-4E12-877B-4DCE96FBED54}" |
|
||||||
EndProject |
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Dom", "..\..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj", "{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}" |
|
||||||
EndProject |
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", "..\..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj", "{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}" |
|
||||||
EndProject |
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "..\..\..\..\Libraries\NRefactory\Project\NRefactory.csproj", "{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}" |
|
||||||
EndProject |
|
||||||
Global |
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|
||||||
Debug|Any CPU = Debug|Any CPU |
|
||||||
Release|Any CPU = Release|Any CPU |
|
||||||
EndGlobalSection |
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|
||||||
{50A89267-A28B-4DF3-8E62-912E005143B8}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
||||||
{50A89267-A28B-4DF3-8E62-912E005143B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
||||||
{50A89267-A28B-4DF3-8E62-912E005143B8}.Release|Any CPU.Build.0 = Release|Any CPU |
|
||||||
{50A89267-A28B-4DF3-8E62-912E005143B8}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
||||||
{BF38FB72-B380-4196-AF8C-95749D726C61}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
||||||
{BF38FB72-B380-4196-AF8C-95749D726C61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
||||||
{BF38FB72-B380-4196-AF8C-95749D726C61}.Release|Any CPU.Build.0 = Release|Any CPU |
|
||||||
{BF38FB72-B380-4196-AF8C-95749D726C61}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
||||||
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
||||||
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
||||||
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Release|Any CPU.Build.0 = Release|Any CPU |
|
||||||
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
||||||
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
||||||
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
||||||
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|Any CPU.Build.0 = Release|Any CPU |
|
||||||
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
||||||
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
||||||
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
||||||
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|Any CPU.Build.0 = Release|Any CPU |
|
||||||
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
||||||
{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
||||||
{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
||||||
{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Any CPU.Build.0 = Release|Any CPU |
|
||||||
{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
||||||
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
||||||
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
||||||
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.Build.0 = Release|Any CPU |
|
||||||
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
||||||
EndGlobalSection |
|
||||||
EndGlobal |
|
||||||
@ -0,0 +1,35 @@ |
|||||||
|
' Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) |
||||||
|
' This code is distributed under the GNU LGPL (for details please see \doc\license.txt) |
||||||
|
|
||||||
|
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' |
||||||
|
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' |
||||||
|
'' '' |
||||||
|
'' DO NOT EDIT GlobalAssemblyInfo.vb, it is recreated using AssemblyInfo.vb.template whenever '' |
||||||
|
'' ICSharpCode.Core is compiled. '' |
||||||
|
'' '' |
||||||
|
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' |
||||||
|
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' |
||||||
|
|
||||||
|
Imports System.Resources |
||||||
|
Imports System.Reflection |
||||||
|
|
||||||
|
<Assembly: System.Runtime.InteropServices.ComVisible(False)> |
||||||
|
<Assembly: AssemblyCompany("ic#code")> |
||||||
|
<Assembly: AssemblyProduct("SharpDevelop")> |
||||||
|
<Assembly: AssemblyCopyright("2000-$INSERTYEAR$ AlphaSierraPapa for the SharpDevelop Team")> |
||||||
|
<Assembly: AssemblyVersion(RevisionClass.Major + "." + RevisionClass.Minor + "." + RevisionClass.Build + "." + RevisionClass.Revision)> |
||||||
|
<Assembly: AssemblyInformationalVersion(RevisionClass.FullVersion + "-$INSERTSHORTCOMMITHASH$")> |
||||||
|
<Assembly: NeutralResourcesLanguage("en-US")> |
||||||
|
|
||||||
|
<Assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2243:AttributeStringLiteralsShouldParseCorrectly", Justification := "AssemblyInformationalVersion does not need to be a parsable version")> |
||||||
|
|
||||||
|
' DO NOT FORGET TO EDIT the GlobalAssemblyInfo.cs.template! |
||||||
|
Friend NotInheritable Class RevisionClass |
||||||
|
Public Const Major As String = "5" |
||||||
|
Public Const Minor As String = "0" |
||||||
|
Public Const Build As String = "0" |
||||||
|
Public Const Revision As String = "$INSERTREVISION$" |
||||||
|
Public Const VersionName As String = "alpha" ' "" is not valid for no version name, you have to use Nothing if you don't want a version name (eg "Beta 1") |
||||||
|
|
||||||
|
Public Const FullVersion As String = Major + "." + Minor + "." + Build + ".$INSERTREVISION$$INSERTBRANCHPOSTFIX$$INSERTVERSIONNAMEPOSTFIX$" |
||||||
|
End Class |
||||||
Loading…
Reference in new issue