use of com.google.gwt.core.client.JsArrayInteger in project rstudio by rstudio.
the class RoxygenHelper method amendExistingRoxygenBlock.
private void amendExistingRoxygenBlock(int row, String objectName, JsArrayString argNames, JsArrayString argTypes, String tagName, Pattern pattern) {
// Get the range encompassing this Roxygen block.
Range range = getRoxygenBlockRange(row);
// Extract that block (as an array of strings)
JsArrayString block = extractRoxygenBlock(editor_.getWidget().getEditor(), range);
// bail.
for (int i = 0; i < block.length(); i++) {
if (RE_ROXYGEN_NONLOCAL.test(block.get(i))) {
view_.showWarningBar("Cannot automatically update roxygen blocks " + "that are not self-contained.");
return;
}
}
String roxygenDelim = RE_ROXYGEN.match(block.get(0), 0).getGroup(1);
// The replacement block (we build by munging parts of
// the old block
JsArrayString replacement = JsArray.createArray().cast();
// Scan through the block to get the names of
// pre-existing parameters.
JsArrayString params = listParametersInRoxygenBlock(block, pattern);
// Figure out what parameters need to be removed, and remove them.
// Any parameter not mentioned in the current function's argument list
// should be stripped out.
JsArrayString paramsToRemove = setdiff(params, argNames);
int blockLength = block.length();
for (int i = 0; i < blockLength; i++) {
// If we encounter a param we don't want to extract, then
// move over it.
Match match = pattern.match(block.get(i), 0);
if (match != null && contains(paramsToRemove, match.getGroup(1))) {
i++;
while (i < blockLength && !RE_ROXYGEN_WITH_TAG.test(block.get(i))) i++;
i--;
continue;
}
replacement.push(block.get(i));
}
// Now, add example roxygen for any parameters that are
// present in the function prototype, but not present
// within the roxygen block.
int insertionPosition = findParamsInsertionPosition(replacement, pattern);
JsArrayInteger indices = setdiffIndices(argNames, params);
// NOTE: modifies replacement
insertNewTags(replacement, argNames, argTypes, indices, roxygenDelim, tagName, insertionPosition);
// Ensure space between final param and next tag
ensureSpaceBetweenFirstParamAndPreviousEntry(replacement, roxygenDelim, pattern);
ensureSpaceBetweenFinalParamAndNextTag(replacement, roxygenDelim, pattern);
// Apply the replacement.
editor_.getSession().replace(range, replacement.join("\n") + "\n");
}
use of com.google.gwt.core.client.JsArrayInteger in project rstudio by rstudio.
the class CompletionRequester method fillCompletionResult.
private void fillCompletionResult(Completions response, boolean implicit, ServerRequestCallback<CompletionResult> callback) {
JsArrayString comp = response.getCompletions();
JsArrayString pkgs = response.getPackages();
JsArrayBoolean quote = response.getQuote();
JsArrayInteger type = response.getType();
ArrayList<QualifiedName> newComp = new ArrayList<QualifiedName>();
for (int i = 0; i < comp.length(); i++) {
newComp.add(new QualifiedName(comp.get(i), pkgs.get(i), quote.get(i), type.get(i), response.getHelpHandler()));
}
CompletionResult result = new CompletionResult(response.getToken(), newComp, response.getGuessedFunctionName(), response.getSuggestOnAccept(), response.getOverrideInsertParens());
if (response.isCacheable()) {
cachedCompletions_.put("", result);
}
if (!implicit || result.completions.size() != 0)
callback.onResponseReceived(result);
}
use of com.google.gwt.core.client.JsArrayInteger in project playn by threerings.
the class ArrayUtils method toJsArray.
public static JsArrayInteger toJsArray(int[] data) {
JsArrayInteger jsan = (JsArrayInteger) JsArrayInteger.createArray();
int len = data.length;
for (int i = len - 1; i >= 0; i--) {
jsan.set(i, data[i]);
}
return jsan;
}
use of com.google.gwt.core.client.JsArrayInteger in project perun by CESNET.
the class PerunWebSession method setRoles.
/**
* Sets user's roles and editable entities received from RPC
* within PerunPrincipal into Session
*
* Call only once when loading GUI!
*
* @param roles roles returned from PerunPrincipal
*/
public void setRoles(Roles roles) {
this.perunAdmin = roles.hasRole(PERUN_ADMIN_PRINCIPAL_ROLE);
this.voAdmin = roles.hasRole(VO_ADMIN_PRINCIPAL_ROLE);
this.facilityAdmin = roles.hasRole(FACILITY_ADMIN_PRINCIPAL_ROLE);
this.groupAdmin = roles.hasRole(GROUP_ADMIN_PRINCIPAL_ROLE);
this.self = roles.hasRole(USER_ROLE);
this.voObserver = roles.hasRole(VO_OBSERVER_PRINCIPAL_ROLE);
this.securityAdmin = roles.hasRole(SECURITY_ADMIN_PRINCIPAL_ROLE);
JsArrayInteger array = roles.getEditableEntities("VOADMIN", "Vo");
for (int i = 0; i < array.length(); i++) {
addEditableVo(array.get(i));
}
JsArrayInteger array2 = roles.getEditableEntities("SELF", "User");
for (int i = 0; i < array2.length(); i++) {
addEditableUser(array2.get(i));
}
JsArrayInteger array3 = roles.getEditableEntities("FACILITYADMIN", "Facility");
for (int i = 0; i < array3.length(); i++) {
addEditableFacility(array3.get(i));
}
JsArrayInteger array4 = roles.getEditableEntities("GROUPADMIN", "Group");
for (int i = 0; i < array4.length(); i++) {
addEditableGroup(array4.get(i));
}
JsArrayInteger array5 = roles.getEditableEntities("VOOBSERVER", "Vo");
for (int i = 0; i < array5.length(); i++) {
addViewableVo(array5.get(i));
}
JsArrayInteger array6 = roles.getEditableEntities("SECURITYADMIN", "SecurityTeam");
for (int i = 0; i < array6.length(); i++) {
addEditableSecurityTeam(array6.get(i));
}
JsArrayInteger array7 = roles.getEditableEntities("SPONSOR", "SponsoredUser");
for (int i = 0; i < array7.length(); i++) {
addEditableSponsoredUsers(array7.get(i));
}
}
Aggregations