mirror of https://github.com/icsharpcode/ILSpy.git
Browse Source
e2eef88 Add 'HasBody' property to IMethod. Closes #100. 2ed6497 Merge pull request #101 from mono-soc-2012/mansheng aedf4e2 [CodeActions] ConvertImplicitToExplicitImplementationAction: removed a redundant test 1d3c30b Merge remote-tracking branch 'upstream/master' into mansheng 612ab59 Merge pull request #99 from mono-soc-2012/simonl 2a45c1e Merge branch 'master' into simonl aa55c20 Add AbstractUnresolvedEntity.Clone() method. e975667 [Formatting] Fixed wrong default option. 4945fa5 [CodeIssues] MultipleEnumerationIssue: added documentation dc7fa56 [CodeIssue] RedundantAssignmentIssue: fixed a bug in issue finding b7f6501 [CodeIssues] Improve ParameterCanBeDemotedIssue. 408b298 [TypeSystem] Don't consider non-public members for interface implementors. 79b4c25 [CodeIssues] ParameterCanBeDemotedIssue: Add Criterions for suitable indexer members and for array types. Also start resolving the method with the new type to check for errors. 458bd90 [CodeIssues] Add incomplete dependency tracking to VariableDeclaredInWideScopeIssue. a27b051 [CodeIssues] ConstantConditionIssue: check if condition is compile time constant to avoid fake warnings 352dcce [CodeIssues] CompareBooleanWithTrueOrFalseIssue: check if the expression being compared is of boolean type 588b127 [CodeIssues] MethodNeverReturnsIssue: handle 'throw' case 71e42df [CodeActions] Moved GetDefaultValueExpression back to CreateOverloadWithoutParameterAction class 6f063c6 [CodeIssues] RedundantFieldInitializerIssue: handle some number type initializer cases c403f38 Move the fix for #94 into CSharpConversions.IsConstraintConvertible. 40bbafd Set NET_4_0 preprocessor symbol for mcs. Rename "NET45" to "NET_4_5" to be consistent with mcs and Mono.Cecil. 284a4cc Fix InvalidCastException in MemberLookup.RemoveInterfaceMembersHiddenByClassMembers 8ede23f Merge pull request #94 from erik-kallen/InvokeGenericMethodWithNullableTypeArgument eb4de73 Merge pull request #93 from erik-kallen/DuplicateUsingsIssue 740a30c [Completion] CreateNamespace completion data now takes a INamespace instead of a string. f3ae264 [Demo] Reverted an unnecessary change f5c370a [CodeIssues] MethodOverloadHidesOptionalParameterIssue: fixed namespace 8d77f4b [CodeIssues] Removed some unused usings f1dad51 [CodeActions] CreateCustomEventImplementationAction: removed TODO which is already done. 11b9fd1 [CodeActions]ConvertLambdaBodyExpressionToStatementAction: removed unused usings c461c7b [CodeActions] ConvertConditionalToIfAction: check context location 0140f2d [CodeActions] ConvertCastToAsAction: fixed tests 90356ad [CodeActions] ConvertCastToAsAction: check context location. Reorganized code. f2b8be7 [CodeAction] ConvertAsToCastAction: check context location 9c521f8 Fixed issue with nullable types not being usable as generic arguments. a00495c Test that demonstrates that a generic method cannot be invoked with a nullable type argument. a9e0bd9 [CodeIssues] IncorrectCallTogetHashCodeIssue: Only look at calls to members of 'base' or 'this'. 5b29f2b Fixed issue with duplicate using directives. d857a8b Test demonstrating issue with duplicate using directive. 821e157 [CodeIssues] VariableDeclaredInWideScopeIssue: Handle nested scopes that are not BlockStatements and don't suggest moving declarations into closures 713b88f [CodeIssues] Don't consider empty catches redundant. 611cc25 Merge remote-tracking branch 'upstream/master' into mansheng c63f65a [CodeIssue] Added MethodOverloadHidesOptionalParameterIssue 810c03a NRefactory 5.2.0 release 76670db [CodeActions] Add ConvertLambdaToAnonymousDelegateAction. 1797fa2 [CodeActions] Add convertAnonymousDelegateToLambdaAction. 0b56b42 Remove redundant call to ValidateMethodConstraints(). Fix demo application. eeb5c3f Added unit test to check completion in #if regions. d2038a4 [Completion] Added conditional symbols to the completion engine context. ddd341b [CodeActions] Fixed bug in create backing store. 19815e8 Merge branch 'master' into simonl 352b20c [CodeIssue] Added RedundantObjectCreationArgumentListIssue 9a8d671 [CodeIssue] RedundantObjectOrCollectionInitializerIssue: added some tests c0870db [CodeIssue] Added RedundantObjectOrCollectionInitializerIssue 4af1379 [CodeIssue] Added RedundantCaseLabelIssue b5bd89b [Refactoring] track renaming of ParsedFile to UnresolvedFile 7a2d9f8 Merge remote-tracking branch 'upstream/master' into mansheng c3a31c9 Fix #92: The resolver does not check type constraints on calls to generic methods 1f6c4f0 Update solution-loading logic in ConsistencyCheck. 2c24a05 Merge branch 'master' into simonl 86e4d9a [CodeIssue] Added CastExpressionOfIncompatibleTypeIssue 16aa0c6 Rename IParsedFile -> IUnresolvedFile to make clear it belongs to the unresolved type system. 4a6a43d Change output path - build everything into \bin\Debug in NRefactory directory (not into ICSharpCode.NRefactory subdirectory). 7a3b25b Add WriteTextTo() method to ITextSource. 9a9485a Add ProjectReference class to NRefactory to simplify creating the type system for a solution with multiple projects. 5241e34 Merge pull request #91 from mono-soc-2012/simonl-attributesection-fix ea49b1a [CodeIssues] Add StaticFieldInGenericTypeIssue. 7c19dfa [Parser] Set locations of AttributeSections correctly. 4424f0e [Parser] Add failing unit tests for AttributeSections with multiple attributes. e5f5d6c [CodeIssues] Add ThreadStaticOnInstanceFieldsIssue. fec84f8 Implemented missing operation on new SeekableStreamReader 699d841 Merge pull request #90 from erik-kallen/FixOrderByParsing 7794385 Enabled query expander tests now that multiple orderings are supported. 32d43b2 Fixed query orderings when ordering by more than one expression. cdfde8b [CodeActions] Greatly improved OptionalParameterCouldBeSkippedIssue. 8635a6f Merge remote-tracking branch 'upstream/master' into mansheng d9dbd25 [CodeIssue] Added RedundantArrayInitializerCommaIssue 62a8b20 Fix icsharpcode/NRefactory#89: explicit conversion of array to generic IList fails when array covariance is used. 82ab94f [CodeIssues] OptionalParameterCouldBeSkippedIssue: Check for unmappable arguments. d69abea [CodeActions] Handle resolution errors in IterateViaForeachAction. 1371e6d [CodeIssues] Fix bugs in RedundantCatchIssue. d6054d1 [CodeIssues] Add ExceptionRethrowIssue 78cf6b1 Merge remote-tracking branch 'upstream/master' into mansheng e97b6b2 [Parser] Fixed some optional comma bugs. ff4b265 [CodeIssue] Added MethodNeverReturnsIssue 087aee7 Simplify parser API. 83776a1 [CodeIssue] Added RedundantAttributeParenthesesIssue 34932ef [Parser] Hacked work around for parser error. 29c686a [CodeIssue] Added DoubleNegationIssue f81ecd7 [Parser] Implemented own seekable stream reader. 102ce25 Merge pull request #87 from erik-kallen/DynamicExpressionsUseNamedArgumentResolveResult 927f263 Merge pull request #85 from erik-kallen/QueryExpressionExpander 26409db Implemented explicit conversions - invalid casts now resolve to Conversion.None. 73b80fc [CodeIssues] CallToObjectViaBaseIssue: Ignore calls which do not target members of 'base'. eaba979 Rename 'cu' to 'syntaxTree'. 979fa91 Fix icsharpcode/NRefactory#88: implicit conversion between type parameters. 7038892 Ensure that named argument instances are unique for dynamic invocations. 273178a Rename CompilationUnit to SyntaxTree. 93940f8 [CodeIssue] RedundantToStringIssue: Don't crash on parameter with declaration-less types. 7375967 Merge remote-tracking branch 'upstream/master' into mansheng 0af0137 Use NamedArgumentResolveResult for dynamic invocations. 7ece3ce Statements ending in select (i) now acts as if the statement was not parenthesized. 9a53205 Merge remote-tracking branch 'upstream/master' into simonl 17cdd1f [CodeAction] Add ConvertInitializerToExplicitInitializationsAction. 35475a2 [Refactoring] Make NamingHelper less horrible and remove the helper from RefactoringContext. cc37a71 TypeSystemAstBuilder: do not specify accessibility on accessors unless necessary. 4717de9 Optimized the AstNode.Descendants property. 07fb368 Add visitor benchmark. 359fdd2 Provide both Enter and Leave events in ObservableAstVisitor. d4372bf Add DefaultAttribute. fb44364 Remove outdated code contracts. d6b4420 Introduced NamedArgumentResolveResult. 6bd0bfc Add failing unit test for CompilationUnit.ConditionalSymbols. 8728c08 Add project configurations for .NET 4.5. 3f782ce Add ITypeDefinition.GetInterfaceImplementation(). 0f82920 GenerateProperty: do not propose to generate a setter if the field is readonly. f4e5cbd Merge remote-tracking branch 'upstream/master' into mansheng 574b3d2 [CodeIssue] CompareFloatWithEqualityOperator: handle a failed test case 0ee9c33 [CodeIssue] Added ReferenceEqualsCalledWithValueTypeIssue 10fc738 [CodeIssue] Added ExpressionIsNeverOfProvidedTypeIssue 0ba24d9 [CodeIssue] Added ExpressionIsAlwaysOfProvidedTypeIssue 60607bc Fix icsharpcode/NRefactory#86: method declaration with attributes fails to resolve since 2926e24. 7d5f1e0 Make CecilResolvedAttribute.DecodeBlob() more robust. 522d6c6 [CodeActions] Fix bugs in ConvertToInitializer. 88d89e7 [CodeActions] ConvertToInitializer: Handle collections with Add() calls taking multiple arguments. 903e46d [CodeActions] Cleanups in StatementsToInitializerConverter. 2426d1e Rename method ExpandQueryExpression to ExpandQueryExpressions. e384bfb [CodeActons] Handle more edge cases in ConvertToInitializer. 0deb852 Report parameter instead of its name token in the result map, unpack parenthesized expressions. 4dbac01 [CodeActions] Fix bugs in ConvertToInitializerAction. 40b8ce5 [CodeIssues] Converted IgnoreConstructors to a property. 0eaf61e [Completion] Fixed wrong delegate signature. 99de4e1 Updated mcs. bf69983 Merge remote-tracking branch 'upstream/master' into mansheng 384e0b6 [CodeIssue] CompareFloatWithEqualityOperatorIssue: fixed 'NaN' issue 47f2531 [CodeIssue] ConstantConditionIssue: use a better title 5c4a2da [CodeAction] NegateRelationalExpressionAction: fixed title f5d0318 [CodeAction] JoinStringAction: handle the case when left operand is a BinaryOperatorExpression b0f16b2 Test to ensure that range variables are not in scope for join equals expression, renamed method. 40266d1 Inherit QueryExpressionExpander from DepthFirstAstVisitor. 2926e24 C# type system convert visitor: do not include attributes in IEntity.Region e83d77a Ignore redundant 'this' in constructors. 7db1cbe Merge NRefactory changes from SharpDevelop repository: cb034bd Implemented QueryExpressionExpander. b8b2c61 [CodeIssue] Added CompareBooleanWithTrueOrFalseIssue 93fae44 [CodeAction] Added JoinDeclarationAndAssignmentAction 580fa30 Merge remote-tracking branch 'upstream/master' into mansheng f47fd76 [CodeIssues] RedundantToStringIssue: Also check formatting calls. 23d282d [Completion] Only check browsable attribute inside the same assembly. a08bde6 Fixed tests. 5418c1c [NRefactory] Removed Browsable Attribute from GetEditorBrowsableState - that attribute should not affect completion, only design time editors. 6575de9 [Completion] Moved the browsable check helper methods to nrefactory. The browsable state is a .NET feature and not C# specific. a747e47 [CodeIssues] Use IsKnownType in more places. 8dc6911 [Completion] Generalized browsable state method. bea810b [Completion] Recognized browsable attributes / streamlined completion API a bit. c60e01e [Completion] Show synthetic members again. 56114fe Simplify ImplementInterfaceAction by using the TypeSystemAstBuilder. 264c4c1 [CodeIssues] Use IsKnownType to check for System.Object. b0e12f0 Merge remote-tracking branch 'upstream/master' into mansheng 3ef7fd7 Merge remote-tracking branch 'upstream/master' into simonl b14db35 [CodeIssue] CompareFloatWithEqualityOperatorIssue: handle double.NaN case 3be1ef1 [CodeIssue] NegativeRelationalExpressionIssue: no longer report issues for floating-point operations dbdb7c7 [CodeIssues] Handle non-object base classes in IncorrentCallTogetHashCodeIssue and CallToObjectEqualsViaBaseIssue. 80d02a5 [CodeIssues] RedundantTypeCastIssue: use .Equals() for comparing types 519dc12 Add IsKnownType() extension method. 58fea52 [Completion] Added more synthetic member checks/added forgotton accessible check for nested types. 40ba86a [Completion] Added some synthetic member checks. c954742 Merge remote-tracking branch 'upstream/master' into simonl ecf167d [CodeIssues] Add IncorrectCalltoGetHashCodeIssue. f7a0fb5 Merge remote-tracking branch 'upstream/master' into mansheng 0cf2d39 [CodeIssue] Renamed DoubleNegationExpressionIssue to NegativeRelationalExpressionIssue 5307b16 [CodeAction] Added JoinStringAction 783a79c [CodeIssues] Add CallToObjectEqualsViaBaseIssue. 444ecf7 [CodeIssues] Add RedundantToStringIssue. a3534f2 Add INamespace.ContributingAssemblies. 144ddcd [CodeIssue] Added DoubleNegationExpressionIssue c71b3fa [CodeAction] NegateRelationalExpressionAction: improved tests c9612ed [CodeAction] NegateRelationalExpressionAction: use CSharpUtil.NegateRelationalOperator 0b81174 [Ast] CSharpUtil: extract negating a relational operator into a method 8b026d4 Script.Link() dummy implementation: return a completed task instead of null. fa9d5ac [CodeAction] Added NegateRelationalExpressionAction 79ae62a Merge remote-tracking branch 'upstream/master' into mansheng bfe463b NRefactory 5.1.0 4513b6e Avoid NullReferenceExceptions now that MethodGroupResolveResult.TargetResult can be null. 41b7775 Merge pull request #80 from erik-kallen/DynamicImprovementsNewTry 3ddf30c Fix icsharpcode/NRefactory#71: entity type for indexers (explicit interface implementations) acb1218 Test demonstrating issue with EntityType for indexers that explicitly implement interface members. 65097ed Add unit test for named attribute argument. dfbca85 Add (failing) unit test for icsharpcode/NRefactory#56. a15921d Merge pull request #81 from erik-kallen/IsConstantExpressionConversion f3d13ee Added property Conversion.IsConstantExpressionConversion 916cc2a Fixed issues pointed out by Daniel. 6192d7a Documentation for MethodListWithDeclaringType d7ebf92 Add (failing) unit tests for icsharpcode/NRefactory#45 9e84873 Change "string[] Conditionals" to "IList<string> ConditionalSymbols" ecd3de7 Implementation of feature ce5a42c Tests for the improved dynamic handling. 13dce76 Add Conversion.IsNullLiteralConversion (icsharpcode/NRefactory#59) ea5e36c Fix icsharpcode/NRefactory#60: Implicit type parameter conversion b656371 Implemented C# cref parser. 90c1b11 [CodeIssue] ConstantConditionIssue: use 'true'/'false' instead of 'True'/'False' in title 6c33cf8 [CodeIssue] IdenticalConditionalBranchIssue: use a better title dab4b01 [CodeIssue] AssignmentMadeToSameVariableIssue: use a better title 3d74abb Use directly specific corlib implementation for GetAllBaseTypesTest so that the tests don't fail if interfaces are added to .NET BCL types. 9640abd Add (failing) unit test for icsharpcode/NRefactory#73. 0e7fe7a Merge pull request #77 from erik-kallen/MembersInDerivedInterfacesShouldNotImplementBaseMembers 93e2def Fix #75: conversion between delegate types 32ee4d4 Fix icsharpcode/NRefactory#76: definite assignment analysis ignores false part of conditional expressions. dd07a77 CSharpParser: when parsing part of a compilation unit, detach the resulting nodes from the dummy compilation. ad46ffd Merge remote-tracking branch 'upstream/master' into mansheng 209d3f0 [CodeIssue] Added RedundantTypeCastIssue e71a8fd Fixed conditional symbol bug. d1f0807 Use location from Cecil instead of providing it as an extra parameter to LoadAssembly(). 5a1f7d7 Fixed issues with CecilLoader.LazyLoad=true. ed0e4c5 Fixed conversions from "dynamic" - these only exist from expressions, not from the type (this was causing subtle issues with type inference). 8090455 [Parser] Added conditional symbols to the compilation unit. 5f60958 [TypeSystem] Cecil loader can now take the loaded assembly location. 14addf4 [TypeSystem] Added SetLocation to IProjectContent. be9a3ed [Completion] Fixed get extension method call in parameter completion. c032382 [TypeSystem] Added location property to IAssembly. 1146033 Fixed get extension method call. 1d499ae [CodeIssues] Remove unused field. 58d7ac0 Improved ToString() for methods. 5592e88 Fixed bug when passing an extension method as a method group to a generic function. cc35fcc Revert f01a4b2 and 58c4ec8. Fixed small issue in CSharpResolver.GetExtensionMethods: when type parameters are provided explicitly, use the specialized method for the eligibility check. 0a7fdcd [CodeCompletion] No longer show static enum members on enum types (even if the call is theoretical valid). 247d588 [CodeIssues] Fix some false suggestions in VariableDeclaredInWideScopeIssue. c2b1946 [CodeIssue]RedundantElseIssue: changed Severity to Warning 54fbfc8 [CodeIssue] Added ConstantConditionIssue 092a18f [CodeIssues] Check redundant optional arguments of constructors. 342c87a [Utils] Don't allow escape sequences in numeric fields of format items. 1e561dd [CodeIssues] Be more allowing when picking format string arguments in FormatStringIssue. 58c4ec8 [Resolver] Fixed type inference use case. Daniel: The fix may not be correct - it's hard to tell which side effects that change will cause. c7de3da [CodeAction] Fixed getter/setters of the implemented interface/abstract class properties & indexers. 4f70f16 [CodeActions] Implemented abstract members action/Improved implement interface action & fixed unit tests. 2154c15 Merge remote-tracking branch 'upstream/master' into mansheng 4acb9b8 [Resolver] Don't check the location of value parameters in accessors. (Revert remaining parts of revision e60567ab869d59e74397c34cd994b2c732c615f4) ebfd941 [CodeIssues] Fix ValueParameterUnusedIssue. b375e1f [CodeIssues] Add RedundantCatchIssue. 77fd14e [CodeIssue] Added IdenticalConditionalBranchIssue 1863ed6 [CodeAction] Implement interface now tends to implement the more specialized members non explicit. fea0060 [CodeIssue] Added AssignmentMadeToSameVariableIssue 286091b [CodeActions] Finished first implement interface implementation. cbf1bdf Merge remote-tracking branch 'upstream/master' into mansheng a4344c8 Checked for possible null refrence exception. 461d5da [Completion] Fixed completion bug. d4209d0 [CodeAction] Fixed extract method unit test. 4a5d1e8 [CodeAction] Fixed most extract method tests. 61faaca [CodeIssue] RedundantAssignmentIssue: fixed incorrect text marking f9aa82c Merge remote-tracking branch 'upstream/master' into mansheng 63a8ca1 [CodeIssue] Added RedundantAssignmentIssue e6abbcb [CodeIssue] Added MultipleEnumerationIssue c37d18a [CodeIssue] ParameterNotUsedIssue: only check parameters of methods 21a87ec [CodeIssue] VariableOnlyAssignedIssue: out argument should be considered as assignment 2c98a2c [Completion] Filter out System.Void type 3963b40 Fix 0bc0d09 Failing test. cf69275 [Completion] Fix enum method list. f01a4b2 [Resolver] Interfere extension method type arguments from the target type if no parameter is given. 62283e2 [TypeSystem] Made error message more verbose. 68aa35a [Ast] Added MemberNameToken property for pointer reference expressions. 53d9b6e [CodeIssues] Fix some false positives in ParameterCanBeDemotedIssue. dc1e33d [CodeIssue] ParameterHidesMemberIssue and LocalVariableHidesMemberIssue now distinguish static and non-static members 35179fd [CodeIssues] Remove leftover Console.WriteLine(). 865c288 [CodeIssues] OptionalParameterCouldBeSkippedIssue: Add null check. 3ae6b9f [CodeIssues] FormatStringIssue: Handle extra arguments that do not have a matching formal parameter. e5f346b [CodeIssues] Add OptionalParameterCouldBeSkippedIssue. 3757871 [CodeIssues] FormatStringIssue: Show errors in TextSegments too. 101294e [Utils] CompositeFormatStringParser: More error handling + refactoring of the code. 927c388 [CodeIssue] Added UnreachableCodeIssue ef6302d [Utils] CompositeFormatStringParser: Handle unclosed format items better 900aec2 [CodeIssues] Add FormatStringIssue. d2474e5 [Utils] Make CompositeFormatStringParser.Parse() wrap the segments in a class instead of just returning an IEnumerable. 185779b [Utils] Add more error checks to CompositeFormatStringParser. af7d214 [Utils] Some CompositeFormatStringParser cleanups. 7edf902 [Utils] More error handling in CompositeFormatStringParser. 1b96e9b [Utils] Add lots of error checks to CompositeFormatStringParser. 11c428e [Utils] Add CompositeFormatStringParser and related classes. 23c7dc0 [Tests] Added helper methods for checking a specific fix to InspectionActionTestBase 1133382 [CodeIssues] Add missing class IsTypeCriterion. 2307bcb [CodeIssues] ParameterCanBeDemotedTests: Add checks for what types variables are used as. 03ea217 [CodeIssues] Rename CallToStaticMemberViaDerivedTypeIssue to ReferenceToStaticMemberViaDerivedTypeIssue. a3e6c14 [CodeIssues] Handle members in CallToStaticMemberViaDerivedTypeIssue. a1cbcc2 Merge remote-tracking branch 'upstream/master' into mansheng 7a9fdf4 [CodeIssues] Make CallToVirtualFunctionFromConstructorIssue less whiny. 1a7d2e1 [CodeIssues] CallToStaticMemberViaDerivedTypeIssue: Ignore member methods of the current class. 6f2aed1 [CodeIssues] ParamaterCanBeDemotedIssue: Don't crash on parameters that aren't used. db8e971 [CodeAction] Add ContextAction attribute to MoveToOuterScopeAction. ce1e2ee [CodeIssues] Fix crashes in VariableDeclaredInWideScopeIssue. f33aa32 Merge remote-tracking branch 'upstream/master' into simonl 008aaa1 [CodeIssues] Factor out some type restriction finding infrastructure. e62a046 Fixed resolving compile-time operations on enum types with an underlying type smaller than int. (always use unchecked context for the cast back to enum) 459a2ef Fixed bug resolving indexer parameter declarations (was introduced with #66 [9476183]). 807e9c5 Allow multiple occurrences of UnknownError. 0aa37bc Add lazy-loading support to CecilLoader. 164592f [CodeIssue] Added CompareFloatWithEqualityOperatorIssue aff3328 [CodeIssue] Added BitwiseOperationOnNonFlagsEnumIssue 3372603 [CodeIssue] Added ForControlVariableNotModifiedIssue 7f7fcec [CodeIssue] Added RedundantElseIssue 5f6f274 Merge pull request #70 from erik-kallen/DynamicResolveResults a7816c2 Fixed handling of user-defined conversions between primitive types. 8426277 Merge remote-tracking branch 'upstream/master' into mansheng fca3cfe [CodeIssue] Added RedundantFieldInitializerIssue 5c1418e [CodeAction] Moved GetDefaultValueExpression to BaseRefactoringContext be0d89c [CodeIssues] Improve ParameterCouldBeDemotedIssue. 61044a8 [CodeIssues] Add initial version of ParameterCanBeDemotedIssue. 8a80ae0 [Completion] Added pointer reference completion. 77c9ccb [CodeIssues] Rename VariableDeclaredInWideScopeIssue => VariableDeclaredInWideScopeTests in the test project. 5720dc7 [CodeActions] MoveToOuterScopeAction: Handle lambdas. 4bae4ed [CodeIssues] Add VariableDeclaredInWideScopeIssue. 774c707 [CodeIssues] Change the namespace on IncorrectExceptionParameterOrderingIssue. ac2e8ef [CodeActions] Don't crash on null accessors in ValueParameterUnusedIssue. 3ec073f [CodeActions] Add MoveToOuterScopeAction. 2de5021 Fixed failing unit test. 4a3192d [CodeIssues] Add CallToStaticMemberViaDerivedTypeIssue. 9d5a384 [CodeActions] Add ConvertToInitializerAction. 73530de [CodeIssue] Added VariableHidesMemberIssue c1db937 Merge remote-tracking branch 'upstream/master' into mansheng 7354574 [CodeAction] ConvertIfToConditionalTests: fixed a test 754adbc AccessToModifiedClosureIssue: always use "var" keyword to avoid some null type issues, fixed "fails for field declaration" issue. 9d37b9a GatherVisitor: make sure base visit methods are always called 549d6bb ExtractAnonymousMethodAction: Fixed "fails to insert generated method when anonymous method is not in a method" issue bd1f050 GatherVisitor: added calls to base methods 0bf9891 ResolveResults for dynamic expressions cf08a17 AccessToClosureIssue: fixed some constructor issues 77283dc Merge minor changes from SharpDevelop repository (mostly additional documentation for ResolveResults). 2b41cda Simplify Demo app. 4ff155e Merge remote-tracking branch 'upstream/master' into mansheng 5d2fee1 Add CompilerSettings class instead of using the one from Mono.CSharp. e7a902b Merge remote-tracking branch 'upstream/master' into mansheng b37dedf [CodeIssue] Added LocalVariableOnlyAssignedIssue and ParameterOnlyAssignedIssue 6ba62c6 [Formatting] Fixed override. 3e2fe59 [CodeActions] Added Task async excecution for insertion & link modes. 8e02a17 Merge remote-tracking branch 'upstream/master' into mansheng 585ae50 CSharpAstResolver: don't return the same ResolveResult for two different nodes. 08636db [Completion] Fixed named argument completion bug. fbc1cfd Fixed some failing unit tests. 6e5b973 [ContextAction] Added null check to create method. 1c0a730 [CodeIssue] TypeParameterNotUsedIssue: removed the fix because it may introduce errors. 454bfe5 [CodeIssue] LocalVariableNotUsedIssue: Find unused foreach variable e2221f2 Merge remote-tracking branch 'upstream/master' into mansheng ca048e6 [CodeIssue] Added VariableNotUsedIssue, ParameterNotUsedIssue and TypeParameterNotUsedIssue fadffd3 [Completion] Improved the closing tag insertion (xml documentation). 3dc4463 [Resolver] Array initalizers no longer show up in ResolveAtLocation. 84c092c Merge pull request #67 from erik-kallen/UserDefinedExplicitConversionBetweenReferenceTypes 25cf612 Merge pull request #66 from erik-kallen/ParameterIdentity 951d9a6 Fix for the issue that user-defined explicit conversions don't work. 0fec8d3 Failing test that demonstrates that explicit user-defined conversions don't work. e058d61 [Completion] Improved xml document completion. 95bc695 [Completion] Be more general when providing type level keywords in members. 839b19e [TyeSystem] Fixed bug in nested type property. d8aac6d Merge remote-tracking branch 'upstream/master' into mansheng 4ac7fec [Refactoring] Don't suggest names that are used in a parent scope when falling back to numbered names. 3ded985 [Formatting] Fixed overlapping changes issue. d355b0f [CodeIssues] Added indexer case. da2eea8 [CodeIssues] Improved naming check (skipp overriden members). 4c87520 [CodeAction] Create field now works on member reference expressions with 'this.' target. 9476183 Fix for the parameter identity in accessors issue. 1363faf Tests demonstrating issues with parameter identity in accessors. 806869e Add IType.GetAccessors(). Accessors now use EntityType.Accessor instead of EntityType.Method. Added accessors support to DefaultMemberReference and ExplicitInterfaceImplementationMemberReference. Removed hacky code from CecilLoader - we now allow IsExplicitInterfaceImplementation=true on accessors. 13ca351 [CodeActions] Make IterateViaForeachAction use names based on their type and add handling of using and for statements. da5bbf3 [Refactoring, Competion] Add NamingHelper, use it from CSharpCompletionEngine and add convenience functions to RefactoringContext. 98674db Merge remote-tracking branch 'upstream/master' into mansheng 99c34cb Merge pull request #65 from erik-kallen/ImplementedInterfaceMembersForPropertyAccessors 728bf05 [CodeIssue] Added AccessToModifiedClosureIssue and AccessToDisposedClosureIssue 2a7c0cb Merge pull request #64 from erik-kallen/IsOverrideFlag bf89323 Add missing fields in KnownTypeReference. cdaf575 Implement AnonymousType.ToTypeReference(). 74adaba Test demonstrating problem with nesting anonymous objects. c6d8b93 Move SimpleTypeResolveContext out of Implementation namespace. d46cbdb Don't report a member as implementing an interface member if there is another explicit implementation of that interface member. da0feac Another one of those x.IsOverride = y.IsOverridable issues. 4813979 Support explicitly implemented events in the CecilLoader. 8431aa0 Fixed bugs with events: 1) Assignment of IsOverride to IsOverridable, and 2) AccessorOwner not being set for auto-events. 7640141 Added support for explicit method and property implementations to the cecil loader. 18995bd Fixed InheritanceHelper to support explicit interface implementation of base accessors. 4d868ba Failing test with explicit indexer implementation 4bc84b0 Merge remote-tracking branch 'upstream/master' into mansheng fd39748 (Rather ugly) fix for indexer accessor's ImplementedInterfaceMembers. 7e2a5a3 Tests for ImplementedInterfaceMembers for indexer accessors. 7ce5de3 (Rather ugly) fix ensure that accessor method are reported as implementing the corresponding accessor methods from interfaces. baad38a Tests demonstrating that the accessors for a property that implements an interface property do not have any ImplementedInterfaceMembers. 7f6620e Merge branch 'master' into soc-master a2a0975 Fixes IsOverridable flag for accessors 840cde9 Failing test for IsOverride flag of accessors. 4d60290 [CodeAction] IterateViaForeachAction: Add tests for slightly invalid expression statements and use Script.InsertAfter() to avoid problematic formatting. 97185cf [Refactoring] Add optional parameter expectErrors = false to ContextActonTestBase.Test(). 9b256fb [Completion] Only show public enum members. 68e12e4 [Completion] Filtered double added enums. a4d5b7a [Refactoring] Add Script.InsertAfter(). 0c9704d [Parser] Give ExpressionStatements with an invalid expression a semicolon if there was one in the file. 80c3b8d [Formatter] The formatting visitor can now take a region to format. b5b1bd1 [CodeActions] Ignore whitespace tests for now. c45b646 [CodeActions] Handle AssignmentExpressions differently in IterateViaForeachAction. a546a8f [CodeActions] Rename SetterDoesNotUseValueParameterAction to ValueParameterUnusedAction and generalize it to include event accessors as well. c8f36ae [CodeActions] Handle auto-setters and missing setters in SetterDoesNotUseValueParameterIssue. f562e97 Merge branch 'master' into soc-master f99663b [CodeActions] Add IterateViaForeachAction. 1e63663 [CodeActions] Add failing unit tests for whitespace preservation in in AddCatchTypeAction and RemoveRedundantCatchTypeAction. eea162a [CodeIssues] Update some strings to be more inline with the rest of the issues (and more informative too). 05f8cfe [CodeActions] Don't return a convert to extension method call code action if the call is already using extension method syntax. 94e43f2 [CodeActions] Add the ContextAction attribute to the static method call <=> extension method call converters. bf6217d Improved CodeDomConvertVisitor. d6ed3b7 Fixed resolving accessors. cd9c948 Add ICollection, ICollection<T> and IList to KnownTypeReference. a9d8769 Implemented CSharpResolver.ResolveConditionFalse() for resolving operator false() calls. Add message to ErrorResolveResult. Expose CSharpOutputVisitor.PrintPrimitiveValue and CSharpConversions.IsImplicitReferenceConversion/IsBoxingConversion. a77fa31 Add IMethod.AccessorOwner. 731ddf7 Add ConversionResolveResult.CheckForOverflow 79f634c Change TextChangeEventArgs.InsertedText and RemovedText from string to ITextSource. c8f2115 [CodeAction] Added ExtractAnonymousMethodAction d1388d5 Merge remote-tracking branch 'upstream/master' into mansheng b304675 Merge branch 'master' into soc-master 00d5de8 [CodeIssues] Optimized word break algorithm. 81c7daa [Completion] Renamed IMemberProvider -> ICompletionContextProvider. 6cbda46 [Completion] It's no longer needed to specify a parsed file for the completion engine. 33efe34 [Documentation] Added support for relative redirection targets. 4ca0f1d [CodeAction] Add code actions for converting between static method calls and extension method calls. 3597535 [CodeAction] Added ConvertConditionalToIfAction and ConvertIfToConditionalAction c9d2776 [Completion] Added GetMemberTextToCaret interface method. 1a33039 [Completion] Use getstate to get the current resolver state. a8e702b [Completion] Lowered parsed file usages. 39ac51c [Completion] Made API a bit simpler. d60aaeb [Completion] Member provider now needs to be given in the constructor. aa59c76 Merge remote-tracking branch 'upstream/master' into mansheng f198d68 [CodeAction] Fixed bug in create property action. 4e44369 [CodeIssues] Fdg rules now apply only to public & protected entities. (The Fdg rules only apply to that, we were more restrictive). b0c73cc [CodeIssues] Fixed fdg naming rules. 6c36d6e Merge pull request #58 from mono-soc-2012/simonl-newline-fix 513ffec Merge pull request #51 from nieve/ExtractFieldAction eb41192 Fix unit test failing on .NET 4.5 RC. 0500351 Simplify API for retrieving compiler errors/warnings. e914c9e [CodeIssue,CodeAction] Use the FindReferences class instead of custom visitors to find variable references. e60567a [Resolver] Give the value parameter a domregion close to the setter or adder. 75f65da Fixed typo. ad0ef5d [CodeIssue] Remove stray exception creation. 47da624 [CodeIssue] Add CallToVirtualFunctionFromConstructorIssue. 8d46989 [Formatter] Avoid newlines between multiline arguments and the ending parenthesis in function calls. 8e94126 [CodeIssue] Add IncorrectExceptionParameterOrderingIssue. 2396e99 [CodeIssue] Add SetterDoesNotUseValueParameterIssue. b6203ac [CodeAction] Add AddCatchTypeAction. e2ff414 [Code Action] Only show MergeNestedIfAction on 'if' token 712102c [Code Action] Only show ConvertSwitchToIfAction on 'switch' token 4da8bc8 [Code Action] Only show ConvertIfToSwitchAction on 'if' token b8c6547 Merge remote-tracking branch 'upstream/master' into mansheng 73a44b2 [NRefactory] Be more verbose on cecil load error. 44eff13 Add RemoveRedundantCatchTypeAction. 875d509 Merge remote-tracking branch 'upstream/master' into mansheng 4bfa589 [CodeAction] Added ConvertLambdaBodyExpressionToStatementAction and ConvertLambdaBodyStatementToExpressionAction 0f01589 [CodeAction] Added UseStringFormatAction 7fb257f Fixed completion bug. 5fe3dbd [UnitTest] Added test case for parser bug. d29d429 [CSharp] Updated mcs. f934c9a [CodeAction] ConvertExplicitToImplicitImplementation: make implicit implementation public bfa89c7 [CodeAction] Added ConvertExplicitToImplicitImplementationAction and ConvertImplicitToExplicitImplementationAction 1066186 [CodeAction] Added PutInsideUsingAction d01ed9e Merge remote-tracking branch 'upstream/master' into mansheng 33cc204 [CodeAction] Added MergeNestedIfAction 5bc69fd [CodeActions] Fixed remove braces whitespace removal. 38c8028 [CodeAction] SplitDeclarationList: Corrected a test 9c078eb Merge remote-tracking branch 'upstream/master' into mansheng 16a84b9 [CodeAction] Added SplitDeclarationListAction 1911868 [NRefactory] Removed extra new line for fields. 4433ab1 [Ast] Added IdentifierToken property to IdentifierExpression. 88c1287 [CodeAction] Added CreateCustomEventImplementationAction fc6c24c [CodeAction] Added CreateOverloadWithoutParameterAction b5843ad [CodeAction] Added ConvertAsToCastAction and ConvertCastToAsAction 5afae04 Merge remote-tracking branch 'upstream/master' into mansheng 2786d0c [Formatting] Set wrap options to do not change. a362d45 Merge remote-tracking branch 'upstream/master' into mansheng 5823267 [CodeAction]Added ConvertSwitchToIfAction c93ef39 [CodeAction]ConvertIfToSwitchAction: avoid generating redundant default section. d061eaa [CodeAction]Added ConvertIfToSwitchAction 2e4a497 [Completion] Fixed GetLineIndent method. 0cc7a4e [Completion] Fixed delegate context bug. 1c0b3b5 [Completion] Filter inaccessible classes in completion lookup. 7b21777 [Completion] Fixed 'this' keyword for extension method declarations. 9e7c9be [Completion] Fixed enum completion bug. a1e4b07 [Completion] Fixed enum completion in binary operator expressions. 5587b77 [Analysis] Fixed control flow generation for null embedded statement (for statement). 7e3e016 Add back WinForms-based NRefactory.Demo. 1640cb8 Set version number to 5.0.1; fixed some compiler warnings. cbb1fe5 Fixed some issues resolving members. c93aca4 Fixed failing unit test. 180ed85 Implemented IUnresolvedMember.Resolve(). 4b3bb7e Fixed completion bug. e0e30ae [Completion] Improved object initializer case. a270f6a [Resolver] ResolveAtLocation can now postpone the creation of compilations. 293af2e [Resolver] Fixed resolve at location bug. f197829 [Formatter] Fixed failing unit tests. 4add679 [TypeSystem] Cecil loader no longer crashes loading gtk-sharp.dll on windows. 282d3c3 Fix icsharpcode/NRefactory#32: ResolveResult for anonymous type creation 4d07b33 CSharpAstResolver now can resolve type members even when no parsedFile is specified. 3745ade Merge pull request #54 from Duikmeester/patch-1 6f9065e "__StackĄlloc" corrected in "__StackAlloc" 7d89302 [Tests] Added test case for a parser bug. ff1118a [Formatter] Fixed bug where keywords were put into comments. 99b856a added extract field code action 9b7c635 Merge pull request #50 from riviti/enh-genprop 7a3e68f [TypeSystem] All attributes from partial method declarations are now merged. a300c56 GeneratePropertyAction: Handle fields named like properties by renaming them before creating the property. b9780fb [CodeAction] Fixed check if parameter is null bug. 75c3a07 [Formatting] Fixed overlapping change bug. 7a03092 [Completion] Fixed parameter completion for static methods. 1852a3d [Refactoring] Fixed some bugs in create code actions in conjunction with enums. d888899 Solution: Set correct indent width. 57d4bd4 [TypeSystem] UsingScope now uses as operator for casts. 8305999 [TypeSystem] Added default parameter for GetClassTypeReference typeParameterCount. bb6660e [TypeSystem] Added TypeReference.Resolve (Compilation) extension method. 8c8e6cf [Parser] Merged mcs. 49e1b67 [Completion] GetParameterCompletionCommandOffset is now reusable/removed code duplication of GetCurrentParameterIndex. bcb45ff [Refactoring] Better use of the text editor options class in the script node output (output formatter should maybe use the formatting indent class). ad0ae7a [Completion] Improved handling of named parameters. 8722483 [Formatting] Fixed using alias declarations. 5a53174 [Formatting] Guard against empty changes. 73396ed Improved named parameter completion case. cff1fb2 [Completion] Fixed member lookup. 14ed907 [Formatting] Wrapping is now an intrusive task. 570c4d8 Fixed bug in completion. 8ff1e4c Fixed completion bug. 1ade7c4 [Resolver] Fixed using statement. 93f0d71 Fixed completion bug. bc77559 [Completion] Fixed catch context completion. 8523068 [Completion] Fixed object initializer unit tests. c32e988 [Completion] Fixed unit test. 4fe7c72 Fixed context for determining accessibility of protected inner classes when resolving a base type reference (NameLookupTests.InheritFromProtectedInnerClassTest) f7fb298 Implemented better solution for the array initializer workaround hack. 121c786 Removed duplicate unit test. f5b7f57 [UnitTest] Added failing unit test. 7bf1b4a Added some unit tests. d9113f3 [CodeAction] Fixed possible null reference. 63009ac Fixed 'Bug 4604 - [Resolver] Attribute Properties are not offered valid autocomplete choices'. 89be9aa [UnitTest] Enabled broken unit test. 7a69c65 Fixed Issue #38: Parser Regression in ObjectCreate initialization 6f1325d Fixed Issue #44: The ending TextLocation of an ArrayCreateExpression is incorrect when the array is initialized with zero elements 6a45cef Updated mcs. ef726be [UnitTests] Disabled broken tests. a93372d Removed some files that shouldn't be in the repository cdd492e Merge pull request #36 from awatertree/master 0179c76 Merge pull request #43 from turbanoff/patch-1 c06cfed Fix icsharpcode/NRefactory#42: const IField returns IsStatic=false 76e3cb4 Fixed output visitor inserting too many newlines in SwitchSection. 1077aa9 Add .jay to symbol package. 5239719 Fixed property formatting bug. 24f1637 remove redundant check 5b83b2d Only wrap arguments that are longer than 1. c4b9519 [CodeAction] Convert foreach to for now preserves old block. 94a8fde Added unit test for Bug 4525 - Unexpected code completion exception 56bfccb Fixed possible null ref exception cf9d360 [CodeActions] Worked on implement interface. 0581a41 Ignored failing unit test. bfdaaad Fixed declaration parameter formatting bugs. 6126d9b [Formatting] Fixed some formatting bugs. 805e072 Started implement interface/abstract members code action. da56a5b Fixed completion bug. 1a1487f [Formatting] Checked token for null, before using the parent. 6d1e90b [Formatting] Added null check. 2aec1be Improved the handling of delegate contexts. c773b58 Fixed formatting unit tests. 2eb61ac Added failing unit test. I assume that the problem is that B has a inner lass B.Foo - sicne it works when Foobar inherits just from 'Foo'. e8a5226 Changed formatting policy. 063d0f5 Renamed named expression identifier -> name. 5dbe365 [Ast] Renamed named argument expression identifier -> name. 98b2dfa Fixed unit tests. aa111ad Added completion categories for derived types. 45c8d0e Fixed object creation completion issue. 29ec90e changed method call wrap default. 04127ad [Formatting] Improved the wrap if too long option. 639f6b9 Updated formatting factory options. e308e3d Added more formatting styles. c2e912a [Completion] Fixed bug in pre processor directive context detection. c8f8dc7 [CodeIssue] removed '.' in name. c36be0b Fixed some add another accessor issues. 1704bd0 [Formatting] Implemented parameter wrapping. 95b0c25 [Formatting] New line placement is now a 3 state. ecbc616 Added unit test for bug report. (use case already works) 198c085 Added some formatting options. a4064df Added indexer argument wrapping options. debc7a0 Added method call wrapping options. fa4f2e0 Added chained method call wrapping option. 62f621e Merge branch 'master' of github.com:icsharpcode/NRefactory e912bdf Fixed possible cast exception. 658cb4b patched up handling indexing issue aff71a5 try revert critical method 9d29131 merge a34aaa8 project compilation 18d7ca4 failing tests for issue 35 c189c5d failing tests for issue 35 3f465c6 failing tests for issue 35 git-subtree-dir: NRefactory git-subtree-split: e2eef883e176bb5017a9fdfc7afe9113e7448c27pull/384/head
563 changed files with 53237 additions and 10716 deletions
@ -1,2 +1,5 @@
@@ -1,2 +1,5 @@
|
||||
bin |
||||
obj |
||||
/lib/*.dll |
||||
/ICSharpCode.NRefactory.Tests/PartCover/* |
||||
/ICSharpCode.NRefactory.Tests/PartCover/* |
||||
_ReSharper*/* |
||||
|
@ -1,3 +0,0 @@
@@ -1,3 +0,0 @@
|
||||
|
||||
bin/ |
||||
obj/ |
@ -1,49 +1,69 @@
@@ -1,49 +1,69 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<ProductVersion>10.0.0</ProductVersion> |
||||
<SchemaVersion>2.0</SchemaVersion> |
||||
<ProjectGuid>{961DADFA-7CE6-429F-BC22-47630D6DB826}</ProjectGuid> |
||||
<OutputType>Exe</OutputType> |
||||
<RootNamespace>ICSharpCode.NRefactory.CSharp.AstVerifier</RootNamespace> |
||||
<AssemblyName>AstVerifier</AssemblyName> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>full</DebugType> |
||||
<Optimize>false</Optimize> |
||||
<OutputPath>bin\Debug</OutputPath> |
||||
<DefineConstants>DEBUG;</DefineConstants> |
||||
<ErrorReport>prompt</ErrorReport> |
||||
<WarningLevel>4</WarningLevel> |
||||
<Externalconsole>true</Externalconsole> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
||||
<DebugType>none</DebugType> |
||||
<Optimize>false</Optimize> |
||||
<OutputPath>bin\Release</OutputPath> |
||||
<ErrorReport>prompt</ErrorReport> |
||||
<WarningLevel>4</WarningLevel> |
||||
<Externalconsole>true</Externalconsole> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="System" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="Main.cs" /> |
||||
<Compile Include="AssemblyInfo.cs" /> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
||||
<ItemGroup> |
||||
<ProjectReference Include="..\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj"> |
||||
<Project>{53DCA265-3C3C-42F9-B647-F72BA678122B}</Project> |
||||
<Name>ICSharpCode.NRefactory.CSharp</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj"> |
||||
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project> |
||||
<Name>ICSharpCode.NRefactory</Name> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<ProductVersion>10.0.0</ProductVersion> |
||||
<SchemaVersion>2.0</SchemaVersion> |
||||
<ProjectGuid>{961DADFA-7CE6-429F-BC22-47630D6DB826}</ProjectGuid> |
||||
<OutputType>Exe</OutputType> |
||||
<RootNamespace>ICSharpCode.NRefactory.CSharp.AstVerifier</RootNamespace> |
||||
<AssemblyName>AstVerifier</AssemblyName> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>full</DebugType> |
||||
<Optimize>false</Optimize> |
||||
<OutputPath>bin\Debug</OutputPath> |
||||
<DefineConstants>DEBUG;</DefineConstants> |
||||
<ErrorReport>prompt</ErrorReport> |
||||
<WarningLevel>4</WarningLevel> |
||||
<Externalconsole>true</Externalconsole> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
||||
<DebugType>none</DebugType> |
||||
<Optimize>false</Optimize> |
||||
<OutputPath>bin\Release</OutputPath> |
||||
<ErrorReport>prompt</ErrorReport> |
||||
<WarningLevel>4</WarningLevel> |
||||
<Externalconsole>true</Externalconsole> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_4_5_Debug|AnyCPU' "> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>full</DebugType> |
||||
<Optimize>false</Optimize> |
||||
<OutputPath>bin\Debug</OutputPath> |
||||
<DefineConstants>DEBUG;</DefineConstants> |
||||
<ErrorReport>prompt</ErrorReport> |
||||
<WarningLevel>4</WarningLevel> |
||||
<Externalconsole>true</Externalconsole> |
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_4_5_Release|AnyCPU' "> |
||||
<DebugType>none</DebugType> |
||||
<Optimize>false</Optimize> |
||||
<OutputPath>bin\Release</OutputPath> |
||||
<ErrorReport>prompt</ErrorReport> |
||||
<WarningLevel>4</WarningLevel> |
||||
<Externalconsole>true</Externalconsole> |
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="System" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="Main.cs" /> |
||||
<Compile Include="AssemblyInfo.cs" /> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
||||
<ItemGroup> |
||||
<ProjectReference Include="..\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj"> |
||||
<Project>{53DCA265-3C3C-42F9-B647-F72BA678122B}</Project> |
||||
<Name>ICSharpCode.NRefactory.CSharp</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj"> |
||||
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project> |
||||
<Name>ICSharpCode.NRefactory</Name> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
</Project> |
@ -1,3 +0,0 @@
@@ -1,3 +0,0 @@
|
||||
|
||||
bin/ |
||||
obj/ |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,213 @@
@@ -0,0 +1,213 @@
|
||||
//
|
||||
// IMemberProvider.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <mkrueger@xamarin.com>
|
||||
//
|
||||
// Copyright (c) 2012 Xamarin Inc.
|
||||
//
|
||||
// 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 ICSharpCode.NRefactory.TypeSystem; |
||||
using ICSharpCode.NRefactory.Editor; |
||||
using ICSharpCode.NRefactory.CSharp.TypeSystem; |
||||
using System.Linq; |
||||
using ICSharpCode.NRefactory.CSharp.Resolver; |
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp.Completion |
||||
{ |
||||
public interface ICompletionContextProvider |
||||
{ |
||||
IList<string> ConditionalSymbols { |
||||
get; |
||||
} |
||||
|
||||
void GetCurrentMembers (int offset, out IUnresolvedTypeDefinition currentType, out IUnresolvedMember currentMember); |
||||
|
||||
Tuple<string, TextLocation> GetMemberTextToCaret(int caretOffset, IUnresolvedTypeDefinition currentType, IUnresolvedMember currentMember); |
||||
|
||||
CSharpAstResolver GetResolver (CSharpResolver resolver, AstNode rootNode); |
||||
} |
||||
|
||||
public class DefaultCompletionContextProvider : ICompletionContextProvider |
||||
{ |
||||
readonly IDocument document; |
||||
readonly CSharpUnresolvedFile unresolvedFile; |
||||
readonly List<string> symbols = new List<string> (); |
||||
|
||||
public IList<string> ConditionalSymbols { |
||||
get { |
||||
return symbols; |
||||
} |
||||
} |
||||
|
||||
public DefaultCompletionContextProvider (IDocument document, CSharpUnresolvedFile unresolvedFile) |
||||
{ |
||||
if (document == null) |
||||
throw new ArgumentNullException("document"); |
||||
if (unresolvedFile == null) |
||||
throw new ArgumentNullException("unresolvedFile"); |
||||
this.document = document; |
||||
this.unresolvedFile = unresolvedFile; |
||||
} |
||||
|
||||
public void AddSymbol (string sym) |
||||
{ |
||||
symbols.Add (sym); |
||||
} |
||||
public void GetCurrentMembers(int offset, out IUnresolvedTypeDefinition currentType, out IUnresolvedMember currentMember) |
||||
{ |
||||
//var document = engine.document;
|
||||
var location = document.GetLocation(offset); |
||||
|
||||
currentType = null; |
||||
|
||||
foreach (var type in unresolvedFile.TopLevelTypeDefinitions) { |
||||
if (type.Region.Begin < location) |
||||
currentType = type; |
||||
} |
||||
currentType = FindInnerType (currentType, location); |
||||
|
||||
// location is beyond last reported end region, now we need to check, if the end region changed
|
||||
if (currentType != null && currentType.Region.End < location) { |
||||
if (!IsInsideType (currentType, location)) |
||||
currentType = null; |
||||
} |
||||
currentMember = null; |
||||
if (currentType != null) { |
||||
foreach (var member in currentType.Members) { |
||||
if (member.Region.Begin < location && (currentMember == null || currentMember.Region.Begin < member.Region.Begin)) |
||||
currentMember = member; |
||||
} |
||||
} |
||||
|
||||
// location is beyond last reported end region, now we need to check, if the end region changed
|
||||
// NOTE: Enums are a special case, there the "last" field needs to be treated as current member
|
||||
if (currentMember != null && currentMember.Region.End < location && currentType.Kind != TypeKind.Enum) { |
||||
if (!IsInsideType (currentMember, location)) |
||||
currentMember = null; |
||||
}/* |
||||
var stack = GetBracketStack (engine.GetMemberTextToCaret ().Item1); |
||||
if (stack.Count == 0) |
||||
currentMember = null;*/ |
||||
} |
||||
|
||||
IUnresolvedTypeDefinition FindInnerType (IUnresolvedTypeDefinition parent, TextLocation location) |
||||
{ |
||||
if (parent == null) |
||||
return null; |
||||
var currentType = parent; |
||||
foreach (var type in parent.NestedTypes) { |
||||
if (type.Region.Begin < location && location < type.Region.End) |
||||
currentType = FindInnerType (type, location); |
||||
} |
||||
|
||||
return currentType; |
||||
} |
||||
|
||||
bool IsInsideType (IUnresolvedEntity currentType, TextLocation location) |
||||
{ |
||||
int startOffset = document.GetOffset (currentType.Region.Begin); |
||||
int endOffset = document.GetOffset (location); |
||||
//bool foundEndBracket = false;
|
||||
|
||||
var bracketStack = new Stack<char> (); |
||||
|
||||
bool isInString = false, isInChar = false; |
||||
bool isInLineComment = false, isInBlockComment = false; |
||||
|
||||
for (int i = startOffset; i < endOffset; i++) { |
||||
char ch = document.GetCharAt (i); |
||||
switch (ch) { |
||||
case '(': |
||||
case '[': |
||||
case '{': |
||||
if (!isInString && !isInChar && !isInLineComment && !isInBlockComment) |
||||
bracketStack.Push (ch); |
||||
break; |
||||
case ')': |
||||
case ']': |
||||
case '}': |
||||
if (!isInString && !isInChar && !isInLineComment && !isInBlockComment) |
||||
if (bracketStack.Count > 0) |
||||
bracketStack.Pop (); |
||||
break; |
||||
case '\r': |
||||
case '\n': |
||||
isInLineComment = false; |
||||
break; |
||||
case '/': |
||||
if (isInBlockComment) { |
||||
if (i > 0 && document.GetCharAt (i - 1) == '*') |
||||
isInBlockComment = false; |
||||
} else if (!isInString && !isInChar && i + 1 < document.TextLength) { |
||||
char nextChar = document.GetCharAt (i + 1); |
||||
if (nextChar == '/') |
||||
isInLineComment = true; |
||||
if (!isInLineComment && nextChar == '*') |
||||
isInBlockComment = true; |
||||
} |
||||
break; |
||||
case '"': |
||||
if (!(isInChar || isInLineComment || isInBlockComment)) |
||||
isInString = !isInString; |
||||
break; |
||||
case '\'': |
||||
if (!(isInString || isInLineComment || isInBlockComment)) |
||||
isInChar = !isInChar; |
||||
break; |
||||
default : |
||||
break; |
||||
} |
||||
} |
||||
return bracketStack.Any (t => t == '{'); |
||||
} |
||||
|
||||
public Tuple<string, TextLocation> GetMemberTextToCaret(int caretOffset, IUnresolvedTypeDefinition currentType, IUnresolvedMember currentMember) |
||||
{ |
||||
int startOffset; |
||||
if (currentMember != null && currentType != null && currentType.Kind != TypeKind.Enum) { |
||||
startOffset = document.GetOffset(currentMember.Region.Begin); |
||||
} else if (currentType != null) { |
||||
startOffset = document.GetOffset(currentType.Region.Begin); |
||||
} else { |
||||
startOffset = 0; |
||||
} |
||||
while (startOffset > 0) { |
||||
char ch = document.GetCharAt(startOffset - 1); |
||||
if (ch != ' ' && ch != '\t') { |
||||
break; |
||||
} |
||||
--startOffset; |
||||
} |
||||
|
||||
return Tuple.Create (document.GetText (startOffset, caretOffset - startOffset), document.GetLocation (startOffset)); |
||||
} |
||||
|
||||
|
||||
public CSharpAstResolver GetResolver (CSharpResolver resolver, AstNode rootNode) |
||||
{ |
||||
return new CSharpAstResolver (resolver, rootNode, unresolvedFile); |
||||
} |
||||
|
||||
|
||||
} |
||||
} |
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,151 @@
@@ -0,0 +1,151 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// 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 ICSharpCode.NRefactory.TypeSystem.Implementation; |
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp |
||||
{ |
||||
/// <summary>
|
||||
/// C# compiler settings.
|
||||
/// </summary>
|
||||
[Serializable] |
||||
public class CompilerSettings : AbstractFreezable |
||||
{ |
||||
protected override void FreezeInternal() |
||||
{ |
||||
conditionalSymbols = FreezableHelper.FreezeList(conditionalSymbols); |
||||
specificWarningsAsErrors = FreezableHelper.FreezeList(specificWarningsAsErrors); |
||||
disabledWarnings = FreezableHelper.FreezeList(disabledWarnings); |
||||
base.FreezeInternal(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Creates a new CompilerSettings instance.
|
||||
/// </summary>
|
||||
public CompilerSettings() |
||||
{ |
||||
} |
||||
|
||||
bool allowUnsafeBlocks = true; |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets whether <c>unsafe</c> code is allowed.
|
||||
/// The default is <c>true</c>. If set to false, parsing unsafe code will result in parser errors.
|
||||
/// </summary>
|
||||
public bool AllowUnsafeBlocks { |
||||
get { return allowUnsafeBlocks; } |
||||
set { |
||||
FreezableHelper.ThrowIfFrozen(this); |
||||
allowUnsafeBlocks = value; |
||||
} |
||||
} |
||||
|
||||
bool checkForOverflow; |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets whether overflow checking is enabled.
|
||||
/// The default is <c>false</c>. This setting effects semantic analysis.
|
||||
/// </summary>
|
||||
public bool CheckForOverflow { |
||||
get { return checkForOverflow; } |
||||
set { checkForOverflow = value; } |
||||
} |
||||
|
||||
Version languageVersion = new Version((int)Mono.CSharp.LanguageVersion.Default, 0); |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the language version used by the parser.
|
||||
/// Using language constructs newer than the supplied version will result in parser errors.
|
||||
/// </summary>
|
||||
public Version LanguageVersion { |
||||
get { return languageVersion; } |
||||
set { |
||||
FreezableHelper.ThrowIfFrozen(this); |
||||
if (value == null) |
||||
throw new ArgumentNullException(); |
||||
languageVersion = value; |
||||
} |
||||
} |
||||
|
||||
IList<string> conditionalSymbols = new List<string>(); |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the list of conditional symbols that are defined project-wide.
|
||||
/// </summary>
|
||||
public IList<string> ConditionalSymbols { |
||||
get { return conditionalSymbols; } |
||||
} |
||||
|
||||
bool treatWarningsAsErrors; |
||||
|
||||
public bool TreatWarningsAsErrors { |
||||
get { return treatWarningsAsErrors; } |
||||
set { |
||||
FreezableHelper.ThrowIfFrozen(this); |
||||
treatWarningsAsErrors = value; |
||||
} |
||||
} |
||||
|
||||
IList<int> specificWarningsAsErrors = new List<int>(); |
||||
|
||||
/// <summary>
|
||||
/// Allows treating specific warnings as errors without setting <see cref="TreatWarningsAsErrors"/> to true.
|
||||
/// </summary>
|
||||
public IList<int> SpecificWarningsAsErrors { |
||||
get { return specificWarningsAsErrors; } |
||||
} |
||||
|
||||
int warningLevel = 4; |
||||
|
||||
public int WarningLevel { |
||||
get { return warningLevel; } |
||||
set { |
||||
FreezableHelper.ThrowIfFrozen(this); |
||||
warningLevel = value; |
||||
} |
||||
} |
||||
|
||||
IList<int> disabledWarnings = new List<int>(); |
||||
|
||||
/// <summary>
|
||||
/// Allows treating specific warnings as errors without setting <see cref="TreatWarningsAsErrors"/> to true.
|
||||
/// </summary>
|
||||
public IList<int> DisabledWarnings { |
||||
get { return disabledWarnings; } |
||||
} |
||||
|
||||
internal Mono.CSharp.CompilerSettings ToMono() |
||||
{ |
||||
var s = new Mono.CSharp.CompilerSettings(); |
||||
s.Unsafe = allowUnsafeBlocks; |
||||
s.Checked = checkForOverflow; |
||||
s.Version = (Mono.CSharp.LanguageVersion)languageVersion.Major; |
||||
s.WarningsAreErrors = treatWarningsAsErrors; |
||||
s.WarningLevel = warningLevel; |
||||
foreach (int code in disabledWarnings) |
||||
s.SetIgnoreWarning(code); |
||||
foreach (int code in specificWarningsAsErrors) |
||||
s.AddWarningAsError(code); |
||||
foreach (string sym in conditionalSymbols) |
||||
s.AddConditionalSymbol(sym); |
||||
return s; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,103 @@
@@ -0,0 +1,103 @@
|
||||
//
|
||||
// SeekableStreamReader.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <mkrueger@xamarin.com>
|
||||
//
|
||||
// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
|
||||
//
|
||||
// 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 ICSharpCode.NRefactory.Editor; |
||||
using System.IO; |
||||
using System.Text; |
||||
|
||||
namespace Mono.CSharp |
||||
{ |
||||
public class SeekableStreamReader : IDisposable |
||||
{ |
||||
public const int DefaultReadAheadSize = 2048; |
||||
|
||||
readonly ITextSource textSource; |
||||
|
||||
int pos; |
||||
|
||||
static string GetAllText(Stream stream, Encoding encoding) { |
||||
using (var rdr = new StreamReader(stream, encoding)) { |
||||
return rdr.ReadToEnd(); |
||||
} |
||||
} |
||||
|
||||
public SeekableStreamReader (Stream stream, Encoding encoding, char[] sharedBuffer = null) : this(new StringTextSource(GetAllText(stream, encoding))) |
||||
{ |
||||
} |
||||
|
||||
public SeekableStreamReader (ITextSource source) |
||||
{ |
||||
this.textSource = source; |
||||
} |
||||
|
||||
|
||||
public void Dispose () |
||||
{ |
||||
} |
||||
|
||||
/// <remarks>
|
||||
/// This value corresponds to the current position in a stream of characters.
|
||||
/// The StreamReader hides its manipulation of the underlying byte stream and all
|
||||
/// character set/decoding issues. Thus, we cannot use this position to guess at
|
||||
/// the corresponding position in the underlying byte stream even though there is
|
||||
/// a correlation between them.
|
||||
/// </remarks>
|
||||
public int Position { |
||||
get { |
||||
return pos; |
||||
} |
||||
|
||||
set { |
||||
pos = value; |
||||
} |
||||
} |
||||
|
||||
public char GetChar (int position) |
||||
{ |
||||
return textSource.GetCharAt (position); |
||||
} |
||||
|
||||
public char[] ReadChars (int fromPosition, int toPosition) |
||||
{ |
||||
return textSource.GetText (fromPosition, toPosition - fromPosition).ToCharArray (); |
||||
} |
||||
|
||||
public int Peek () |
||||
{ |
||||
if (pos >= textSource.TextLength) |
||||
return -1; |
||||
return textSource.GetCharAt (pos); |
||||
} |
||||
|
||||
public int Read () |
||||
{ |
||||
if (pos >= textSource.TextLength) |
||||
return -1; |
||||
return textSource.GetCharAt (pos++); |
||||
} |
||||
} |
||||
} |
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,357 @@
@@ -0,0 +1,357 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics; |
||||
using System.Globalization; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using ICSharpCode.NRefactory.PatternMatching; |
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp { |
||||
public class QueryExpressionExpansionResult { |
||||
public AstNode AstNode { get; private set; } |
||||
|
||||
/// <summary>
|
||||
/// Maps original range variables to some node in the new tree that represents them.
|
||||
/// </summary>
|
||||
public IDictionary<Identifier, AstNode> RangeVariables { get; private set; } |
||||
|
||||
/// <summary>
|
||||
/// Maps clauses to method calls. The keys will always be either a <see cref="QueryClause"/> or a <see cref="QueryOrdering"/>
|
||||
/// </summary>
|
||||
public IDictionary<AstNode, Expression> Expressions { get; private set; } |
||||
|
||||
public QueryExpressionExpansionResult(AstNode astNode, IDictionary<Identifier, AstNode> rangeVariables, IDictionary<AstNode, Expression> expressions) { |
||||
AstNode = astNode; |
||||
RangeVariables = rangeVariables; |
||||
Expressions = expressions; |
||||
} |
||||
} |
||||
|
||||
public class QueryExpressionExpander { |
||||
class Visitor : DepthFirstAstVisitor<AstNode> { |
||||
int currentTransparentParameter; |
||||
const string TransparentParameterNameTemplate = "<>x{0}"; |
||||
|
||||
protected override AstNode VisitChildren(AstNode node) { |
||||
List<AstNode> newChildren = null; |
||||
|
||||
int i = 0; |
||||
foreach (var child in node.Children) { |
||||
var newChild = child.AcceptVisitor(this); |
||||
if (newChild != null) { |
||||
newChildren = newChildren ?? Enumerable.Repeat((AstNode)null, i).ToList(); |
||||
newChildren.Add(newChild); |
||||
} |
||||
else if (newChildren != null) { |
||||
newChildren.Add(null); |
||||
} |
||||
i++; |
||||
} |
||||
|
||||
if (newChildren == null) |
||||
return null; |
||||
|
||||
var result = node.Clone(); |
||||
|
||||
i = 0; |
||||
foreach (var children in result.Children) { |
||||
if (newChildren[i] != null) |
||||
children.ReplaceWith(newChildren[i]); |
||||
i++; |
||||
} |
||||
|
||||
return result; |
||||
} |
||||
|
||||
Expression MakeNestedMemberAccess(Expression target, IEnumerable<string> members) { |
||||
return members.Aggregate(target, (current, m) => current.Member(m)); |
||||
} |
||||
|
||||
Expression VisitNested(Expression node, ParameterDeclaration transparentParameter) { |
||||
var oldRangeVariableSubstitutions = activeRangeVariableSubstitutions; |
||||
try { |
||||
if (transparentParameter != null && currentTransparentType.Count > 1) { |
||||
activeRangeVariableSubstitutions = new Dictionary<string, Expression>(activeRangeVariableSubstitutions); |
||||
foreach (var t in currentTransparentType) |
||||
activeRangeVariableSubstitutions[t.Item1.Name] = MakeNestedMemberAccess(new IdentifierExpression(transparentParameter.Name), t.Item2); |
||||
} |
||||
var result = node.AcceptVisitor(this); |
||||
return (Expression)(result ?? node.Clone()); |
||||
} |
||||
finally { |
||||
activeRangeVariableSubstitutions = oldRangeVariableSubstitutions; |
||||
} |
||||
} |
||||
|
||||
QueryClause GetNextQueryClause(QueryClause clause) { |
||||
for (AstNode node = clause.NextSibling; node != null; node = node.NextSibling) { |
||||
if (node.Role == QueryExpression.ClauseRole) |
||||
return (QueryClause)node; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public IDictionary<Identifier, AstNode> rangeVariables = new Dictionary<Identifier, AstNode>(); |
||||
public IDictionary<AstNode, Expression> expressions = new Dictionary<AstNode, Expression>(); |
||||
|
||||
Dictionary<string, Expression> activeRangeVariableSubstitutions = new Dictionary<string, Expression>(); |
||||
List<Tuple<Identifier, List<string>>> currentTransparentType = new List<Tuple<Identifier, List<string>>>(); |
||||
Expression currentResult; |
||||
bool eatSelect; |
||||
|
||||
void MapExpression(AstNode orig, Expression newExpr) { |
||||
Debug.Assert(orig is QueryClause || orig is QueryOrdering); |
||||
expressions[orig] = newExpr; |
||||
} |
||||
|
||||
ParameterDeclaration CreateParameterForCurrentRangeVariable() { |
||||
var param = new ParameterDeclaration(); |
||||
|
||||
if (currentTransparentType.Count == 1) { |
||||
var clonedRangeVariable = (Identifier)currentTransparentType[0].Item1.Clone(); |
||||
if (!rangeVariables.ContainsKey(currentTransparentType[0].Item1)) |
||||
rangeVariables[currentTransparentType[0].Item1] = param; |
||||
param.AddChild(clonedRangeVariable, Roles.Identifier); |
||||
} |
||||
else { |
||||
param.AddChild(Identifier.Create(string.Format(CultureInfo.InvariantCulture, TransparentParameterNameTemplate, currentTransparentParameter++)), Roles.Identifier); |
||||
} |
||||
return param; |
||||
} |
||||
|
||||
LambdaExpression CreateLambda(IList<ParameterDeclaration> parameters, Expression body) { |
||||
var result = new LambdaExpression(); |
||||
if (parameters.Count > 1) |
||||
result.AddChild(new CSharpTokenNode(TextLocation.Empty), Roles.LPar); |
||||
result.AddChild(parameters[0], Roles.Parameter); |
||||
for (int i = 1; i < parameters.Count; i++) { |
||||
result.AddChild(new CSharpTokenNode(TextLocation.Empty), Roles.Comma); |
||||
result.AddChild(parameters[i], Roles.Parameter); |
||||
} |
||||
if (parameters.Count > 1) |
||||
result.AddChild(new CSharpTokenNode(TextLocation.Empty), Roles.RPar); |
||||
result.AddChild(body, LambdaExpression.BodyRole); |
||||
|
||||
return result; |
||||
} |
||||
|
||||
ParameterDeclaration CreateParameter(Identifier identifier) { |
||||
var result = new ParameterDeclaration(); |
||||
result.AddChild(identifier, Roles.Identifier); |
||||
return result; |
||||
} |
||||
|
||||
Expression AddMemberToCurrentTransparentType(ParameterDeclaration param, Identifier name, Expression value, bool namedExpression) { |
||||
Expression newAssignment = VisitNested(value, param); |
||||
if (namedExpression) { |
||||
newAssignment = new NamedExpression(name.Name, VisitNested(value, param)); |
||||
if (!rangeVariables.ContainsKey(name) ) |
||||
rangeVariables[name] = ((NamedExpression)newAssignment).NameToken; |
||||
} |
||||
|
||||
foreach (var t in currentTransparentType) |
||||
t.Item2.Insert(0, param.Name); |
||||
|
||||
currentTransparentType.Add(Tuple.Create(name, new List<string> { name.Name })); |
||||
return new AnonymousTypeCreateExpression(new[] { new IdentifierExpression(param.Name), newAssignment }); |
||||
} |
||||
|
||||
void AddFirstMemberToCurrentTransparentType(Identifier identifier) { |
||||
Debug.Assert(currentTransparentType.Count == 0); |
||||
currentTransparentType.Add(Tuple.Create(identifier, new List<string>())); |
||||
} |
||||
|
||||
public override AstNode VisitQueryExpression(QueryExpression queryExpression) { |
||||
var oldTransparentType = currentTransparentType; |
||||
var oldResult = currentResult; |
||||
var oldEatSelect = eatSelect; |
||||
try { |
||||
currentTransparentType = new List<Tuple<Identifier, List<string>>>(); |
||||
currentResult = null; |
||||
eatSelect = false; |
||||
|
||||
foreach (var clause in queryExpression.Clauses) { |
||||
var result = (Expression)clause.AcceptVisitor(this); |
||||
MapExpression(clause, result ?? currentResult); |
||||
currentResult = result; |
||||
} |
||||
|
||||
return currentResult; |
||||
} |
||||
finally { |
||||
currentTransparentType = oldTransparentType; |
||||
currentResult = oldResult; |
||||
eatSelect = oldEatSelect; |
||||
} |
||||
} |
||||
|
||||
public override AstNode VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause) { |
||||
var prev = VisitNested(queryContinuationClause.PrecedingQuery, null); |
||||
AddFirstMemberToCurrentTransparentType(queryContinuationClause.IdentifierToken); |
||||
return prev; |
||||
} |
||||
|
||||
public override AstNode VisitQueryFromClause(QueryFromClause queryFromClause) { |
||||
if (currentResult == null) { |
||||
AddFirstMemberToCurrentTransparentType(queryFromClause.IdentifierToken); |
||||
if (queryFromClause.Type.IsNull) { |
||||
return VisitNested(queryFromClause.Expression, null); |
||||
} |
||||
else { |
||||
return VisitNested(queryFromClause.Expression, null).Invoke("Cast", new[] { queryFromClause.Type.Clone() }, new Expression[0]); |
||||
} |
||||
} |
||||
else { |
||||
var innerSelectorParam = CreateParameterForCurrentRangeVariable(); |
||||
var innerSelector = CreateLambda(new[] { innerSelectorParam }, VisitNested(queryFromClause.Expression, innerSelectorParam)); |
||||
|
||||
var clonedIdentifier = (Identifier)queryFromClause.IdentifierToken.Clone(); |
||||
|
||||
var resultParam = CreateParameterForCurrentRangeVariable(); |
||||
Expression body; |
||||
// Second from clause - SelectMany
|
||||
var select = GetNextQueryClause(queryFromClause) as QuerySelectClause; |
||||
if (select != null) { |
||||
body = VisitNested(select.Expression, resultParam); |
||||
eatSelect = true; |
||||
} |
||||
else { |
||||
body = AddMemberToCurrentTransparentType(resultParam, queryFromClause.IdentifierToken, new IdentifierExpression(queryFromClause.Identifier), false); |
||||
} |
||||
|
||||
var resultSelectorParam2 = CreateParameter(clonedIdentifier); |
||||
var resultSelector = CreateLambda(new[] { resultParam, resultSelectorParam2 }, body); |
||||
rangeVariables[queryFromClause.IdentifierToken] = resultSelectorParam2; |
||||
|
||||
return currentResult.Invoke("SelectMany", innerSelector, resultSelector); |
||||
} |
||||
} |
||||
|
||||
public override AstNode VisitQueryLetClause(QueryLetClause queryLetClause) { |
||||
var param = CreateParameterForCurrentRangeVariable(); |
||||
var body = AddMemberToCurrentTransparentType(param, queryLetClause.IdentifierToken, queryLetClause.Expression, true); |
||||
var lambda = CreateLambda(new[] { param }, body); |
||||
|
||||
return currentResult.Invoke("Select", lambda); |
||||
} |
||||
|
||||
public override AstNode VisitQueryWhereClause(QueryWhereClause queryWhereClause) { |
||||
var param = CreateParameterForCurrentRangeVariable(); |
||||
return currentResult.Invoke("Where", CreateLambda(new[] { param }, VisitNested(queryWhereClause.Condition, param))); |
||||
} |
||||
|
||||
public override AstNode VisitQueryJoinClause(QueryJoinClause queryJoinClause) { |
||||
Expression resultSelectorBody = null; |
||||
var inExpression = VisitNested(queryJoinClause.InExpression, null); |
||||
var key1SelectorFirstParam = CreateParameterForCurrentRangeVariable(); |
||||
var key1Selector = CreateLambda(new[] { key1SelectorFirstParam }, VisitNested(queryJoinClause.OnExpression, key1SelectorFirstParam)); |
||||
var key2Param = CreateParameter(Identifier.Create(queryJoinClause.JoinIdentifier)); |
||||
var key2Selector = CreateLambda(new[] { key2Param }, VisitNested(queryJoinClause.EqualsExpression, null)); |
||||
|
||||
var resultSelectorFirstParam = CreateParameterForCurrentRangeVariable(); |
||||
|
||||
var select = GetNextQueryClause(queryJoinClause) as QuerySelectClause; |
||||
if (select != null) { |
||||
resultSelectorBody = VisitNested(select.Expression, resultSelectorFirstParam); |
||||
eatSelect = true; |
||||
} |
||||
|
||||
if (queryJoinClause.IntoKeyword.IsNull) { |
||||
// Normal join
|
||||
if (resultSelectorBody == null) |
||||
resultSelectorBody = AddMemberToCurrentTransparentType(resultSelectorFirstParam, queryJoinClause.JoinIdentifierToken, new IdentifierExpression(queryJoinClause.JoinIdentifier), false); |
||||
|
||||
var resultSelector = CreateLambda(new[] { resultSelectorFirstParam, CreateParameter(Identifier.Create(queryJoinClause.JoinIdentifier)) }, resultSelectorBody); |
||||
rangeVariables[queryJoinClause.JoinIdentifierToken] = key2Param; |
||||
return currentResult.Invoke("Join", inExpression, key1Selector, key2Selector, resultSelector); |
||||
} |
||||
else { |
||||
// Group join
|
||||
if (resultSelectorBody == null) |
||||
resultSelectorBody = AddMemberToCurrentTransparentType(resultSelectorFirstParam, queryJoinClause.IntoIdentifierToken, new IdentifierExpression(queryJoinClause.IntoIdentifier), false); |
||||
|
||||
var intoParam = CreateParameter(Identifier.Create(queryJoinClause.IntoIdentifier)); |
||||
var resultSelector = CreateLambda(new[] { resultSelectorFirstParam, intoParam }, resultSelectorBody); |
||||
rangeVariables[queryJoinClause.IntoIdentifierToken] = intoParam; |
||||
|
||||
return currentResult.Invoke("GroupJoin", inExpression, key1Selector, key2Selector, resultSelector); |
||||
} |
||||
} |
||||
|
||||
public override AstNode VisitQueryOrderClause(QueryOrderClause queryOrderClause) { |
||||
var current = currentResult; |
||||
bool first = true; |
||||
foreach (var o in queryOrderClause.Orderings) { |
||||
string methodName = first ? (o.Direction == QueryOrderingDirection.Descending ? "OrderByDescending" : "OrderBy") |
||||
: (o.Direction == QueryOrderingDirection.Descending ? "ThenByDescending" : "ThenBy"); |
||||
|
||||
var param = CreateParameterForCurrentRangeVariable(); |
||||
current = current.Invoke(methodName, CreateLambda(new[] { param }, VisitNested(o.Expression, param))); |
||||
MapExpression(o, current); |
||||
first = false; |
||||
} |
||||
return current; |
||||
} |
||||
|
||||
bool IsSingleRangeVariable(Expression expr) { |
||||
if (currentTransparentType.Count > 1) |
||||
return false; |
||||
var unpacked = ParenthesizedExpression.UnpackParenthesizedExpression(expr); |
||||
return unpacked is IdentifierExpression && ((IdentifierExpression)unpacked).Identifier == currentTransparentType[0].Item1.Name; |
||||
} |
||||
|
||||
public override AstNode VisitQuerySelectClause(QuerySelectClause querySelectClause) { |
||||
if (eatSelect) { |
||||
eatSelect = false; |
||||
return currentResult; |
||||
} |
||||
else if (((QueryExpression)querySelectClause.Parent).Clauses.Count > 2 && IsSingleRangeVariable(querySelectClause.Expression)) { |
||||
// A simple query that ends with a trivial select should be removed.
|
||||
return currentResult; |
||||
} |
||||
|
||||
var param = CreateParameterForCurrentRangeVariable(); |
||||
var lambda = CreateLambda(new[] { param }, VisitNested(querySelectClause.Expression, param)); |
||||
return currentResult.Invoke("Select", lambda); |
||||
} |
||||
|
||||
public override AstNode VisitQueryGroupClause(QueryGroupClause queryGroupClause) { |
||||
var param = CreateParameterForCurrentRangeVariable(); |
||||
var keyLambda = CreateLambda(new[] { param }, VisitNested(queryGroupClause.Key, param)); |
||||
|
||||
if (IsSingleRangeVariable(queryGroupClause.Projection)) { |
||||
// We are grouping by the single active range variable, so we can use the single argument form of GroupBy
|
||||
return currentResult.Invoke("GroupBy", keyLambda); |
||||
} |
||||
else { |
||||
var projectionParam = CreateParameterForCurrentRangeVariable(); |
||||
var projectionLambda = CreateLambda(new[] { projectionParam }, VisitNested(queryGroupClause.Projection, projectionParam)); |
||||
return currentResult.Invoke("GroupBy", keyLambda, projectionLambda); |
||||
} |
||||
} |
||||
|
||||
public override AstNode VisitIdentifierExpression(IdentifierExpression identifierExpression) { |
||||
Expression subst; |
||||
activeRangeVariableSubstitutions.TryGetValue(identifierExpression.Identifier, out subst); |
||||
return subst != null ? subst.Clone() : null; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Expands all occurances of query patterns in the specified node. Returns a clone of the node with all query patterns expanded, or null if there was no query pattern to expand.
|
||||
/// </summary>
|
||||
/// <param name="node"></param>
|
||||
/// <returns></returns>
|
||||
public QueryExpressionExpansionResult ExpandQueryExpressions(AstNode node) { |
||||
var visitor = new Visitor(); |
||||
var astNode = node.AcceptVisitor(visitor); |
||||
if (astNode != null) { |
||||
astNode.Freeze(); |
||||
return new QueryExpressionExpansionResult(astNode, visitor.rangeVariables, visitor.expressions); |
||||
} |
||||
else { |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,59 @@
@@ -0,0 +1,59 @@
|
||||
//
|
||||
// AddCatchTypeAction.cs
|
||||
//
|
||||
// Author:
|
||||
// Simon Lindgren <simon.n.lindgren@gmail.com>
|
||||
//
|
||||
// Copyright (c) 2012 Simon Lindgren
|
||||
//
|
||||
// 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 ICSharpCode.NRefactory.CSharp; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp.Refactoring |
||||
{ |
||||
[ContextAction("Add type", |
||||
Description = "Adds an exception type specifier to catch clauses.")] |
||||
public class AddCatchTypeAction : ICodeActionProvider |
||||
{ |
||||
#region ICodeActionProvider implementation
|
||||
|
||||
public IEnumerable<CodeAction> GetActions(RefactoringContext context) |
||||
{ |
||||
var catchClause = context.GetNode<CatchClause>(); |
||||
if (catchClause == null) |
||||
yield break; |
||||
if (!catchClause.Type.IsNull) |
||||
yield break; |
||||
yield return new CodeAction(context.TranslateString("Add type specifier"), script => { |
||||
var newIdentifier = Identifier.Create("e"); |
||||
var newType = context.CreateShortType("System", "Exception"); |
||||
script.Replace(catchClause, new CatchClause() { |
||||
Type = newType, |
||||
VariableNameToken = newIdentifier, |
||||
Body = catchClause.Body.Clone() as BlockStatement |
||||
}); |
||||
script.Link(newType); |
||||
script.Link(newIdentifier); |
||||
}); |
||||
} |
||||
|
||||
#endregion
|
||||
} |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue