public ICompletionData CreateEventCreationCompletionData(string varName, IType delegateType, IEvent evt, string parameterDefinition, IUnresolvedMember currentMember, IUnresolvedTypeDefinition currentType) { return new CompletionData(varName); }
public void AddType (IUnresolvedTypeDefinition type, string shortType) { if (type == null || string.IsNullOrEmpty (shortType) || usedTypes.Contains (shortType)) return; usedTypes.Add (shortType); result.Add (Factory.CreateTypeCompletionData (type, shortType)); }
public SuggestedHandlerCompletionData (Project project, CodeMemberMethod methodInfo, IType codeBehindClass, IUnresolvedTypeDefinition codeBehindClassPart) { this.project = project; this.methodInfo = methodInfo; this.codeBehindClass = codeBehindClass; this.codeBehindClassPart = codeBehindClassPart; }
public DefaultUnresolvedEvent(IUnresolvedTypeDefinition declaringType, string name) { this.EntityType = EntityType.Event; this.DeclaringTypeDefinition = declaringType; this.Name = name; if (declaringType != null) this.ParsedFile = declaringType.ParsedFile; }
public DefaultUnresolvedTypeDefinition(IUnresolvedTypeDefinition declaringTypeDefinition, string name) { this.EntityType = EntityType.TypeDefinition; this.DeclaringTypeDefinition = declaringTypeDefinition; this.namespaceName = declaringTypeDefinition.Namespace; this.Name = name; this.ParsedFile = declaringTypeDefinition.ParsedFile; }
public DefaultUnresolvedField(IUnresolvedTypeDefinition declaringType, string name) { this.SymbolKind = SymbolKind.Field; this.DeclaringTypeDefinition = declaringType; this.Name = name; if (declaringType != null) this.UnresolvedFile = declaringType.UnresolvedFile; }
public DefaultUnresolvedMethod(IUnresolvedTypeDefinition declaringType, string name) { this.EntityType = EntityType.Method; this.DeclaringTypeDefinition = declaringType; this.Name = name; if (declaringType != null) this.UnresolvedFile = declaringType.UnresolvedFile; }
public DefaultUnresolvedTypeDefinition(IUnresolvedTypeDefinition declaringTypeDefinition, string name) { this.SymbolKind = SymbolKind.TypeDefinition; this.DeclaringTypeDefinition = declaringTypeDefinition; this.namespaceName = declaringTypeDefinition.Namespace; this.Name = name; this.UnresolvedFile = declaringTypeDefinition.UnresolvedFile; }
/// <summary> /// Initializes a new instance of the <see cref="VB6UnresolvedMethod"/> class. /// </summary> /// <param name="method">The instance of <see cref="IVbMethod"/> that is the source of this entity.</param> /// <param name="file">The file that is the source of this entity.</param> /// <param name="typeReference">The <see cref="IUnresolvedTypeReference"/> that this member is a child of. May be null.</param> /// <param name="typeDefinition">The <see cref="IUnresolvedTypeDefinition"/> that this entity is a child of. May be null.</param> internal VB6UnresolvedMethod(IVbMethod method, IUnresolvedFile file, ITypeReference typeReference, IUnresolvedTypeDefinition typeDefinition) : base(method, file, typeReference, typeDefinition) { if (method == null) { throw new ArgumentNullException("method"); } }
public NewPartialCompletionData(int declarationBegin, IUnresolvedTypeDefinition type, IUnresolvedMember member) { DeclarationBeginningIndex = declarationBegin; Type = type; Member = member; // check this: DeclarationCategory = type.SymbolKind.ResolveDeclarationCategoryFromSymbolKind(); SetDefaultText(member.Name); }
/// <summary> /// Initializes a new instance of the <see cref="VB6UnresolvedEntityBase"/> class. /// </summary> /// <param name="file">The file that is the source of this entity.</param> /// <param name="typeDefinition">The <see cref="IUnresolvedTypeDefinition"/> that this entity is a child of. May be null.</param> protected VB6UnresolvedEntityBase(IUnresolvedFile file, IUnresolvedTypeDefinition typeDefinition) : this() { this.UnresolvedFile = file; VB6UnresolvedFile vb6File = (VB6UnresolvedFile)file; this.VbpProject = vb6File.Project; this.DeclaringTypeDefinition = typeDefinition; }
public EventCreationCompletionData(string handlerName, IType delegateType, IEvent evt, string parameterList, IUnresolvedMember callingMember, IUnresolvedTypeDefinition declaringType, CSharpResolver contextAtCaret) { if (string.IsNullOrEmpty(handlerName)) { handlerName = (evt != null ? evt.Name : "Handle"); } this.handlerName = handlerName; this.DisplayText = StringParser.Parse("${res:CSharpBinding.Refactoring.EventCreation.EventHandlerText}", new[] { new StringTagPair("HandlerName", handlerName) }); this.delegateTypeReference = delegateType.ToTypeReference(); this.isStatic = callingMember != null && callingMember.IsStatic; }
public EventCreationCompletionData(string handlerName, IType delegateType, IEvent evt, string parameterList, IUnresolvedMember callingMember, IUnresolvedTypeDefinition declaringType, CSharpResolver contextAtCaret) { if (string.IsNullOrEmpty(handlerName)) { handlerName = (evt != null ? evt.Name : "Handle"); } this.handlerName = handlerName; this.DisplayText = "<Create " + handlerName + ">"; this.delegateTypeReference = delegateType.ToTypeReference(); this.isStatic = callingMember != null && callingMember.IsStatic; }
public EventCompletionData(string varName, IType delegateType, IEvent evt, string parameterDefinition, IUnresolvedMember currentMember, IUnresolvedTypeDefinition currentType) { SetDefaultText(varName); DeclarationCategory = DeclarationCategory.Event; // what should we do with parameterDefinition??? DelegateType = delegateType; CurrentMember = currentMember; CurrentType = currentType; //Description = currentMember }
ContextActionViewModel MakeViewModel(IUnresolvedTypeDefinition entity) { var ambience = AmbienceService.GetCurrentAmbience(); ambience.ConversionFlags = ConversionFlags.ShowDeclaringType | ConversionFlags.ShowTypeParameterList; return new ContextActionViewModel { Action = new GoToDomRegionAction(entity.Region), Image = IconService.GetImageSource(IconService.GetImageForFile(entity.Region.FileName)), Comment = string.Format("(in {0})", Path.GetDirectoryName(entity.Region.FileName)), ChildActions = null }; }
public NewOverrideCompletionData (CSharpCompletionTextEditorExtension ext, int declarationBegin, IUnresolvedTypeDefinition type, IMember member) : base (null) { this.ext = ext; this.type = type; this.member = member; this.declarationBegin = declarationBegin; this.GenerateBody = true; this.Icon = member.GetStockIcon (); this.DisplayText = ambience.GetString (member, OutputFlags.IncludeParameters | OutputFlags.IncludeParameterName | OutputFlags.IncludeGenerics | OutputFlags.HideExtensionsParameter| OutputFlags.IncludeAccessor); this.CompletionText = member.EntityType == EntityType.Indexer ? "this" : member.Name; }
public static Node AsTree ( IUnresolvedTypeDefinition topLevelTypeDefinition , IDocument document) { var retval = new Node() { ChildNodes = topLevelTypeDefinition.Members .Select(m => new Node(m, document)) , Location = QuickFix.ForNonBodyRegion (topLevelTypeDefinition, document)}; return retval; }
public EventCreationCompletionData(string varName, IType delegateType, IEvent evt, string parameterList, IUnresolvedMember callingMember, IUnresolvedTypeDefinition declaringType, CSharpResolver contextAtCaret) : base(evt) { if (string.IsNullOrEmpty(varName)) { this.DisplayText = "Create handler for " + (evt != null ? evt.Name : ""); } else { this.DisplayText = "Create handler for " + char.ToUpper(varName[0]) + varName.Substring(1) + (evt != null ? evt.Name : ""); } this.DisplayText = "<" + this.DisplayText + ">"; this.eventDefinition = evt; this.delegateType = delegateType; }
public static ITypeDefinition GetDesignableClass(IUnresolvedFile parsedFile, ICompilation compilation, out IUnresolvedTypeDefinition primaryPart) { primaryPart = null; if (parsedFile == null) return null; foreach (var utd in parsedFile.TopLevelTypeDefinitions) { var td = utd.Resolve(new SimpleTypeResolveContext(compilation.MainAssembly)).GetDefinition(); if (IsDesignable(td)) { primaryPart = utd; return td; } } return null; }
void AddEntityBookmarks(IUnresolvedTypeDefinition c, IDocument document) { if (c.IsSynthetic) return; if (!c.Region.IsEmpty) { bookmarks.Add(new EntityBookmark(c, document)); } foreach (var innerClass in c.NestedTypes) { AddEntityBookmarks(innerClass, document); } foreach (var m in c.Members) { if (m.Region.IsEmpty || m.IsSynthetic) continue; bookmarks.Add(new EntityBookmark(m, document)); } }
/// <summary> /// Initializes a new instance of the <see cref="VB6UnresolvedMemberBase"/> class. /// </summary> /// <param name="member">The instance of <see cref="IVbMember"/> that is the source of this entity.</param> /// <param name="file">The file that is the source of this entity.</param> /// <param name="typeReference">The <see cref="IUnresolvedTypeReference"/> that this member is a child of. May be null.</param> /// <param name="typeDefinition">The <see cref="IUnresolvedTypeDefinition"/> that this entity is a child of. May be null.</param> protected VB6UnresolvedMemberBase(IVbMember member, IUnresolvedFile file, ITypeReference typeReference, IUnresolvedTypeDefinition typeDefinition) : base(file, typeDefinition) { if (member == null) { throw new ArgumentNullException("member"); } this.Member = member; this.Name = member.Name; this.Accessibility = member.ToAccessibility(); this.DeclaringTypeReference = typeReference; }
public OverrideContext (Request request, BufferParser parser) { this.BufferParser = parser; this.CompletionContext = new BufferContext (request, this.BufferParser); currentTypeDefinition = this.CompletionContext.ParsedContent .UnresolvedFile.GetInnermostTypeDefinition (this.CompletionContext.TextLocation); this.CurrentType = currentTypeDefinition.Resolve(this.CompletionContext.ResolveContext); this.OverrideTargets = GetOverridableMembers() .Select(m => new GetOverrideTargetsResponse (m, this.CompletionContext.ResolveContext)) .ToArray(); }
protected void SetOffset (int offset) { Reset (); this.offset = offset; this.location = document.GetLocation (offset); this.currentType = CSharpParsedFile.GetInnermostTypeDefinition (location); this.currentMember = null; if (this.currentType != null) { foreach (var member in currentType.Members) { if (member.Region.Begin < location && (currentMember == null || currentMember.Region.Begin < member.Region.Begin)) currentMember = member; } } var stack = GetBracketStack (GetMemberTextToCaret ().Item1); if (stack.Count == 0) currentMember = null; }
public MonoDevelopProxy (Project project, string className) { this.project = project; if (className != null) { ICompilation compilation = TypeSystemService.GetProjectContext (project).CreateCompilation (); foreach (ITypeDefinition itd in compilation.MainAssembly.TopLevelTypeDefinitions) { if (itd.FullName == className) fullClass = itd as IType; } } else fullClass = null; if (fullClass != null) nonDesignerClass = MonoDevelop.DesignerSupport.CodeBehind.GetNonDesignerClass (fullClass); else nonDesignerClass = null; }
public EventCreationCompletionData (CSharpCompletionTextEditorExtension ext, string varName, IType delegateType, IEvent evt, string parameterList, IUnresolvedMember callingMember, IUnresolvedTypeDefinition declaringType) : base (null) { if (string.IsNullOrEmpty (varName)) { this.DisplayText = "Handle" + (evt != null ? evt.Name : ""); } else { this.DisplayText = "Handle" + Char.ToUpper (varName[0]) + varName.Substring (1) + (evt != null ? evt.Name : ""); } if (declaringType != null && declaringType.Members.Any (m => m.Name == this.DisplayText)) { for (int i = 1; i < 10000; i++) { if (!declaringType.Members.Any (m => m.Name == this.DisplayText + i)) { this.DisplayText = this.DisplayText + i.ToString (); break; } } } this.editor = ext.TextEditorData; this.parameterList = parameterList; this.callingMember = callingMember; this.Icon = "md-newmethod"; this.initialOffset = editor.Caret.Offset; }
public static IUnresolvedMember AddCodeDomMember (Project project, IUnresolvedTypeDefinition type, CodeTypeMember newMember) { bool isOpen; var data = TextFileProvider.Instance.GetTextEditorData (type.Region.FileName, out isOpen); var parsedDocument = TypeSystemService.ParseFile (data.Document.FileName, data.Document.MimeType, data.Text); var insertionPoints = GetInsertionPoints (data, parsedDocument, type); var suitableInsertionPoint = GetSuitableInsertionPoint (insertionPoints, type, newMember); var dotNetProject = project as DotNetProject; if (dotNetProject == null) { LoggingService.LogError ("Only .NET projects are supported."); return null; } var generator = dotNetProject.LanguageBinding.GetCodeDomProvider (); StringWriter sw = new StringWriter (); var options = new CodeGeneratorOptions (); options.IndentString = data.GetLineIndent (type.Region.BeginLine) + "\t"; if (newMember is CodeMemberMethod) options.BracingStyle = "C"; generator.GenerateCodeFromMember (newMember, sw, options); var code = sw.ToString (); if (!string.IsNullOrEmpty (code)) suitableInsertionPoint.Insert (data, code); if (!isOpen) { try { File.WriteAllText (type.Region.FileName, data.Text); } catch (Exception e) { LoggingService.LogError (string.Format ("Failed to write file '{0}'.", type.Region.FileName), e); MessageService.ShowError (GettextCatalog.GetString ("Failed to write file '{0}'.", type.Region.FileName)); } } var newDocument = TypeSystemService.ParseFile (data.FileName, data.MimeType, data.Text); return newDocument.ParsedFile.GetMember (suitableInsertionPoint.Location.Line, int.MaxValue); }
public static void AddNewMember (ITypeDefinition type, IUnresolvedTypeDefinition part, IUnresolvedMember newMember, bool implementExplicit = false) { bool isOpen; var data = TextFileProvider.Instance.GetTextEditorData (part.Region.FileName, out isOpen); var parsedDocument = TypeSystemService.ParseFile (data.FileName, data.MimeType, data.Text); var insertionPoints = GetInsertionPoints (data, parsedDocument, part); var suitableInsertionPoint = GetSuitableInsertionPoint (insertionPoints, part, newMember); var generator = CreateCodeGenerator (data, type.Compilation); generator.IndentLevel = CalculateBodyIndentLevel (parsedDocument.GetInnermostTypeDefinition (type.Region.Begin)); var generatedCode = generator.CreateMemberImplementation (type, part, newMember, implementExplicit); suitableInsertionPoint.Insert (data, generatedCode.Code); if (!isOpen) { try { File.WriteAllText (type.Region.FileName, data.Text); } catch (Exception e) { LoggingService.LogError (GettextCatalog.GetString ("Failed to write file '{0}'.", type.Region.FileName), e); MessageService.ShowError (GettextCatalog.GetString ("Failed to write file '{0}'.", type.Region.FileName)); } } }
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;*/ }
ITypeDefinition Resolve(IUnresolvedTypeDefinition typeDef) { return(compilation.MainAssembly.GetTypeDefinition(typeDef)); }
/// <summary> /// Called indirectly by the CSharpCompletionEngine.GetPartialCompletionData method. /// </summary> /// <param name="declarationBegin"></param> /// <param name="type"></param> /// <param name="m"></param> /// <returns></returns> public ICompletionData CreateNewPartialCompletionData(int declarationBegin, IUnresolvedTypeDefinition type, IUnresolvedMember member) { var cd = new NewPartialCompletionData(declarationBegin, type, member); return(cd); }
public ICompletionData CreateNewPartialCompletionData(int declarationBegin, IUnresolvedTypeDefinition type, IUnresolvedMember m) { return(new CompletionData(m.Name)); }
public BaseTypeFolder(IUnresolvedTypeDefinition type) { this.Type = type; }
public NewOverrideCompletionData(CSharpCompletionTextEditorExtension ext, int declarationBegin, IUnresolvedTypeDefinition type, IMember member) : base(null) { this.ext = ext; this.type = type; this.member = member; this.declarationBegin = declarationBegin; this.GenerateBody = true; this.Icon = member.GetStockIcon(); this.DisplayText = ambience.GetString(member, OutputFlags.IncludeParameters | OutputFlags.IncludeParameterName | OutputFlags.IncludeGenerics | OutputFlags.HideExtensionsParameter | OutputFlags.IncludeAccessor); this.CompletionText = member.SymbolKind == SymbolKind.Indexer ? "this" : member.Name; }
public abstract CodeGeneratorMemberResult CreateMemberImplementation(ITypeDefinition implementingType, IUnresolvedTypeDefinition part, IMember member, bool explicitDeclaration);
public static List <InsertionPoint> GetInsertionPoints(MonoDevelop.Ide.Gui.Document document, IUnresolvedTypeDefinition type) { if (document == null) { throw new ArgumentNullException("document"); } if (document.ParsedDocument == null) { return(new List <InsertionPoint> ()); } return(GetInsertionPoints(document.Editor, document.ParsedDocument, type)); }
ICompletionData ICompletionDataFactory.CreateNewPartialCompletionData(int declarationBegin, IUnresolvedTypeDefinition type, IUnresolvedMember m) { var ctx = CSharpUnresolvedFile.GetTypeResolveContext(Compilation, document.Editor.Caret.Location); return(new NewOverrideCompletionData(this, declarationBegin, type, m.CreateResolved(ctx))); }
static void AddType(MonoDevelop.Ide.Gui.Document document, TypeSystemSegmentTree result, IUnresolvedTypeDefinition type) { int offset = document.Editor.LocationToOffset(type.Region.Begin); int endOffset = document.Editor.LocationToOffset(type.Region.End); result.Add(new TypeSystemTreeSegment(offset, endOffset - offset, type)); foreach (var entity in type.Members) { offset = document.Editor.LocationToOffset(entity.Region.Begin); endOffset = document.Editor.LocationToOffset(entity.Region.End); result.Add(new TypeSystemTreeSegment(offset, endOffset - offset, entity)); } foreach (var nested in type.NestedTypes) { AddType(document, result, nested); } }
void ICompletionContextProvider.GetCurrentMembers(int offset, out IUnresolvedTypeDefinition currentType, out IUnresolvedMember currentMember) { currentType = GetTypeAt(offset); currentMember = GetMemberAt(offset); }
/// <summary> /// Initializes a new instance of the <see cref="VB6UnresolvedMethod"/> class. /// </summary> /// <param name="method">The instance of <see cref="IVbMethod"/> that is the source of this entity.</param> /// <param name="file">The file that is the source of this entity.</param> /// <param name="typeReference">The <see cref="IUnresolvedTypeReference"/> that this member is a child of. May be null.</param> /// <param name="typeDefinition">The <see cref="IUnresolvedTypeDefinition"/> that this entity is a child of. May be null.</param> internal VB6UnresolvedMethod(IVbMethod method, IUnresolvedFile file, ITypeReference typeReference, IUnresolvedTypeDefinition typeDefinition) : base(method, file, typeReference, typeDefinition) { if (method == null) { throw new ArgumentNullException("method"); } }
public EventCreationCompletionData(CSharpCompletionTextEditorExtension ext, string varName, IType delegateType, IEvent evt, string parameterList, IUnresolvedMember callingMember, IUnresolvedTypeDefinition declaringType) : base(null) { if (string.IsNullOrEmpty(varName)) { this.DisplayText = "Handle" + (evt != null ? evt.Name : ""); } else { this.DisplayText = "Handle" + Char.ToUpper(varName[0]) + varName.Substring(1) + (evt != null ? evt.Name : ""); } if (declaringType != null && declaringType.Members.Any(m => m.Name == this.DisplayText)) { for (int i = 1; i < 10000; i++) { if (!declaringType.Members.Any(m => m.Name == this.DisplayText + i)) { this.DisplayText = this.DisplayText + i.ToString(); break; } } } this.editor = ext.TextEditorData; this.parameterList = parameterList; this.callingMember = callingMember; this.Icon = "md-newmethod"; this.initialOffset = editor.Caret.Offset; }
public override string CreateFieldEncapsulation (IUnresolvedTypeDefinition implementingType, IField field, string propertyName, Accessibility modifiers, bool readOnly) { SetIndentTo (implementingType); StringBuilder result = new StringBuilder (); AppendIndent (result); // if (modifiers != MonoDevelop.Projects.Dom.Modifiers.None) { // switch (modifiers) { // } // result.Append (ambience.GetString (modifiers)); // result.Append (" "); // } var options = new CodeGenerationOptions () { ImplementingType = field.DeclaringTypeDefinition, Part = implementingType }; result.Append ("public "); AppendReturnType (result, options, field.ReturnType); result.Append (" "); result.Append (propertyName); AppendBraceStart (result, Policy.PropertyBraceStyle); AppendIndent (result); result.Append ("get"); AppendBraceStart (result, Policy.PropertyGetBraceStyle); AppendIndent (result); result.Append ("return this."); result.Append (CSharpAmbience.FilterName (field.Name)); result.Append (";"); AppendLine (result); AppendBraceEnd (result, Policy.PropertyGetBraceStyle); AppendLine (result); if (!readOnly) { AppendIndent (result); result.Append ("set"); AppendBraceStart (result, Policy.PropertyGetBraceStyle); AppendIndent (result); result.Append (CSharpAmbience.FilterName (field.Name)); result.Append (" = value;"); AppendLine (result); AppendBraceEnd (result, Policy.PropertyGetBraceStyle); AppendLine (result); } AppendBraceEnd (result, Policy.PropertyBraceStyle); return result.ToString (); }
Tuple <string, TextLocation> ICompletionContextProvider.GetMemberTextToCaret(int caretOffset, IUnresolvedTypeDefinition currentType, IUnresolvedMember currentMember) { int startOffset; if (currentMember != null && currentType != null && currentType.Kind != TypeKind.Enum) { startOffset = document.Editor.LocationToOffset(currentMember.Region.Begin); } else if (currentType != null) { startOffset = document.Editor.LocationToOffset(currentType.Region.Begin); } else { startOffset = 0; } while (startOffset > 0) { char ch = document.Editor.GetCharAt(startOffset - 1); if (ch != ' ' && ch != '\t') { break; } --startOffset; } return(Tuple.Create(document.Editor.GetTextAt(startOffset, caretOffset - startOffset), (TextLocation)document.Editor.OffsetToLocation(startOffset))); }
public static List <InsertionPoint> GetInsertionPoints(TextEditorData data, ParsedDocument parsedDocument, IUnresolvedTypeDefinition type) { if (data == null) { throw new ArgumentNullException("data"); } if (parsedDocument == null) { throw new ArgumentNullException("parsedDocument"); } if (type == null) { throw new ArgumentNullException("type"); } // update type from parsed document, since this is always newer. //type = parsedDocument.GetInnermostTypeDefinition (type.GetLocation ()) ?? type; List <InsertionPoint> result = new List <InsertionPoint> (); int offset = data.LocationToOffset(type.Region.Begin); if (offset < 0 || type.BodyRegion.IsEmpty) { return(result); } while (offset < data.Length && data.GetCharAt(offset) != '{') { offset++; } var realStartLocation = data.OffsetToLocation(offset); result.Add(GetInsertionPosition(data.Document, realStartLocation.Line, realStartLocation.Column)); result [0].LineBefore = NewLineInsertion.None; foreach (var member in type.Members) { TextLocation domLocation = member.BodyRegion.End; if (domLocation.Line <= 0) { DocumentLine lineSegment = data.GetLine(member.Region.BeginLine); if (lineSegment == null) { continue; } domLocation = new TextLocation(member.Region.BeginLine, lineSegment.Length + 1); } result.Add(GetInsertionPosition(data.Document, domLocation.Line, domLocation.Column)); } foreach (var nestedType in type.NestedTypes) { TextLocation domLocation = nestedType.BodyRegion.End; if (domLocation.Line <= 0) { DocumentLine lineSegment = data.GetLine(nestedType.Region.BeginLine); if (lineSegment == null) { continue; } domLocation = new TextLocation(nestedType.Region.BeginLine, lineSegment.Length + 1); } result.Add(GetInsertionPosition(data.Document, domLocation.Line, domLocation.Column)); } result [result.Count - 1].LineAfter = NewLineInsertion.None; CheckStartPoint(data.Document, result [0], result.Count == 1); if (result.Count > 1) { result.RemoveAt(result.Count - 1); NewLineInsertion insertLine; var lineBefore = data.GetLine(type.BodyRegion.EndLine - 1); if (lineBefore != null && lineBefore.Length == lineBefore.GetIndentation(data.Document).Length) { insertLine = NewLineInsertion.None; } else { insertLine = NewLineInsertion.Eol; } // search for line start int col = type.BodyRegion.EndColumn - 1; var line = data.GetLine(type.BodyRegion.EndLine); if (line != null) { var lineOffset = line.Offset; col = Math.Min(line.Length, col); while (lineOffset + col - 2 >= 0 && col > 1 && char.IsWhiteSpace(data.GetCharAt(lineOffset + col - 2))) { col--; } } result.Add(new InsertionPoint(new DocumentLocation(type.BodyRegion.EndLine, col), insertLine, NewLineInsertion.Eol)); CheckEndPoint(data.Document, result [result.Count - 1], result.Count == 1); } foreach (var region in parsedDocument.UserRegions.Where(r => type.BodyRegion.IsInside(r.Region.Begin))) { result.Add(new InsertionPoint(new DocumentLocation(region.Region.BeginLine + 1, 1), NewLineInsertion.Eol, NewLineInsertion.Eol)); result.Add(new InsertionPoint(new DocumentLocation(region.Region.EndLine, 1), NewLineInsertion.Eol, NewLineInsertion.Eol)); result.Add(new InsertionPoint(new DocumentLocation(region.Region.EndLine + 1, 1), NewLineInsertion.Eol, NewLineInsertion.Eol)); } result.Sort((left, right) => left.Location.CompareTo(right.Location)); // foreach (var res in result) // Console.WriteLine (res); return(result); }
ICompletionData ICompletionDataFactory.CreateNewOverrideCompletionData(int declarationBegin, IUnresolvedTypeDefinition type, IMember m) { return(new NewOverrideCompletionData(this, declarationBegin, type, m)); }
public abstract string CreateFieldEncapsulation(IUnresolvedTypeDefinition implementingType, IField field, string propertyName, Accessibility modifiers, bool readOnly);
ICompletionData ICompletionDataFactory.CreateEventCreationCompletionData(string varName, IType delegateType, IEvent evt, string parameterDefinition, IUnresolvedMember currentMember, IUnresolvedTypeDefinition currentType) { return(new EventCreationCompletionData(this, varName, delegateType, evt, parameterDefinition, currentMember, currentType)); }
static void AddTreeClassContents(TreeStore store, TreeIter parent, ParsedDocument parsedDocument, ITypeDefinition cls, IUnresolvedTypeDefinition part) { List <object> items = new List <object> (); if (cls.Kind != TypeKind.Delegate) { foreach (var o in cls.GetMembers(m => part.Region.FileName == m.Region.FileName && part.Region.IsInside(m.Region.Begin))) { items.Add(o); } foreach (var o in cls.GetNestedTypes(m => part.Region.FileName == m.Region.FileName && part.Region.IsInside(m.Region.Begin))) { if (o.DeclaringType == cls) { items.Add(o); } } foreach (var o in cls.GetConstructors(m => part.Region.FileName == m.Region.FileName && part.Region.IsInside(m.Region.Begin))) { if (o.IsSynthetic) { continue; } items.Add(o); } } items.Sort(ClassOutlineNodeComparer.CompareRegion); List <FoldingRegion> regions = new List <FoldingRegion> (); foreach (FoldingRegion fr in parsedDocument.UserRegions) { //check regions inside class if (cls.BodyRegion.IsInside(fr.Region.Begin) && cls.BodyRegion.IsInside(fr.Region.End)) { regions.Add(fr); } } regions.Sort(delegate(FoldingRegion x, FoldingRegion y) { return(x.Region.Begin.CompareTo(y.Region.Begin)); }); IEnumerator <FoldingRegion> regionEnumerator = regions.GetEnumerator(); if (!regionEnumerator.MoveNext()) { regionEnumerator = null; } FoldingRegion currentRegion = null; TreeIter currentParent = parent; foreach (object item in items) { //no regions left; quick exit if (regionEnumerator != null) { DomRegion itemRegion = ClassOutlineNodeComparer.GetRegion(item); //advance to a region that could potentially contain this member while (regionEnumerator != null && !OuterEndsAfterInner(regionEnumerator.Current.Region, itemRegion)) { if (!regionEnumerator.MoveNext()) { regionEnumerator = null; } } //if member is within region, make sure it's the current parent. //If not, move target iter back to class parent if (regionEnumerator != null && regionEnumerator.Current.Region.IsInside(itemRegion.Begin)) { if (currentRegion != regionEnumerator.Current) { currentParent = store.AppendValues(parent, regionEnumerator.Current); currentRegion = regionEnumerator.Current; } } else { currentParent = parent; } } TreeIter childIter = store.AppendValues(currentParent, item); if (item is ITypeDefinition) { AddTreeClassContents(store, childIter, parsedDocument, (ITypeDefinition)item, part); } } }
internal VB6UnresolvedField(IVbField field, IUnresolvedFile file, ITypeReference typeReference, IUnresolvedTypeDefinition typeDefinition) : base(field, file, typeReference, typeDefinition) { this.IsConst = field.IsConstant; }
public void Dispose() { Type = null; }
static InsertionPoint GetNewEventPosition(IEnumerable <InsertionPoint> points, IUnresolvedTypeDefinition cls) { if (!cls.Events.Any()) { return(GetNewMethodPosition(points, cls)); } var lastEvent = cls.Events.Last(); return(points.FirstOrDefault(p => p.Location.Convert() > lastEvent.Region.Begin)); }
protected static ITypeResolveContext ExtendContextForType(ITypeResolveContext assemblyContext, IUnresolvedTypeDefinition typeDef) { if (typeDef == null) { return(assemblyContext); } ITypeResolveContext parentContext; if (typeDef.DeclaringTypeDefinition != null) { parentContext = ExtendContextForType(assemblyContext, typeDef.DeclaringTypeDefinition); } else { parentContext = assemblyContext; } ITypeDefinition resolvedTypeDef = typeDef.Resolve(assemblyContext).GetDefinition(); return(typeDef.CreateResolveContext(parentContext).WithCurrentTypeDefinition(resolvedTypeDef)); }
static InsertionPoint GetNewPropertyPosition(IEnumerable <InsertionPoint> points, IUnresolvedTypeDefinition cls) { if (!cls.Properties.Any()) { return(GetNewFieldPosition(points, cls)); } var lastProperty = cls.Properties.Last(); return(points.FirstOrDefault(p => p.Location.Convert() > lastProperty.Region.Begin)); }
public bool IsBetterPart(IUnresolvedTypeDefinition part1, IUnresolvedTypeDefinition part2) { return(EntityModelContextUtils.IsBetterPart(part1, part2, primaryCodeFileExtension)); }
static InsertionPoint GetSuitableInsertionPoint(IEnumerable <InsertionPoint> points, IUnresolvedTypeDefinition cls, CodeTypeMember mem) { var mainPart = cls; if (mem is System.CodeDom.CodeMemberEvent) { return(GetNewEventPosition(points, mainPart)); } if (mem is System.CodeDom.CodeMemberProperty) { return(GetNewPropertyPosition(points, mainPart)); } if (mem is System.CodeDom.CodeMemberField) { return(GetNewFieldPosition(points, mainPart)); } if (mem is System.CodeDom.CodeMemberMethod) { return(GetNewMethodPosition(points, mainPart)); } return(GetNewFieldPosition(points, mainPart)); }
void AddItem(IUnresolvedTypeDefinition c, int matchType, bool inCurrentFile) { AddItem(c, ClassBrowserIconService.GetIcon(c), matchType, inCurrentFile); }
static InsertionPoint GetSuitableInsertionPoint(IEnumerable <InsertionPoint> points, IUnresolvedTypeDefinition cls, IUnresolvedMember member) { var mainPart = cls; switch (member.EntityType) { case EntityType.Field: return(GetNewFieldPosition(points, mainPart)); case EntityType.Method: case EntityType.Constructor: case EntityType.Destructor: case EntityType.Operator: return(GetNewMethodPosition(points, mainPart)); case EntityType.Event: return(GetNewEventPosition(points, mainPart)); case EntityType.Property: return(GetNewPropertyPosition(points, mainPart)); } throw new InvalidOperationException("Invalid member type: " + member.EntityType); }
public override Task <Script> InsertWithCursor(string operation, ITypeDefinition parentType, Func <Script, RefactoringContext, IList <AstNode> > nodeCallback) { // TODO : Use undo group var tcs = new TaskCompletionSource <Script>(); if (parentType == null) { return(tcs.Task); } IUnresolvedTypeDefinition part = null; foreach (var p in parentType.Parts) { if (part == null || EntityModelContextUtils.IsBetterPart(p, part, ".cs")) { part = p; } } if (part == null) { return(tcs.Task); } var fileName = new ICSharpCode.Core.FileName(part.Region.FileName); IViewContent document = SD.FileService.OpenFile(fileName); var area = document.GetService <TextArea>(); if (area == null) { return(tcs.Task); } var loc = part.Region.Begin; var parsedFile = SD.ParserService.ParseFile(fileName, area.Document, cancellationToken: context.CancellationToken); var declaringType = parsedFile.GetInnermostTypeDefinition(loc); EditorScript script; if (area.Document != context.Document) { script = new EditorScript(area.GetService <ITextEditor>(), SDRefactoringContext.Create(fileName, area.Document, loc, context.CancellationToken), FormattingOptions); startedScripts.Add(script); } else { script = this; } var nodes = nodeCallback(script, script.context); var insertionPoints = InsertionPoint.GetInsertionPoints(area.Document, part); if (insertionPoints.Count == 0) { SD.MessageService.ShowErrorFormatted("No valid insertion point can be found in type '{0}'.", part.Name); return(tcs.Task); } var layer = new InsertionCursorLayer(area, operation, insertionPoints); area.Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action)area.TextView.InvalidateVisual); if (declaringType.Kind == TypeKind.Enum) { foreach (var node in nodes.Reverse()) { int indentLevel = GetIndentLevelAt(area.Document.GetOffset(declaringType.BodyRegion.Begin)); var output = OutputNode(indentLevel, node); var point = insertionPoints[0]; var offset = area.Document.GetOffset(point.Location); var text = output.Text + ","; var delta = point.Insert(area.Document, text); output.RegisterTrackedSegments(script, delta + offset); } tcs.SetResult(script); return(tcs.Task); } InsertWithCursorOnLayer(script, layer, tcs, nodes, area.Document); return(tcs.Task); }
public bool IsBetterPart(IUnresolvedTypeDefinition part1, IUnresolvedTypeDefinition part2) { return(false); }
static MonoDevelop.Ide.FindInFiles.SearchResult GetJumpTypePartSearchResult (IUnresolvedTypeDefinition part) { var provider = new MonoDevelop.Ide.FindInFiles.FileProvider (part.Region.FileName); var doc = new Mono.TextEditor.TextDocument (); doc.Text = provider.ReadString (); int position = doc.LocationToOffset (part.Region.BeginLine, part.Region.BeginColumn); while (position + part.Name.Length < doc.TextLength) { if (doc.GetTextAt (position, part.Name.Length) == part.Name) break; position++; } return new MonoDevelop.Ide.FindInFiles.SearchResult (provider, position, part.Name.Length); }
ITypeDefinition GetTypeDefinition(IUnresolvedTypeDefinition unresolved) { return(typeDict.GetOrAdd(unresolved, t => CreateTypeDefinition(t))); }