         lineNumber = bufferPosition.row - 1
 
         while lineNumber > 0
-            line = editor.getTextInBufferRange([[lineNumber, 0], bufferPosition])
+            line = editor.lineTextForBufferRow(lineNumber)
 
             if not bestMatch
                 # Check for $x = new XXXXX()

                    # don't recognize the class name is irrelevant.
                    bestMatchRow = lineNumber
                    bestMatch = @parseElements(editor, newPosition, elements)

            chain = editor.scopeDescriptorForBufferPosition([lineNumber, line.length]).getScopeChain()


                    return @getFullClassName(editor, matches[1])

            # We've reached the function definition, check for type hints and/or the docblock.
            if chain.indexOf("function") != -1
                break

            --lineNumber
