Examples of ItemSet


Examples of net.sourceforge.chaperon.build.ItemSet

    assertNotEquals("Test if sets are not equal", set, set2);
  }

  public void testEqualsCore()
  {
    ItemSet set = new ItemSet(grammar, firstsets);
    set.addItem(0, 0, eof);
    set.addItem(1, 0, c);
    set.addItem(1, 0, d);
    set.addItem(2, 0, c);
    set.addItem(2, 0, d);

    ItemSet set2 = new ItemSet(grammar, firstsets);
    set2.addItem(0, 0, eof);
    set2.addItem(1, 0, c);
    set2.addItem(2, 0, d);

    assertTrue("Test if sets have the same core", set.equalsCore(set2));

    set = new ItemSet(grammar, firstsets);
    set.addItem(0, 0, eof);
    set.addItem(1, 0, c);
    set.addItem(1, 0, d);
    set.addItem(2, 0, c);
    set.addItem(2, 0, d);

    set2 = new ItemSet(grammar, firstsets);
    set2.addItem(2, 0, d);
    set2.addItem(0, 0, eof);
    set2.addItem(1, 0, c);

    assertTrue("Test if sets have the same core", set.equalsCore(set2));

    set = new ItemSet(grammar, firstsets);
    set.addItem(0, 0, eof);
    set.addItem(1, 1, c);
    set.addItem(1, 1, d);
    set.addItem(2, 1, c);
    set.addItem(2, 1, d);

    set2 = new ItemSet(grammar, firstsets);
    set2.addItem(2, 1, d);
    set2.addItem(0, 0, eof);
    set2.addItem(1, 1, c);

    assertTrue("Test if sets have the same core", set.equalsCore(set2));

    set2 = new ItemSet(grammar, firstsets);
    set2.addItem(1, 1, d);
    set2.addItem(0, 0, eof);
    set2.addItem(1, 1, c);

    assertTrue("Test if sets don't have the same core", !set.equalsCore(set2));
  }
View Full Code Here

Examples of net.sourceforge.chaperon.build.ItemSet

  }

  public void testClosure()
  {
    // ---- Case 1 ----
    ItemSet set = new ItemSet(grammar, firstsets);
    set.addItem(0, 0, eof);

    ItemSet result = new ItemSet(grammar, firstsets);
    result.addItem(0, 0, eof);
    result.addItem(1, 0, c);
    result.addItem(1, 0, d);
    result.addItem(2, 0, c);
    result.addItem(2, 0, d);

    assertEquals("Test if sets are equal", result, set.closure());

    set = new ItemSet(grammar, firstsets);
    set.addItem(0, 1, eof);

    result = new ItemSet(grammar, firstsets);
    result.addItem(0, 1, eof);
    result.addItem(1, 0, eof);
    result.addItem(2, 0, eof);

    assertEquals("Test if sets are equal", result, set.closure());

    set = new ItemSet(grammar, firstsets);
    set.addItem(0, 2, eof);

    result = new ItemSet(grammar, firstsets);
    result.addItem(0, 2, eof);

    assertEquals("Test if sets are equal", result, set.closure());

    set = new ItemSet(grammar, firstsets);
    set.addItem(1, 1, c);
    set.addItem(1, 1, d);

    result = new ItemSet(grammar, firstsets);
    result.addItem(1, 1, c);
    result.addItem(1, 1, d);
    result.addItem(1, 0, c);
    result.addItem(1, 0, d);
    result.addItem(2, 0, c);
    result.addItem(2, 0, d);

    assertEquals("Test if sets are equal", result, set.closure());

    // ---- Case 2 ----
    Terminal a = new Terminal("a");
    Terminal b = new Terminal("b");
    Terminal c = new Terminal("c");

    Nonterminal A = new Nonterminal("A");
    Nonterminal B = new Nonterminal("B");
    Nonterminal C = new Nonterminal("C");
    Nonterminal D = new Nonterminal("D");

    grammar = new Grammar();

    Production production = new Production(A);
    production.getDefinition().addSymbol(B);
    production.getDefinition().addSymbol(a);
    grammar.addProduction(production);

    production = new Production(B);
    production.getDefinition().addSymbol(b);
    grammar.addProduction(production);

    production = new Production(C);
    production.getDefinition().addSymbol(B);
    production.getDefinition().addSymbol(D);
    grammar.addProduction(production);

    production = new Production(D);

    // empty
    grammar.addProduction(production);

    firstsets = new FirstSetCollection(grammar);

    set = new ItemSet(grammar, firstsets);
    set.addItem(0, 0, c);

    result = new ItemSet(grammar, firstsets);
    result.addItem(0, 0, c);
    result.addItem(1, 0, a);

    assertEquals("Test if sets are equal", result, set.closure());

    set = new ItemSet(grammar, firstsets);
    set.addItem(2, 0, a);

    result = new ItemSet(grammar, firstsets);
    result.addItem(2, 0, a);
    result.addItem(1, 0, a);

    assertEquals("Test if sets are equal", result, set.closure());

    // ---- Case 3 ----
    grammar = new Grammar();

    production = new Production(A);
    production.getDefinition().addSymbol(B);
    production.getDefinition().addSymbol(D);
    grammar.addProduction(production);

    production = new Production(B);
    production.getDefinition().addSymbol(C);
    grammar.addProduction(production);

    production = new Production(C);
    production.getDefinition().addSymbol(d);
    grammar.addProduction(production);

    production = new Production(D);
    production.getDefinition().addSymbol(b);
    grammar.addProduction(production);

    firstsets = new FirstSetCollection(grammar);

    set = new ItemSet(grammar, firstsets);
    set.addItem(0, 0, c);

    result = new ItemSet(grammar, firstsets);
    result.addItem(0, 0, c);
    result.addItem(1, 0, b);
    result.addItem(2, 0, b);

    assertEquals("Test if sets are equal", result, set.closure());
  }
View Full Code Here

Examples of org.jboss.ide.eclipse.freemarker.model.ItemSet

  @Override
  public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer,
      int offset) {
    try {
      ItemSet directiveSet = editor.getItemSet();

      Map<String, Class<?>> context = new HashMap<String, Class<?>>();
      ContextValue[] values = ConfigurationManager.getInstance(
          editor.getProject()).getContextValues(editor.getFile(),
          true);
      for (int i = 0; i < values.length; i++) {
        context.put(values[i].name, values[i].objClass);
      }

      Item directive = directiveSet.getSelectedItem(offset);
      if (null != directive) {
        return directive.getCompletionProposals(offset, context);
      } else {
        // we might be starting something
        Item item = editor.getItemSet().getPreviousItem(offset);
View Full Code Here

Examples of org.jboss.ide.eclipse.freemarker.model.ItemSet

    if (getEditorInput() instanceof IFileEditorInput) {
      resource = ((IFileEditorInput) getEditorInput()).getFile();
      // } else if (getEditorInput() instanceof JarEntryEditorInput) {
      // resource = null;
    }
    return new ItemSet(getSourceViewer(), regions, resource);
  }
View Full Code Here

Examples of org.jboss.ide.eclipse.freemarker.model.ItemSet

    reconcile(regions);
  }

  public void reconcile(List<ITypedRegion> regions) {
    /* re-create the model in the reconciler thread */
    final ItemSet newItemSet = createItemSet(regions);

    Runnable newItemSetTask = new Runnable() {
      @Override
      public void run() {
        Editor.this.itemSet = newItemSet;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.