Example usage for org.eclipse.jdt.core.dom ASTNode getProperty

List of usage examples for org.eclipse.jdt.core.dom ASTNode getProperty

Introduction

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

Prototype

public final Object getProperty(String propertyName) 

Source Link

Document

Returns the value of the named property of this node, or null if none.

Usage

From source file:ca.uvic.chisel.javasketch.internal.ast.groups.ASTLoopGroupCalculator.java

License:Open Source License

/**
 * @param blockNode//from  w w  w.  j a  v a  2  s  .com
 * @param child
 * @param i
 * @param groupings
 * @return
 */
private static ASTMessageGroupingTree getGrouping(ASTNode blockNode) {
    ASTMessageGroupingTree currentGrouping = (ASTMessageGroupingTree) blockNode.getProperty(CURRENT_GROUPING);

    if (currentGrouping == null) {
        //first: if this blockNode is a method declaration, create a root group
        if (blockNode.getNodeType() == ASTNode.METHOD_DECLARATION) {
            currentGrouping = new ASTMessageGroupingTree(null, blockNode);
            blockNode.setProperty(CURRENT_GROUPING, currentGrouping);
            return currentGrouping;
        } else {
            ASTMessageGroupingTree parentGrouping = getGrouping(findBlockParent(blockNode));
            currentGrouping = new ASTMessageGroupingTree(parentGrouping, blockNode);
            blockNode.setProperty(CURRENT_GROUPING, currentGrouping);
            return currentGrouping;
        }
        //         
        //         ASTMessageGroupingTree parentGrouping = 
        //         //create a new grouping for this node and all of its parents.
        //         LinkedList<IMessageGrouping> created = new LinkedList<IMessageGrouping>();
        //         currentGrouping = new ASTMessageGroupingTree(activation, blockNode);
        //         currentGrouping.setStartIndex(i);
        //         currentGrouping.setEndIndex(i);
        //         blockNode.setProperty(CURRENT_GROUPING, currentGrouping);
        //         updateGrouping(currentGrouping);
        //         created.addFirst(currentGrouping);
        //         ASTNode parent = findBlockParent(blockNode);
        //         while (parent != null) {
        //            ASTMessageGroupingTree newGrouping = (ASTMessageGroupingTree) parent.getProperty(CURRENT_GROUPING);
        //            if (newGrouping != null) {
        //               //update it to include the new index
        //               if (newGrouping.getEndIndex() < i) {
        //                  newGrouping.setEndIndex(i);
        //               }
        //            } else {
        //               newGrouping = new ASTMessageGroupingTree(activation, parent);
        //               parent.setProperty(CURRENT_GROUPING, newGrouping);
        //               newGrouping.setStartIndex(i);
        //               newGrouping.setEndIndex(i);
        //               updateGrouping(newGrouping);
        //               created.addFirst(newGrouping);
        //            }
        //            parent = findBlockParent(parent);      
        //         }
        //         groupings.addAll(created);
    }
    return currentGrouping;
}

From source file:ca.uvic.chisel.javasketch.internal.ast.groups.ASTLoopGroupCalculator.java

License:Open Source License

/**
 * Clears the current grouping for the block node, and all of its children.
 * @param blockNode//from   w w  w .j  ava 2s. co  m
 * @param child
 * @param i
 * @param groupings
 * @return
 */
private static ASTMessageGroupingTree resetGrouping(ASTNode blockNode) {
    ASTNode loop = findLoopingParent(blockNode);
    if (loop != null) {
        ASTMessageGroupingTree loopGroup = (ASTMessageGroupingTree) loop.getProperty(CURRENT_GROUPING);
        int currentIteration = loopGroup.getIteration();
        //clear the children
        loop.accept(new GenericVisitor() {
            /* (non-Javadoc)
             * @see ca.uvic.chisel.javasketch.internal.ast.groups.GenericVisitor#visitNode(org.eclipse.jdt.core.dom.ASTNode)
             */
            @Override
            protected boolean visitNode(ASTNode node) {
                node.setProperty(CURRENT_GROUPING, null);
                return true;
            }
        });
        //create a new group for the loop
        ASTMessageGroupingTree newLoop = getGrouping(loop);
        newLoop.setIteration(currentIteration + 1);
        return getGrouping(blockNode);
    }
    return (ASTMessageGroupingTree) blockNode.getProperty(CURRENT_GROUPING);
}

From source file:com.github.parzonka.ccms.engine.SortElementsOperation.java

License:Open Source License

boolean checkMalformedNodes(ASTNode node) {
    final Object property = node.getProperty(CONTAINS_MALFORMED_NODES);
    if (property == null)
        return false;
    return ((Boolean) property).booleanValue();
}

From source file:org.decojer.cavaj.utils.Expressions.java

License:Open Source License

/**
 * Get originating operation./*from   ww w . j  a va  2s  . c  om*/
 *
 * @param node
 *            AST node
 * @return originating operation
 */
@Nullable
public static Op getOp(@Nullable final ASTNode node) {
    return node == null ? null : (Op) node.getProperty(PROP_OP);
}

From source file:org.eclipse.recommenders.codesearch.rcp.index.indexer.AstHelper.java

License:Open Source License

public static IProject getProject(ASTNode node) {
    while (node != null && !(node instanceof CompilationUnit)) {
        node = node.getParent();//from  w  ww .j a v  a 2s . co  m
    }
    final ITypeRoot root = ((CompilationUnit) node).getTypeRoot();
    if (root == null) {
        final IJavaProject property = (IJavaProject) node.getProperty("project");
        return property.getProject();
    }
    return root.getJavaProject().getProject();
}

From source file:org.eclipse.wb.core.eval.ExecutionFlowUtils.java

License:Open Source License

/**
 * @return <code>true</code> if given variable has cache stamp (there was related bug, so we test
 *         for this now).//from w  w w .  j av a2 s.  co m
 */
public static boolean hasVariableStamp(ASTNode variable) {
    return variable.getProperty(KEY_LAST_VARIABLE_STAMP) != null;
}

From source file:org.eclipse.wb.core.eval.ExecutionFlowUtils.java

License:Open Source License

/**
 * @return the cached value for given variable.
 *//*from  w w  w .  ja  v  a 2 s  .  c o m*/
private static Object getVariableCachedValue(ExecutionFlowDescription flowDescription, ASTNode variable,
        String key) {
    if (clearCachedValuesForDanglingNode(variable)) {
        return null;
    }
    // check for cached value
    {
        Long lastStamp = (Long) variable.getProperty(KEY_LAST_VARIABLE_STAMP);
        if (lastStamp != null && lastStamp.longValue() == variable.getAST().modificationCount()) {
            return variable.getProperty(key);
        }
    }
    // well, we don't have cached value, so prepare
    prepareAssignmentInformation(flowDescription);
    // return newly created result
    return variable.getProperty(key);
}

From source file:org.eclipse.wb.core.eval.ExecutionFlowUtils2.java

License:Open Source License

public static void ensureValues(ExecutionFlowDescription flowDescription) {
    ASTNode rootNode = flowDescription.getCompilationUnit();
    long stampAST = rootNode.getAST().modificationCount();
    long stampFlow = flowDescription.modificationCount();
    Long cache_stampAST = (Long) rootNode.getProperty(STAMP_AST);
    Long cache_stampFlow = (Long) rootNode.getProperty(STAMP_FLOW);
    if (cache_stampAST == null || cache_stampAST.longValue() != stampAST || cache_stampFlow == null
            || cache_stampFlow.longValue() != stampFlow) {
        rootNode.setProperty(STAMP_AST, stampAST);
        rootNode.setProperty(STAMP_FLOW, stampFlow);
        trackValues(flowDescription, rootNode);
    }//from  ww  w  . j ava  2  s.c om
}

From source file:org.eclipse.wb.internal.core.model.creation.ThisCreationSupport.java

License:Open Source License

/**
 * @return <code>true</code> if currently invoked {@link Method} was from
 *         {@link SuperMethodInvocation}. Removes this flag.
 *//*  w w w  .  j  ava  2s. co m*/
private boolean isSuperMethodInvocation() {
    ASTNode root = m_constructor.getRoot();
    try {
        return root.getProperty(InvocationEvaluator.SUPER_MI_KEY) == Boolean.TRUE;
    } finally {
        root.setProperty(InvocationEvaluator.SUPER_MI_KEY, null);
    }
}

From source file:org.eclipse.wb.internal.core.model.util.PlaceholderUtils.java

License:Open Source License

/**
 * @return exceptions associated with given {@link ASTNode}, may be <code>null</code>.
 *///from w  w  w . j av a2  s  . c om
@SuppressWarnings("unchecked")
private static List<Throwable> getExceptions0(ASTNode node) {
    return (List<Throwable>) node.getProperty(KEY_EXCEPTIONS);
}