本文整理汇总了C#中DomLocation类的典型用法代码示例。如果您正苦于以下问题:C# DomLocation类的具体用法?C# DomLocation怎么用?C# DomLocation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DomLocation类属于命名空间,在下文中一共展示了DomLocation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Format
public static void Format (TextEditorData data, ProjectDom dom, DomLocation location, bool correctBlankLines)
{
PolicyContainer policyParent = dom != null && dom.Project != null? dom.Project.Policies
: PolicyService.DefaultPolicies;
var mimeTypeChain = DesktopService.GetMimeTypeInheritanceChain (CSharpFormatter.MimeType);
Format (policyParent, mimeTypeChain, data, dom, location, correctBlankLines);
}
示例2: GetResult
public GenerateNamespaceImport GetResult (ProjectDom dom, ICompilationUnit unit, IType type, TextEditorData data)
{
GenerateNamespaceImport result;
if (cache.TryGetValue (type.Namespace, out result))
return result;
result = new GenerateNamespaceImport ();
cache[type.Namespace] = result;
result.InsertNamespace = false;
DomLocation location = new DomLocation (data.Caret.Line, data.Caret.Column);
foreach (IUsing u in unit.Usings.Where (u => u.ValidRegion.Contains (location))) {
if (u.Namespaces.Any (ns => type.Namespace == ns)) {
result.GenerateUsing = false;
return result;
}
}
result.GenerateUsing = true;
string name = type.DecoratedFullName.Substring (type.Namespace.Length + 1);
foreach (IUsing u in unit.Usings.Where (u => u.ValidRegion.Contains (location))) {
foreach (string ns in u.Namespaces) {
if (dom.SearchType (unit, unit.GetTypeAt (location), unit.GetMemberAt (location), ns + "." + name) != null) {
result.GenerateUsing = false;
result.InsertNamespace = true;
return result;
}
}
}
return result;
}
示例3: Write
public static void Write (BinaryWriter writer, INameEncoder nameTable, DomLocation location)
{
if (WriteNull (writer, location))
return;
writer.Write (location.Line);
writer.Write (location.Column);
}
示例4: Format
public static void Format (MonoDevelop.Ide.Gui.Document data, ProjectDom dom, DomLocation location, bool correctBlankLines, bool runAferCR = false)
{
PolicyContainer policyParent = dom != null && dom.Project != null ? dom.Project.Policies
: PolicyService.DefaultPolicies;
var mimeTypeChain = DesktopService.GetMimeTypeInheritanceChain (CSharpFormatter.MimeType);
Format (policyParent, mimeTypeChain, data, dom, location, correctBlankLines, runAferCR);
}
示例5: IsValid
public override bool IsValid (RefactoringOptions options)
{
INRefactoryASTProvider provider = options.GetASTProvider ();
IResolver resolver = options.GetResolver ();
if (provider == null || resolver == null)
return false;
if (invoke == null)
invoke = GetInvocationExpression (options);
if (invoke == null)
return false;
returnType = DomReturnType.Void;
modifiers = ICSharpCode.NRefactory.Ast.Modifiers.None;
resolvePosition = new DomLocation (options.Document.Editor.Caret.Line + 1, options.Document.Editor.Caret.Column + 1);
ResolveResult resolveResult = resolver.Resolve (new ExpressionResult (provider.OutputNode (options.Dom, invoke)), resolvePosition);
if (resolveResult is MethodResolveResult) {
MethodResolveResult mrr = (MethodResolveResult)resolveResult ;
if (mrr.ExactMethodMatch)
return false;
returnType = mrr.MostLikelyMethod.ReturnType;
modifiers = (ICSharpCode.NRefactory.Ast.Modifiers)mrr.MostLikelyMethod.Modifiers;
}
if (invoke.TargetObject is MemberReferenceExpression) {
string callingObject = provider.OutputNode (options.Dom, ((MemberReferenceExpression)invoke.TargetObject).TargetObject);
resolveResult = resolver.Resolve (new ExpressionResult (callingObject), resolvePosition);
if (resolveResult == null || resolveResult.ResolvedType == null || resolveResult.CallingType == null)
return false;
IType type = options.Dom.GetType (resolveResult.ResolvedType);
return type != null && type.CompilationUnit != null && File.Exists (type.CompilationUnit.FileName) && RefactoringService.GetASTProvider (DesktopService.GetMimeTypeForUri (type.CompilationUnit.FileName)) != null;
}
return invoke.TargetObject is IdentifierExpression;
}
示例6: GetUsingScope
public UsingScope GetUsingScope(DomLocation location)
{
foreach (UsingScope scope in usingScopes) {
if (scope.Region.IsInside(location.Line, location.Column))
return scope;
}
return rootUsingScope;
}
示例7: GetTopLevelTypeDefinition
public ITypeDefinition GetTopLevelTypeDefinition(DomLocation location)
{
foreach (ITypeDefinition typeDef in topLevelTypeDefinitions) {
if (typeDef.Region.IsInside(location.Line, location.Column))
return typeDef;
}
return null;
}
示例8: ReadWriteLocationTest
public void ReadWriteLocationTest ()
{
DomLocation input = new DomLocation (3, 9);
MemoryStream ms = new MemoryStream ();
BinaryWriter writer = new BinaryWriter (ms);
DomPersistence.Write (writer, null, input);
byte[] bytes = ms.ToArray ();
DomLocation result = DomPersistence.ReadLocation (CreateReader (bytes), null);
Assert.AreEqual (3, result.Line);
Assert.AreEqual (9, result.Column);
}
示例9: ContextActionWidget
public ContextActionWidget (ContextActionEditorExtension ext, MonoDevelop.Ide.Gui.Document document, DomLocation loc, List<ContextAction> fixes)
{
this.ext = ext;
this.document = document;
this.loc = loc;
this.fixes = fixes;
Events = Gdk.EventMask.AllEventsMask;
icon = ImageService.GetPixbuf ("md-text-quickfix", Gtk.IconSize.Menu);
this.SetSizeRequest (Math.Max ((int)document.Editor.LineHeight , icon.Width) + 4, (int)document.Editor.LineHeight + 4);
ShowAll ();
document.Editor.Parent.EditorOptionsChanged += HandleDocumentEditorParentEditorOptionsChanged;
;
}
示例10: CreateWidget
public void CreateWidget (List<ContextAction> fixes, DomLocation loc)
{
if (!fixes.Any ())
return;
widget = new ContextActionWidget (this, Document, loc, fixes);
var container = Document.Editor.Parent.Parent as TextEditorContainer;
if (container == null)
return;
container.AddTopLevelWidget (widget,
2 + (int)Document.Editor.Parent.TextViewMargin.XOffset,
-2 + (int)document.Editor.Parent.LineToY (document.Editor.Caret.Line));
widget.Show ();
}
示例11: CursorPositionChanged
public override void CursorPositionChanged ()
{
RemoveWidget ();
if (Document.ParsedDocument != null) {
DomLocation loc = new DomLocation (Document.Editor.Caret.Line, Document.Editor.Caret.Column);
RefactoringService.QueueQuickFixAnalysis (Document, loc, delegate(List<ContextAction> fixes) {
Application.Invoke (delegate {
RemoveWidget ();
CreateWidget (fixes, loc);
});
});
}
base.CursorPositionChanged ();
}
示例12: Format
public static void Format (TextEditorData data, ProjectDom dom, DomLocation location)
{
CSharp.Dom.CompilationUnit compilationUnit = new MonoDevelop.CSharp.Parser.CSharpParser ().Parse (data);
IEnumerable<string> types = DesktopService.GetMimeTypeInheritanceChain (CSharpFormatter.MimeType);
CSharpFormattingPolicy policy = dom.Project.Policies != null ? dom.Project.Policies.Get<CSharpFormattingPolicy> (types) : MonoDevelop.Projects.Policies.PolicyService.GetDefaultPolicy<CSharpFormattingPolicy> (types);
DomSpacingVisitor domSpacingVisitor = new DomSpacingVisitor (policy, data);
domSpacingVisitor.AutoAcceptChanges = false;
compilationUnit.AcceptVisitor (domSpacingVisitor, null);
DomIndentationVisitor domIndentationVisitor = new DomIndentationVisitor (policy, data);
domIndentationVisitor.AutoAcceptChanges = false;
compilationUnit.AcceptVisitor (domIndentationVisitor, null);
List<Change> changes = new List<Change> ();
changes.AddRange (domSpacingVisitor.Changes);
changes.AddRange (domIndentationVisitor.Changes);
RefactoringService.AcceptChanges (null, null, changes);
}
示例13: NRefactoryTemplateParameterDataProvider
public NRefactoryTemplateParameterDataProvider (TextEditorData editor, NRefactoryResolver resolver, IEnumerable<string> namespaces, ExpressionResult expressionResult, DomLocation loc)
{
// this.editor = editor;
ResolveResult plainResolveResult = resolver.Resolve (expressionResult, loc);
MethodResolveResult resolveResult = plainResolveResult as MethodResolveResult;
if (resolveResult != null) {
foreach (IMethod method in resolveResult.Methods) {
if (method.TypeParameters.Count > 0)
this.types.Add (method);
}
} else {
string typeName = expressionResult.Expression.Trim ();
foreach (string ns in namespaces) {
string prefix = ns + (ns.Length > 0 ? "." : "") + typeName + "`";
for (int i = 1; i < 99; i++) {
IType possibleType = resolver.Dom.GetType (prefix + i);
if (possibleType != null)
this.types.Add (possibleType);
}
}
IType resolvedType = plainResolveResult != null ? resolver.Dom.GetType (plainResolveResult.ResolvedType) : null;
if (resolvedType == null) {
int idx = expressionResult.Expression.LastIndexOf (".");
if (idx < 0)
return;
typeName = expressionResult.Expression.Substring (idx + 1);
expressionResult.Expression = expressionResult.Expression.Substring (0, idx);
plainResolveResult = resolver.Resolve (expressionResult, loc);
resolvedType = resolver.Dom.GetType (plainResolveResult.ResolvedType);
}
if (resolvedType == null)
return;
foreach (IType innerType in resolvedType.InnerTypes) {
this.types.Add (innerType);
}
}
}
示例14: VisitPreprocessorDirective
void VisitPreprocessorDirective (ParsedDocument result, SpecialsBag.PreProcessorDirective directive)
{
DomLocation loc = new DomLocation (directive.Line, directive.Col);
switch (directive.Cmd) {
case Tokenizer.PreprocessorDirective.If:
conditionalRegions.Push (new ConditionalRegion (visitor.Text));
ifBlocks.Push (directive);
ConditionalRegion.Start = loc;
break;
case Tokenizer.PreprocessorDirective.Elif:
CloseConditionBlock (new DomLocation (directive.EndLine, directive.EndCol));
if (ConditionalRegion != null)
ConditionalRegion.ConditionBlocks.Add (new ConditionBlock (visitor.Text, loc));
break;
case Tokenizer.PreprocessorDirective.Else:
CloseConditionBlock (new DomLocation (directive.EndLine, directive.EndCol));
if (ConditionalRegion != null)
ConditionalRegion.ElseBlock = new DomRegion (loc, DomLocation.Empty);
break;
case Tokenizer.PreprocessorDirective.Endif:
DomLocation endLoc = new DomLocation (directive.EndLine, directive.EndCol);
CloseConditionBlock (endLoc);
if (ConditionalRegion != null && !ConditionalRegion.ElseBlock.Start.IsEmpty)
ConditionalRegion.ElseBlock = new DomRegion (ConditionalRegion.ElseBlock.Start, endLoc);
AddCurRegion (result, directive.EndLine, directive.EndCol);
if (ifBlocks.Count > 0) {
var ifBlock = ifBlocks.Pop ();
DomRegion dr = new DomRegion (ifBlock.Line, ifBlock.Col, directive.EndLine, directive.EndCol);
result.Add (new FoldingRegion ("#if " + ifBlock.Arg.Trim (), dr, FoldType.UserRegion, false));
foreach (var d in elifBlocks) {
dr.Start = new DomLocation (d.Line, d.Col);
result.Add (new FoldingRegion ("#elif " + ifBlock.Arg.Trim (), dr, FoldType.UserRegion, false));
}
if (elseBlock != null) {
dr.Start = new DomLocation (elseBlock.Line, elseBlock.Col);
result.Add (new FoldingRegion ("#else", dr, FoldType.UserRegion, false));
}
}
elseBlock = null;
break;
case Tokenizer.PreprocessorDirective.Define:
result.Add (new PreProcessorDefine (directive.Arg, loc));
break;
case Tokenizer.PreprocessorDirective.Region:
regions.Push (directive);
break;
case Tokenizer.PreprocessorDirective.Endregion:
if (regions.Count > 0) {
var start = regions.Pop ();
DomRegion dr = new DomRegion (start.Line, start.Col, directive.EndLine, directive.EndCol);
result.Add (new FoldingRegion (start.Arg, dr, FoldType.UserRegion, true));
}
break;
}
}
示例15: CloseConditionBlock
void CloseConditionBlock (DomLocation loc)
{
if (ConditionalRegion == null || ConditionalRegion.ConditionBlocks.Count == 0 || !ConditionalRegion.ConditionBlocks[ConditionalRegion.ConditionBlocks.Count - 1].End.IsEmpty)
return;
ConditionalRegion.ConditionBlocks[ConditionalRegion.ConditionBlocks.Count - 1].End = loc;
}