ZeroBrane studio
#29
I was more playing with the thought of concatenating all files into a single string and passing that to the analyzer - that should, theoretically, allow it to do a better job with those functions. I might give it a try later on, for now I'm content with what ZBS does and will recommend it to anyone doing plugin development for MCS, especially when on Linux / MacOS. For Windows, Decoda is still my favorite IDE because it allows me to see stack traces in both the Lua code as well as C++ code.

Hmm, I just couldn't keep off of it. I've tried the following snippet and it seems to do what I want, now only it needs converting from the big blob linenumbers back to original files' names and line numbers
-- packages/analyzeall.lua:
local G = ...
local id = G.ID("analyzeall.analyzeall")
local menuid
 
local function analyzeProject()
  local frame = ide:GetMainFrame()
  local menubar = ide:GetMenuBar()
  if menubar:IsChecked(ID_CLEAROUTPUT) then ClearOutput() end
  DisplayOutputLn("Analyzing the project code.")
  frame:Update()
 
  local projectPath = ide:GetProject()
  local src = {}
  local files = {}
  if projectPath then
    for _, filePath in ipairs(FileSysGetRecursive(projectPath, true, "*.lua")) do
      files[#files + 1] = filePath
    end
    table.sort(files)
    for _, fileName in ipairs(files) do
      src[#src + 1] = FileRead(fileName)
    end
    local warn, err, line = AnalyzeString(table.concat(src, "\n"))
    if err then
      DisplayOutputNoMarker("Error: " .. err .. "\n")
    elseif (#warn > 0) then
      DisplayOutputNoMarker(table.concat(warn, "\n") .. "\n")
    end
    frame:Update() -- refresh the output with new results
  end
end
 
return {
  name = "Analyze all files as a single blob",
  description = "Analyzes all files in a project.",
  author = "Paul Kulchenko",
  version = 0.1,
 
  onRegister = function(self)
    local menu = ide:GetMenuBar():GetMenu(ide:GetMenuBar():FindMenu(TR("&Project")))
    local _, analyzepos = ide:FindMenuItem(menu, ID_ANALYZE)
    if analyzepos then
      menu:Insert(analyzepos+1, id, TR("Analyze All")..KSC(id), TR("Analyze the project source code"))
    end
    ide:GetMainFrame():Connect(id, wx.wxEVT_COMMAND_MENU_SELECTED, analyzeProject)
  end,
 
  onUnRegister = function(self)
    local menu = ide:GetMenuBar():GetMenu(ide:GetMenuBar():FindMenu(TR("&Project")))
    ide:GetMainFrame():Disconnect(id, wx.wxID_ANY, wx.wxEVT_COMMAND_MENU_SELECTED)
    if menuid then menu:Destroy(menuid) end
  end,
}



-- Add this to src/editor/inspect.lua:
function AnalyzeString(src)
  local warn, err, line, pos = M.warnings_from_string(src, "src")
  if err then
    err = err:gsub("line %d+, char %d+", "syntax error")
  end
  return warn, err, line, pos
end

Of course I'm just messing around, the code will need proper massaging if we want it production-grade.
Reply
Thanks given by:


Messages In This Thread
ZeroBrane studio - by xoft - 02-22-2014, 11:10 PM
RE: ZeroBrane studio - by FakeTruth - 02-23-2014, 12:14 AM
RE: ZeroBrane studio - by xoft - 02-23-2014, 12:30 AM
RE: ZeroBrane studio - by paulclinger - 02-24-2014, 04:01 PM
RE: ZeroBrane studio - by xoft - 02-24-2014, 05:19 PM
RE: ZeroBrane studio - by paulclinger - 02-25-2014, 09:02 AM
RE: ZeroBrane studio - by FakeTruth - 02-25-2014, 04:39 PM
RE: ZeroBrane studio - by paulclinger - 02-26-2014, 05:54 AM
RE: ZeroBrane studio - by FakeTruth - 02-24-2014, 10:54 PM
RE: ZeroBrane studio - by xoft - 02-25-2014, 08:36 AM
RE: ZeroBrane studio - by xoft - 02-25-2014, 09:25 AM
RE: ZeroBrane studio - by paulclinger - 02-25-2014, 01:56 PM
RE: ZeroBrane studio - by FakeTruth - 02-27-2014, 04:40 AM
RE: ZeroBrane studio - by paulclinger - 02-28-2014, 08:55 AM
RE: ZeroBrane studio - by xoft - 02-28-2014, 01:08 AM
RE: ZeroBrane studio - by xoft - 02-28-2014, 06:27 AM
RE: ZeroBrane studio - by xoft - 03-01-2014, 01:29 AM
RE: ZeroBrane studio - by paulclinger - 03-01-2014, 03:58 AM
RE: ZeroBrane studio - by xoft - 03-01-2014, 11:53 AM
RE: ZeroBrane studio - by paulclinger - 03-01-2014, 04:43 PM
RE: ZeroBrane studio - by xoft - 03-01-2014, 09:45 PM
RE: ZeroBrane studio - by FakeTruth - 03-01-2014, 11:00 PM
RE: ZeroBrane studio - by xoft - 03-01-2014, 11:15 PM
RE: ZeroBrane studio - by FakeTruth - 03-02-2014, 12:17 AM
RE: ZeroBrane studio - by paulclinger - 03-02-2014, 04:24 AM
RE: ZeroBrane studio - by paulclinger - 03-03-2014, 10:43 AM
RE: ZeroBrane studio - by xoft - 03-04-2014, 06:44 PM
RE: ZeroBrane studio - by paulclinger - 03-05-2014, 03:07 AM
RE: ZeroBrane studio - by xoft - 03-05-2014, 03:37 AM
RE: ZeroBrane studio - by xoft - 03-17-2014, 06:17 AM
RE: ZeroBrane studio - by paulclinger - 03-17-2014, 01:09 PM
RE: ZeroBrane studio - by xoft - 03-17-2014, 07:20 PM
RE: ZeroBrane studio - by xoft - 03-20-2014, 07:47 AM
RE: ZeroBrane studio - by xoft - 04-01-2014, 02:14 AM
RE: ZeroBrane studio - by bearbin - 04-01-2014, 05:04 AM
RE: ZeroBrane studio - by NiLSPACE - 04-12-2015, 03:33 AM
RE: ZeroBrane studio - by xoft - 04-12-2015, 03:48 AM
RE: ZeroBrane studio - by NiLSPACE - 04-12-2015, 03:51 AM
RE: ZeroBrane studio - by xoft - 07-25-2015, 04:09 PM



Users browsing this thread: 1 Guest(s)