Removing ugly looking jsdoc comment

This commit is contained in:
2014-11-02 01:56:28 +01:00
parent a33b867112
commit c5709a403c
3 changed files with 74 additions and 231 deletions

View File

@@ -4,24 +4,13 @@ var Types = require("types");
var Buffer = require("buffer");
/**
* A Transform Stream implementation that output full VNB protocol messages
* @constructor
* @param {object} opts Options passed to the Transform constructor
*/
//A stream Transform implementation returning full netbeans messages
function MessageTransform(opts) {
"use strict";
Transform.call(this,opts);
var buffer;
/**
* Transform stream Write implementation
* @function
* @param {string} data Upstream data already converted as string
* @param {string} encoding String encoding (should be utf8, but should be checked upward)
* @param {function} callback Downstream Stream receiving only full VNB messages
**/
this._transform = function(data, encoding, callback) {
var endpos = data.indexOf("\n");
@@ -45,31 +34,14 @@ function MessageTransform(opts) {
}
};
/**
* Flush still data. Remaining data is lost since it can only be an incomplete message
* @function
* @param {function} callback Callback to call when data has been flushed
**/
this._flush = function (callback) {
buffer = undefined;
callback();
};
}
/**
* Authentication callback
* @callback authenticationCallback
* @param {string} password Password given by the authenticating client
* @return {bool} Result of the authentication
*/
/**
* Client implementation for vim netbeans protocol (communication from vim to the netbeans server)
* @constructor
* @param {Socket} socket Incomming stream
* @param {authenticationCallback} authentication Callback function called when the AUTH message is received
*/
//Main netbeans object. Needs the socket of the incomming connexion and an authentication callback
//This callback just get the password sent by Vim. It must return true to allow connexion
function Controler(socket, authentication) {
"use strict";
@@ -80,14 +52,14 @@ function Controler(socket, authentication) {
var currentSeqno = 0;
var connected = false;
//TODO check if this is needed
/* TODO check if this is needed */
socket.setEncoding("utf8");
var messageTransform = new MessageTransform();
messageTransform.on("data",function (message) {
//The first message must be an authentication one
/* The first message must be an authentication one */
if (message.startsWith("AUTH ") && authentication(message.substring(message.indexOf(" ") + 1))) {
connected = true;
@@ -95,10 +67,10 @@ function Controler(socket, authentication) {
messageTransform.on("data", function(message) {
try {
var iName = 0; //Index of the name separator in case of an Event
var iSeqno = 0; //Index of the seqno separator in case of an Event
var iName = 0; /*Index of the name separator in case of an Event */
var iSeqno = 0; /*Index of the seqno separator in case of an Event */
//Header of the message
/* Header of the message */
for (var i = 0 ; i < message.length && message[i] !== " "; ++i) {
if (message[i] === ":") {
iName = i;
@@ -236,13 +208,8 @@ function Controler(socket, authentication) {
});
/**
* Send a command message
* @function sendCommand
* @param {string} name Name of the command
* @param {number} buffer Name of the buffer
* @param {...string} arguments Parameters of the command
*/
//Send a command message.
//Needs the name of the buffer, the buffer id and the parameters of the command
this.sendCommand = function(name, buffer) {
let seqno = currentSeqno;
currentSeqno += 1;
@@ -258,23 +225,14 @@ function Controler(socket, authentication) {
socket.write(data);
};
/**
* Send a function message
* @function callFunction
* @param {string} name Name of the function
* @param {number} buffer ID of the buffer
* @param {...string} arguments Parameters of the function. Use the string, bool, color and position function
* of the method to convert javascript types to string
* @param {function} callback Callback function called with reply value
* */
//Call a function.
//Needs the name of the function, the bufferid, the parametres of the command and the callback to retreive the reply
this.callFunction = function(name, buffer) {
let seqno = currentSeqno;
currentSeqno += 1;
var lastArg = arguments.length - 1;
//If the function is called with a callback (wich should always be the case)
//add the calback to the map so it's fired when the reply is received
if (typeof(arguments[lastArg]) === "function") {
callbacks[currentSeqno] = arguments[lastArg];
lastArg -= 1;
@@ -297,12 +255,8 @@ function Controler(socket, authentication) {
InternalClient.prototype = EventEmitter;
/**
* Connexion with a vim client
* @constructor
* @param {Socket} socket Connexion's socket
* @param {authenticationCallback} authentication Callback used to authenticate the client
*/
//Wrapper around the controler exposing functions and commands as methods
//Needs the incomming connexon socket and an authentication callback that get the password and return true to allow connexion
function Client(socket, authentication) {
"use strict";
@@ -311,26 +265,22 @@ function Client(socket, authentication) {
/* GLOBAL COMMANDS */
this.startAtomic = function () {
client.sendCommand("startAtomic", 0);
};
this.endAtomic = function() {
client.sendCommand("endAtmoic", 0);
};
//Bring Vim to the front (GVim only)
this.raise = function () {
client.sendCommand("raise", 0);
};
//Set an exiting delay, allowing the controler to handle things
this.setExitDelay = function (seconds) {
client.sendCommand("setExitDelay", 0, seconds);
};
//Set key binding. Absolutely not documented feature...
this.specialKeys = function (keys) {
client.sendCommand("specialKeys", 0,Types.string(keys)); //TODO : Wild guess, no documentation about this one
client.sendCommand("specialKeys", 0,Types.string(keys));
};
//Create a new buffer. Return the buffer created
this.create = function() {
var buffer = new Buffer(client, buffId);
buffId += 1;
@@ -338,12 +288,8 @@ function Client(socket, authentication) {
return buffer;
};
/**
* putBufferNumber
* @function
* @param {string} pathname Path of the file whose buffer is identified
* @return {undefined}
*/
//Associate already opened buffer on Vim to a controler owned buffer
//Return the newly created buffer
this.putBufferNumber = function (pathname) {
var buffer = new Buffer(client, buffId);
buffId += 1;
@@ -351,11 +297,8 @@ function Client(socket, authentication) {
return buffer;
};
/**
* Set a buffer number to a file opened by Vim and sets its buffer as current buffer
* @function
* @param {string} pathname Path of the file
*/
//Associate already opened buffer on Vim to a controler owned buffer and bring it to front
//Return the newly created buffer
this.setBufferNumber = function (pathname) {
var buffer = new Buffer(client, buffId);
buffId += 1;
@@ -365,16 +308,12 @@ function Client(socket, authentication) {
/* GLOBAL FUNCTIONS */
/**
* saveAndExit
*
* @param callback
* @return {undefined}
*/
//Ask Vim to save and exit
this.saveAndExit = function (callback) {
client.callFunction("saveAndExit", 0, callback);
};
//Get the numbr of modified buffers
this.getModified = function (callback) {
client.callFunction("getModified", 0, callback);
};