@@ -6,6 +6,7 @@ import { ILintMessage } from './baseLinter';
66import { OutputChannel } from 'vscode' ;
77import { execPythonFile , IS_WINDOWS } from './../common/utils' ;
88import { Product } from '../common/installer' ;
9+ import { TextDocument } from 'vscode' ;
910
1011export class Linter extends baseLinter . BaseLinter {
1112 constructor ( outputChannel : OutputChannel , workspaceRootPath ?: string ) {
@@ -15,15 +16,15 @@ export class Linter extends baseLinter.BaseLinter {
1516 public isEnabled ( ) : Boolean {
1617 return this . pythonSettings . linting . pydocstyleEnabled ;
1718 }
18- public runLinter ( filePath : string , txtDocumentLines : string [ ] ) : Promise < baseLinter . ILintMessage [ ] > {
19+ public runLinter ( document : TextDocument ) : Promise < baseLinter . ILintMessage [ ] > {
1920 if ( ! this . pythonSettings . linting . pydocstyleEnabled ) {
2021 return Promise . resolve ( [ ] ) ;
2122 }
2223
2324 let pydocstylePath = this . pythonSettings . linting . pydocstylePath ;
2425 let pydocstyleArgs = Array . isArray ( this . pythonSettings . linting . pydocstyleArgs ) ? this . pythonSettings . linting . pydocstyleArgs : [ ] ;
2526 return new Promise < baseLinter . ILintMessage [ ] > ( resolve => {
26- this . run ( pydocstylePath , pydocstyleArgs . concat ( [ filePath ] ) , filePath , txtDocumentLines ) . then ( messages => {
27+ this . run ( pydocstylePath , pydocstyleArgs . concat ( [ document . uri . fsPath ] ) , document ) . then ( messages => {
2728 // All messages in pep8 are treated as warnings for now
2829 messages . forEach ( msg => {
2930 msg . severity = baseLinter . LintMessageSeverity . Information ;
@@ -34,7 +35,7 @@ export class Linter extends baseLinter.BaseLinter {
3435 } ) ;
3536 }
3637
37- protected run ( commandLine : string , args : string [ ] , filePath : string , txtDocumentLines : string [ ] ) : Promise < ILintMessage [ ] > {
38+ protected run ( commandLine : string , args : string [ ] , document : TextDocument ) : Promise < ILintMessage [ ] > {
3839 let outputChannel = this . outputChannel ;
3940
4041 return new Promise < ILintMessage [ ] > ( ( resolve , reject ) => {
@@ -43,7 +44,7 @@ export class Linter extends baseLinter.BaseLinter {
4344 outputChannel . append ( data ) ;
4445 let outputLines = data . split ( / \r ? \n / g) ;
4546 let diagnostics : ILintMessage [ ] = [ ] ;
46- let baseFileName = path . basename ( filePath ) ;
47+ let baseFileName = path . basename ( document . uri . fsPath ) ;
4748
4849 // Remember, the first line of the response contains the file name and line number, the next line contains the error message
4950 // So we have two lines per message, hence we need to take lines in pairs
@@ -76,7 +77,7 @@ export class Linter extends baseLinter.BaseLinter {
7677 let code = part . substring ( 0 , part . indexOf ( ':' ) ) . trim ( ) ;
7778 let message = part . substring ( part . indexOf ( ':' ) + 1 ) . trim ( ) ;
7879
79- let sourceLine = txtDocumentLines [ lineNumber - 1 ] ;
80+ let sourceLine = document . lineAt ( lineNumber - 1 ) . text ;
8081 let trmmedSourceLine = sourceLine . trim ( ) ;
8182 let sourceStart = sourceLine . indexOf ( trmmedSourceLine ) ;
8283
0 commit comments