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

Commit

Permalink
Merge pull request #835 from AtomLinter/arcanemagus/add-current-scope
Browse files Browse the repository at this point in the history
Log the file scope in debug command
  • Loading branch information
Arcanemagus committed Mar 5, 2017
2 parents b878023 + e635a3e commit 9bd6aac
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
16 changes: 13 additions & 3 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@ exports.processESLintMessages = exports.generateDebugString = exports.getDebugIn
let getDebugInfo = exports.getDebugInfo = (() => {
var _ref = _asyncToGenerator(function* (worker) {
const textEditor = atom.workspace.getActiveTextEditor();
const filePath = textEditor.getPath();
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;
if (packagePath === undefined) {
Expand Down Expand Up @@ -37,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 @@ -53,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
15 changes: 13 additions & 2 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,16 @@ function validatePoint(textEditor, line, col) {

export async function getDebugInfo(worker) {
const textEditor = atom.workspace.getActiveTextEditor()
const filePath = textEditor.getPath()
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
if (packagePath === undefined) {
Expand Down Expand Up @@ -99,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 @@ -114,7 +124,8 @@ export async function generateDebugString(worker) {
`ESLint version: ${debug.eslintVersion}`,
`Hours since last Atom restart: ${debug.hoursSinceRestart}`,
`Platform: ${debug.platform}`,
`Using ${debug.eslintType} ESLint from ${debug.eslintPath}`,
`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 9bd6aac

Please sign in to comment.