private void UpdateTags(AntlrParseResultEventArgs antlrParseResultArgs) { List <IEditorNavigationTarget> navigationTargets = new List <IEditorNavigationTarget>(); IAstRuleReturnScope resultArgs = antlrParseResultArgs.Result as IAstRuleReturnScope; var result = resultArgs != null ? resultArgs.Tree as CommonTree : null; if (result != null) { ITextSnapshot snapshot = antlrParseResultArgs.Snapshot; string package = string.Empty; /* ^('package' qualifiedName) * * ^(CLASS_TYPE_IDENTIFIER modifiers .* ^(TYPE_BODY .* '}')) * * ^(INTERFACE_TYPE_IDENTIFIER modifiers .* ^(TYPE_BODY .* '}')) * * ^(ANNOTATION_TYPE_IDENTIFIER modifiers .* ^(TYPE_BODY .* '}')) * * ^(FIELD_DECLARATION modifiers (.* ^(VARIABLE_IDENTIFIER .*))*) * * ^(METHOD_IDENTIFIER modifiers .* ^(FORMAL_PARAMETERS .* ')') .* ^(METHOD_BODY .* '}')) */ /* STATEMENT COMPLETION (description unrelated to this file) * * IDENTIFIER ('.' IDENTIFIER)* * * ^(CALL IDENTIFIER .*) * * ^('(' ^('==' .*) ')') * */ for (CommonTreeNodeStream treeNodeStream = new CommonTreeNodeStream(result); treeNodeStream.LA(1) != CharStreamConstants.EndOfFile; treeNodeStream.Consume()) { switch (treeNodeStream.LA(1)) { case Java2Lexer.PACKAGE: // ^('package' qualifiedName) { CommonTree child = treeNodeStream.LT(1) as CommonTree; if (child != null && child.ChildCount > 0) { package = GetQualifiedIdentifier(child.GetChild(0)); } } break; case Java2Lexer.VARIABLE_IDENTIFIER: // ^(FIELD_DECLARATION (.* ^(VARIABLE_IDENTIFIER))*) { CommonTree child = treeNodeStream.LT(1) as CommonTree; if (child != null && child.HasAncestor(Java2Lexer.FIELD_DECLARATION)) { string name = child.Token.Text; IEditorNavigationType navigationType = EditorNavigationTypeRegistryService.GetEditorNavigationType(PredefinedEditorNavigationTypes.Members); var startToken = antlrParseResultArgs.Tokens[child.TokenStartIndex]; var stopToken = antlrParseResultArgs.Tokens[child.TokenStopIndex]; SnapshotSpan span = new SnapshotSpan(snapshot, new Span(startToken.StartIndex, stopToken.StopIndex - startToken.StartIndex + 1)); SnapshotSpan seek = new SnapshotSpan(snapshot, new Span(child.Token.StartIndex, 0)); StandardGlyphGroup glyphGroup = StandardGlyphGroup.GlyphGroupJSharpField; StandardGlyphItem glyphItem = GetGlyphItemFromChildModifier((CommonTree)child.GetAncestor(Java2Lexer.FIELD_DECLARATION)); ImageSource glyph = _provider.GlyphService.GetGlyph(glyphGroup, glyphItem); NavigationTargetStyle style = NavigationTargetStyle.None; navigationTargets.Add(new EditorNavigationTarget(name, navigationType, span, seek, glyph, style)); } } break; case Java2Lexer.METHOD_IDENTIFIER: // ^(METHOD_IDENTIFIER ^(FORMAL_PARAMETERS formalParameterDecls?) ^(METHOD_BODY .* END_METHOD_BODY)) { CommonTree child = treeNodeStream.LT(1) as CommonTree; if (child != null) { string name = child.Token.Text; IEnumerable <string> args = ProcessArguments((CommonTree)child.GetFirstChildWithType(Java2Lexer.FORMAL_PARAMETERS)); string sig = string.Format("{0}({1})", name, string.Join(", ", args)); IEditorNavigationType navigationType = EditorNavigationTypeRegistryService.GetEditorNavigationType(PredefinedEditorNavigationTypes.Members); var startToken = antlrParseResultArgs.Tokens[child.TokenStartIndex]; var stopToken = antlrParseResultArgs.Tokens[child.TokenStopIndex]; SnapshotSpan span = new SnapshotSpan(snapshot, new Span(startToken.StartIndex, stopToken.StopIndex - startToken.StartIndex + 1)); SnapshotSpan seek = new SnapshotSpan(snapshot, new Span(child.Token.StartIndex, 0)); StandardGlyphGroup glyphGroup = StandardGlyphGroup.GlyphGroupJSharpMethod; StandardGlyphItem glyphItem = GetGlyphItemFromChildModifier(child); ImageSource glyph = _provider.GlyphService.GetGlyph(glyphGroup, glyphItem); NavigationTargetStyle style = NavigationTargetStyle.None; navigationTargets.Add(new EditorNavigationTarget(sig, navigationType, span, seek, glyph, style)); } } break; case Java2Lexer.ENUM_TYPE_IDENTIFIER: case Java2Lexer.ANNOTATION_TYPE_IDENTIFIER: case Java2Lexer.INTERFACE_TYPE_IDENTIFIER: case Java2Lexer.CLASS_TYPE_IDENTIFIER: { CommonTree child = treeNodeStream.LT(1) as CommonTree; if (child != null) { string name = child.Token.Text; for (ITree parent = child.Parent; parent != null; parent = parent.Parent) { switch (parent.Type) { case Java2Lexer.ENUM_TYPE_IDENTIFIER: case Java2Lexer.ANNOTATION_TYPE_IDENTIFIER: case Java2Lexer.INTERFACE_TYPE_IDENTIFIER: case Java2Lexer.CLASS_TYPE_IDENTIFIER: name = parent.Text + "." + name; continue; default: continue; } } if (!string.IsNullOrEmpty(package)) { name = package + "." + name; } IEditorNavigationType navigationType = EditorNavigationTypeRegistryService.GetEditorNavigationType(PredefinedEditorNavigationTypes.Types); var startToken = antlrParseResultArgs.Tokens[child.TokenStartIndex]; var stopToken = antlrParseResultArgs.Tokens[child.TokenStopIndex]; SnapshotSpan span = new SnapshotSpan(snapshot, new Span(startToken.StartIndex, stopToken.StopIndex - startToken.StartIndex + 1)); SnapshotSpan seek = new SnapshotSpan(snapshot, new Span(child.Token.StartIndex, 0)); StandardGlyphGroup glyphGroup; switch (child.Type) { case Java2Lexer.ENUM_TYPE_IDENTIFIER: glyphGroup = StandardGlyphGroup.GlyphGroupEnum; break; case Java2Lexer.ANNOTATION_TYPE_IDENTIFIER: case Java2Lexer.INTERFACE_TYPE_IDENTIFIER: glyphGroup = StandardGlyphGroup.GlyphGroupJSharpInterface; break; case Java2Lexer.CLASS_TYPE_IDENTIFIER: default: glyphGroup = StandardGlyphGroup.GlyphGroupJSharpClass; break; } StandardGlyphItem glyphItem = GetGlyphItemFromChildModifier(child); ImageSource glyph = _provider.GlyphService.GetGlyph(glyphGroup, glyphItem); NavigationTargetStyle style = NavigationTargetStyle.None; navigationTargets.Add(new EditorNavigationTarget(name, navigationType, span, seek, glyph, style)); } } break; default: continue; } } } this._navigationTargets = navigationTargets; OnNavigationTargetsChanged(EventArgs.Empty); }