Example usage for org.eclipse.jdt.core.dom Javadoc tags

List of usage examples for org.eclipse.jdt.core.dom Javadoc tags

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom Javadoc tags.

Prototype

ASTNode.NodeList tags

To view the source code for org.eclipse.jdt.core.dom Javadoc tags.

Click Source Link

Document

The list of tag elements (element type: TagElement ).

Usage

From source file:ac.at.tuwien.dsg.uml.statemachine.export.transformation.engines.AbstractStateMachineTestStrategy.java

License:Open Source License

/**
 * Method which for any type of trigger Event, from CallEvent, to ChangeEvent, TimeEvent, etc, creates an abstract method
 * @param trigger/*from   w  ww .  java2  s .c  om*/
 * @param ast
 * @return
 */
protected MethodDeclaration createAbstractTriggerInvocation(Trigger trigger, AST ast) {

    //get trigger event
    Event event = trigger.getEvent();
    //if UML operation triggers event (so CLass method)

    String methodName = GENERATE_EVENT_LEADING;
    Javadoc javadoc = ast.newJavadoc();
    TagElement tag = ast.newTagElement();
    TextElement textElement = ast.newTextElement();

    if (event instanceof CallEvent) {

        CallEvent callEvent = (CallEvent) event;
        Operation operation = callEvent.getOperation();
        Class operationClass = (Class) operation.eContainer();

        methodName = operationClass.getName().replaceAll("\\W", "") + "_"
                + operation.getName().replaceAll("\\W", "");
        textElement.setText("Method must return true if method invocation is successful."
                + " Method designed to allow particular implementation  call of \"" + operation.getName() + "\""
                + " on class \"" + operationClass.getName()
                + "\" so we can assert if transition after event is correct");

    } else if (event instanceof ChangeEvent) {

        ChangeEvent changeEvent = (ChangeEvent) event;
        OpaqueExpression changeExpression = (OpaqueExpression) changeEvent.getChangeExpression();
        if (changeExpression.getBodies().isEmpty()) {
            System.err.println("Event " + event.getName() + " has no body/expression");
        } else {
            String body = changeExpression.getBodies().iterator().next();
            body = StringFormatter.convertNonAlphanumericalSymbolsToUnderscore(
                    StringFormatter.convertMathSymbolsToText(body));

            methodName = changeEvent.getName().replaceAll("\\W", "") + "_" + body;
            textElement.setText("Method must return true if event invocation is successful"
                    + " Method designed to allow particular implementation  for forcing condition \"" + body
                    + "\" encountered on event \"" + changeEvent.getName()
                    + "\" to true so we can assert if transition after event is correct");
        }
    } else if (event instanceof TimeEvent) {

        TimeEvent timeEvent = (TimeEvent) event;

        if (timeEvent.getWhen() == null || timeEvent.getWhen().getExpr() == null) {
            System.err.println("Event " + event.getName() + " has no when/expression");
        } else {
            String expression = ((LiteralString) timeEvent.getWhen().getExpr()).getValue(); // maybe can do something more with TimeExpression
            expression = StringFormatter.convertNonAlphanumericalSymbolsToUnderscore(
                    StringFormatter.convertMathSymbolsToText(expression));

            methodName = timeEvent.getName().replaceAll("\\W", "") + "_" + expression;
            textElement.setText("Method must return true if event invocation is successful"
                    + " Method designed to allow particular implementation  for forcing the time event "
                    + timeEvent.getName() + " with body \"" + expression
                    + "\" to happen so we can assert if transition after event is correct");
        }

    } else if (event instanceof SignalEvent) {

        SignalEvent signalEvent = (SignalEvent) event;
        Signal signal = signalEvent.getSignal();

        methodName = signal.getName().replaceAll("\\W", "");
        textElement.setText("Method must return true if method invocation is successful."
                + " Method designed to allow particular implementation call of \"" + signal.getName()
                + "\" so we can assert if transition after event is correct");
    } else {

        System.err.println("Event type of " + event.getClass() + " not supported yet ");
        methodName = "invoke" + event.getName().replaceAll("\\W", "_");
        textElement.setText("Event type of " + event.getClass()
                + " not supported yet so generated javadoc not very usefull. Method must ensure the event is called so we can assert if transition after event is correct.");
    }

    tag.fragments().add(textElement);
    javadoc.tags().add(tag);

    MethodDeclaration method = createAbstractAssertMethod(javadoc, methodName, ast);
    return method;
}

From source file:ac.at.tuwien.dsg.uml.statemachine.export.transformation.engines.AbstractStateMachineTestStrategy.java

License:Open Source License

protected MethodDeclaration createAbstractMethodForState(StateMachineState state, AST ast) {

    String stateName = state.equals(StateMachineState.INITIAL_STATE) ? "InitialState"
            : state.getName().replaceAll("\\W", "");

    Javadoc javadoc = ast.newJavadoc();
    TagElement tag = ast.newTagElement();
    TextElement textElement = ast.newTextElement();
    textElement.setText("Method must return true if the current state is " + stateName);
    tag.fragments().add(textElement);/*from ww w. j av  a2 s .com*/
    javadoc.tags().add(tag);

    MethodDeclaration method = createAbstractAssertMethod(javadoc, ASSERT_STATE_LEADING + stateName, ast);
    return method;
}

From source file:ac.at.tuwien.dsg.uml.statemachine.export.transformation.engines.AbstractStateMachineTestStrategy.java

License:Open Source License

protected MethodDeclaration createAbstractMethodForGuard(String condition, AST ast) {

    String conditionName = StringFormatter
            .convertNonAlphanumericalSymbolsToUnderscore(StringFormatter.convertMathSymbolsToText(condition));

    Javadoc javadoc = ast.newJavadoc();
    TagElement tag = ast.newTagElement();
    TextElement textElement = ast.newTextElement();
    textElement.setText(//from w w  w . j av a 2s.c  o m
            "Method must evaluate and return true if the following condition is true:  state is " + condition);
    tag.fragments().add(textElement);
    javadoc.tags().add(tag);

    MethodDeclaration method = createAbstractAssertMethod(javadoc,
            ASSERT_GUARD_LEADING + (conditionName.substring(0, 1).toUpperCase() + conditionName.substring(1)),
            ast);
    return method;
}

From source file:ac.at.tuwien.dsg.uml.statemachine.export.transformation.engines.AbstractStateMachineTestStrategy.java

License:Open Source License

protected MethodDeclaration createAbstractForceConditionMethod(String condition, AST ast) {

    String conditionName = StringFormatter
            .convertNonAlphanumericalSymbolsToUnderscore(StringFormatter.convertMathSymbolsToText(condition));

    Javadoc javadoc = ast.newJavadoc();
    TagElement tag = ast.newTagElement();
    TextElement textElement = ast.newTextElement();
    textElement.setText(//from  ww w .j a  v a  2 s  .c  om
            "Method must call tested system and ensure the following condition is true so the test can progress on the current test branch: "
                    + condition);
    tag.fragments().add(textElement);
    javadoc.tags().add(tag);

    MethodDeclaration method = createAbstractAssertMethod(javadoc,
            FORCE_GUARD_LEADING + (conditionName.substring(0, 1).toUpperCase() + conditionName.substring(1)),
            ast);
    return method;
}

From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java

License:Open Source License

@Override
public boolean visit(Javadoc node) {
    this.fBuffer.append("/** ");//$NON-NLS-1$
    for (Iterator<TagElement> it = node.tags().iterator(); it.hasNext();) {
        ASTNode e = it.next();//from  ww  w. j  a v a 2s. c o m
        e.accept(this);
    }
    this.fBuffer.append("\n */");//$NON-NLS-1$
    return false;
}

From source file:at.bestsolution.fxide.jdt.editor.JDTJavaDocSupport.java

License:Open Source License

public static HtmlString toHtml(IJavaElement element, String rawJavadoc) {
    String source = rawJavadoc + "class C{}"; //$NON-NLS-1$
    CompilationUnit root = createAST(element, source);
    if (root == null)
        return null;
    List<AbstractTypeDeclaration> types = root.types();
    if (types.size() != 1)
        return null;
    AbstractTypeDeclaration type = types.get(0);
    Javadoc javadoc = type.getJavadoc();
    String js = "";
    try (InputStream in = JDTJavaDocSupport.class.getResourceAsStream("internal/prettify.js")) {
        js = IOUtils.readToString(in, Charset.forName("UTF-8"));
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();//  w w w .ja va  2 s  .  c o m
    }

    StringBuilder b = new StringBuilder("<html><head></head><body>");
    List<TagElement> l = javadoc.tags();
    for (TagElement e : l) {
        if (e.getTagName() == null) {
            b.append(' ');
            handleContents(b, e);
        }
        // System.err.println(" ===> " + e.getTagName());
    }
    b.append("</body></html>");
    //      System.err.println(b);
    return new HtmlString(b.toString());

    // BufferedReader r = new BufferedReader(new StringReader(javaDoc));
    // StringBuilder b = new StringBuilder();
    // return javaDoc.replaceAll("/\\*.*\r?\n", "").replaceAll(".*\\*", "");
}

From source file:coloredide.utils.CopiedNaiveASTFlattener.java

License:Open Source License

public boolean visit(Javadoc node) {
    printIndent();/* ww  w. ja v  a 2s .co  m*/
    this.buffer.append("/** ");//$NON-NLS-1$
    for (Iterator it = node.tags().iterator(); it.hasNext();) {
        ASTNode e = (ASTNode) it.next();
        e.accept(this);
    }
    this.buffer.append("\n */\n");//$NON-NLS-1$
    return false;
}

From source file:com.android.icu4j.srcgen.HideDraftProvisionalInternal.java

License:Apache License

@Override
protected boolean mustTag(Javadoc javadoc) {
    for (TagElement tagElement : (List<TagElement>) javadoc.tags()) {
        if (tagElement.getTagName() != null
                && HideDraftProvisionalInternal.toMatch.contains(tagElement.getTagName().toLowerCase())) {
            return true;
        }//from w  w  w  . j  a va  2s  . co m
    }
    return false;
}

From source file:com.crispico.flower.designer.tests.UID.AlterUIDTestBase.java

License:Open Source License

/**
 * Searches <code>javadoc</code> to find the correct UID
 *   //from   w ww  .ja v a  2 s  .  c o  m
 * @param javadoc doc comment of the file after sync
 * @return true if found the correct UID in javadoc
 */
private boolean correctUIDInserted(Javadoc javadoc) {
    TagElement tagElement = null;

    for (Object tag : javadoc.tags()) {
        if (tag instanceof TagElement) {
            tagElement = (TagElement) tag;
            String containment = tagElement.getTagName() + tagElement.fragments().get(0);
            if (containment.equals(ModelSyncUtils.ID_MARKER + ModelSyncUtils.getModelElementID(masterType_)))
                return true;
        }
    }
    return false;
}

From source file:com.crispico.flower.mp.codesync.code.java.adapter.JavaAbstractAstNodeModelAdapter.java

License:Open Source License

@Override
protected void updateUID(Object element, Object correspondingElement) {
    if (element instanceof BodyDeclaration) {
        BodyDeclaration node = (BodyDeclaration) element;
        Javadoc javadoc = node.getJavadoc();
        // if it doesn't have any doc, create it
        if (javadoc == null) {
            javadoc = node.getAST().newJavadoc();
            node.setJavadoc(javadoc);//from w  ww  .  j  a v  a2 s.c  o m
        }
        // first remove the existing flower tag, this way we also make sure that it's the last tag
        // note: if we only change the id, the rewriter won't format it correctly
        for (Object obj : javadoc.tags()) {
            if (FLOWER_UID.equals(((TagElement) obj).getTagName())) {
                javadoc.tags().remove(obj);
                break;
            }
        }
        // create new tag element for UID
        TagElement tag = javadoc.getAST().newTagElement();
        tag.setTagName(FLOWER_UID);
        javadoc.tags().add(tag);
        TextElement text = javadoc.getAST().newTextElement();
        tag.fragments().add(text);
        EObject eObject = (EObject) correspondingElement;
        text.setText(eObject.eResource().getURIFragment(eObject));
        System.out.println(javadoc);
    }
}