parent
06b5411fb3
commit
5ae3a573b9
@ -1,6 +1,6 @@
|
|||||||
flake8>=2.0
|
flake8>=2.0
|
||||||
mock>=1.0.1
|
mock>=1.0.1
|
||||||
nose>=1.3.0
|
nose>=1.3.0
|
||||||
PyHamcrest>=1.7.2
|
PyHamcrest>=1.8.0
|
||||||
WebTest>=2.0.9
|
WebTest>=2.0.9
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ FILE_TOO_SHORT_MESSAGE = (
|
|||||||
'File is less than {0} lines long; not compiling.'.format(
|
'File is less than {0} lines long; not compiling.'.format(
|
||||||
MIN_LINES_IN_FILE_TO_PARSE ) )
|
MIN_LINES_IN_FILE_TO_PARSE ) )
|
||||||
NO_DIAGNOSTIC_MESSAGE = 'No diagnostic for current line!'
|
NO_DIAGNOSTIC_MESSAGE = 'No diagnostic for current line!'
|
||||||
|
PRAGMA_DIAG_TEXT_TO_IGNORE = '#pragma once in main file'
|
||||||
|
|
||||||
|
|
||||||
class ClangCompleter( Completer ):
|
class ClangCompleter( Completer ):
|
||||||
@ -196,6 +197,7 @@ class ClangCompleter( Completer ):
|
|||||||
self.GetUnsavedFilesVector( request_data ),
|
self.GetUnsavedFilesVector( request_data ),
|
||||||
flags )
|
flags )
|
||||||
|
|
||||||
|
diagnostics = _FilterDiagnostics( diagnostics )
|
||||||
self._diagnostic_store = DiagnosticsToDiagStructure( diagnostics )
|
self._diagnostic_store = DiagnosticsToDiagStructure( diagnostics )
|
||||||
return [ ConvertToDiagnosticResponse( x ) for x in
|
return [ ConvertToDiagnosticResponse( x ) for x in
|
||||||
diagnostics[ : self._max_diagnostics_to_display ] ]
|
diagnostics[ : self._max_diagnostics_to_display ] ]
|
||||||
@ -261,7 +263,7 @@ def ConvertCompletionData( completion_data ):
|
|||||||
|
|
||||||
|
|
||||||
def DiagnosticsToDiagStructure( diagnostics ):
|
def DiagnosticsToDiagStructure( diagnostics ):
|
||||||
structure = defaultdict(lambda : defaultdict(list))
|
structure = defaultdict( lambda : defaultdict( list ) )
|
||||||
for diagnostic in diagnostics:
|
for diagnostic in diagnostics:
|
||||||
structure[ diagnostic.filename_ ][ diagnostic.line_number_ ].append(
|
structure[ diagnostic.filename_ ][ diagnostic.line_number_ ].append(
|
||||||
diagnostic )
|
diagnostic )
|
||||||
@ -283,4 +285,14 @@ def ConvertToDiagnosticResponse( diagnostic ):
|
|||||||
diagnostic.text_,
|
diagnostic.text_,
|
||||||
diagnostic.kind_ )
|
diagnostic.kind_ )
|
||||||
|
|
||||||
|
def _FilterDiagnostics( diagnostics ):
|
||||||
|
# Clang has an annoying warning that shows up when we try to compile header
|
||||||
|
# files if the header has "#pragma once" inside it. The error is not
|
||||||
|
# legitimate because it shows up because libclang thinks we are compiling a
|
||||||
|
# source file instead of a header file.
|
||||||
|
#
|
||||||
|
# See our issue #216 and upstream bug:
|
||||||
|
# http://llvm.org/bugs/show_bug.cgi?id=16686
|
||||||
|
return [ x for x in diagnostics if x.text_ != PRAGMA_DIAG_TEXT_TO_IGNORE ]
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ from .test_utils import Setup, BuildRequest
|
|||||||
from webtest import TestApp
|
from webtest import TestApp
|
||||||
from nose.tools import with_setup
|
from nose.tools import with_setup
|
||||||
from hamcrest import ( assert_that, contains, contains_string, has_entries,
|
from hamcrest import ( assert_that, contains, contains_string, has_entries,
|
||||||
has_entry )
|
has_entry, empty )
|
||||||
from .. import handlers
|
from .. import handlers
|
||||||
import bottle
|
import bottle
|
||||||
|
|
||||||
@ -53,6 +53,29 @@ struct Foo {
|
|||||||
'line_num': 2,
|
'line_num': 2,
|
||||||
'column_num': 7 } ) ) )
|
'column_num': 7 } ) ) )
|
||||||
|
|
||||||
|
@with_setup( Setup )
|
||||||
|
def Diagnostics_ClangCompleter_PragmaOnceWarningIgnored_test():
|
||||||
|
app = TestApp( handlers.app )
|
||||||
|
contents = """
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
struct Foo {
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int c;
|
||||||
|
int d;
|
||||||
|
};
|
||||||
|
"""
|
||||||
|
|
||||||
|
event_data = BuildRequest( compilation_flags = ['-x', 'c++'],
|
||||||
|
event_name = 'FileReadyToParse',
|
||||||
|
contents = contents,
|
||||||
|
filepath = '/foo.h',
|
||||||
|
filetype = 'cpp' )
|
||||||
|
|
||||||
|
response = app.post_json( '/event_notification', event_data )
|
||||||
|
assert_that( response.body, empty() )
|
||||||
|
|
||||||
|
|
||||||
@with_setup( Setup )
|
@with_setup( Setup )
|
||||||
def GetDetailedDiagnostic_ClangCompleter_Works_test():
|
def GetDetailedDiagnostic_ClangCompleter_Works_test():
|
||||||
|
Loading…
Reference in New Issue
Block a user