Search in sources :

Example 1 with NodeKey

use of com.android.manifmerger.XmlNode.NodeKey in project buck by facebook.

the class ActionRecorder method getAttributeRecords.

@NonNull
private synchronized List<Actions.AttributeRecord> getAttributeRecords(@NonNull XmlAttribute attribute) {
    XmlElement originElement = attribute.getOwnerElement();
    NodeKey storageKey = originElement.getOriginalId();
    @Nullable Actions.DecisionTreeRecord nodeDecisionTree = mRecords.get(storageKey);
    // by now the node should have been added for this element.
    Preconditions.checkNotNull(nodeDecisionTree, "No record for key [%s]", storageKey);
    List<Actions.AttributeRecord> attributeRecords = nodeDecisionTree.mAttributeRecords.get(attribute.getName());
    if (attributeRecords == null) {
        attributeRecords = new ArrayList<Actions.AttributeRecord>();
        nodeDecisionTree.mAttributeRecords.put(attribute.getName(), attributeRecords);
    }
    return attributeRecords;
}
Also used : NodeKey(com.android.manifmerger.XmlNode.NodeKey) Nullable(com.android.annotations.Nullable) NonNull(com.android.annotations.NonNull)

Example 2 with NodeKey

use of com.android.manifmerger.XmlNode.NodeKey in project buck by facebook.

the class ActionRecorder method recordImpliedNodeAction.

/**
     * Record a node that was added due to an implicit presence in earlier SDK release but requires
     * an explicit declaration in the application targeted SDK.
     * @param xmlElement the implied element that was added to the resulting xml.
     * @param reason optional contextual information whey the implied element was added.
     */
synchronized void recordImpliedNodeAction(@NonNull XmlElement xmlElement, @Nullable String reason) {
    NodeKey storageKey = xmlElement.getOriginalId();
    Actions.DecisionTreeRecord nodeDecisionTree = mRecords.get(storageKey);
    if (nodeDecisionTree == null) {
        nodeDecisionTree = new Actions.DecisionTreeRecord();
        mRecords.put(storageKey, nodeDecisionTree);
    }
    Actions.NodeRecord record = new Actions.NodeRecord(Actions.ActionType.IMPLIED, new SourceFilePosition(xmlElement.getDocument().getSourceFile(), xmlElement.getDocument().getRootNode().getPosition()), xmlElement.getOriginalId(), reason, xmlElement.getOperationType());
    nodeDecisionTree.addNodeRecord(record);
}
Also used : SourceFilePosition(com.android.common.ide.common.blame.SourceFilePosition) NodeKey(com.android.manifmerger.XmlNode.NodeKey)

Example 3 with NodeKey

use of com.android.manifmerger.XmlNode.NodeKey in project buck by facebook.

the class ActionRecorder method recordNodeAction.

/**
     * Records a {@link com.android.manifmerger.Actions.NodeRecord} action on a xml element.
     * @param mergedElement the target element of the action.
     * @param nodeRecord the record of the action.
     */
synchronized void recordNodeAction(@NonNull XmlElement mergedElement, @NonNull Actions.NodeRecord nodeRecord) {
    NodeKey storageKey = mergedElement.getOriginalId();
    Actions.DecisionTreeRecord nodeDecisionTree = mRecords.get(storageKey);
    if (nodeDecisionTree == null) {
        nodeDecisionTree = new Actions.DecisionTreeRecord();
        mRecords.put(storageKey, nodeDecisionTree);
    }
    nodeDecisionTree.addNodeRecord(nodeRecord);
}
Also used : NodeKey(com.android.manifmerger.XmlNode.NodeKey)

Aggregations

NodeKey (com.android.manifmerger.XmlNode.NodeKey)3 NonNull (com.android.annotations.NonNull)1 Nullable (com.android.annotations.Nullable)1 SourceFilePosition (com.android.common.ide.common.blame.SourceFilePosition)1