From b562d11994950613cc0e51a4f3ca553d12a2ec02 Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Wed, 2 Oct 2019 11:10:34 -0700 Subject: [PATCH] plugin: Remove Logging alias and update imports --- plugin/src/Components/App.lua | 16 ++++++++-------- plugin/src/InstanceMap.lua | 10 +++++----- plugin/src/Logging.lua | 2 -- plugin/src/Reconciler.lua | 10 +++++----- plugin/src/Session.lua | 4 +--- plugin/src/preloadAssets.lua | 5 +++-- plugin/src/setCanonicalProperty.lua | 2 +- 7 files changed, 23 insertions(+), 26 deletions(-) delete mode 100644 plugin/src/Logging.lua diff --git a/plugin/src/Components/App.lua b/plugin/src/Components/App.lua index 7fcd4095..62150174 100644 --- a/plugin/src/Components/App.lua +++ b/plugin/src/Components/App.lua @@ -2,11 +2,11 @@ local Rojo = script:FindFirstAncestor("Rojo") local Plugin = Rojo.Plugin local Roact = require(Rojo.Roact) +local Log = require(Rojo.Log) local Assets = require(Plugin.Assets) local Config = require(Plugin.Config) local DevSettings = require(Plugin.DevSettings) -local Logging = require(Plugin.Logging) local Session = require(Plugin.Session) local Version = require(Plugin.Version) local preloadAssets = require(Plugin.preloadAssets) @@ -26,7 +26,7 @@ local function showUpgradeMessage(lastVersion) Version.display(Config.version), Config.expectedServerVersionString ) - Logging.info(message) + Log.info(message) end --[[ @@ -114,7 +114,7 @@ function App:render() children = { ConnectionActivePanel = e(ConnectionActivePanel, { stopSession = function() - Logging.trace("Disconnecting session") + Log.trace("Disconnecting session") self.currentSession:disconnect() self.currentSession = nil @@ -122,7 +122,7 @@ function App:render() sessionStatus = SessionStatus.Disconnected, }) - Logging.trace("Session terminated by user") + Log.trace("Session terminated by user") end, }), } @@ -130,13 +130,13 @@ function App:render() children = { ConnectPanel = e(ConnectPanel, { startSession = function(address, port) - Logging.trace("Starting new session") + Log.trace("Starting new session") local success, session = Session.new({ address = address, port = port, onError = function(message) - Logging.warn("Rojo session terminated because of an error:\n%s", tostring(message)) + Log.warn("Rojo session terminated because of an error:\n%s", tostring(message)) self.currentSession = nil self:setState({ @@ -153,7 +153,7 @@ function App:render() end end, cancel = function() - Logging.trace("Canceling session configuration") + Log.trace("Canceling session configuration") self:setState({ sessionStatus = SessionStatus.Disconnected, @@ -169,7 +169,7 @@ function App:render() end function App:didMount() - Logging.trace("Rojo %s initializing", self.displayedVersion) + Log.trace("Rojo %s initializing", self.displayedVersion) checkUpgrade(self.props.plugin) preloadAssets() diff --git a/plugin/src/InstanceMap.lua b/plugin/src/InstanceMap.lua index 16cefbd9..8ec3bf54 100644 --- a/plugin/src/InstanceMap.lua +++ b/plugin/src/InstanceMap.lua @@ -1,4 +1,4 @@ -local Logging = require(script.Parent.Logging) +local Log = require(script.Parent.Parent.Log) --[[ A bidirectional map between instance IDs and Roblox instances. It lets us @@ -30,7 +30,7 @@ function InstanceMap:removeId(id) self.fromIds[id] = nil self.fromInstances[instance] = nil else - Logging.warn("Attempted to remove nonexistant ID %s", tostring(id)) + Log.warn("Attempted to remove nonexistant ID %s", tostring(id)) end end @@ -41,7 +41,7 @@ function InstanceMap:removeInstance(instance) self.fromInstances[instance] = nil self.fromIds[id] = nil else - Logging.warn("Attempted to remove nonexistant instance %s", tostring(instance)) + Log.warn("Attempted to remove nonexistant instance %s", tostring(instance)) end end @@ -51,7 +51,7 @@ function InstanceMap:destroyInstance(instance) if id ~= nil then self:destroyId(id) else - Logging.warn("Attempted to destroy untracked instance %s", tostring(instance)) + Log.warn("Attempted to destroy untracked instance %s", tostring(instance)) end end @@ -74,7 +74,7 @@ function InstanceMap:destroyId(id) instance:Destroy() else - Logging.warn("Attempted to destroy nonexistant ID %s", tostring(id)) + Log.warn("Attempted to destroy nonexistant ID %s", tostring(id)) end end diff --git a/plugin/src/Logging.lua b/plugin/src/Logging.lua deleted file mode 100644 index 398568ad..00000000 --- a/plugin/src/Logging.lua +++ /dev/null @@ -1,2 +0,0 @@ --- TODO: Remove this once all references have been updated. -return require(script.Parent.Parent.Log) \ No newline at end of file diff --git a/plugin/src/Reconciler.lua b/plugin/src/Reconciler.lua index 0e626bef..4a2d0884 100644 --- a/plugin/src/Reconciler.lua +++ b/plugin/src/Reconciler.lua @@ -1,7 +1,7 @@ local t = require(script.Parent.Parent.t) +local Log = require(script.Parent.Parent.Log) local InstanceMap = require(script.Parent.InstanceMap) -local Logging = require(script.Parent.Logging) local setCanonicalProperty = require(script.Parent.setCanonicalProperty) local rojoValueToRobloxValue = require(script.Parent.rojoValueToRobloxValue) local Types = require(script.Parent.Types) @@ -50,7 +50,7 @@ function Reconciler:reconcile(virtualInstancesById, id, instance) -- If an instance changes ClassName, we assume it's very different. That's -- not always the case! if virtualInstance.ClassName ~= instance.ClassName then - Logging.trace("Switching to reify for %s because ClassName is different", instance:GetFullName()) + Log.trace("Switching to reify for %s because ClassName is different", instance:GetFullName()) -- TODO: Preserve existing children instead? local parent = instance.Parent @@ -95,7 +95,7 @@ function Reconciler:reconcile(virtualInstancesById, id, instance) unvisitedExistingChildren[existingChildInstance] = nil self:reconcile(virtualInstancesById, childId, existingChildInstance) else - Logging.trace( + Log.trace( "Switching to reify for %s.%s because it does not exist", instance:GetFullName(), virtualInstancesById[childId].Name @@ -125,7 +125,7 @@ function Reconciler:reconcile(virtualInstancesById, id, instance) local parent = self.instanceMap.fromIds[virtualInstance.Parent] if parent == nil then - Logging.info("Instance %s wanted parent of %s", tostring(id), tostring(virtualInstance.Parent)) + Log.info("Instance %s wanted parent of %s", tostring(id), tostring(virtualInstance.Parent)) error("Rojo bug: During reconciliation, an instance referred to an instance ID as parent that does not exist.") end @@ -232,7 +232,7 @@ function Reconciler:__applyUpdatePiece(id, visitedIds, virtualInstancesById) return end - Logging.trace("Instance ID %s, parent ID %s", tostring(id), tostring(virtualInstance.Parent)) + Log.trace("Instance ID %s, parent ID %s", tostring(id), tostring(virtualInstance.Parent)) error("Rojo NYI: Instances with parents that weren't mentioned in an update payload") end diff --git a/plugin/src/Session.lua b/plugin/src/Session.lua index a9b30005..ef37f16c 100644 --- a/plugin/src/Session.lua +++ b/plugin/src/Session.lua @@ -1,6 +1,4 @@ -local Rojo = script:FindFirstAncestor("Rojo") - -local Promise = require(Rojo.Promise) +local Promise = require(script.Parent.Parent.Promise) local ApiContext = require(script.Parent.ApiContext) local Reconciler = require(script.Parent.Reconciler) diff --git a/plugin/src/preloadAssets.lua b/plugin/src/preloadAssets.lua index 6f40e001..a8a4a4f1 100644 --- a/plugin/src/preloadAssets.lua +++ b/plugin/src/preloadAssets.lua @@ -1,6 +1,7 @@ local ContentProvider = game:GetService("ContentProvider") -local Logging = require(script.Parent.Logging) +local Log = require(script.Parent.Parent.Log) + local Assets = require(script.Parent.Assets) local function preloadAssets() @@ -18,7 +19,7 @@ local function preloadAssets() table.insert(contentUrls, url) end - Logging.trace("Preloading assets: %s", table.concat(contentUrls, ", ")) + Log.trace("Preloading assets: %s", table.concat(contentUrls, ", ")) coroutine.wrap(function() ContentProvider:PreloadAsync(contentUrls) diff --git a/plugin/src/setCanonicalProperty.lua b/plugin/src/setCanonicalProperty.lua index 8314cfcd..9554d020 100644 --- a/plugin/src/setCanonicalProperty.lua +++ b/plugin/src/setCanonicalProperty.lua @@ -1,4 +1,4 @@ -local RbxDom = require(script:FindFirstAncestor("Rojo").RbxDom) +local RbxDom = require(script.Parent.Parent.RbxDom) --[[ Attempts to set a property on the given instance.