public string GetDescription() { string description = Name; SQDeclarationType type = Type; if (type == SQDeclarationType.Function || type == SQDeclarationType.Variable || type == SQDeclarationType.Class || type == SQDeclarationType.Enum) { string classname = Parent != null && Parent.Type != SQDeclarationType.File ? Parent.Name : ""; string key = Name; string name = key; if (!string.IsNullOrEmpty(classname)) { description = classname + "::" + key; } string id = ""; switch (type) { case SQDeclarationType.Class: id = "class"; break; case SQDeclarationType.Function: { id = "function"; //des SQDeclaration.SQFunction f = (SQDeclaration.SQFunction) this; var parameters = f.GetParameterNames(); description += string.Format("({0})", string.Join(", ", parameters.ToArray())); break; } case SQDeclarationType.Variable: id = "variable"; break; case SQDeclarationType.Enum: id = "enum"; break; } description = string.Format("{0} {1}", id, description); } return(description); }
public IEnumerable <ITagSpan <IOutliningRegionTag> > GetTags(NormalizedSnapshotSpanCollection spans) { if (spans.Count == 0) { yield break; } ITextSnapshot currentSnapshot = _buffer.CurrentSnapshot; /*_CompilerError errors = null; * SQDeclaration sqdec = _languangeService.Parse(currentSnapshot.TextBuffer, ref errors); * if (sqdec == null) * yield return null; * _textspans.Clear(); * GetSpans(_textspans, sqdec);*/ var ts = _languangeService.GetClassificationInfo(filepath); foreach (var t in ts) { SQDeclarationType type = t.Item4; if (type == SQDeclarationType.Class || type == SQDeclarationType.Function || type == SQDeclarationType.Scope || type == SQDeclarationType.AttributeScope || type == SQDeclarationType.Enum || type == SQDeclarationType.Constructor || type == SQDeclarationType.CommentScope) { var scope = t.Item2; if (scope.iStartLine == scope.iEndLine || scope.iEndLine == -1 || scope.iStartLine == -1 || scope.iEndLine >= currentSnapshot.LineCount || scope.iStartLine >= currentSnapshot.LineCount) { continue; } SnapshotSpan?snap = null; string collpasedlabel = "..."; bool collapsed = type == SQDeclarationType.AttributeScope; try { collpasedlabel = t.Item3; var startLine = currentSnapshot.GetLineFromLineNumber(scope.iStartLine); var endLine = currentSnapshot.GetLineFromLineNumber(scope.iEndLine); var start = startLine.Start + scope.iStartIndex; int length = (endLine.Start - startLine.Start) + scope.iEndIndex - scope.iStartIndex; if (start.Position + length >= currentSnapshot.Length) { length = currentSnapshot.Length - start.Position; } if (length > 0) { snap = new SnapshotSpan(start, length); } } catch (Exception) { //this is a safe assumption as the currentsnapshot may have changed at this time } if (snap != null) { yield return(new TagSpan <IOutliningRegionTag>(snap.Value, new OutliningRegionTag(collapsed, collapsed, collpasedlabel, snap.Value.GetText()))); } } } }
public SQVariable(SQDeclarationType variabletype) { _variabletype = variabletype; }
SQVariable ParseVariable(SQDeclaration parent, ref LexerTokenDesc currentDesc, SQDeclarationType type) { string key; SQVariable v = new SQVariable(type) { Name = key = _scanner.svalue, Parent = parent, Span = currentDesc.span, ScopeSpan = currentDesc.span, Level = parent.Level, Url = this.Name }; parent.Children.Add(new SQDeclare(key, v)); return(v); }