use of com.twosigma.beakerx.autocomplete.AutocompleteCandidate in project beakerx by twosigma.
the class JavaImportDeclarationCompletion method importPackageName.
private void importPackageName(ImportDeclarationContext ctx) {
String st = ctx.getText();
st = removeImportWord(st);
String[] txtv = st.split("\\.");
AutocompleteCandidate c = new AutocompleteCandidate(JavaCompletionTypes.PACKAGE_NAME, txtv);
addQuery(c, AutocompleteJavaResult.getStartIndex(ctx));
c = new AutocompleteCandidate(JavaCompletionTypes.FQ_TYPE, txtv);
addQuery(c, AutocompleteJavaResult.getStartIndex(ctx));
}
use of com.twosigma.beakerx.autocomplete.AutocompleteCandidate in project beakerx by twosigma.
the class GroovyImportDeclarationCompletion method importPackageNameAfterDot.
private void importPackageNameAfterDot(ImportStatementContext ctx) {
String st = ctx.getText();
st = removeImportWord(st);
if (GroovyCompletionTypes.debug)
logger.info("wants next package name for {}", st);
String[] txtv = (st + "X").split("\\.");
txtv[txtv.length - 1] = EMPTY_NODE;
AutocompleteCandidate c = new AutocompleteCandidate(GroovyCompletionTypes.PACKAGE_NAME, txtv);
addQuery(c, AutocompleteGroovyResult.getStartIndex(ctx) + 1);
c = new AutocompleteCandidate(GroovyCompletionTypes.FQ_TYPE, txtv);
addQuery(c, AutocompleteGroovyResult.getStartIndex(ctx) + 1);
}
use of com.twosigma.beakerx.autocomplete.AutocompleteCandidate in project beakerx by twosigma.
the class GroovyImportDeclarationCompletion method importPackageName.
private void importPackageName(ImportStatementContext ctx) {
String st = ctx.getText();
st = removeImportWord(st);
if (GroovyCompletionTypes.debug)
logger.info("wants to finish package name for {}", st);
String[] txtv = st.split("\\.");
AutocompleteCandidate c = new AutocompleteCandidate(GroovyCompletionTypes.PACKAGE_NAME, txtv);
addQuery(c, AutocompleteGroovyResult.getStartIndex(ctx));
c = new AutocompleteCandidate(GroovyCompletionTypes.FQ_TYPE, txtv);
addQuery(c, AutocompleteGroovyResult.getStartIndex(ctx));
}
use of com.twosigma.beakerx.autocomplete.AutocompleteCandidate in project beakerx by twosigma.
the class GroovyImportDeclarationCompletion method importWithWildcard.
private void importWithWildcard(String st) {
String[] txtv = st.split("\\.");
AutocompleteCandidate c = new AutocompleteCandidate(GroovyCompletionTypes.PACKAGE_NAME, txtv);
registry.addCandidate(c);
st = st.substring(0, st.length() - 2);
List<String> cls = cps.getClasses(st);
if (cls != null) {
c = new AutocompleteCandidate(GroovyCompletionTypes.FQ_TYPE, txtv);
AutocompleteCandidate l = c.findLeaf();
for (String s : cls) {
l.addChildren(new AutocompleteCandidate(GroovyCompletionTypes.CUSTOM_TYPE, s));
registry.addCandidate(new AutocompleteCandidate(GroovyCompletionTypes.CUSTOM_TYPE, s));
classUtils.defineClassShortName(s, st + "." + s);
if (GroovyCompletionTypes.debug)
logger.info("define {} {}.{}", s, st, s);
}
registry.addCandidate(c);
}
}
use of com.twosigma.beakerx.autocomplete.AutocompleteCandidate in project beakerx by twosigma.
the class GroovyNameBuilder method exitDeclarationRule.
@Override
public void exitDeclarationRule(DeclarationRuleContext ctx) {
if (ctx.getChildCount() == 4 && ctx.getChild(0) instanceof TypeDeclarationContext && ctx.getChild(3) instanceof ExpressionContext && ctx.getChild(3).getChildCount() > 0) {
if (!ctx.getChild(1).getText().contains(".")) {
if (ctx.getChild(3).getChild(0) instanceof PathExpressionContext) {
String typpen = ctx.getChild(3).getChild(0).getText().trim();
AutocompleteCandidate c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, ctx.getChild(1).getText());
registry.addCandidate(c);
if (GroovyCompletionTypes.debug)
logger.info("define variable of type " + ctx.getChild(1).getText() + " " + typpen);
if (classUtils.getVariableType(typpen) != null) {
classUtils.defineVariable(ctx.getChild(1).getText(), classUtils.getVariableType(typpen));
}
} else if (ctx.getChild(3).getChild(0) instanceof NewInstanceRuleContext) {
nameDeclaration(ctx);
} else {
if (GroovyCompletionTypes.debug)
System.out.println(((ExpressionContext) ctx.getChild(3)).getStart().getType());
String typpen = null;
if (ctx.getChild(3) instanceof ListConstructorContext)
typpen = "Array";
else if (ctx.getChild(3) instanceof MapConstructorContext)
typpen = "Map";
else {
switch(((ExpressionContext) ctx.getChild(3)).getStart().getType()) {
case GroovyLexer.STRING:
typpen = "String";
break;
case GroovyLexer.INTEGER:
typpen = "Integer";
break;
case GroovyLexer.DECIMAL:
typpen = "Double";
break;
}
}
AutocompleteCandidate c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, ctx.getChild(1).getText());
registry.addCandidate(c);
if (GroovyCompletionTypes.debug)
logger.info("define variable of type " + ctx.getChild(1).getText() + " " + typpen);
if (typpen != null)
classUtils.defineVariable(ctx.getChild(1).getText(), typpen);
}
}
}
}
Aggregations