Skip to content

Commit

Permalink
Merge remote-tracking branch 'valloric/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
puremourning committed Jan 19, 2024
2 parents 5c0dd73 + 7bc5d08 commit 59942f8
Show file tree
Hide file tree
Showing 15 changed files with 294 additions and 56 deletions.
6 changes: 3 additions & 3 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ def Exit( self ):
)$
"""

JDTLS_MILESTONE = '1.26.0'
JDTLS_BUILD_STAMP = '202307271613'
JDTLS_MILESTONE = '1.31.0'
JDTLS_BUILD_STAMP = '202401111522'
JDTLS_SHA256 = (
'ba5fe5ee3b2a8395287e24aef20ce6e17834cf8e877117e6caacac6a688a6c53'
'6c25f62d0b74d1dd92ab19afbafbe5041eb06c2b853eab57f7f42fe6feb01f7c'
)

DEFAULT_RUST_TOOLCHAIN = 'nightly-2023-08-18'
Expand Down
9 changes: 3 additions & 6 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -237,21 +237,18 @@ find_package( Python3 3.6 REQUIRED COMPONENTS Interpreter Development )
#############################################################################

set( CMAKE_POSITION_INDEPENDENT_CODE ON )
set( ABSL_PROPAGATE_CXX_STD ON )
if ( USE_SYSTEM_ABSEIL )
find_package( absl REQUIRED )
else()
include( FetchContent )
FetchContent_Declare(
absl
GIT_REPOSITORY https://github.com/abseil/abseil-cpp
GIT_TAG 3b4a16abad2c2ddc494371cc39a2946e36d35d11
GIT_TAG fb3621f4f897824c0dbe0615fa94543df6192f30
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/absl
)
FetchContent_GetProperties( absl )
if ( NOT absl_POPULATED )
FetchContent_Populate( absl )
endif()
add_subdirectory( absl )
FetchContent_MakeAvailable( absl )
endif()

add_subdirectory( ycm )
6 changes: 1 addition & 5 deletions cpp/ycm/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ else()
GIT_TAG 3b19d7222db7babfdc9b3949408b2294c3bbb540
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/benchmark
)
FetchContent_GetProperties( benchmark )
if ( NOT benchmark_POPULATED )
FetchContent_Populate( benchmark )
endif()
add_subdirectory( benchmark )
FetchContent_MakeAvailable( benchmark )
endif()

file( GLOB SOURCES *.h *.cpp )
Expand Down
6 changes: 1 addition & 5 deletions cpp/ycm/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ else()
GIT_TAG f5e592d8ee5ffb1d9af5be7f715ce3576b8bf9c4
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/gmock
)
FetchContent_GetProperties( gmock )
if ( NOT benchmark_POPULATED )
FetchContent_Populate( gmock )
endif()
add_subdirectory( gmock )
FetchContent_MakeAvailable( gmock )
endif()

file( GLOB SOURCES *.h *.cpp )
Expand Down
43 changes: 29 additions & 14 deletions ycmd/completers/cs/cs_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ def GetSubcommandsMap( self ):
self._SolutionSubcommand( request_data,
method = '_RefactorRename',
args = args ) ),
'GoToDocumentOutline' : ( lambda self, request_data, args:
self._SolutionSubcommand( request_data,
method = '_GoToDocumentOutline' ) ),
}


Expand Down Expand Up @@ -631,36 +634,48 @@ def _GoToSymbol( self, request_data, args ):
if quickfixes:
if len( quickfixes ) == 1:
ref = quickfixes[ 0 ]
ref_file = ref[ 'FileName' ]
ref_line = ref[ 'Line' ]
lines = GetFileLines( request_data, ref_file )
line = lines[ min( len( lines ), ref_line - 1 ) ]
return responses.BuildGoToResponseFromLocation(
_BuildLocation(
request_data,
ref_file,
ref_line,
ref[ 'FileName' ],
ref[ 'Line' ],
ref[ 'Column' ] ),
line )
ref[ 'Text' ] )
else:
goto_locations = []
for ref in quickfixes:
ref_file = ref[ 'FileName' ]
ref_line = ref[ 'Line' ]
lines = GetFileLines( request_data, ref_file )
line = lines[ min( len( lines ), ref_line - 1 ) ]
goto_locations.append(
responses.BuildGoToResponseFromLocation(
_BuildLocation( request_data,
ref_file,
ref_line,
ref[ 'FileName' ],
ref[ 'Line' ],
ref[ 'Column' ] ),
line ) )
ref[ 'Text' ] ) )

return goto_locations
else:
raise RuntimeError( 'No symbols found' )


def _GoToDocumentOutline( self, request_data ):
request = self._DefaultParameters( request_data )
response = self._GetResponse( '/currentfilemembersasflat', request )
if response is not None and len( response ) > 0:
goto_locations = []
for ref in response:
goto_locations.append(
responses.BuildGoToResponseFromLocation(
_BuildLocation( request_data,
ref[ 'FileName' ],
ref[ 'Line' ],
ref[ 'Column' ] ),
ref[ 'Text' ] ) )
if len( goto_locations ) > 1:
return goto_locations
return goto_locations[ 0 ]
else:
raise RuntimeError( 'No symbols found' )

def _GoToReferences( self, request_data ):
""" Jump to references of identifier under cursor """
# _GetResponse can throw. Original code by @mispencer
Expand Down
23 changes: 12 additions & 11 deletions ycmd/completers/language_server/language_server_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2536,9 +2536,7 @@ def _GoToRequest( self, request_data, handler ):
except ResponseFailedException:
result = None

if not result:
raise RuntimeError( 'Cannot jump to location' )
if not isinstance( result, list ):
if result and not isinstance( result, list ):
return [ result ]
return result

Expand All @@ -2553,15 +2551,18 @@ def GoTo( self, request_data, handlers ):

self._UpdateServerWithFileContents( request_data )

if len( handlers ) == 1:
result = self._GoToRequest( request_data, handlers[ 0 ] )
else:
for handler in handlers:
result = self._GoToRequest( request_data, handler )
if len( result ) > 1 or not _CursorInsideLocation( request_data,
result[ 0 ] ):
break
result = []
for handler in handlers:
new_result = self._GoToRequest( request_data, handler )
if new_result:
result = new_result
if len( result ) > 1 or ( result and
not _CursorInsideLocation( request_data,
result[ 0 ] ) ):
break

if not result:
raise RuntimeError( 'Cannot jump to location' )
return _LocationListToGoTo( request_data, result )


Expand Down
20 changes: 20 additions & 0 deletions ycmd/completers/typescript/typescript_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,12 @@ def _GetDoc( self, request_data ):
'offset': request_data[ 'column_codepoint' ]
} )

extra_info = _AggregateTagsFromDocstring( info )

message = f'{ info[ "displayString" ] }\n\n{ info[ "documentation" ] }'
if extra_info:
message += f'\n\n{ extra_info }'

return responses.BuildDetailedInfoResponse( message )


Expand Down Expand Up @@ -1117,6 +1122,16 @@ def _LogLevel():
return 'verbose' if LOGGER.isEnabledFor( logging.DEBUG ) else 'normal'


def _AggregateTagsFromDocstring( info ):
extra_info = []
for tag in info.get( 'tags', [] ):
tag_name = tag[ 'name' ]
tag_text = tag.get( 'text' )
formated_tag = tag_name + ( f': { tag_text }' if tag_text else '' )
extra_info.append( formated_tag )
return '\n'.join( extra_info )


def _BuildCompletionExtraMenuAndDetailedInfo( request_data, entry ):
signature = _DisplayPartsToString( entry[ 'displayParts' ] )
if entry[ 'name' ] == signature:
Expand All @@ -1130,6 +1145,11 @@ def _BuildCompletionExtraMenuAndDetailedInfo( request_data, entry ):

docs = entry.get( 'documentation', [] )
detailed_info += [ doc[ 'text' ].strip() for doc in docs if doc ]

extra_info = _AggregateTagsFromDocstring( entry )
if extra_info:
detailed_info.append( extra_info )

detailed_info = '\n\n'.join( detailed_info )

return extra_menu_info, detailed_info
Expand Down
65 changes: 65 additions & 0 deletions ycmd/tests/cs/subcommands_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,3 +909,68 @@ def test_Subcommands_OrganizeImports( self, app ):
LocationMatcher( filepath, 3, 1 ),
)
) } ) ) } ) )


@SharedYcmd
def test_Subcommands_GoToDocumentOutline( self, app ):

for filepath, expected in [
( PathToTestFile( 'testy', 'Empty.cs' ),
ErrorMatcher( RuntimeError, 'No symbols found' ) ),
( PathToTestFile( 'testy', 'SingleEntity.cs' ),
LocationMatcher(
PathToTestFile( 'testy', 'SingleEntity.cs' ), 6, 8 ) ),
( PathToTestFile( 'testy', 'GotoTestCase.cs' ),
has_items(
LocationMatcher(
PathToTestFile( 'testy', 'GotoTestCase.cs' ), 6, 8 ),
LocationMatcher(
PathToTestFile( 'testy', 'GotoTestCase.cs' ), 26, 12 ),
LocationMatcher(
PathToTestFile( 'testy', 'GotoTestCase.cs' ), 30, 8 ),
LocationMatcher(
PathToTestFile( 'testy', 'GotoTestCase.cs' ), 35, 12 ),
LocationMatcher(
PathToTestFile( 'testy', 'GotoTestCase.cs' ), 39, 12 ),
LocationMatcher(
PathToTestFile( 'testy', 'GotoTestCase.cs' ), 43, 8 ),
LocationMatcher(
PathToTestFile( 'testy', 'GotoTestCase.cs' ), 48, 8 ),
LocationMatcher(
PathToTestFile( 'testy', 'GotoTestCase.cs' ), 8, 15 ),
LocationMatcher(
PathToTestFile( 'testy', 'GotoTestCase.cs' ), 13, 15 ),
LocationMatcher(
PathToTestFile( 'testy', 'GotoTestCase.cs' ), 17, 15 ),
LocationMatcher(
PathToTestFile( 'testy', 'GotoTestCase.cs' ), 21, 15 ),
LocationMatcher(
PathToTestFile( 'testy', 'GotoTestCase.cs' ), 27, 8 ),
LocationMatcher(
PathToTestFile( 'testy', 'GotoTestCase.cs' ), 31, 15 ),
LocationMatcher(
PathToTestFile( 'testy', 'GotoTestCase.cs' ), 36, 8 ),
LocationMatcher(
PathToTestFile( 'testy', 'GotoTestCase.cs' ), 40, 8 ),
LocationMatcher(
PathToTestFile( 'testy', 'GotoTestCase.cs' ), 44, 15 ),
LocationMatcher(
PathToTestFile( 'testy', 'GotoTestCase.cs' ), 49, 15 ) ) )
]:
with self.subTest( filepath = filepath, expected = expected ):
with WrapOmniSharpServer( app, filepath ):

# the command name and file are the only relevant arguments for this
# subcommand. our current cursor position in the file doesn't matter.
request = BuildRequest( command_arguments = [ 'GoToDocumentOutline' ],
line_num = 0,
column_num = 0,
contents = ReadFile( filepath ),
filetype = 'cs',
filepath = filepath )

response = app.post_json( '/run_completer_command',
request,
expect_errors = True ).json
print( 'completer response = ', response )
assert_that( response, expected )
6 changes: 6 additions & 0 deletions ycmd/tests/cs/testdata/testy/Empty.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using System;
using System.Data;

namespace testy
{
}
9 changes: 9 additions & 0 deletions ycmd/tests/cs/testdata/testy/SingleEntity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;
using System.Data;

namespace testy
{
class GotoTestCase
{
}
}
2 changes: 2 additions & 0 deletions ycmd/tests/cs/testdata/testy/testy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ZeroColumnDiagnostic.cs" />
<Compile Include="Empty.cs" />
<Compile Include="SingleEntity.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
Loading

0 comments on commit 59942f8

Please sign in to comment.