Commit 5b1dd9b0 authored by David Kalnischkies's avatar David Kalnischkies

New upstream version 0+20180505+gitc027b16

parent 2f672642
[report]
omit =
*/tests/*
# Issue Prelude
**Please complete these steps and check these boxes (by putting an `x` inside
the brackets) _before_ filing your issue:**
- [ ] I have read and understood YCM's [CONTRIBUTING][cont] document.
- [ ] I have read and understood YCM's [CODE_OF_CONDUCT][code] document.
- [ ] I have read and understood YCM's [README][readme], **especially the
[Frequently Asked Questions][faq] section.**
- [ ] I have searched YCM's issue tracker to find issues similar to the one I'm
about to report and couldn't find an answer to my problem. ([Example Google
search.][search])
- [ ] If filing a bug report, I have included the output of `vim --version`.
- [ ] If filing a bug report, I have included the output of `:YcmDebugInfo`.
- [ ] If filing a bug report, I have attached the contents of the logfiles using
the `:YcmToggleLogs` command.
- [ ] If filing a bug report, I have included which OS (including specific OS
version) I am using.
- [ ] If filing a bug report, I have included a minimal test case that reproduces
my issue.
- [ ] **I understand this is an open-source project staffed by volunteers and
that any help I receive is a selfless, heartfelt _gift_ of their free time. I
know I am not entitled to anything and will be polite and courteous.**
- [ ] **I understand my issue may be closed if it becomes obvious I didn't
actually perform all of these steps.**
Thank you for adhering to this process! It ensures your issue is resolved
quickly and that neither your nor our time is needlessly wasted.
# Issue Details
[If filing a bug report, please include **a list of steps** that describe how to
reproduce the bug you are experiencing. Also include test code if relevant.]
[cont]: https://github.com/Valloric/YouCompleteMe/blob/master/CONTRIBUTING.md
[code]: https://github.com/Valloric/YouCompleteMe/blob/master/CODE_OF_CONDUCT.md
[readme]: https://github.com/Valloric/YouCompleteMe/blob/master/README.md
[faq]: https://github.com/Valloric/YouCompleteMe/blob/master/README.md#faq
[search]: https://www.google.com/search?q=site%3Ahttps%3A%2F%2Fgithub.com%2FValloric%2FYouCompleteMe%2Fissues%20python%20mac
# PR Prelude
Thank you for working on YCM! :)
**Please complete these steps and check these boxes (by putting an `x` inside
the brackets) _before_ filing your PR:**
- [ ] I have read and understood YCM's [CONTRIBUTING][cont] document.
- [ ] I have read and understood YCM's [CODE_OF_CONDUCT][code] document.
- [ ] I have included tests for the changes in my PR. If not, I have included a
rationale for why I haven't.
- [ ] **I understand my PR may be closed if it becomes obvious I didn't
actually perform all of these steps.**
# Why this change is necessary and useful
[Please explain **in detail** why the changes in this PR are needed.]
[cont]: https://github.com/Valloric/YouCompleteMe/blob/master/CONTRIBUTING.md
[code]: https://github.com/Valloric/YouCompleteMe/blob/master/CODE_OF_CONDUCT.md
This diff is collapsed.
version: '{build}'
image: Visual Studio 2017
environment:
COVERAGE: true
matrix:
- arch: 32
python: 35
python: 36
# We only test Python 2.7 on 64 bits.
- arch: 64
python: 27
- arch: 64
python: 35
python: 36
install:
- ci\appveyor\appveyor_install.bat
build_script:
......
This diff is collapsed.
# Linux-specific installation
# We can't use sudo, so we have to approximate the behaviour of setting the
# default system compiler.
mkdir ${HOME}/bin
ln -s /usr/bin/g++-4.8 ${HOME}/bin/c++
ln -s /usr/bin/gcc-4.8 ${HOME}/bin/cc
export PATH=${HOME}/bin:${PATH}
# In order to work with ycmd, python *must* be built as a shared library. This
# is set via the PYTHON_CONFIGURE_OPTS option.
export PYTHON_CONFIGURE_OPTS="--enable-shared"
# OS X-specific installation
# There's a homebrew bug which causes brew update to fail the first time. Run
# it twice to workaround. https://github.com/Homebrew/homebrew/issues/42553
brew update || brew update
# List of homebrew formulae to install in the order they appear.
# These are dependencies of pyenv.
REQUIREMENTS="ninja
readline
autoconf
pkg-config
openssl"
# Install pyenv and dependencies
for pkg in $REQUIREMENTS; do
# Install package, or upgrade it if it is already installed
brew install $pkg || brew outdated $pkg || brew upgrade $pkg
done
# In order to work with ycmd, python *must* be built as a shared library. The
# most compatible way to do this on OS X is with --enable-framework. This is
# set via the PYTHON_CONFIGURE_OPTS option
export PYTHON_CONFIGURE_OPTS="--enable-framework"
......@@ -2,41 +2,56 @@
set -ev
####################
# OS-specific setup
####################
# RVM overrides the cd, popd, and pushd shell commands, causing the
# "shell_session_update: command not found" error on macOS when executing those
# commands.
unset -f cd popd pushd
# Requirements of OS-specific install:
# - install any software which is not installed by Travis configuration
# - set up everything necessary so that pyenv can build python
source ci/travis/travis_install.${TRAVIS_OS_NAME}.sh
################
# Compiler setup
################
#############
# pyenv setup
#############
# We can't use sudo, so we have to approximate the behaviour of setting the
# default system compiler.
export PYENV_ROOT="${HOME}/.pyenv"
mkdir -p ${HOME}/bin
ln -s /usr/bin/g++-4.8 ${HOME}/bin/c++
ln -s /usr/bin/gcc-4.8 ${HOME}/bin/cc
export PATH=${HOME}/bin:${PATH}
##############
# Python setup
##############
PYENV_ROOT="${HOME}/.pyenv"
if [ ! -d "${PYENV_ROOT}/.git" ]; then
rm -rf ${PYENV_ROOT}
git clone https://github.com/yyuu/pyenv.git ${PYENV_ROOT}
fi
pushd ${PYENV_ROOT}
git fetch --tags
git checkout v20160202
git checkout v1.2.1
popd
export PATH="${PYENV_ROOT}/bin:${PATH}"
eval "$(pyenv init -)"
if [ "${YCM_PYTHON_VERSION}" == "2.6" ]; then
PYENV_VERSION="2.6.6"
elif [ "${YCM_PYTHON_VERSION}" == "2.7" ]; then
PYENV_VERSION="2.7.6"
if [ "${YCM_PYTHON_VERSION}" == "2.7" ]; then
# Tests are failing on Python 2.7.0 with the exception
# "TypeError: argument can't be <type 'unicode'>"
PYENV_VERSION="2.7.1"
else
PYENV_VERSION="3.3.6"
PYENV_VERSION="3.4.0"
fi
# In order to work with ycmd, python *must* be built as a shared library. This
# is set via the PYTHON_CONFIGURE_OPTS option.
export PYTHON_CONFIGURE_OPTS="--enable-shared"
pyenv install --skip-existing ${PYENV_VERSION}
pyenv rehash
pyenv global ${PYENV_VERSION}
......@@ -48,11 +63,6 @@ python_version=$(python -c 'import sys; print( "{0}.{1}".format( sys.version_inf
echo "Checking python version (actual ${python_version} vs expected ${YCM_PYTHON_VERSION})"
test ${python_version} == ${YCM_PYTHON_VERSION}
############
# pip setup
############
pip install -U pip wheel setuptools
pip install -r python/test_requirements.txt
# The build infrastructure prints a lot of spam after this script runs, so make
......
This diff is collapsed.
......@@ -11,11 +11,11 @@ import sys
import os.path as p
import glob
PY_MAJOR, PY_MINOR = sys.version_info[ 0 : 2 ]
if not ( ( PY_MAJOR == 2 and PY_MINOR >= 6 ) or
( PY_MAJOR == 3 and PY_MINOR >= 3 ) or
PY_MAJOR, PY_MINOR, PY_PATCH = sys.version_info[ 0 : 3 ]
if not ( ( PY_MAJOR == 2 and PY_MINOR == 7 and PY_PATCH >= 1 ) or
( PY_MAJOR == 3 and PY_MINOR >= 4 ) or
PY_MAJOR > 3 ):
sys.exit( 'YouCompleteMe requires Python >= 2.6 or >= 3.3; '
sys.exit( 'YouCompleteMe requires Python >= 2.7.1 or >= 3.4; '
'your version of Python is ' + sys.version )
DIR_OF_THIS_SCRIPT = p.dirname( p.abspath( __file__ ) )
......
......@@ -27,16 +27,44 @@ endfunction
if exists( "g:loaded_youcompleteme" )
call s:restore_cpo()
finish
elseif v:version < 704 || (v:version == 704 && !has('patch143'))
elseif v:version < 704 || (v:version == 704 && !has( 'patch1578' ))
echohl WarningMsg |
\ echomsg "YouCompleteMe unavailable: requires Vim 7.4.143+" |
\ echomsg "YouCompleteMe unavailable: requires Vim 7.4.1578+." |
\ echohl None
if v:version == 704 && has( 'patch8056' )
" Very very special case for users of the default Vim on macOS. For some
" reason, that version of Vim contains a completely arbitrary (presumably
" custom) patch '8056', which fools users (but not our has( 'patch1578' )
" check) into thinking they have a sufficiently new Vim. In fact they do
" not and YCM fails to initialise. So we give them a more specific warning.
echohl WarningMsg
\ | echomsg
\ "Info: You appear to be running the default system Vim on macOS. "
\ . "It reports as patch 8056, but it is really older than 1578. "
\ . "Please consider MacVim, homebrew Vim or a self-built Vim that "
\ . "satisfies the minimum requirement."
\ | echohl None
endif
call s:restore_cpo()
finish
elseif !has( 'timers' )
echohl WarningMsg |
\ echomsg "YouCompleteMe unavailable: requires Vim compiled with " .
\ "the timers feature." |
\ echohl None
call s:restore_cpo()
finish
elseif !has( 'python' ) && !has( 'python3' )
echohl WarningMsg |
\ echomsg "YouCompleteMe unavailable: requires Vim compiled with " .
\ "Python (2.6+ or 3.3+) support" |
\ "Python (2.7.1+ or 3.4+) support." |
\ echohl None
call s:restore_cpo()
finish
elseif &encoding !~? 'utf-\?8'
echohl WarningMsg |
\ echomsg "YouCompleteMe unavailable: requires UTF-8 encoding. " .
\ "Put the line 'set encoding=utf-8' in your vimrc." |
\ echohl None
call s:restore_cpo()
finish
......@@ -50,9 +78,6 @@ let g:loaded_youcompleteme = 1
" The only defaults that are here are the ones that are only relevant to the YCM
" Vim client and not the ycmd server.
let g:ycm_allow_changing_updatetime =
\ get( g:, 'ycm_allow_changing_updatetime', 1 )
let g:ycm_open_loclist_on_ycm_diags =
\ get( g:, 'ycm_open_loclist_on_ycm_diags', 1 )
......@@ -71,6 +96,9 @@ let g:ycm_key_list_select_completion =
let g:ycm_key_list_previous_completion =
\ get( g:, 'ycm_key_list_previous_completion', ['<S-TAB>', '<Up>'] )
let g:ycm_key_list_stop_completion =
\ get( g:, 'ycm_key_list_stop_completion', ['<C-y>'] )
let g:ycm_key_invoke_completion =
\ get( g:, 'ycm_key_invoke_completion', '<C-Space>' )
......@@ -128,14 +156,15 @@ let g:ycm_goto_buffer_command =
let g:ycm_disable_for_files_larger_than_kb =
\ get( g:, 'ycm_disable_for_files_larger_than_kb', 1000 )
" On-demand loading. Let's use the autoload folder and not slow down vim's
" startup procedure.
if has( 'vim_starting' ) " loading at startup
if has( 'vim_starting' ) " Loading at startup.
" We defer loading until after VimEnter to allow the gui to fork (see
" `:h gui-fork`) and avoid a deadlock situation, as explained here:
" https://github.com/Valloric/YouCompleteMe/pull/2473#issuecomment-267716136
augroup youcompletemeStart
autocmd!
autocmd VimEnter * call youcompleteme#Enable()
augroup END
else " manual loading with :packadd
else " Manual loading with :packadd.
call youcompleteme#Enable()
endif
......
# Flake8 3.x dropped support of Python 2.6 and 3.3
flake8 < 3.0.0; python_version == '2.6' or python_version == '3.3'
flake8 >= 3.0.0; python_version == '2.7' or python_version > '3.3'
mock >= 1.0.1
nose >= 1.3.7
PyHamcrest >= 1.8.0
flake8 >= 3.0.0
flake8-comprehensions >= 1.4.1
mock >= 1.0.1
nose >= 1.3.7
PyHamcrest >= 1.8.0
# This needs to be kept in sync with submodule checkout in
# third_party/ycmd/third_party
future == 0.15.2
codecov >= 2.0.5
future == 0.15.2
# coverage.py 4.4 removed the path from the filename attribute in its reports.
# This leads to incorrect coverage from codecov as it relies on this attribute
# to find the source file.
coverage < 4.4
codecov >= 2.0.5
......@@ -19,14 +19,12 @@ from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()
# Not installing aliases from python-future; it's unreliable and slow.
from builtins import * # noqa
from future.utils import iteritems
from ycm import vimsupport
from ycmd import user_options_store
from ycmd import request_wrap
from ycmd import identifier_utils
YCM_VAR_PREFIX = 'ycm_'
......@@ -58,19 +56,11 @@ def LoadJsonDefaultsIntoVim():
vimsupport.SetVariableValue( new_key, value )
def CompletionStartColumn():
return ( request_wrap.CompletionStartColumn(
vimsupport.CurrentLineContents(),
vimsupport.CurrentColumn() + 1,
vimsupport.CurrentFiletypes()[ 0 ] ) - 1 )
def CurrentIdentifierFinished():
current_column = vimsupport.CurrentColumn()
line, current_column = vimsupport.CurrentLineContentsAndCodepointColumn()
previous_char_index = current_column - 1
if previous_char_index < 0:
return True
line = vimsupport.CurrentLineContents()
filetype = vimsupport.CurrentFiletypes()[ 0 ]
regex = identifier_utils.IdentifierRegexForFiletype( filetype )
......@@ -83,10 +73,9 @@ def CurrentIdentifierFinished():
def LastEnteredCharIsIdentifierChar():
current_column = vimsupport.CurrentColumn()
line, current_column = vimsupport.CurrentLineContentsAndCodepointColumn()
if current_column - 1 < 0:
return False
line = vimsupport.CurrentLineContents()
filetype = vimsupport.CurrentFiletypes()[ 0 ]
return (
identifier_utils.StartOfLongestIdentifierEndingAtIndex(
......
# Copyright (C) 2016, Davit Samvelyan
#
# This file is part of YouCompleteMe.
#
# YouCompleteMe is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# YouCompleteMe is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
# Not installing aliases from python-future; it's unreliable and slow.
from builtins import * # noqa
from ycm import vimsupport
from ycm.client.event_notification import EventNotification
from ycm.diagnostic_interface import DiagnosticInterface
DIAGNOSTIC_UI_FILETYPES = { 'cpp', 'cs', 'c', 'objc', 'objcpp', 'typescript' }
DIAGNOSTIC_UI_ASYNC_FILETYPES = { 'java' }
# Emulates Vim buffer
# Used to store buffer related information like diagnostics, latest parse
# request. Stores buffer change tick at the parse request moment, allowing
# to effectively determine whether reparse is needed for the buffer.
class Buffer( object ):
def __init__( self, bufnr, user_options, async_diags ):
self.number = bufnr
self._parse_tick = 0
self._handled_tick = 0
self._parse_request = None
self._async_diags = async_diags
self._diag_interface = DiagnosticInterface( bufnr, user_options )
def FileParseRequestReady( self, block = False ):
return bool( self._parse_request and
( block or self._parse_request.Done() ) )
def SendParseRequest( self, extra_data ):
self._parse_request = EventNotification( 'FileReadyToParse',
extra_data = extra_data )
self._parse_request.Start()
# Decrement handled tick to ensure correct handling when we are forcing
# reparse on buffer visit and changed tick remains the same.
self._handled_tick -= 1
self._parse_tick = self._ChangedTick()
def NeedsReparse( self ):
return self._parse_tick != self._ChangedTick()
def ShouldResendParseRequest( self ):
return bool( self._parse_request and self._parse_request.ShouldResend() )
def UpdateDiagnostics( self, force=False ):
if force or not self._async_diags:
self.UpdateWithNewDiagnostics( self._parse_request.Response() )
else:
# We need to call the response method, because it might throw an exception
# or require extra config confirmation, even if we don't actually use the
# diagnostics.
self._parse_request.Response()
def UpdateWithNewDiagnostics( self, diagnostics ):
self._diag_interface.UpdateWithNewDiagnostics( diagnostics )
def UpdateMatches( self ):
self._diag_interface.UpdateMatches()
def PopulateLocationList( self ):
return self._diag_interface.PopulateLocationList()
def GetResponse( self ):
return self._parse_request.Response()
def IsResponseHandled( self ):
return self._handled_tick == self._parse_tick
def MarkResponseHandled( self ):
self._handled_tick = self._parse_tick
def OnCursorMoved( self ):
self._diag_interface.OnCursorMoved()
def GetErrorCount( self ):
return self._diag_interface.GetErrorCount()
def GetWarningCount( self ):
return self._diag_interface.GetWarningCount()
def _ChangedTick( self ):
return vimsupport.GetBufferChangedTick( self.number )
class BufferDict( dict ):
def __init__( self, user_options ):
self._user_options = user_options
def __missing__( self, key ):
# Python does not allow to return assignment operation result directly
new_value = self[ key ] = Buffer(
key,
self._user_options,
any( x in DIAGNOSTIC_UI_ASYNC_FILETYPES
for x in vimsupport.GetBufferFiletypes( key ) ) )
return new_value
This diff is collapsed.
......@@ -19,15 +19,10 @@ from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()
# Not installing aliases from python-future; it's unreliable and slow.
from builtins import * # noqa
from requests.exceptions import ReadTimeout
from ycmd.responses import ServerError
from ycm.client.base_request import ( BaseRequest, BuildRequestData,
HandleServerException )
from ycm.client.base_request import BaseRequest, BuildRequestData
from ycm import vimsupport
from ycmd.utils import ToUnicode
......@@ -39,25 +34,26 @@ def _EnsureBackwardsCompatibility( arguments ):
class CommandRequest( BaseRequest ):
def __init__( self, arguments, completer_target = None ):
def __init__( self, arguments, completer_target = None, extra_data = None ):
super( CommandRequest, self ).__init__()
self._arguments = _EnsureBackwardsCompatibility( arguments )
self._command = arguments and arguments[ 0 ]
self._completer_target = ( completer_target if completer_target
else 'filetype_default' )
self._extra_data = extra_data
self._response = None
def Start( self ):
request_data = BuildRequestData()
if self._extra_data:
request_data.update( self._extra_data )
request_data.update( {
'completer_target': self._completer_target,
'command_arguments': self._arguments
} )
try:
self._response = self.PostDataToHandler( request_data,
'run_completer_command' )
except ( ServerError, ReadTimeout ) as e:
HandleServerException( e )
self._response = self.PostDataToHandler( request_data,
'run_completer_command' )
def Response( self ):
......@@ -92,9 +88,8 @@ class CommandRequest( BaseRequest ):
def _HandleGotoResponse( self ):
if isinstance( self._response, list ):
vimsupport.SetQuickFixList(
[ _BuildQfListItem( x ) for x in self._response ],
focus = True,
autoclose = True )
[ _BuildQfListItem( x ) for x in self._response ] )
vimsupport.OpenQuickFixList( focus = True, autoclose = True )
else:
vimsupport.JumpToLocation( self._response[ 'filepath' ],
self._response[ 'line_num' ],
......@@ -118,7 +113,8 @@ class CommandRequest( BaseRequest ):
[ fixit[ 'text' ] for fixit in self._response[ 'fixits' ] ] )
vimsupport.ReplaceChunks(
self._response[ 'fixits' ][ fixit_index ][ 'chunks' ] )
self._response[ 'fixits' ][ fixit_index ][ 'chunks' ],
silent = self._command == 'Format' )
except RuntimeError as e:
vimsupport.PostVimMessage( str( e ) )
......@@ -135,8 +131,8 @@ class CommandRequest( BaseRequest ):
vimsupport.WriteToPreviewWindow( self._response[ 'detailed_info' ] )
def SendCommandRequest( arguments, completer ):
request = CommandRequest( arguments, completer )
def SendCommandRequest( arguments, completer, extra_data = None ):
request = CommandRequest( arguments, completer, extra_data )
# This is a blocking call.
request.Start()
request.RunPostCommandActionsIfNeeded()
......
......@@ -19,15 +19,10 @@ from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()
# Not installing aliases from python-future; it's unreliable and slow.
from builtins import * # noqa
from requests.exceptions import ReadTimeout
from ycm.client.base_request import ( BaseRequest, BuildRequestData,
HandleServerException )
from ycmd.responses import ServerError
from ycm.client.base_request import BaseRequest, BuildRequestData
class CompleterAvailableRequest( BaseRequest ):
......@@ -40,11 +35,8 @@ class CompleterAvailableRequest( BaseRequest ):
def Start( self ):
request_data = BuildRequestData()
request_data.update( { 'filetypes': self.filetypes } )
try:
self._response = self.PostDataToHandler( request_data,
'semantic_completion_available' )
except ( ServerError, ReadTimeout ) as e:
HandleServerException( e )
self._response = self.PostDataToHandler( request_data,
'semantic_completion_available' )
def Response( self ):
......
# Copyright (C) 2013 Google Inc.
# Copyright (C) 2013-2018 YouCompleteMe contributors
#
# This file is part of YouCompleteMe.
#
......@@ -19,58 +19,174 @@ from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()
# Not installing aliases from python-future; it's unreliable and slow.
from builtins import * # noqa
from requests.exceptions import ReadTimeout
import logging
from future.utils import iteritems
from ycmd.utils import ToUnicode
from ycm.client.base_request import ( BaseRequest, JsonFromFuture,
HandleServerException,
from ycm.client.base_request import ( BaseRequest, DisplayServerException,
MakeServerException )
from ycmd.responses import ServerError
from ycm import vimsupport
TIMEOUT_SECONDS = 0.5
_logger = logging.getLogger( __name__ )
class CompletionRequest( BaseRequest ):
def __init__( self, request_data ):
super( CompletionRequest, self ).__init__()
self.request_data = request_data
self._response_future = None
self._complete_done_hooks = {
'cs': self._OnCompleteDone_Csharp,
'java': self._OnCompleteDone_FixIt,
'typescript': self._OnCompleteDone_FixIt,
}
def Start( self ):
self._response_future = self.PostDataToHandlerAsync( self.request_data,
'completions',
TIMEOUT_SECONDS )
'completions' )
def Done( self ):
return self._response_future.done()
return bool( self._response_future ) and self._response_future.done()
def RawResponse( self ):
if not self._response_future:
return []
try:
response = JsonFromFuture( self._response_future )
return { 'completions': [], 'completion_start_column': -1 }
errors = response[ 'errors' ] if 'errors' in response else []
for e in errors:
HandleServerException( MakeServerException( e ) )
response = self.HandleFuture( self._response_future,
truncate_message = True )
if not response:
return { 'completions': [], 'completion_start_column': -1 }
return JsonFromFuture( self._response_future )[ 'completions' ]
except ( ServerError, ReadTimeout ) as e:
HandleServerException( e, truncate = True )
return []
# Vim may not be able to convert the 'errors' entry to its internal format
# so we remove it from the response.