Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
Log the file scope in debug
Browse files Browse the repository at this point in the history
Display the scopes of the last cursor in the current file in the debug
command so they can be verified against the scopes allowed in the
configuration of the package.
  • Loading branch information
Arcanemagus committed Mar 3, 2017
1 parent 4a3d02d commit e635a3e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ let getDebugInfo = exports.getDebugInfo = (() => {
var _ref = _asyncToGenerator(function* (worker) {
const textEditor = atom.workspace.getActiveTextEditor();
let filePath;
let editorScopes;
if (atom.workspace.isTextEditor(textEditor)) {
filePath = textEditor.getPath();
editorScopes = textEditor.getLastCursor().getScopeDescriptor().getScopesArray();
} else {
// Somehow this can be called with no active TextEditor, impossible I know...
filePath = 'unknown';
editorScopes = ['unknown'];
}
const packagePath = atom.packages.resolvePackagePath('linter-eslint');
let linterEslintMeta;
Expand Down Expand Up @@ -43,7 +46,8 @@ let getDebugInfo = exports.getDebugInfo = (() => {
hoursSinceRestart,
platform: process.platform,
eslintType: response.type,
eslintPath: response.path
eslintPath: response.path,
editorScopes
};
} catch (error) {
atom.notifications.addError(`${error}`);
Expand All @@ -59,7 +63,7 @@ let getDebugInfo = exports.getDebugInfo = (() => {
let generateDebugString = exports.generateDebugString = (() => {
var _ref2 = _asyncToGenerator(function* (worker) {
const debug = yield getDebugInfo(worker);
const details = [`Atom version: ${debug.atomVersion}`, `linter-eslint version: ${debug.linterEslintVersion}`, `ESLint version: ${debug.eslintVersion}`, `Hours since last Atom restart: ${debug.hoursSinceRestart}`, `Platform: ${debug.platform}`, `Using ${debug.eslintType} ESLint from: ${debug.eslintPath}`, `linter-eslint configuration: ${JSON.stringify(debug.linterEslintConfig, null, 2)}`];
const details = [`Atom version: ${debug.atomVersion}`, `linter-eslint version: ${debug.linterEslintVersion}`, `ESLint version: ${debug.eslintVersion}`, `Hours since last Atom restart: ${debug.hoursSinceRestart}`, `Platform: ${debug.platform}`, `Using ${debug.eslintType} ESLint from: ${debug.eslintPath}`, `Current file's scopes: ${JSON.stringify(debug.editorScopes, null, 2)}`, `linter-eslint configuration: ${JSON.stringify(debug.linterEslintConfig, null, 2)}`];
return details.join('\n');
});

Expand Down
5 changes: 5 additions & 0 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,14 @@ function validatePoint(textEditor, line, col) {
export async function getDebugInfo(worker) {
const textEditor = atom.workspace.getActiveTextEditor()
let filePath
let editorScopes
if (atom.workspace.isTextEditor(textEditor)) {
filePath = textEditor.getPath()
editorScopes = textEditor.getLastCursor().getScopeDescriptor().getScopesArray()
} else {
// Somehow this can be called with no active TextEditor, impossible I know...
filePath = 'unknown'
editorScopes = ['unknown']
}
const packagePath = atom.packages.resolvePackagePath('linter-eslint')
let linterEslintMeta
Expand Down Expand Up @@ -105,6 +108,7 @@ export async function getDebugInfo(worker) {
platform: process.platform,
eslintType: response.type,
eslintPath: response.path,
editorScopes,
}
} catch (error) {
atom.notifications.addError(`${error}`)
Expand All @@ -121,6 +125,7 @@ export async function generateDebugString(worker) {
`Hours since last Atom restart: ${debug.hoursSinceRestart}`,
`Platform: ${debug.platform}`,
`Using ${debug.eslintType} ESLint from: ${debug.eslintPath}`,
`Current file's scopes: ${JSON.stringify(debug.editorScopes, null, 2)}`,
`linter-eslint configuration: ${JSON.stringify(debug.linterEslintConfig, null, 2)}`
]
return details.join('\n')
Expand Down

0 comments on commit e635a3e

Please sign in to comment.