diff options
author | Jose Miguel Torres <jostor@microsoft.com> | 2020-01-15 18:42:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-15 18:42:02 +0300 |
commit | 173d2294466251e76c910738060bd94692d75cfa (patch) | |
tree | 27d82247a81cd932ec468ecb6f9f3353ca36fa55 /main/src | |
parent | 967dbe01c855c59b5ad545966954210ececc12d2 (diff) | |
parent | 9d3876b19ac294d913958625fb964f2a0897a613 (diff) |
Merge pull request #9447 from mono/nrefactory-removal
Remove various references to NRefactory that are not used
Diffstat (limited to 'main/src')
25 files changed, 16 insertions, 820 deletions
diff --git a/main/src/addins/AspNet/MonoDevelop.AspNet.csproj b/main/src/addins/AspNet/MonoDevelop.AspNet.csproj index b9cb30001a..745f737986 100644 --- a/main/src/addins/AspNet/MonoDevelop.AspNet.csproj +++ b/main/src/addins/AspNet/MonoDevelop.AspNet.csproj @@ -72,11 +72,6 @@ <Name>MonoDevelop.Xml</Name> <Private>False</Private> </ProjectReference> - <ProjectReference Include="..\..\..\external\nrefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj"> - <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project> - <Name>ICSharpCode.NRefactory</Name> - <Private>False</Private> - </ProjectReference> </ItemGroup> <ItemGroup> <Reference Include="System" /> diff --git a/main/src/addins/AspNet/Tests/MonoDevelop.AspNet.Tests.csproj b/main/src/addins/AspNet/Tests/MonoDevelop.AspNet.Tests.csproj index caa9916dab..48f291c505 100644 --- a/main/src/addins/AspNet/Tests/MonoDevelop.AspNet.Tests.csproj +++ b/main/src/addins/AspNet/Tests/MonoDevelop.AspNet.Tests.csproj @@ -48,11 +48,6 @@ <Name>MonoDevelop.Ide</Name> <Private>False</Private> </ProjectReference> - <ProjectReference Include="..\..\..\..\external\nrefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj"> - <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project> - <Name>ICSharpCode.NRefactory</Name> - <Private>False</Private> - </ProjectReference> <ProjectReference Include="..\..\MonoDevelop.DesignerSupport\MonoDevelop.DesignerSupport.csproj"> <Project>{2C24D515-4A2C-445C-8419-C09231913CFA}</Project> <Name>MonoDevelop.DesignerSupport</Name> diff --git a/main/src/addins/CSharpBinding/AspNet/CSharpBinding.AspNet.csproj b/main/src/addins/CSharpBinding/AspNet/CSharpBinding.AspNet.csproj index ddeea9f747..c12fa966e8 100644 --- a/main/src/addins/CSharpBinding/AspNet/CSharpBinding.AspNet.csproj +++ b/main/src/addins/CSharpBinding/AspNet/CSharpBinding.AspNet.csproj @@ -51,16 +51,6 @@ <Name>MonoDevelop.Refactoring</Name> <Private>False</Private> </ProjectReference> - <ProjectReference Include="..\..\..\..\external\nrefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj"> - <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project> - <Name>ICSharpCode.NRefactory</Name> - <Private>False</Private> - </ProjectReference> - <ProjectReference Include="..\..\..\..\external\nrefactory\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj"> - <Project>{53DCA265-3C3C-42F9-B647-F72BA678122B}</Project> - <Name>ICSharpCode.NRefactory.CSharp</Name> - <Private>False</Private> - </ProjectReference> <ProjectReference Include="..\..\Deployment\MonoDevelop.Deployment\MonoDevelop.Deployment.csproj"> <Project>{9BC670A8-1851-40EC-9685-279F4C98433D}</Project> <Name>MonoDevelop.Deployment</Name> diff --git a/main/src/addins/CSharpBinding/CSharpBinding.addin.xml b/main/src/addins/CSharpBinding/CSharpBinding.addin.xml index dff822e330..5ce1d72d91 100644 --- a/main/src/addins/CSharpBinding/CSharpBinding.addin.xml +++ b/main/src/addins/CSharpBinding/CSharpBinding.addin.xml @@ -225,17 +225,6 @@ </Extension> <!-- - <Extension path = "/MonoDevelop/Refactoring/CodeActions"> - <Action mimeType="text/x-csharp" - _title = "Move type to another file" - _description = "Moves current type to another file that matches the name of the type." - class = "MonoDevelop.CSharp.Refactoring.CodeActions.MoveTypeToFile" /> - <Action mimeType="text/x-csharp" - _title = "Convert to enum" - _description = "Converts constant fields to enumeration" - class = "MonoDevelop.CSharp.Refactoring.CodeActions.ConvertToEnumAction" /> - </Extension> - <Extension path = "/MonoDevelop/Refactoring/CodeIssues"> <CodeIssue mimeType="text/x-csharp" severity = "Error" class="MonoDevelop.CSharp.Refactoring.CodeIssues.MonoTODOIssue"/> </Extension> --> diff --git a/main/src/addins/CSharpBinding/CSharpBinding.csproj b/main/src/addins/CSharpBinding/CSharpBinding.csproj index 479d10513f..c4fcfe8138 100644 --- a/main/src/addins/CSharpBinding/CSharpBinding.csproj +++ b/main/src/addins/CSharpBinding/CSharpBinding.csproj @@ -188,7 +188,6 @@ <Compile Include="MonoDevelop.CSharp.CodeRefactorings\PredefinedCodeRefactoringProviderNames.cs" /> <Compile Include="MonoDevelop.CSharp.Diagnostics\IDEDiagnosticIds.cs" /> <Compile Include="MonoDevelop.CSharp.Diagnostics\MonoTODO\MonoTODODiagnosticAnalyzer.cs" /> - <Compile Include="MonoDevelop.CSharp.CodeRefactorings\ConvertToEnum\ConvertToEnumDialog.cs" /> <Compile Include="MonoDevelop.CSharp.Refactoring\CSharpFeaturesTextEditorExtension.cs" /> <Compile Include="MonoDevelop.CSharp.Refactoring\RenameHandler.cs" /> <Compile Include="MonoDevelop.CSharp.Refactoring\FindReferencesHandler.cs" /> @@ -284,9 +283,6 @@ <Compile Include="MonoDevelop.CSharp.Debugger\CSharpBreakpointSpanResolver.cs" /> </ItemGroup> <ItemGroup> - <None Include="MonoDevelop.CSharp.CodeRefactorings\ConvertToEnum\ConvertToEnumCodeRefactoringProvider.cs" /> - </ItemGroup> - <ItemGroup> <InternalsVisibleTo Include="MonoDevelop.Ide.Tests" /> <InternalsVisibleTo Include="MonoDevelop.CSharpBinding.AspNet" /> <InternalsVisibleTo Include="MonoDevelop.CSharpBinding.Tests" /> diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/ConvertToEnum/ConvertToEnumCodeRefactoringProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/ConvertToEnum/ConvertToEnumCodeRefactoringProvider.cs deleted file mode 100644 index 03a55232b1..0000000000 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/ConvertToEnum/ConvertToEnumCodeRefactoringProvider.cs +++ /dev/null @@ -1,504 +0,0 @@ -// -// Author: -// Luís Reis <luiscubal@gmail.com> -// -// Copyright (c) 2013 Luís Reis -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -using System; -using System.Collections.Generic; -using System.Linq; -using ICSharpCode.NRefactory.Semantics; -using ICSharpCode.NRefactory.TypeSystem; -using ICSharpCode.NRefactory.TypeSystem.Implementation; -using ICSharpCode.NRefactory.PatternMatching; -using MonoDevelop.CodeActions; -using ICSharpCode.NRefactory; -using System.Threading; -using ICSharpCode.NRefactory.CSharp; -using ICSharpCode.NRefactory.CSharp.Refactoring; -using ICSharpCode.Decompiler.ILAst; -using MonoDevelop.Core; -using MonoDevelop.Ide.Editor; - -namespace MonoDevelop.CSharp.Refactoring.CodeActions -{ - /// <summary> - /// Generates an enumeration from const fields - /// </summary> - class ConvertToEnumAction : MonoDevelop.CodeActions.CodeActionProvider - { - public override IEnumerable<MonoDevelop.CodeActions.CodeAction> GetActions (TextEditor editor, DocumentContext doc, object refactoringContext, MonoDevelop.Ide.Editor.DocumentLocation loc, CancellationToken cancellationToken) - { - var mdCtx = refactoringContext as MDRefactoringContext; - - if (mdCtx == null || mdCtx.IsInvalid) - yield break; - - VariableInitializer currentVariable = mdCtx.GetNode<VariableInitializer>(); - if (currentVariable == null) { - yield break; - } - - FieldDeclaration currentField = currentVariable.Parent as FieldDeclaration; - if (currentField == null) { - yield break; - } - - if (!currentField.Modifiers.HasFlag(Modifiers.Const)) { - yield break; - } - - PrimitiveType baseType = TypeToIntegerPrimitive(mdCtx, currentField.ReturnType); - if (baseType == null) { - //Can't make enums of these types - yield break; - } - - TypeDeclaration containerType = currentVariable.GetParent<TypeDeclaration>(); - - //Get all the fields/variables that the enum can possibly cover - //Don't check the name just yet. That'll come later. - - var constFields = containerType.Members.OfType<FieldDeclaration>() - .Where(field => field.GetParent<TypeDeclaration>() == containerType && field.HasModifier(Modifiers.Const)).ToList(); - - var constVariables = constFields.SelectMany(field => field.Variables).ToList(); - - //Now, it's time to check the name of the selected variable - //We'll use this to search for prefixes later - - var names = constVariables.Select(variable => variable.Name).ToList(); - string currentName = currentVariable.Name; - - //Now, find the common name prefixes - //If the variable is called 'A_B_C_D', then 'A', 'A_B' and 'A_B_C' are - //the potentially available prefixes. - //Note that the common prefixes are the ones that more than one variable - //has. - //Each prefix has an associated action. - - foreach (var prefix in GetCommonPrefixes (currentName, names)) { - string title = string.Format(GettextCatalog.GetString("Create enum '{0}'"), prefix); - - yield return new DefaultCodeAction(title, (ctx, script) => { - PrepareToRunAction (prefix, baseType, containerType, constVariables, cancellationToken, ctx, script); - }); - } - } - - void PrepareToRunAction (string prefix, PrimitiveType baseType, TypeDeclaration containerType, List<VariableInitializer> variables, CancellationToken cancellationToken, RefactoringContext context, Script script) - { - List<string> names = variables.Select(variable => variable.Name).ToList(); - Dictionary<string, string> newNames = names.ToDictionary(originalName => originalName, originalName => { - if (!originalName.StartsWith(prefix)) { - return originalName; - } - int startName = prefix.Length; - while (startName < originalName.Length - 1 && originalName[startName] == '_') { - ++startName; - } - return originalName.Substring(startName); - }); - - string enumName; - using (var dialog = new ConvertToEnumDialog (prefix, variables, variables.Where(variable => variable.Name.StartsWith(prefix, StringComparison.InvariantCulture) - && VariableHasSpecifiedIntegerType(context, variable, baseType)).ToList(), newNames)) - { - if (dialog.Run (/*MonoDevelop.Ide.IdeApp.Workbench.RootWindow*/) != Xwt.Command.Ok) { - return; - } - enumName = dialog.EnumName; - variables = dialog.SelectedVariables; - newNames = dialog.NewNames; - } - - RunAction (context, baseType, enumName, newNames, containerType, variables, script); - - } - - void RunAction(RefactoringContext context, AstType baseType, string enumName, Dictionary<string, string> newNames, TypeDeclaration containerTypeDeclaration, List<VariableInitializer> variables, Script script) - { - var names = variables.Select (variable => variable.Name).ToList (); - var containerType = (context.Resolve(containerTypeDeclaration) as TypeResolveResult).Type; - - var fields = containerTypeDeclaration.Members.OfType<FieldDeclaration>().Where(field => field.Modifiers.HasFlag(Modifiers.Const)).ToList(); - List<VariableInitializer> variableUnitsToRemove = new List<VariableInitializer>(variables); - List<FieldDeclaration> fieldsToRemove = new List<FieldDeclaration>(); - - foreach (var field in fields) { - if (field.Variables.All(variableUnitsToRemove.Contains)) { - fieldsToRemove.Add(field); - - variableUnitsToRemove.RemoveAll(field.Variables.Contains); - } - } - - var generatedEnum = CreateEnumDeclaration(baseType, enumName, variables, names, newNames); - - AstNode root = GetRootNodeOf(containerTypeDeclaration); - var newRoot = root.Clone(); - - FixIdentifiers(context, enumName, variables, containerType, baseType, names, newNames, root, newRoot); - foreach (var member in root.Descendants.OfType<MemberReferenceExpression>().Where (member => names.Contains (member.MemberName))) { - if (variables.Any(variable => variable.Descendants.Contains(member))) { - //Already handled - continue; - } - - var resolvedIdentifier = context.Resolve(member) as MemberResolveResult; - if (resolvedIdentifier == null) { - continue; - } - - if (resolvedIdentifier.Type.Equals(containerType)) { - continue; - } - - var equivalentMember = GetEquivalentNodeFor(root, newRoot, member); - MemberReferenceExpression memberToReplace = (MemberReferenceExpression)equivalentMember; - - var replacement = CreateReplacementMemberReference(enumName, baseType, newNames, memberToReplace); - memberToReplace.ReplaceWith(replacement); - } - - //Fix the file - InsertAfterEquivalent(root, newRoot, containerTypeDeclaration.LBraceToken, generatedEnum, Roles.TypeMemberRole); - - foreach (var variableToRemove in variableUnitsToRemove) { - GetEquivalentNodeFor(root, newRoot, variableToRemove).Remove(); - } - foreach (var fieldToRemove in fieldsToRemove) { - GetEquivalentNodeFor(root, newRoot, fieldToRemove).Remove(); - } - - script.Replace(root, newRoot); - - ReplaceVariableReferences(context, root, baseType, enumName, script, newNames, variables); - } - - static void ReplaceVariableReferences(RefactoringContext context, AstNode root, AstType baseType, string enumName, Script script, Dictionary<string, string> newNames, IEnumerable<VariableInitializer> variables) - { - var resolveResults = variables.Select(context.Resolve).Cast<MemberResolveResult> (); - var resolvedFields = resolveResults.Select(resolveResult => resolveResult.Member); - script.DoGlobalOperationOn(resolvedFields, (newCtx, newScript, foundNodes) => { - foreach (var foundNode in foundNodes) { - TypeDeclaration newContainerType = foundNode.GetParent<TypeDeclaration>(); - if (root.Descendants.OfType<TypeDeclaration>().Select(type => ((TypeResolveResult)context.Resolve(type)).Type.FullName).ToList().Contains(((TypeResolveResult)newCtx.Resolve(newContainerType)).Type.FullName)) { - //This file has already been fixed - return; - } - var identifierExpr = foundNode as IdentifierExpression; - if (identifierExpr != null) { - newScript.Replace(identifierExpr, CreateIdentifierReplacement(enumName, baseType, newNames, identifierExpr)); - continue; - } - var memberRef = foundNode as MemberReferenceExpression; - if (memberRef != null) { - var replacement = CreateReplacementMemberReference(enumName, baseType, newNames, memberRef); - newScript.Replace(memberRef, replacement); - } - } - }); - } - - TypeDeclaration CreateEnumDeclaration(AstType baseType, string enumName, List<VariableInitializer> variables, List<string> names, Dictionary<string, string> newNames) - { - TypeDeclaration generatedEnum = new TypeDeclaration(); - generatedEnum.ClassType = ClassType.Enum; - generatedEnum.BaseTypes.Add(baseType.Clone()); - generatedEnum.Name = enumName; - generatedEnum.Modifiers = GetCombinedModifier((Modifiers)variables.Select(variable => ((FieldDeclaration)variable.Parent).Modifiers).Aggregate(0, (prev, newModifier) => prev | (int)newModifier)); - foreach (var variable in variables) { - var generatedMember = new EnumMemberDeclaration(); - generatedMember.Name = newNames[variable.Name]; - var value = variable.Initializer.Clone(); - foreach (var identifier in value.DescendantsAndSelf.OfType<IdentifierExpression>().Where(identifier => names.Contains(identifier.Identifier))) { - var newIdentifier = new IdentifierExpression(newNames[identifier.Identifier]); - if (identifier == value) { - value = newIdentifier; - break; - } - identifier.ReplaceWith(newIdentifier); - } - generatedMember.Initializer = value; - generatedEnum.Members.Add(generatedMember); - } - return generatedEnum; - } - - /// <summary> - /// Determines whether the initialized variable has the specified primitive integer type - /// </summary> - /// <returns><c>true</c> if the initialized variable has the specified type; otherwise, <c>false</c>.</returns> - /// <param name="context">The context to use.</param> - /// <param name="variable">The variable initializer to check.</param> - /// <param name="type">The type to compare with.</param> - bool VariableHasSpecifiedIntegerType(RefactoringContext context, VariableInitializer variable, AstType type) - { - return TypeToIntegerPrimitive(context, variable.GetParent<FieldDeclaration>().ReturnType).Match(type).Success; - } - - static Dictionary<string, PrimitiveType> primitiveTypes = new Dictionary<string, PrimitiveType>(); - - static ConvertToEnumAction() - { - primitiveTypes.Add(typeof(byte).FullName, new PrimitiveType("byte")); - primitiveTypes.Add(typeof(sbyte).FullName, new PrimitiveType("sbyte")); - - primitiveTypes.Add(typeof(short).FullName, new PrimitiveType("short")); - primitiveTypes.Add(typeof(int).FullName, new PrimitiveType("int")); - primitiveTypes.Add(typeof(long).FullName, new PrimitiveType("long")); - - primitiveTypes.Add(typeof(ushort).FullName, new PrimitiveType("ushort")); - primitiveTypes.Add(typeof(uint).FullName, new PrimitiveType("uint")); - primitiveTypes.Add(typeof(ulong).FullName, new PrimitiveType("ulong")); - } - - /// <summary> - /// Gets a PrimitiveType instance from an AstType. - /// Only returns integer types (and never the char type) - /// </summary> - /// <returns>The integer primitive.</returns> - /// <param name="context">The context to use.</param> - /// <param name="type">The AstType to get the primitive from.</param> - PrimitiveType TypeToIntegerPrimitive(RefactoringContext context, AstType type) - { - var resolvedType = context.ResolveType(type) as DefaultResolvedTypeDefinition; - - PrimitiveType primitiveType; - if (!primitiveTypes.TryGetValue(resolvedType.FullName, out primitiveType)) { - return null; - } - - return primitiveType; - } - - static Expression CreateReplacementMemberReference(string enumName, AstType baseType, Dictionary<string, string> newNames, MemberReferenceExpression memberToReplace) - { - return new ParenthesizedExpression(new CastExpression(baseType.Clone(), new MemberReferenceExpression(new MemberReferenceExpression(memberToReplace.Target.Clone(), enumName), newNames [memberToReplace.MemberName]))); - } - - void FixIdentifiers(RefactoringContext context, string enumName, List<VariableInitializer> variables, IType containerType, AstType baseType, List<string> names, Dictionary<string, string> newNames, AstNode root, AstNode newRoot) - { - foreach (var identifier in root.Descendants.OfType<IdentifierExpression> ().Where (identifier => names.Contains (identifier.Identifier))) { - if (variables.Any(variable => variable.Descendants.Contains(identifier))) { - //Already handled - continue; - } - var resolvedIdentifier = context.Resolve(identifier) as MemberResolveResult; - if (resolvedIdentifier == null) { - continue; - } - if (resolvedIdentifier.Type.Equals(containerType)) { - continue; - } - var replacement = CreateIdentifierReplacement(enumName, baseType, newNames, identifier); - GetEquivalentNodeFor(root, newRoot, identifier).ReplaceWith(replacement); - } - } - - static ParenthesizedExpression CreateIdentifierReplacement(string enumName, AstType baseType, Dictionary<string, string> newNames, IdentifierExpression identifier) - { - var replacement = new ParenthesizedExpression(new CastExpression(baseType.Clone(), new MemberReferenceExpression(new IdentifierExpression(enumName), newNames [identifier.Identifier]))); - return replacement; - } - - /// <summary> - /// Finds the corresponding node in another ("new") AST. - /// Assumes entities have not been renamed and no statements have been removed. - /// </summary> - /// <returns>The equivalent node in the new AST.</returns> - /// <param name="root">The root of the first ("old") AST.</param> - /// <param name="newRoot">The root of the new AST.</param> - /// <param name="nodeToFind">Node (from the old AST) to find in the new one.</param> - AstNode GetEquivalentNodeFor(AstNode root, AstNode newRoot, AstNode nodeToFind) - { - if (nodeToFind == null) { - throw new ArgumentNullException("nodeToFind"); - } - - if (nodeToFind.Parent != root) { - AstNode foundRoot = GetEquivalentNodeFor(root, newRoot, nodeToFind.Parent); - if (foundRoot == null) { - //If the equivalent of the parent does not exist in the new AST, - //then neither does this node. - return null; - } - newRoot = foundRoot; - root = nodeToFind.Parent; - } - - //At this point, the roots are the parents of the nodes to check - //root is the parent of the nodeToFind, and newRoot is the parent of the node to return - - var block = root as BlockStatement; - if (block != null && nodeToFind.Role == BlockStatement.StatementRole) { - //This could be a problem if statements were removed in the new AST, - //but fortunately that's not the problem we're trying to solve. - return ((BlockStatement)newRoot).Statements.ElementAt(block.TakeWhile(statement => statement != nodeToFind).Count()); - } - - //First, we'll narrow down the search - the equivalent node *always* has the same type and role as nodeToFind - //The Role check will help e.g. in binary expressions (where there is a 'Left' and a 'Right' role) - var candidates = newRoot.Children.Where(child => child.GetType() == nodeToFind.GetType() && child.Role == nodeToFind.Role); - var entity = nodeToFind as EntityDeclaration; - if (entity != null) { - var field = nodeToFind as FieldDeclaration; - if (field != null) { - //Fields have to be treated separately because fields have no names - candidates = candidates.Where(candidate => IsEquivalentField((FieldDeclaration) candidate, field)); - } - else { - //Some entities can be distinguished by name. - candidates = candidates.Where(candidate => ((EntityDeclaration)candidate).Name == entity.Name); - - var method = nodeToFind as MethodDeclaration; - if (method != null) { - //Methods, however, can be overloaded - so their names aren't enough. - candidates = candidates.Where(candidate => CheckIfMethodsHaveSameParameters((MethodDeclaration) candidate, method)); - } - } - } - - var ns = nodeToFind as NamespaceDeclaration; - if (ns != null) { - candidates = candidates.Where(candidate => ((NamespaceDeclaration)candidate).Name == ns.Name).ToList(); - if (candidates.Count() > 1) { - throw new NotImplementedException("Two or more namespace declarations with the same name are siblings. This case is not currently supported by this action."); - } - } - - var initializer = nodeToFind as VariableInitializer; - if (initializer != null) { - candidates = candidates.Where(candidate => ((VariableInitializer)candidate).Name == initializer.Name); - } - - var equivalentNode = candidates.SingleOrDefault(); - return equivalentNode; - } - - bool IsEquivalentField(FieldDeclaration field1, FieldDeclaration field2) { - return field1.Variables.Any(variable1 => { - return field2.Variables.Any(variable2 => variable1.Name == variable2.Name); - }); - } - - bool CheckIfMethodsHaveSameParameters(MethodDeclaration methodDeclaration, MethodDeclaration comparedMethod) - { - if (methodDeclaration.Parameters.Count != comparedMethod.Parameters.Count) { - return false; - } - - ParameterDeclaration param1 = methodDeclaration.Parameters.FirstOrDefault(); - ParameterDeclaration param2 = comparedMethod.Parameters.FirstOrDefault(); - - while (param1 != null) { - //If the names or initializers are different, this will still match. - //But if the type or order changes, this will complain - if (!param1.Type.Match(param2.Type).Success) { - return false; - } - - param1 = (ParameterDeclaration) param1.GetNextSibling(node => node is ParameterDeclaration); - param2 = (ParameterDeclaration) param2.GetNextSibling(node => node is ParameterDeclaration); - } - - return true; - } - - void InsertAfterEquivalent<T>(AstNode root, AstNode newRoot, AstNode prevNode, T newNode, Role<T> role) - where T : AstNode - { - AstNode equivalentPrevNode = GetEquivalentNodeFor(root, newRoot, prevNode); - equivalentPrevNode.Parent.InsertChildAfter<T>(equivalentPrevNode, newNode, role); - } - - /// <summary> - /// Gets the least permissive access modifier that still allows access to - /// fields or methods with the specified modifiers. - /// This will ignore all modifiers unrelated to access - such as const and readonly - /// </summary> - /// <returns>A modifier that is at least as permissive as all provided modifiers.</returns> - /// <param name="modifiers">The modifiers to use.</param> - Modifiers GetCombinedModifier(Modifiers modifiers) - { - if (modifiers.HasFlag(Modifiers.Public)) - return Modifiers.Public; - - Modifiers combinedModifier = 0; - if (modifiers.HasFlag(Modifiers.Protected)) { - combinedModifier |= Modifiers.Protected; - } - if (modifiers.HasFlag(Modifiers.Internal)) { - combinedModifier |= Modifiers.Internal; - } - - //No modifier if the fields are all private. - return combinedModifier; - } - - /// <summary> - /// Gets all prefixes that more than one name have. - /// </summary> - /// <returns>The common prefixes.</returns> - /// <param name="currentName">The name to use.</param> - /// <param name="names">The names to check.</param> - IEnumerable<string> GetCommonPrefixes(string currentName, IEnumerable<string> names) - { - //Find the indexes that 'split' words in the variable name - var boundariesForCurrentWord = GetWordsBoundaries(currentName); - - //Get the candidate prefixes - List<string> proposedPrefixes = boundariesForCurrentWord.Select(boundary => currentName.Substring(0, boundary)).ToList(); - - //Return only the prefixes that more than one variable has. - return proposedPrefixes.Where(prefix => names.Count(name => name.StartsWith(prefix, StringComparison.InvariantCulture)) > 1); - } - - List<int> GetWordsBoundaries(string name) - { - List<int> foundBoundaries = new List<int>(); - for (int i = 1; i < name.Length - 1; ++i) { - char chr = name [i]; - if (chr == '_') { - foundBoundaries.Add(i); - continue; - } - - if (char.IsUpper(chr) && char.IsLower(name [i - 1])) { - foundBoundaries.Add(i); - continue; - } - } - - return foundBoundaries; - } - - AstNode GetRootNodeOf(AstNode node) - { - while (node.Parent != null) { - node = node.Parent; - } - - return node; - } - } -} - diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/ConvertToEnum/ConvertToEnumDialog.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/ConvertToEnum/ConvertToEnumDialog.cs deleted file mode 100644 index cfb078973a..0000000000 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/ConvertToEnum/ConvertToEnumDialog.cs +++ /dev/null @@ -1,122 +0,0 @@ -// -// ConvertToEnumDialog.cs -// -// Author: -// Luís Reis <luiscubal@gmail.com> -// -// Copyright (c) 2013 Luís Reis -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -using System; -using System.Linq; -using MonoDevelop.Core; -using System.Collections.Generic; -using ICSharpCode.NRefactory.CSharp; - -namespace MonoDevelop.CSharp.Refactoring.CodeActions -{ - class ConvertToEnumDialog : Xwt.Dialog - { - Xwt.TextEntry enumNameEntry; - Xwt.ListView variableList; - Xwt.ListStore variableStore; - Xwt.DataField<bool> enabledField; - Xwt.ListViewColumn enabledColumn; - Xwt.DataField<string> oldNameField; - Xwt.ListViewColumn oldNameColumn; - Xwt.DataField<string> newNameField; - Xwt.ListViewColumn newNameColumn; - List<VariableInitializer> variables; - - public ConvertToEnumDialog(string proposedEnumName, List<VariableInitializer> variables, List<VariableInitializer> defaultActiveVariables, Dictionary<string, string> newNames) { - this.variables = variables; - - Title = GettextCatalog.GetString("Convert fields to enumeration"); - - Xwt.VBox vbox = new Xwt.VBox (); - - vbox.PackStart(new Xwt.Label(GettextCatalog.GetString("Name of enum"))); - - enumNameEntry = new Xwt.TextEntry (); - enumNameEntry.Text = proposedEnumName; - vbox.PackStart (enumNameEntry); - - vbox.PackStart (new Xwt.Label (GettextCatalog.GetString ("Variables to include"))); - - variableList = new Xwt.ListView (); - enabledField = new Xwt.DataField<bool> (); - oldNameField = new Xwt.DataField<string> (); - newNameField = new Xwt.DataField<string> (); - - variableStore = new Xwt.ListStore (enabledField, oldNameField, newNameField); - variableList.DataSource = variableStore; - - enabledColumn = new Xwt.ListViewColumn (GettextCatalog.GetString ("Included"), new Xwt.CheckBoxCellView(enabledField) { Editable = true }); - variableList.Columns.Add (enabledColumn); - oldNameColumn = new Xwt.ListViewColumn(GettextCatalog.GetString("Field name"), new Xwt.TextCellView(oldNameField) { Editable = false }); - variableList.Columns.Add (oldNameColumn); - newNameColumn = new Xwt.ListViewColumn(GettextCatalog.GetString("Enum name"), new Xwt.TextCellView(newNameField) { Editable = true, }); - variableList.Columns.Add (newNameColumn); - - for (int i = 0; i < variables.Count; ++i) { - var variable = variables[i]; - - variableStore.AddRow (); - variableStore.SetValue (i, enabledField, defaultActiveVariables.Contains(variable)); - variableStore.SetValue (i, oldNameField, variable.Name); - - variableStore.SetValue (i, newNameField, newNames [variable.Name]); - } - - vbox.PackStart (variableList, true, true); - - vbox.PackStart (new Xwt.Label (GettextCatalog.GetString ("Warning: This may take a while..."))); - - Content = vbox; - - Buttons.Add (new Xwt.DialogButton (Xwt.Command.Ok)); - Buttons.Add (new Xwt.DialogButton (Xwt.Command.Cancel)); - } - - public string EnumName { - get { return enumNameEntry.Text; } - } - - public List<VariableInitializer> SelectedVariables - { - get { - return variables.Where((variable, idx) => variableStore.GetValue<bool>(idx, enabledField)).ToList(); - } - } - - public Dictionary<string, string> NewNames - { - get { - var newNames = new Dictionary<string, string> (); - - for (int i = 0; i < variableStore.RowCount; ++i) { - newNames[variableStore.GetValue<string>(i, oldNameField)] = variableStore.GetValue<string>(i, newNameField); - } - - return newNames; - } - } - } -} - diff --git a/main/src/addins/ChangeLogAddIn/ChangeLogAddIn.csproj b/main/src/addins/ChangeLogAddIn/ChangeLogAddIn.csproj index da22a433ef..b1dfbffbf8 100644 --- a/main/src/addins/ChangeLogAddIn/ChangeLogAddIn.csproj +++ b/main/src/addins/ChangeLogAddIn/ChangeLogAddIn.csproj @@ -26,11 +26,6 @@ <Name>MonoDevelop.VersionControl</Name> <Private>False</Private> </ProjectReference> - <ProjectReference Include="..\..\..\external\nrefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj"> - <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project> - <Name>ICSharpCode.NRefactory</Name> - <Private>False</Private> - </ProjectReference> <ProjectReference Include="..\MonoDevelop.Debugger\MonoDevelop.Debugger.csproj"> <Project>{2357AABD-08C7-4808-A495-8FF2D3CDFDB0}</Project> <Name>MonoDevelop.Debugger</Name> diff --git a/main/src/addins/MonoDevelop.ConnectedServices/MonoDevelop.ConnectedServices.csproj b/main/src/addins/MonoDevelop.ConnectedServices/MonoDevelop.ConnectedServices.csproj index fc08ed6b63..408fc35ff6 100644 --- a/main/src/addins/MonoDevelop.ConnectedServices/MonoDevelop.ConnectedServices.csproj +++ b/main/src/addins/MonoDevelop.ConnectedServices/MonoDevelop.ConnectedServices.csproj @@ -13,10 +13,6 @@ <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> - <Reference Include="ICSharpCode.NRefactory"> - <HintPath>..\..\..\build\bin\ICSharpCode.NRefactory.dll</HintPath> - <Private>False</Private> - </Reference> </ItemGroup> <ItemGroup> <ProjectReference Include="..\..\core\MonoDevelop.Core\MonoDevelop.Core.csproj"> diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.PerfTests/MonoDevelop.Debugger.PerfTests.csproj b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.PerfTests/MonoDevelop.Debugger.PerfTests.csproj index 0b2e7f18fa..b2110f98d2 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.PerfTests/MonoDevelop.Debugger.PerfTests.csproj +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.PerfTests/MonoDevelop.Debugger.PerfTests.csproj @@ -42,11 +42,6 @@ <PackageReference Include="NUnit" Version="$(NuGetVersionNUnit2)" /> </ItemGroup> <ItemGroup> - <ProjectReference Include="..\..\..\..\external\nrefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj"> - <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project> - <Name>ICSharpCode.NRefactory</Name> - <Private>False</Private> - </ProjectReference> <ProjectReference Include="..\..\..\..\external\mono-addins\Mono.Addins\Mono.Addins.csproj"> <Project>{91DD5A2D-9FE3-4C3C-9253-876141874DAD}</Project> <Name>Mono.Addins</Name> diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/MonoDevelop.Debugger.Tests.csproj b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/MonoDevelop.Debugger.Tests.csproj index 44807cad5e..342f0f39b5 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/MonoDevelop.Debugger.Tests.csproj +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/MonoDevelop.Debugger.Tests.csproj @@ -41,11 +41,6 @@ <Name>MonoDevelop.Ide</Name> <Private>False</Private> </ProjectReference> - <ProjectReference Include="..\..\..\..\external\nrefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj"> - <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project> - <Name>ICSharpCode.NRefactory</Name> - <Private>False</Private> - </ProjectReference> <ProjectReference Include="..\..\..\..\external\mono-addins\Mono.Addins\Mono.Addins.csproj"> <Project>{91DD5A2D-9FE3-4C3C-9253-876141874DAD}</Project> <Name>Mono.Addins</Name> diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.csproj b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.csproj index 67e4afd42e..716287531c 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.csproj +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.csproj @@ -46,11 +46,6 @@ <Name>MonoDevelop.Ide</Name> <Private>False</Private> </ProjectReference> - <ProjectReference Include="..\..\..\external\nrefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj"> - <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project> - <Name>ICSharpCode.NRefactory</Name> - <Private>False</Private> - </ProjectReference> <ProjectReference Include="..\..\..\external\mono-addins\Mono.Addins\Mono.Addins.csproj"> <Project>{91DD5A2D-9FE3-4C3C-9253-876141874DAD}</Project> <Name>Mono.Addins</Name> diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.csproj b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.csproj index 2e73602ef8..ed4cf412c1 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.csproj +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.csproj @@ -72,11 +72,6 @@ <Name>CSharpBinding</Name> <Private>False</Private> </ProjectReference> - <ProjectReference Include="..\..\..\external\nrefactory\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj"> - <Project>{53DCA265-3C3C-42F9-B647-F72BA678122B}</Project> - <Name>ICSharpCode.NRefactory.CSharp</Name> - <Private>False</Private> - </ProjectReference> </ItemGroup> <ItemGroup> <None Include="icons\window.png" /> diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj index bd9be153c4..6a83e95e4e 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj @@ -450,11 +450,6 @@ <Name>MonoDevelop.DesignerSupport</Name> <Private>False</Private> </ProjectReference> - <ProjectReference Include="..\..\..\external\nrefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj"> - <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project> - <Name>ICSharpCode.NRefactory</Name> - <Private>False</Private> - </ProjectReference> <ProjectReference Include="..\..\core\MonoDevelop.Ide\MonoDevelop.Ide.csproj"> <Project>{27096E7F-C91C-4AC6-B289-6897A701DF21}</Project> <Name>MonoDevelop.Ide</Name> diff --git a/main/src/addins/MonoDevelop.UnitTesting/AddinInfo.cs b/main/src/addins/MonoDevelop.UnitTesting/AddinInfo.cs index f873a69fa0..4bba15a67a 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/AddinInfo.cs +++ b/main/src/addins/MonoDevelop.UnitTesting/AddinInfo.cs @@ -6,6 +6,7 @@ using Mono.Addins.Description; [assembly:Addin ("UnitTesting", Namespace = "MonoDevelop", Version = MonoDevelop.BuildInfo.Version, + CompatVersion = "8.5", Category = "Testing")] [assembly:AddinName ("Unit Testing core support")] diff --git a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.csproj b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.csproj index 8d42275ca8..d768bb8c33 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.csproj +++ b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.csproj @@ -48,11 +48,6 @@ <Name>Xwt</Name> <Private>False</Private> </ProjectReference> - <ProjectReference Include="..\..\..\external\nrefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj"> - <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project> - <Name>ICSharpCode.NRefactory</Name> - <Private>False</Private> - </ProjectReference> <ProjectReference Include="..\MonoDevelop.DotNetCore\MonoDevelop.DotNetCore.csproj"> <Project>{6868153E-41EA-43A4-A81A-C1E7256373F7}</Project> <Name>MonoDevelop.DotNetCore</Name> diff --git a/main/src/addins/MonoDevelop.UnitTesting/Services/AbstractResultsStore.cs b/main/src/addins/MonoDevelop.UnitTesting/Services/AbstractResultsStore.cs index ba03343c15..43bba4ebe1 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/Services/AbstractResultsStore.cs +++ b/main/src/addins/MonoDevelop.UnitTesting/Services/AbstractResultsStore.cs @@ -401,37 +401,21 @@ namespace MonoDevelop.UnitTesting } [Serializable] - public class TestRecordCollection: CollectionBase + public class TestRecordCollection: List<TestRecord> { - public TestRecord this [int n] { - get { return (TestRecord) ((IList)this) [n]; } - } - public TestRecord this [string name] { get { - for (int n=0; n<List.Count; n++) - if (((TestRecord)List [n]).Name == name) - return (TestRecord) List [n]; + foreach (var value in this) { + if (value.Name == name) + return value; + } return null; } } - - public void Add (TestRecord test) - { - ((IList)this).Add (test); - } } [Serializable] - public class UnitTestResultCollection: CollectionBase + public class UnitTestResultCollection: List<UnitTestResult> { - public UnitTestResult this [int n] { - get { return (UnitTestResult) ((IList)this) [n]; } - } - - public void Add (UnitTestResult test) - { - ((IList)this).Add (test); - } } } diff --git a/main/src/addins/MonoDevelop.UnitTesting/Services/BinaryResultsStore.cs b/main/src/addins/MonoDevelop.UnitTesting/Services/BinaryResultsStore.cs index 449ce82484..d57c51d0f7 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/Services/BinaryResultsStore.cs +++ b/main/src/addins/MonoDevelop.UnitTesting/Services/BinaryResultsStore.cs @@ -26,7 +26,7 @@ using System; using System.Xml.Serialization; using System.IO; -using ICSharpCode.NRefactory.Utils; +using Newtonsoft.Json; namespace MonoDevelop.UnitTesting { @@ -54,7 +54,7 @@ namespace MonoDevelop.UnitTesting const string binaryExtension = ".test-result"; const string xmlExtension = ".xml"; - FastSerializer fastSerializer = new FastSerializer(); + JsonSerializer jsonSerializer = JsonSerializer.CreateDefault (); XmlSerializer xmlSerializer; XmlSerializer XmlSerializer { @@ -72,9 +72,10 @@ namespace MonoDevelop.UnitTesting // no need for xml serialization because next time it will be // deserialized from the binary format string binaryFilePath = GetBinaryFilePath (xmlFilePath); - using (var stream = File.OpenWrite(binaryFilePath)) { - fastSerializer.Serialize (stream, testRecord); - } + using var stream = File.OpenWrite (binaryFilePath); + using var writer = new StreamWriter (stream); + + jsonSerializer.Serialize (writer, testRecord); } public TestRecord Deserialize (string xmlFilePath) @@ -83,9 +84,9 @@ namespace MonoDevelop.UnitTesting // deserialize from the binary format if the file exists if (File.Exists(binaryFilePath)) { - using (var stream = File.OpenRead (binaryFilePath)) { - return (TestRecord) fastSerializer.Deserialize (stream); - } + using var stream = File.OpenRead (binaryFilePath); + using var reader = new JsonTextReader (new StreamReader (stream)); + return jsonSerializer.Deserialize<TestRecord> (reader); } // deserialize from xml if the file exists diff --git a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Gui/T4EditorExtension.cs b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Gui/T4EditorExtension.cs index 520954efab..611db18a0d 100644 --- a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Gui/T4EditorExtension.cs +++ b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Gui/T4EditorExtension.cs @@ -31,7 +31,6 @@ using MonoDevelop.Ide.Gui.Content; using MonoDevelop.DesignerSupport; using MonoDevelop.TextTemplating.Parser; using MonoDevelop.Ide; -using ICSharpCode.NRefactory.TypeSystem; using MonoDevelop.Ide.Editor.Extension; using MonoDevelop.Ide.Editor; using System.Threading.Tasks; @@ -85,16 +84,6 @@ namespace MonoDevelop.TextTemplating.Gui } } - protected string GetBufferText (DomRegion region) - { - int start = Editor.LocationToOffset (region.BeginLine, region.BeginColumn); - int end = Editor.LocationToOffset (region.EndLine, region.EndColumn); - if (end > start && start >= 0) - return Editor.GetTextBetween (start, end); - else - return null; - } - #endregion #region Code completion diff --git a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.csproj b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.csproj index f4d393e913..93a403d0a0 100644 --- a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.csproj +++ b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelop.TextTemplating.csproj @@ -55,11 +55,6 @@ <Name>MonoDevelop.Ide</Name> <Private>False</Private> </ProjectReference> - <ProjectReference Include="..\..\..\..\external\nrefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj"> - <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project> - <Name>ICSharpCode.NRefactory</Name> - <Private>False</Private> - </ProjectReference> <ProjectReference Include="..\..\..\..\external\mono-addins\Mono.Addins\Mono.Addins.csproj"> <Project>{91DD5A2D-9FE3-4C3C-9253-876141874DAD}</Project> <Name>Mono.Addins</Name> diff --git a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Parser/T4ParsedDocument.cs b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Parser/T4ParsedDocument.cs index 63d5f95b58..be9322ff9d 100644 --- a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Parser/T4ParsedDocument.cs +++ b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Parser/T4ParsedDocument.cs @@ -28,7 +28,6 @@ using System; using System.Collections.Generic; using Mono.TextTemplating; using MonoDevelop.Ide.TypeSystem; -using ICSharpCode.NRefactory.TypeSystem; using MonoDevelop.Ide.Editor; using System.Linq; diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.csproj b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.csproj index 5b156373db..90f82cd76e 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.csproj +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.csproj @@ -97,11 +97,6 @@ <Project>{EE6ED99F-CB12-4683-B055-D28FC7357A34}</Project> <Name>LibGit2Sharp</Name> </ProjectReference> - <ProjectReference Include="..\..\..\..\external\nrefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj"> - <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project> - <Name>ICSharpCode.NRefactory</Name> - <Private>False</Private> - </ProjectReference> <ProjectReference Include="..\..\MonoDevelop.SourceEditor2\MonoDevelop.SourceEditor.csproj"> <Project>{F8F92AA4-A376-4679-A9D4-60E7B7FBF477}</Project> <Name>MonoDevelop.SourceEditor</Name> diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.csproj b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.csproj index a5af64d19d..4e7abfcd91 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.csproj +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.csproj @@ -27,11 +27,6 @@ <Name>MonoDevelop.Ide</Name> <Private>False</Private> </ProjectReference> - <ProjectReference Include="..\..\..\..\external\nrefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj"> - <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project> - <Name>ICSharpCode.NRefactory</Name> - <Private>False</Private> - </ProjectReference> <ProjectReference Include="..\..\..\..\external\mono-addins\Mono.Addins\Mono.Addins.csproj"> <Project>{91DD5A2D-9FE3-4C3C-9253-876141874DAD}</Project> <Name>Mono.Addins</Name> diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffParser.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffParser.cs index 715d6f4e26..bf10db70d4 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffParser.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffParser.cs @@ -29,8 +29,6 @@ using System.IO; using System.Text.RegularExpressions; using MonoDevelop.Ide.TypeSystem; -using ICSharpCode.NRefactory.TypeSystem; -using ICSharpCode.NRefactory.TypeSystem.Implementation; using MonoDevelop.Projects; using MonoDevelop.Core.Text; @@ -55,62 +53,6 @@ namespace MonoDevelop.VersionControl.Views public override System.Threading.Tasks.Task<ParsedDocument> Parse (ParseOptions parseOptions, System.Threading.CancellationToken cancellationToken) { ParsedDocument doc = new DefaultParsedDocument (parseOptions.FileName); - - DefaultUnresolvedTypeDefinition currentFile = null; - DefaultUnresolvedProperty currentRegion = null; - - string eol = Environment.NewLine; - string content = parseOptions.Content.Text; - Match eolMatch = eolExpression.Match (content); - if (eolMatch != null && eolMatch.Success) - eol = eolMatch.Groups ["eol"].Value; - - string[] lines = content.Split (new string[]{eol}, StringSplitOptions.None); - int linenum = 1; - Match lineMatch; - foreach (string line in lines) { - lineMatch = fileHeaderExpression.Match (line.Trim ()); - if (lineMatch != null && lineMatch.Success) { - if (currentFile != null) // Close out previous file region - currentFile.BodyRegion = new DomRegion (currentFile.BodyRegion.BeginLine, - currentFile.BodyRegion.BeginColumn, - linenum - 1, int.MaxValue); - if (currentRegion != null) // Close out previous chunk region - currentRegion.BodyRegion = new DomRegion (currentRegion.BodyRegion.BeginLine, - currentRegion.BodyRegion.BeginColumn, - linenum - 1, int.MaxValue); - - // Create new file region - currentFile = new DefaultUnresolvedTypeDefinition (string.Empty, string.Empty); - currentFile.Region = currentFile.BodyRegion = new DomRegion (lastToken (lineMatch.Groups ["filepath"].Value), linenum, line.Length + 1, linenum, int.MaxValue); - // doc.TopLevelTypeDefinitions.Add (currentFile); - } else { - lineMatch = chunkExpression.Match (line); - if (lineMatch != null && lineMatch.Success && currentFile != null) { - if (currentRegion != null) // Close out previous chunk region - currentRegion.BodyRegion = new DomRegion (currentRegion.BodyRegion.BeginLine, - currentRegion.BodyRegion.BeginColumn, - linenum - 1, int.MaxValue); - - // Create new chunk region - currentRegion = new DefaultUnresolvedProperty (currentFile, lineMatch.Groups ["chunk"].Value); - currentRegion.Region = currentRegion.BodyRegion = new DomRegion (currentFile.Region.FileName, linenum, line.Length + 1, linenum, int.MaxValue); - currentFile.Members.Add (currentRegion); - } - } - ++linenum; - } - - // Close out trailing regions - if (currentFile != null) - currentFile.BodyRegion = new DomRegion (currentFile.BodyRegion.BeginLine, - currentFile.BodyRegion.BeginColumn, - Math.Max (1, linenum - 2), int.MaxValue); - if (currentRegion != null) - currentRegion.BodyRegion = new DomRegion (currentRegion.BodyRegion.BeginLine, - currentRegion.BodyRegion.BeginColumn, - Math.Max (1, linenum - 2), int.MaxValue); - return System.Threading.Tasks.Task.FromResult (doc); } diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj index 9d63654140..c7e6f72840 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj @@ -37,11 +37,6 @@ <Name>MonoDevelop.Debugger</Name> <Private>False</Private> </ProjectReference> - <ProjectReference Include="..\..\..\..\external\nrefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj"> - <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project> - <Name>ICSharpCode.NRefactory</Name> - <Private>False</Private> - </ProjectReference> <ProjectReference Include="..\..\..\..\external\mono-addins\Mono.Addins\Mono.Addins.csproj"> <Project>{91DD5A2D-9FE3-4C3C-9253-876141874DAD}</Project> <Name>Mono.Addins</Name> |