New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code Rewriting #599
Closed
Closed
Code Rewriting #599
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7428c4e
Created RewritingFilePreProcessor. Added tests.
jjrdk 48e69cc
Moved rewriter tests to ScriptCs.Engine.Roslyn.Tests.
jjrdk 0a5bbf2
Removed unused dependencies.
jjrdk 64e7951
Merge branch 'dev' into rewriting
jjrdk 4a10ea5
Fixed code style.
jjrdk ffc0239
Adding code rewriter registration infrastructure.
jjrdk 62ceaee
Continuing infrastructure wireup.
jjrdk d806ff7
Merge branch 'dev' of https://github.com/scriptcs/scriptcs into rewri…
jjrdk 5db29ca
Changed signature of ICodeRewriter to use FilePreProcessorResult.
jjrdk dcc2103
Code cleanup.
jjrdk 93b3377
Changed failing test.
jjrdk 7be3d97
Merge branch 'dev' into rewriting
jjrdk File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace ScriptCs.Contracts | ||
{ | ||
public interface ICodeRewriter | ||
{ | ||
FilePreProcessorResult Rewrite(FilePreProcessorResult code); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
namespace ScriptCs | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
using Common.Logging; | ||
|
||
using ScriptCs.Contracts; | ||
|
||
public class RewritingFilePreProcessor : FilePreProcessor | ||
{ | ||
private readonly IEnumerable<ICodeRewriter> _rewriters; | ||
|
||
public RewritingFilePreProcessor(IFileSystem fileSystem, ILog logger, IEnumerable<ILineProcessor> lineProcessors, IEnumerable<ICodeRewriter> rewriters) | ||
: base(fileSystem, logger, lineProcessors) | ||
{ | ||
_rewriters = rewriters; | ||
} | ||
|
||
protected override FilePreProcessorResult Process(Action<FileParserContext> parseAction) | ||
{ | ||
var result = base.Process(parseAction); | ||
|
||
var rewrittenResult = _rewriters.Aggregate(result, (r, rewriter) => rewriter.Rewrite(r)); | ||
|
||
return rewrittenResult; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ namespace ScriptCs.Hosting | |
{ | ||
public interface IScriptServicesBuilder : IServiceOverrides<IScriptServicesBuilder> | ||
{ | ||
ScriptServices Build(); | ||
ScriptServices Build(IModuleConfiguration config); | ||
|
||
IScriptServicesBuilder Cache(bool cache = true); | ||
|
||
|
@@ -16,6 +16,6 @@ public interface IScriptServicesBuilder : IServiceOverrides<IScriptServicesBuild | |
|
||
IScriptServicesBuilder LogLevel(LogLevel level); | ||
|
||
IScriptServicesBuilder LoadModules(string extension, params string[] moduleNames); | ||
IModuleConfiguration LoadModules(string extension, params string[] moduleNames); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does this change to return IModuleConfiguration? This breaks the fluent API. |
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jjrdk, this will break all existing implementers of modules. Why are you changing the signature?