Package org.jboss.ide.eclipse.freemarker.model

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


  protected void assertListEnd(Iterator<Item> i) {
    assertDirective(i, ListEndDirective.class);
  }

  protected void assertDirective(Iterator<Item> i, Class<?> cl) {
    Item item;
    item = i.next();
    assertEquals(cl, item.getClass());
    assertEquals(0, item.getChildItems().size());
  }
View Full Code Here


  protected void assertIfEnd(Iterator<Item> i) {
    assertDirective(i, IfEndDirective.class);
  }
  protected Item assertChildren(Iterator<Item> i, Class<?> cl, Class<?>... expectedChildren) {
    Item item;
    List<Item> childItems;
    item = i.next();
    assertEquals(cl, item.getClass());
    childItems = item.getChildItems();
    assertEquals(expectedChildren.length, childItems.size());
    for (int j = 0; j < expectedChildren.length; j++) {
      assertEquals("Child #"+ i +" found "+ childItems.get(j).getClass() + " expected "+expectedChildren[j], expectedChildren[j], childItems.get(j).getClass()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }
    return item;
View Full Code Here

          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);
        int topOffset = 0;
        if (null != item)
          topOffset = item.getRegion().getOffset()
              + item.getRegion().getLength();
        // check for directives and macro calls
        try {
          for (int i = offset - 1; i >= topOffset; i--) {
            char c = editor.getDocument().getChar(i);
            if (c == LexicalConstants.RIGHT_ANGLE_BRACKET || c == LexicalConstants.RIGHT_SQUARE_BRACKET)
              break;
            if (c == LexicalConstants.LEFT_ANGLE_BRACKET || c == LexicalConstants.LEFT_SQUARE_BRACKET) {
              if (editor.getDocument().getLength() > i) {
                char c2 = editor.getDocument().getChar(i + 1);
                if (c2 == LexicalConstants.HASH) {
                  CompletionDirective completionDirective = new CompletionDirective(
                      editor.getItemSet(), i, offset - i,
                      (ISourceViewer) viewer,
                      (IResource) editor.getFile());
                  return completionDirective
                      .getCompletionProposals(offset,
                          context);
                } else if (c2 == LexicalConstants.AT) {
                  CompletionMacroInstance completionMacroInstance = new CompletionMacroInstance(
                      editor.getItemSet(), editor
                          .getDocument().get(i,
                              offset - i), i,
                      editor.getFile());
                  return completionMacroInstance
                      .getCompletionProposals(offset,
                          context);
                } else if (c2 == LexicalConstants.SLASH) {
                  if (editor.getDocument().getLength() < i + 3
                      || editor.getDocument().getChar(
                          i + 2) == LexicalConstants.SPACE
                      || editor.getDocument().getChar(
                          i + 2) == LexicalConstants.CR
                      || editor.getDocument().getChar(
                          i + 2) == LexicalConstants.LF) {
                    Item stackItem = editor.getItemSet()
                        .getPreviousStartItem(offset);
                    StringBuilder value = new StringBuilder();
                    if (null != stackItem
                        && stackItem instanceof MacroInstance)
                      value.append(LexicalConstants.AT);
                    else
                      value.append(LexicalConstants.HASH);
                    String name = null;
                    if (null != stackItem)
                      name = stackItem.getFirstToken();
                    if (null != name)
                      value.append(name);
                    if (c == LexicalConstants.LEFT_ANGLE_BRACKET)
                      value.append(LexicalConstants.RIGHT_ANGLE_BRACKET);
                    else
View Full Code Here

  @Override
  protected void handleCursorPositionChanged() {
    super.handleCursorPositionChanged();
    if (!mouseDown) {
      int offset = getCaretOffset();
      Item item = getItemSet().getSelectedItem(offset);
      if (null == item && offset > 0)
        item = getItemSet().getSelectedItem(offset - 1);
      if (Preferences.getInstance().getBoolean(
          PreferenceKey.HIGHLIGHT_RELATED_ITEMS)) {
        if (null != item && null != item.getRelatedItems()
            && item.getRelatedItems().length > 0) {
          highlightRelatedRegions(item.getRelatedItems(), item);
        } else {
          highlightRelatedRegions(null, item);
        }
      }
      if (null == item) {
View Full Code Here

      getSourceViewer().invalidateTextPresentation();
  }

  public Item getSelectedItem(boolean allowFudge) {
    int caretOffset = getCaretOffset();
    Item item = getItemSet().getSelectedItem(getCaretOffset());
    if (null == item && caretOffset > 0)
      item = getItemSet().getSelectedItem(caretOffset - 1);
    return item;
  }
View Full Code Here

        stale = true;
      }
    }
    if (stale) {
      int offset = getCaretOffset();
      Item item = getItemSet().getSelectedItem(offset);
      if (null == item && offset > 0)
        item = getItemSet().getSelectedItem(offset - 1);
      if (Preferences.getInstance().getBoolean(
          PreferenceKey.HIGHLIGHT_RELATED_ITEMS)) {
        if (null != item && null != item.getRelatedItems()
            && item.getRelatedItems().length > 0) {
          highlightRelatedRegions(item.getRelatedItems(), item);
        } else {
          highlightRelatedRegions(null, item);
        }
      }
      validateContents();
View Full Code Here

    this.editor = editor;
  }

  @Override
  public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
    Item item = editor.getItemSet().getItem(region.getOffset());
    if (null != item && item instanceof MacroInstance) {
      MacroInstance instance = (MacroInstance) item;
      int index = instance.getName().indexOf(LexicalConstants.PERIOD);
      if (index > 0) {
        // it is from a macro library
View Full Code Here

  }

  @Override
  public void doubleClick(DoubleClickEvent event) {
    IStructuredSelection selection = (IStructuredSelection) event.getSelection();
    Item item = (Item) selection.getFirstElement();
    if (null != item) {
      fEditor.select(item);
    }
  }
View Full Code Here

  }

  @Override
  public boolean hasChildren(Object anElement) {
    if (fullAstShown && anElement instanceof Item) {
      Item item = (Item) anElement;
      return !item.getChildItems().isEmpty();
    }
    else {
      return false;
    }
  }
View Full Code Here

TOP

Related Classes of org.jboss.ide.eclipse.freemarker.model.Item

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.