本文整理汇总了C#中EditorContext类的典型用法代码示例。如果您正苦于以下问题:C# EditorContext类的具体用法?C# EditorContext怎么用?C# EditorContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EditorContext类属于命名空间,在下文中一共展示了EditorContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
public void Initialize(EditorContext context)
{
// class at caret (either declaration of usage)
this.Class = GetClass(context.CurrentSymbol);
if (this.Class == null)
return;
var c = this.Class;
// TODO cache
var classDecls = context.GetClassDeclarationsOnCurrentLine().ToList();
this.IsCaretAtClassDeclaration = classDecls.Count == 1 && (classDecls[0].FullyQualifiedName == c.FullyQualifiedName);
this.IsClassFileNameCorrect = (c.IsInnerClass() || (!c.IsUserCode()) ||
c.Name.Equals(Path.GetFileNameWithoutExtension(c.CompilationUnit.FileName), StringComparison.OrdinalIgnoreCase));
if (string.IsNullOrEmpty(c.Name) || c.CompilationUnit == null || string.IsNullOrEmpty(c.CompilationUnit.FileName)) {
// Cannot get path
this.CorrectClassFileName = null;
this.IsCorrectClassFileNameAvailable = false;
return;
}
this.CorrectClassFileName = Path.Combine(Path.GetDirectoryName(c.CompilationUnit.FileName),
c.Name + Path.GetExtension(c.CompilationUnit.FileName));
this.IsCorrectClassFileNameAvailable = (FileUtility.IsValidPath(CorrectClassFileName)
&& Path.IsPathRooted(CorrectClassFileName)
&& !File.Exists(CorrectClassFileName));
this.IsClassReadOnly = FindReferencesAndRenameHelper.IsReadOnly(this.Class);
}
示例2: CalculateEditorSize
protected override Size CalculateEditorSize(EditorContext context)
{
if (Parent.UseColumns)
return context.Bounds.Size;
else
return new Size(EditorWidth, context.Bounds.Height);
}
示例3: GetAddUsingAttributeActions
IEnumerable<IContextAction> GetAddUsingAttributeActions(EditorContext context)
{
ResolveResult symbol = context.CurrentSymbol;
if (!(symbol is UnknownIdentifierResolveResult || symbol is UnknownMethodResolveResult))
yield break;
List<IClass> results = new List<IClass>();
ParseInformation info = context.CurrentParseInformation;
if (info == null || info.CompilationUnit == null || info.CompilationUnit.ProjectContent == null)
yield break;
ICompilationUnit unit = info.CompilationUnit;
IProjectContent pc = info.CompilationUnit.ProjectContent;
string name = null;
if (symbol is UnknownMethodResolveResult) {
name = Search((UnknownMethodResolveResult)symbol, pc, results);
}
if (symbol is UnknownIdentifierResolveResult) {
name = Search((UnknownIdentifierResolveResult)symbol, pc, results);
} else {
yield break;
}
foreach (IClass c in results) {
yield return new RefactoringService.AddUsingAction(unit, context.Editor, c.Namespace);
}
}
示例4: Execute
public override void Execute(EditorContext context)
{
var cache = context.GetCached<CheckAssignmentCache>();
var ifStatement = GenerateAstToInsert(cache.VariableName);
context.Editor.InsertCodeAfter(cache.Element, ifStatement, true);
}
示例5: CalculateEditorSize
protected override Size CalculateEditorSize(EditorContext context)
{
if (Parent.HeaderStyle != ColumnHeaderStyle.None)
return context.Bounds.Size;
else
return new Size(EditorWidth, context.Bounds.Height);
}
示例6: GetAvailableActions
public IEnumerable<IContextAction> GetAvailableActions(EditorContext context)
{
// re-initialize the context
this.Context = context;
if (this.IsAvailable(context))
yield return this;
}
示例7: SetEditorBounds
public void SetEditorBounds(EditorContext context)
{
Size size = CalculateEditorSize(context);
context.Editor.Bounds = new Rectangle(context.Bounds.X, context.Bounds.Y,
Math.Min(size.Width, context.Bounds.Width),
Math.Min(size.Height, Parent.ClientSize.Height - context.Bounds.Y)
);
}
示例8: IsAvailable
public override bool IsAvailable(EditorContext context)
{
var paramAtCaret = GetParameterAtCaret(context.CurrentSymbol);
if (paramAtCaret == null)
return false;
return IsAvailable(paramAtCaret.ResolvedType);
}
示例9: Execute
public override void Execute(EditorContext context)
{
var paramAtCaret = GetParameterAtCaret(context);
if (paramAtCaret != null)
{
Extensions.AddCodeToMethodStart(paramAtCaret.CallingMember, context.Editor, GetCodeToInsert(paramAtCaret.VariableName));
}
}
示例10: GetAvailableActions
public override IEnumerable<IContextAction> GetAvailableActions(EditorContext editorContext)
{
foreach (var targetClass in editorContext.GetClassDeclarationsOnCurrentLine().Where(c => c.ClassType == ClassType.Class).Select(c2 => c2.GetCurrentClassPart(editorContext.Editor.FileName))) {
foreach (var implementAction in RefactoringService.GetImplementAbstractClassActions(targetClass)) {
yield return implementAction;
}
}
}
示例11: Execute
public override void Execute(EditorContext context)
{
IProject project = (IProject)ClassAtCaret.Class.ProjectContent.Project;
RefactoringHelpers.RenameFile(project, ClassAtCaret.Class.CompilationUnit.FileName, ClassAtCaret.CorrectClassFileName);
if (project != null) {
project.Save();
}
}
示例12: Initialize
public void Initialize(EditorContext context)
{
this.context = context;
this.VariableName = GetVariableName(context);
this.CodeGenerator = GetCodeGenerator(context);
this.Element = GetElement(context);
this.ElementRegion = (Element == null) ? DomRegion.Empty : DomRegion.FromLocation(Element.StartLocation, Element.EndLocation);
}
示例13: Execute
public override void Execute(EditorContext context)
{
var conditionExpr = BuildCondition(this.targetExpr);
if (conditionExpr == null)
return;
var ifExpr = new IfElseStatement(conditionExpr, new BlockStatement());
context.Editor.InsertCodeBefore(this.currentExpr, ifExpr);
}
示例14: CalculateEditorSize
protected override Size CalculateEditorSize(EditorContext context)
{
if (Parent.UseColumns)
return context.Bounds.Size;
else
{
Size size = GetLabelSize(context.CurrentNode, context.DrawContext, _label);
int width = Math.Max(size.Width + Font.Height, MinTextBoxWidth); // reserve a place for new typed character
return new Size(width, size.Height);
}
}
示例15: Execute
public override void Execute(EditorContext context)
{
var cache = context.GetCached<CheckAssignmentCache>();
var ifStatement = GenerateAstToInsert(cache.VariableName);
var editor = context.Editor;
string indent = DocumentUtilitites.GetWhitespaceAfter(editor.Document, editor.Document.GetLineStartOffset(cache.ElementRegion.GetStart()));
string code = cache.CodeGenerator.GenerateCode(ifStatement, indent);
int insertOffset = editor.Document.GetLineEndOffset(cache.ElementRegion.GetEnd());
editor.Document.Insert(insertOffset, code);
editor.Caret.Offset = insertOffset + code.Length - 1;
}