5. Edit and
IL Emitter
Continue
Emit API
Go To Definition
Extract Method
Signature Help
Binding and Flow
Analysis APIs
Binder
Quick Info
Rename
Find All
References
Completion List
Symbol API
Metadata
Symbols
Import
Object Browser
Navigate To
Syntax Tree API
Outlining
Parser
Colorizer
Formatter
Compiler API
Language
Compiler
Pipeline
Service
6. Editor Services Code Actions Classification Completion Outlining …
Code Formatting Find All References Name Simplification …
Services
Workspace API
Syntax Tree Symbol Binding and Flow Scripting
Compiler API API Analysis APIs
Emit API
API
8. class C CompilationUnit
{
void M()
{ TypeDeclaration
}
}// C
MethodDeclaration
ParameterList Block
var tree = SyntaxTree.ParseCompilationUnit("...");
9. class C CompilationUnit
{
void M()
{ TypeDeclaration EOF
}
}// C
class C { MethodDeclaration }
void M ParameterList Block
( ) { }
10. class∙C CompilationUnit
{
∙∙∙∙void∙M()
∙∙∙∙{ TypeDeclaration EOF
∙∙∙∙}
}// C
class SP C EOL { EOL MethodDeclaration } // C EOL
SPx4 void SP M ParameterList Block
( ) EOL
SPx4 { EOL SPx4 } EOL
11. class C CompilationUnit
{
void M()
{ TypeDeclaration EOF
}
}// C
class C { MethodDeclaration }
void M ParameterList Block
( ) { }
12. class C CompilationUnit
{
void M(int x)
{ TypeDeclaration EOF
}
}// C
class C { MethodDeclaration }
void M ParameterList Block
var oldList = method.ParameterList;
var newList = oldList.Update( ( ) { }
openParenToken: oldList.OpenParenToken,
parameters: Syntax.SeparatedList(
var oldList = method.ParameterList;
Syntax.Parameter(
var newList = oldList.Update(
typeOpt: Syntax.ParseTypeName("int "),
openParenToken: oldList.OpenParenToken,
identifier: Syntax.Identifier("x"))),
parameters: Syntax.ParseParameterList("(int x)").Parameters,
closeParenToken: oldList.CloseParenToken);
var newRoot = tree.Root.ReplaceNode(oldList, newList);
13. class C CompilationUnit
{
void M(int x)
{ TypeDeclaration EOF
}
}// C
class C { MethodDeclaration }
void M ParameterList Block
( Parameter ) { }
var oldList = method.ParameterList; PredefinedType x
var newList = oldList.Update(
openParenToken: oldList.OpenParenToken,
parameters: Syntax.ParseParameterList("(int x)").Parameters,
closeParenToken: oldList.CloseParenToken); int
var newRoot = tree.Root.ReplaceNode(oldList, newList);
14. class C CompilationUnit
{
void M(int x)
{ TypeDeclaration EOF
}
}// C
class C { MethodDeclaration }
void M ParameterList Block
( Parameter ) { }
var oldList = method.ParameterList; PredefinedType x
var newList = oldList.Update(
openParenToken: oldList.OpenParenToken,
parameters: Syntax.ParseParameterList("(int x)").Parameters,
closeParenToken: oldList.CloseParenToken); int
var newRoot = tree.Root.ReplaceNode(oldList, newList);
15. Syntax
Trees
Compilation
• Symbols
• Semantic Model
• Flow Analysis
• Diagnostics
• Emit
References
19. Code Action A representation of a code change
• Produces both an edit and a preview of that edit
Code Issue An interesting span of source code
• Called for every node, token or trivia in a source file
• Optional: May be squiggled in the editor and shown in the Error List
• Optional: May provide one or more Code Actions
Code Refactoring A contextually-available Code Action
• Operates on the current selection in the editor
• Must provide one or more Code Actions