public ImplementMembersForm(NemerleSource source, TypeBuilder ty, IEnumerable <IGrouping <FixedType.Class, IMember> > unimplementedMembers) { _source = source; _ty = ty; _unimplementedMembers = unimplementedMembers; InitializeComponent(); #region Init events hendlers _grid.CellPainting += CellPainting; _grid.CellValueChanged += CellValueChanged; _grid.CellValidating += CellValidating; _grid.CurrentCellDirtyStateChanged += CurrentCellDirtyStateChanged; #endregion #region Init ImageList imageList1.Images.AddStrip(Resources.SO_TreeViewIcons); _imageSize = imageList1.ImageSize.Width; Debug.Assert(imageList1.ImageSize.Width == imageList1.ImageSize.Height); #endregion if (_unimplementedMembers == null) { return; } FillTable(MakeTypeMembersMap()); }
public NemerleSourceButchEditHelper( NemerleSource source, IVsTextView view, bool merge, string description) : base(source, view, merge, description) { _fileIndex = source.FileIndex; }
public void OnCaretPositionChanged(object sender, CaretPositionChangedEventArgs e) { NemerleSource source = GetNemerleSourceOrNull(); if (source == null) { return; } var compileUnit = source.CompileUnit; if (compileUnit != null) { var point = e.NewPosition.BufferPosition; var textLine = point.GetContainingLine(); var line = textLine.LineNumber + 1; var lineStartPos = textLine.Start; var col = 1 + point.Position - lineStartPos; var member = compileUnit.FindMember(line, col); if (member.IsSome && member.Value.NameLocation.Contains(line, col) && (member.Value is TopDeclaration.Class || member.Value is TopDeclaration.Variant)) { _cursorOnTypeName = true; _typeNameLocation = member.Value.NameLocation; var loc = member.Value.NameLocation; var startPos = lineStartPos + loc.Column - 1; var endPos = lineStartPos + loc.EndColumn - 1; _typeNameSpan = new Span(startPos, endPos - startPos); var snapshot = _buffer.CurrentSnapshot; //SnapshotSpan span2 = new SnapshotSpan(snapshot, _typeNameSpan); //var ttt = span2.GetText(); SnapshotSpan span = new SnapshotSpan(snapshot, new Span(0, snapshot.Length)); EventHandler <SnapshotSpanEventArgs> handler = this.TagsChanged; if (handler != null) { handler(this, new SnapshotSpanEventArgs(span)); } return; } } if (_cursorOnTypeName) { _cursorOnTypeName = false; var snapshot = _buffer.CurrentSnapshot; SnapshotSpan span = new SnapshotSpan(snapshot, new Span(0, snapshot.Length)); EventHandler <SnapshotSpanEventArgs> handler = this.TagsChanged; if (handler != null) { handler(this, new SnapshotSpanEventArgs(span)); } } }
internal void RemoveEditableSource(NemerleSource source) { var fileIndex = source.FileIndex; var taksForSource = GetTaksForSource(source.FileIndex); foreach (var task in taksForSource) { task.DisposeTextLineMarker(); } ReplaseOrAddSource(new FileNemerleSource(fileIndex)); }
internal void ShowInfo(NemerleSource source) { if (!IsAutoUpdate) { return; } Action action = () => { _checkCountLabel.Text = (++_checkCount).ToString(); _items.Clear(); ProjectInfo projectInfo = source.ProjectInfo; if (projectInfo == null || !projectInfo.Engine.IsProjectAvailable) { return; } switch (_displayType.SelectedIndex) { case 0: // Tokens string code = source.GetText(); LexerBase lex = new LexerString((ManagerClass)projectInfo.Engine, code, new Location(source.FileIndex, 1, 1)); //lex.BeginParseFile(); lex.Keywords = lex.Manager.CoreEnv.Keywords; AstUtils.FillList(lex, _items); break; case 1: // AST //var ns = projectInfo.Engine.Project.CompileUnits // .GetTopNamespace(source.FileIndex); //AstUtils.FillList(ns, _items); break; } _grid.RowCount = _items.Count; _grid.Invalidate(); _grid.Update(); }; _checkCountLabel.BeginInvoke(action); }
private static IEnumerable <Location> GetLocationsToHighlight(NemerleSource source, Location loc) { foreach (var x in source.MethodsTypeLocations) { if (x.Item1.IsIntersect(loc)) { foreach (var loc2 in x.Item2) { yield return(loc2); } } } foreach (var x in source.TypeLocations) { if (x.IsIntersect(loc)) { yield return(x); } } }
/// try add text markers (markers visualise errors in editor). void TryAddTextMarkers(IEnumerable <NemerleErrorTask> tasks) { var taskGroups = tasks.GroupBy(t => t.CompilerMessage.Location.FileIndex); foreach (var taskGroup in taskGroups) { IVsTextLines buffer = null; // Маркеры для сообщений, сгенерированных при компиляции secondary // файлов, должны устанавливаться в primary буфере if (NemerleSource.HasSecondarySource(taskGroup.Key)) { var secondarySource = GetSource(NemerleSource.GetSecondaryFileIndex(taskGroup.Key)) as NemerleSource; if (secondarySource != null) { buffer = secondarySource.GetPrimaryTextLines(); } } else { var source = GetSource(taskGroup.Key) as NemerleSource; if (source != null) { buffer = source.GetTextLines(); } } if (buffer != null) { foreach (var task in taskGroup) { task.MakeTextMarker(buffer); } } } }
private ReadOnlyCollection <SmartTagActionSet> GetSmartTagActions(SnapshotSpan span) { List <SmartTagActionSet> actionSetList = new List <SmartTagActionSet>(); List <ISmartTagAction> actionList = new List <ISmartTagAction>(); ITrackingSpan trackingSpan = span.Snapshot.CreateTrackingSpan(span, SpanTrackingMode.EdgeInclusive); var snapShot = trackingSpan.TextBuffer.CurrentSnapshot; NemerleSource source = GetNemerleSourceOrNull(); Trace.Assert(source != null); actionList.Add(new SmartTagLambdaAction("Implement interfaces", () => source.ImplementInterfaces(_typeNameLocation.Line, _typeNameLocation.Column))); actionList.Add(new SmartTagLambdaAction("Override members", () => source.OverrideMembers(_typeNameLocation.Line, _typeNameLocation.Column))); SmartTagActionSet actionSet = new SmartTagActionSet(actionList.AsReadOnly()); actionSetList.Add(actionSet); return(actionSetList.AsReadOnly()); }
internal void AddEditableSource(NemerleSource source) { ReplaseOrAddSource(source); }
private static IEnumerable<Location> GetLocationsToHighlight(NemerleSource source, Location loc) { foreach (var x in source.MethodsTypeLocations) { if (x.Item1.IsIntersect(loc)) foreach (var loc2 in x.Item2) yield return loc2; } foreach (var x in source.TypeLocations) if (x.IsIntersect(loc)) yield return x; }