Examples of SourceElement


Examples of com.google.gdt.eclipse.designer.model.module.SourceElement

        "<module>",
        "  <source path='some.path'/>",
        "</module>"});
    assertThat(m_module.getChildren()).hasSize(1);
    // prepare single "<source>" element
    SourceElement sourceElement;
    {
      List<SourceElement> sourceElements = m_module.getSourceElements();
      assertThat(sourceElements).hasSize(1);
      sourceElement = sourceElements.get(0);
    }
    // current "path" value
    assertEquals("some.path", sourceElement.getPath());
    // set new "path" value
    {
      sourceElement.setPath("new.path");
      assertUpdatedModuleFile(StringUtils.replace(m_moduleContent, "some.path", "new.path"));
    }
  }
View Full Code Here

Examples of com.google.gdt.eclipse.designer.model.module.SourceElement

        "    <exclude name='some.name'/>",
        "  </source>",
        "</module>"});
    assertThat(m_module.getChildren()).hasSize(1);
    // prepare single "<source>" element
    SourceElement sourceElement;
    {
      List<SourceElement> sourceElements = m_module.getSourceElements();
      assertThat(sourceElements).hasSize(1);
      sourceElement = sourceElements.get(0);
    }
    // current "path" value
    assertEquals("some.path", sourceElement.getPath());
    // ExcludeElement
    {
      List<ExcludeElement> excludeElements = sourceElement.getExcludeElements();
      assertThat(excludeElements).hasSize(1);
      ExcludeElement excludeElement = excludeElements.get(0);
      assertEquals("some.name", excludeElement.getName());
    }
  }
View Full Code Here

Examples of com.google.gwt.dom.client.SourceElement

   *
   * @param url a String URL
   * @see #addSource(String, String)
   */
  public SourceElement addSource(String url) {
    SourceElement elem = Document.get().createSourceElement();
    elem.setSrc(url);
    getElement().appendChild(elem);
    return elem;
  }
View Full Code Here

Examples of com.google.gwt.dom.client.SourceElement

   * @param url a String URL
   * @param type the type (format) of the media
   * @see #getSrc()
   */
  public SourceElement addSource(String url, String type) {
    SourceElement elem = addSource(url);
    elem.setType(type);
    return elem;
  }
View Full Code Here

Examples of com.google.gwt.dom.client.SourceElement

    if (media == null) {
      return; // don't continue if not supported
    }

    // Add some source elements.
    SourceElement source0 = media.addSource("file.ogg", "audio/ogg");
    assertTrue(source0.getSrc().endsWith("file.ogg"));
    assertEquals("audio/ogg", source0.getType());
    SourceElement source1 = media.addSource("file.ogv", "video/ogg");
    assertTrue(source1.getSrc().endsWith("file.ogv"));
    assertEquals("video/ogg", source1.getType());

    // Add a source without a type.
    SourceElement source2 = media.addSource("file.mp3");
    assertTrue(source2.getSrc().endsWith("file.mp3"));

    // Check that the sources are a children of the media.
    assertEquals(media.getElement(), source0.getParentElement());
    assertEquals(media.getElement(), source1.getParentElement());
    assertEquals(media.getElement(), source2.getParentElement());
  }
View Full Code Here

Examples of com.google.gwt.dom.client.SourceElement

    if (media == null) {
      return; // don't continue if not supported
    }

    // Add some source elements.
    SourceElement source0 = media.addSource("file.ogg", "audio/ogg");
    SourceElement source1 = media.addSource("file.ogv", "video/ogg");
    SourceElement source2 = media.addSource("file.mp3");
    assertEquals(media.getElement(), source0.getParentElement());
    assertEquals(media.getElement(), source1.getParentElement());
    assertEquals(media.getElement(), source2.getParentElement());

    // Remove a source.
    media.removeSource(source1);
    assertEquals(media.getElement(), source0.getParentElement());
    assertNull(source1.getParentElement());
    assertEquals(media.getElement(), source2.getParentElement());

    // Let a source remove itself.
    source2.removeFromParent();
    assertEquals(media.getElement(), source0.getParentElement());
    assertNull(source1.getParentElement());
    assertNull(source2.getParentElement());

    // Remove a source that is not a child.
    media.removeSource(source0);
  }
View Full Code Here

Examples of net.sf.lapg.api.SourceElement

    this.notifier = notifier;
    this.debuglev = debuglev;
  }

  public void report(int kind, String message, SourceElement ...anchors) {
    SourceElement anchor = anchors != null && anchors.length > 0 ? anchors[0] : null;
    switch(kind) {
    case KIND_FATAL:
    case KIND_ERROR:
      if(anchor != null && anchor.getResourceName() != null) {
        notifier.error(anchor.getResourceName() + "," + anchor.getLine() + ": ");
      }
      notifier.error(message + "\n");
      break;
    case KIND_WARN:
      if(anchor != null && anchor.getResourceName() != null) {
        notifier.warn(anchor.getResourceName() + "," + anchor.getLine() + ": ");
      }
      notifier.warn(message + "\n");
      break;
    }
  }
View Full Code Here

Examples of org.apache.torque.generator.source.SourceElement

            throw new SourceException(
                    "Error parsing Properties source file: " + e.getMessage(),
                    e);
        }

        SourceElement result
                = new SourceElement(ROOT_ELEMENT_NAME);

        for (String key : properties.orderedKeySet())
        {
            String value = properties.getProperty(key);
            SourceElement entryElement
                    = new SourceElement(ENTRY_ELEMENT_NAME);
            entryElement.setAttribute(KEY_ATTRIBUTE_NAME, key);
            entryElement.setAttribute((String) null, value);
            result.getChildren().add(entryElement);
        }
        return result;
    }
View Full Code Here

Examples of org.openquark.cal.compiler.SourceModel.SourceElement

     * null if there is no inner definition containing the given position.
     * @return the innermost definition containing the given position or null if there is no such definition.
     */
    private static Pair<SourceElement, SourceRange> findInnermostDef(LocalDefn.Function.Definition def, SourcePosition position){
        SourceRange next = null;
        SourceElement element = null;
        if (def.getDefiningExpr() instanceof SourceModel.Expr.Let){
            SourceModel.Expr.Let let = (SourceModel.Expr.Let) def.getDefiningExpr();
            for(LocalDefn localDefn : let.getLocalDefinitions()){
                SourceRange testSourcePosition = localDefn.getSourceRange();
                if (testSourcePosition.containsPosition(position)){
View Full Code Here

Examples of org.openquark.cal.compiler.SourceModel.SourceElement

     * source range of the element. This may be null.
     */
    static Pair<SourceElement, SourceRange> findContainingSourceElement(SourceModel.ModuleDefn moduleDefn, SourcePosition position){
        final int nTopLevelDefns = moduleDefn.getNTopLevelDefns();
        SourceRange next = null;
        SourceElement element = null;
        for (int i = 0; i < nTopLevelDefns; i++) {
            TopLevelSourceElement nthTopLevelDefn = moduleDefn.getNthTopLevelDefn(i);
            // Check for matching data constructor
            if (nthTopLevelDefn instanceof SourceModel.TypeConstructorDefn.AlgebraicType){
                SourceModel.TypeConstructorDefn.AlgebraicType algebraicType = (AlgebraicType) nthTopLevelDefn;
                for(DataConsDefn dataConsDefn : algebraicType.getDataConstructors()){
                    SourceRange testSourcePosition = dataConsDefn.getSourceRangeOfDefn();
                    if (testSourcePosition.containsPosition(position)){
                        if (next == null || next.contains(testSourcePosition)){
                            next = testSourcePosition;
                            element = dataConsDefn;
                            return new Pair<SourceElement, SourceRange>(element, element.getSourceRange());
                        }
                    }
                }
            }
            // check for matching class method
            else if (nthTopLevelDefn instanceof SourceModel.TypeClassDefn){
                SourceModel.TypeClassDefn typeClassDefn = (SourceModel.TypeClassDefn) nthTopLevelDefn;
                for(ClassMethodDefn classMethodDefn : typeClassDefn.getClassMethodDefns()){
                    SourceRange testSourcePosition = classMethodDefn.getSourceRangeOfClassDefn();
                    if (testSourcePosition.containsPosition(position)){
                        if (next == null || next.contains(testSourcePosition)){
                            next = testSourcePosition;
                            element = classMethodDefn;
                            return new Pair<SourceElement, SourceRange>(element, element.getSourceRange());
                        }
                    }
                }
            }
            // check for let expressions
            else if (nthTopLevelDefn instanceof SourceModel.FunctionDefn.Algebraic){
                SourceModel.FunctionDefn.Algebraic algebraic = (SourceModel.FunctionDefn.Algebraic) nthTopLevelDefn;
                if (algebraic.getDefiningExpr() instanceof SourceModel.Expr.Let){
                    SourceModel.Expr.Let let = (SourceModel.Expr.Let) algebraic.getDefiningExpr();
                    for(LocalDefn localDefn : let.getLocalDefinitions()){
                        SourceRange testSourcePosition = localDefn.getSourceRange();
                        if (testSourcePosition.containsPosition(position)){
                            if (next == null || next.contains(testSourcePosition)){
                                next = testSourcePosition;
                                element = localDefn;

                                if (localDefn instanceof LocalDefn.Function){
                                    SourceModel.LocalDefn.Function localFunction = (SourceModel.LocalDefn.Function) localDefn;
                                   
                                    // if there is a type declaration then use that to put the
                                    // cal doc in front of
                                    for(LocalDefn localTypeDefn : let.getLocalDefinitions()){                                   
                                        if (localTypeDefn instanceof SourceModel.LocalDefn.Function.TypeDeclaration){
                                            SourceModel.LocalDefn.Function.TypeDeclaration type = (SourceModel.LocalDefn.Function.TypeDeclaration) localTypeDefn;
                                            if (type.getName().equals(localFunction.getName())){
                                                element = type;                                               
                                            }
                                        }
                                    }
                                }
                                if (localDefn instanceof LocalDefn.Function.Definition){
                                    LocalDefn.Function.Definition def = (Definition) localDefn;
                                    Pair<SourceElement, SourceRange> innerMatch = findInnermostDef(def, position);
                                    if (innerMatch != null){
                                        element = innerMatch.fst();
                                        next = innerMatch.snd();
                                    }
                                }
                            }
                        }
                    }
                    if (element != null){
                        break;
                    }
                }
               
            }

            // check the current element
            SourceRange testSourcePosition = nthTopLevelDefn.getSourceRangeOfDefn();
            if (testSourcePosition.containsPosition(position)){
                if (next == null || next.contains(testSourcePosition)){
                    next = testSourcePosition;
                    element = nthTopLevelDefn;
                }
            }
        }

        if (element != null){
            // Find type declaration if any
            if (element instanceof SourceModel.FunctionDefn){
                SourceModel.FunctionDefn functionDefn = (FunctionDefn) element;
                String name = functionDefn.getName();
                for (int i = 0; i < nTopLevelDefns; i++) {
                    TopLevelSourceElement nthTopLevelDefn = moduleDefn.getNthTopLevelDefn(i);
                    if (nthTopLevelDefn instanceof FunctionTypeDeclaration){
                        FunctionTypeDeclaration type = (FunctionTypeDeclaration) nthTopLevelDefn;
                        if (type.getFunctionName().equals(name)){
                            element = type;
                            break;
                        }
                    }
                }
            }
           
            return new Pair<SourceElement, SourceRange>(element, element.getSourceRange());
        }
        else{
            if (moduleDefn.getSourceRange().containsPosition(position)){
                return new Pair<SourceElement, SourceRange>(moduleDefn, moduleDefn.getSourceRange());
            }
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.