Package com.twosigma.beaker.autocomplete.java.JavaParser

Examples of com.twosigma.beaker.autocomplete.java.JavaParser.QualifiedNameContext


      // match... we are autocompleting this import declaration
     
      if(text.charAt(cursor-1)=='.') {
        // looking for next package name
        if(ctx.getChildCount() > 2 && (ctx.getChild(1) instanceof QualifiedNameContext)) {
          QualifiedNameContext qn = (QualifiedNameContext)ctx.getChild(1);
          String st = qn.getText();
          //System.out.println("wants next package name for "+st);
          String [] txtv = (st+".X").split("\\.");
          txtv[txtv.length-1] = "";
          AutocompleteCandidate c = new AutocompleteCandidate(JavaCompletionTypes.PACKAGE_NAME, txtv);
          addQuery(c);
          c = new AutocompleteCandidate(JavaCompletionTypes.FQ_TYPE, txtv);
          addQuery(c);
        }
      } else {
        // looking to autocomplete a package name
        if(ctx.getChildCount() > 2 && (ctx.getChild(1) instanceof QualifiedNameContext)) {
          QualifiedNameContext qn = (QualifiedNameContext)ctx.getChild(1);
          String st = qn.getText();
          //System.out.println("wants to finish package name for "+qn.getText());
          String [] txtv = st.split("\\.");
          AutocompleteCandidate c = new AutocompleteCandidate(JavaCompletionTypes.PACKAGE_NAME, txtv);
          addQuery(c);
          c = new AutocompleteCandidate(JavaCompletionTypes.FQ_TYPE, txtv);
          addQuery(c);
        }
      }
    } else {
      // add this import declaration
      if(ctx.getChildCount() > 2 && (ctx.getChild(1) instanceof QualifiedNameContext)) {
        QualifiedNameContext qn = (QualifiedNameContext)ctx.getChild(1);
        // this imports using '*'
        if(ctx.getChildCount() >= 4 && ctx.getChild(2).getText().equals(".") && ctx.getChild(3).getText().equals("*")) {
          //System.out.println("ADD ALL imports for "+qn.getText());
          String st = qn.getText();
          String [] txtv = st.split("\\.");
          AutocompleteCandidate c = new AutocompleteCandidate(JavaCompletionTypes.PACKAGE_NAME, txtv);
          registry.addCandidate(c);
          List<String> cls = cps.getClasses(st);
          if(cls!=null) {
            c = new AutocompleteCandidate(JavaCompletionTypes.FQ_TYPE, txtv);
            AutocompleteCandidate l = c.findLeaf();
            for ( String s : cls) {
              l.addChildren(new AutocompleteCandidate(JavaCompletionTypes.CUSTOM_TYPE, s));
              registry.addCandidate(new AutocompleteCandidate(JavaCompletionTypes.CUSTOM_TYPE, s));
              classUtils.defineClassShortName(s, st+"."+s);
            }
            registry.addCandidate(c);
          }
        } else {
          // this imports a specific type
          //System.out.println("ADD import for "+qn.getText());
          String st = qn.getText();
          String [] txtv = st.split("\\.");
          AutocompleteCandidate c = new AutocompleteCandidate(JavaCompletionTypes.PACKAGE_NAME, txtv, txtv.length-1);
          registry.addCandidate(c);
          c = new AutocompleteCandidate(JavaCompletionTypes.FQ_TYPE, txtv);
          registry.addCandidate(c);
View Full Code Here

TOP

Related Classes of com.twosigma.beaker.autocomplete.java.JavaParser.QualifiedNameContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.