Package com.google.collide.client.code.autocomplete

Examples of com.google.collide.client.code.autocomplete.AutocompleteProposal


  }

  public void testFullFunctionCompletion() {
    helper.setup(path, "get", 0, 3, false);
    autocompleter.findAutocompletions(helper.editor.getSelection(), CTRL_SPACE);
    AutocompleteProposal functionProposal = new CodeGraphProposal("getFoo",
        path, true);
    AutocompleteResult commonResult = autocompleter.computeAutocompletionResult(
        new ProposalWithContext(SyntaxType.NONE, functionProposal, new Context("get")));
    assertTrue("result type", commonResult instanceof DefaultAutocompleteResult);
    DefaultAutocompleteResult result = (DefaultAutocompleteResult) commonResult;
View Full Code Here


   *               fires notification
   */
  public void testFullPropertyCompletion() {
    helper.setup(path, "g", 0, 1, false);
    autocompleter.findAutocompletions(helper.editor.getSelection(), CTRL_SPACE);
    AutocompleteProposal propertyProposal = new CodeGraphProposal("gender",
        path, false);
    AutocompleteResult commonResult = autocompleter.computeAutocompletionResult(
        new ProposalWithContext(SyntaxType.NONE, propertyProposal, new Context("get")));
    assertTrue("result type", commonResult instanceof DefaultAutocompleteResult);
    DefaultAutocompleteResult result = (DefaultAutocompleteResult) commonResult;
View Full Code Here

  }

  public void testTemplateProcessing() {
    helper.setup(path, "", 0, 0, false);
    autocompleter.findAutocompletions(helper.editor.getSelection(), CTRL_SPACE);
    AutocompleteProposal proposal = new TemplateProposal("simple", "simple (%c) <%i%n>");
    AutocompleteResult commonResult = autocompleter.computeAutocompletionResult(
        new ProposalWithContext(SyntaxType.NONE, proposal, new Context("")));
    assertTrue("result type", commonResult instanceof DefaultAutocompleteResult);
    DefaultAutocompleteResult result = (DefaultAutocompleteResult) commonResult;
    assertEquals("autocompletion text", "simple () <\n  \n>", result.getAutocompletionText());
View Full Code Here

            "Unexpected mode: " + proposal.getSyntaxType().getName());
      }
    }

    HtmlProposalWithContext htmlProposal = (HtmlProposalWithContext) proposal;
    AutocompleteProposal selectedProposal = proposal.getItem();
    String triggeringString = proposal.getContext().getTriggeringString();
    String selectedName = selectedProposal.getName();

    switch (htmlProposal.getType()) {
      case ELEMENT:
        if (htmlAttributes.isSelfClosedTag(selectedName)) {
          return new DefaultAutocompleteResult(
View Full Code Here

  @Override
  public AutocompleteResult computeAutocompletionResult(ProposalWithContext selected) {
    AutocompleteProposals.Context context = selected.getContext();
    String triggeringString = context.getTriggeringString();
    AutocompleteProposal proposal = selected.getItem();

    if (proposal instanceof TemplateProposal) {
      TemplateProposal templateProposal = (TemplateProposal) proposal;
      return templateProposal.buildResult(triggeringString, context.getIndent());
    }
View Full Code Here

    Editor editor = Editor.create(new MockAppContext());
    editor.setDocument(Document.createFromString(""));
    AutocompleteUiController box = new AutocompleteUiController(
        editor, (Resources) GWT.create(Resources.class));
    JsonArray<AutocompleteProposal> items = JsonCollections.createArray();
    items.add(new AutocompleteProposal("First"));
    items.add(new AutocompleteProposal("Second"));
    items.add(new AutocompleteProposal("Third"));
    AutocompleteProposals proposals = new AutocompleteProposals(SyntaxType.NONE, "", items);
    box.positionAndShow(proposals);
    assertEquals(3, box.getList().size());
  }
View Full Code Here

    for (String tag : tags.search(prefix)) {
      if (!tag.startsWith(prefix)) {
        break;
      }
      // TODO: Do we need to cache that?
      result.add(new AutocompleteProposal(tag));
    }
    return result;
  }
View Full Code Here

      }
      if (alreadyPresentAttributes.contains(attribute)) {
        continue;
      }
      // TODO: Do we need to cache that?
      result.add(new AutocompleteProposal(attribute));
    }

    return result;
  }
View Full Code Here

              shouldBeIncluded = false;
              for (int i = 0; i < valueProposals.length(); i++) {
                if (valueProposals.get(i).startsWith(incomplete)
                    && (isRepeatingProperty || !inExistingValues(
                        currentValue, valuesAndSpecialValuesBefore, valuesAndSpecialValuesAfter))) {
                  proposals.add(new AutocompleteProposal(valueProposals.get(i)));
                }
              }
            }
          } else {
            shouldBeIncluded = true;
          }
        } else {
          for (int keyTriggerCt = 0; keyTriggerCt < keyTriggerSet.length(); keyTriggerCt++) {
            String triggerValue = keyTriggerSet.get(keyTriggerCt);
            int triggerSlot = triggers.<Jso>cast().getIntField(triggerValue);
            if (triggerValue.charAt(0) == '<') {
              JsArrayString specialValueProposalsAfterCheck =
                  checkIfSpecialValueAndGetSpecialValueProposals(
                      valuesBefore.get(triggerSlot), triggerValue);
              if (specialValueProposalsAfterCheck.length() != 0) {
                shouldBeIncluded = false;
                for (int i = 0; i < specialValueProposalsAfterCheck.length(); i++) {
                  if (specialValueProposalsAfterCheck.get(i).startsWith(incomplete)
                      && (isRepeatingProperty
                          || !inExistingValues(triggerValue, valuesAndSpecialValuesBefore,
                              valuesAndSpecialValuesAfter))) {
                    proposals.add(new AutocompleteProposal(specialValueProposalsAfterCheck.get(i)));
                  }
                }
              }
            } else if (valuesBefore.get(triggerSlot).compareTo(triggerValue) == 0) {
              shouldBeIncluded = true;
            }
          }
        }
        if (shouldBeIncluded) {
          if (currentValue.startsWith(incomplete) && (isRepeatingProperty || !inExistingValues(
              currentValue, valuesAndSpecialValuesBefore, valuesAndSpecialValuesAfter))) {
            proposals.add(new AutocompleteProposal(currentValue));
          }
        }
      }
    }
    return proposals;
View Full Code Here

    completionQuery = null;
  }

  @Override
  public AutocompleteResult computeAutocompletionResult(ProposalWithContext proposal) {
    AutocompleteProposal selectedProposal = proposal.getItem();
    String triggeringString = proposal.getContext().getTriggeringString();
    String name = selectedProposal.getName();
    CompletionType completionType = completionQuery.getCompletionType();
    if (CLASS == completionType) {
      // In this case implicit autocompletion workflow should trigger,
      // and so execution should never reach this point.
      Log.warn(getClass(), "Invocation of this method in not allowed for type CLASS");
View Full Code Here

TOP

Related Classes of com.google.collide.client.code.autocomplete.AutocompleteProposal

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.