gpt4 book ai didi

eclipse - 将 Stack Overflow 集成到 IDE 中?

转载 作者:行者123 更新时间:2023-12-03 12:06:12 24 4
gpt4 key购买 nike

好吧,这只是我的一个疯狂想法。 Stack Overflow 看起来非常结构化并且可以集成到开发应用程序中。那么,是否有可能,甚至有用,为 Eclipse 提供一个 Stack Overflow 插件?

您希望将 Stack Overflow 的哪些功能直接集成到您的 IDE 中,这样您就可以“本地”使用它而无需更改为浏览器?

编辑:我正在考虑更深入的集成方式,而不仅仅是在 IDE 中使用网页。就像当您使用某个 Java 类并遇到问题时,来自 SO 的答案可能会突然爆发。在某些情况下,这样的事情可能很烦人,但其他人可能会很有帮助。

最佳答案

跟进乔希的回答。此 VS 宏将在 StackOverflow 中搜索 Visual Studio IDE 中突出显示的文本。只需突出显示并按 Alt+F1

Public Sub SearchStackOverflowForSelectedText()
Dim s As String = ActiveWindowSelection().Trim()
If s.Length > 0 Then
DTE.ItemOperations.Navigate("http://www.stackoverflow.com/search?q=" & _
Web.HttpUtility.UrlEncode(s))
End If
End Sub

Private Function ActiveWindowSelection() As String
If DTE.ActiveWindow.ObjectKind = EnvDTE.Constants.vsWindowKindOutput Then
Return OutputWindowSelection()
End If
If DTE.ActiveWindow.ObjectKind = "{57312C73-6202-49E9-B1E1-40EA1A6DC1F6}" Then
Return HTMLEditorSelection()
End If
Return SelectionText(DTE.ActiveWindow.Selection)
End Function

Private Function HTMLEditorSelection() As String
Dim hw As HTMLWindow = ActiveDocument.ActiveWindow.Object
Dim tw As TextWindow = hw.CurrentTabObject
Return SelectionText(tw.Selection)
End Function

Private Function OutputWindowSelection() As String
Dim w As Window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput)
Dim ow As OutputWindow = w.Object
Dim owp As OutputWindowPane = ow.OutputWindowPanes.Item(ow.ActivePane.Name)
Return SelectionText(owp.TextDocument.Selection)
End Function

Private Function SelectionText(ByVal sel As EnvDTE.TextSelection) As String
If sel Is Nothing Then
Return ""
End If
If sel.Text.Length = 0 Then
SelectWord(sel)
End If
If sel.Text.Length <= 2 Then
Return ""
End If
Return sel.Text
End Function

Private Sub SelectWord(ByVal sel As EnvDTE.TextSelection)
Dim leftPos As Integer
Dim line As Integer
Dim pt As EnvDTE.EditPoint = sel.ActivePoint.CreateEditPoint()

sel.WordLeft(True, 1)
line = sel.TextRanges.Item(1).StartPoint.Line
leftPos = sel.TextRanges.Item(1).StartPoint.LineCharOffset
pt.MoveToLineAndOffset(line, leftPos)
sel.MoveToPoint(pt)
sel.WordRight(True, 1)
End Sub

安装:
  • 转到工具 - 宏 - IDE
  • 在“MyMacros”下使用您选择的名称创建一个新模块。或使用现有模块。
  • 将以上代码粘贴到模块
  • 将 System.Web 命名空间(用于 HttpUtility)的引用添加到模块
  • 关闭宏IDE窗口
  • 转到工具-选项-环境-键盘
  • 在“显示包含的命令”文本框中键入“google”。 SearchGoogleForSelectedText 宏应该会出现
  • 单击 Press Shortcut Keys 文本框,然后按 ALT+F1
  • 单击分配按钮
  • 点击确定

  • 这全部取自 Jeff Atwood 的 Google Search VS Macro post,只是修改为搜索 StackOverflow。

    关于eclipse - 将 Stack Overflow 集成到 IDE 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/134520/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com