Esempio n. 1
0
 private void evaluateAll(
     String pluginName,
     Features features,
     Set<String> discovered,
     BooleanTerm term,
     ModuleDeps results,
     String comment) {
   if (feature != null && discovered != null) {
     discovered.add(feature);
   }
   if (feature == null) {
     if (nodeName != null && nodeName.length() > 0) {
       results.add(nodeName, new ModuleDepInfo(pluginName, term, comment, true));
     }
   } else if (!features.contains(feature)) {
     BooleanTerm newTerm = term.andWith(new BooleanTerm(new BooleanVar(feature, true)));
     trueNode.evaluateAll(pluginName, features, discovered, newTerm, results, comment);
     newTerm = term.andWith(new BooleanTerm(new BooleanVar(feature, false)));
     falseNode.evaluateAll(pluginName, features, discovered, newTerm, results, comment);
   } else {
     if (features.isFeature(feature)) {
       trueNode.evaluateAll(pluginName, features, discovered, term, results, comment);
     } else {
       falseNode.evaluateAll(pluginName, features, discovered, term, results, comment);
     }
   }
 }
Esempio n. 2
0
 /**
  * Normalizes the current node relative to the path specified in <code>ref</code> and recursively
  * normalizes child nodes.
  *
  * @param ref The reference path to which relative paths are normalized
  * @return This object, to allow chaining of toString() as in <code>
  *     normalized = new HasNode(name).normalize(ref).toString();</code>
  */
 public HasNode normalize(String ref) {
   if (feature == null) {
     nodeName = PathUtil.normalizePaths(ref, new String[] {nodeName})[0];
   } else {
     trueNode.normalize(ref);
     falseNode.normalize(ref);
   }
   return this;
 }
Esempio n. 3
0
 /**
  * Adds to <code>result</code> the end point nodes (nodes that specify a module name) for this
  * node and all of the child nodes.
  *
  * @param result The collection that the end point nodes will be added to
  */
 public void gatherEndpoints(Collection<HasNode> result) {
   if (nodeName != null && nodeName.length() > 0) {
     result.add(this);
   }
   if (trueNode != null) {
     trueNode.gatherEndpoints(result);
   }
   if (falseNode != null) {
     falseNode.gatherEndpoints(result);
   }
 }
Esempio n. 4
0
 /**
  * Returns the string representation of this node. This is the same as the string used to
  * construct the node, unless the node has been normalized, in which case the output will be the
  * normalized representation of the string used to construct this node.
  *
  * @return The string representation of this node
  */
 public String toString() {
   if (feature == null) {
     return nodeName;
   }
   String trueName = trueNode.toString(), falseName = falseNode.toString();
   if (trueName.length() == 0 && falseName.length() == 0) {
     return ""; //$NON-NLS-1$
   }
   StringBuffer sb = new StringBuffer();
   sb.append(feature).append("?").append(trueName); // $NON-NLS-1$
   if (falseName.length() > 0) {
     sb.append(":").append(falseName); // $NON-NLS-1$
   }
   return sb.toString();
 }
Esempio n. 5
0
 /**
  * Evaluate the has plugin for the given set of features.
  *
  * @param features The features passed to the aggregator.
  * @param discovered A map in which all features encountered in the evaluation will be placed.
  *     This will not necessarily contain all features in the dependency expression. Only the ones
  *     in the evaluation chain will be included.
  * @param coerceUndefinedToFalse If true, then a feature not being defined will be treated the
  *     same as if the feature were defined with a value of false.
  * @return The evaluated resource based on provided features. If a lack of features prevents us
  *     from being able to determine the resource, then null is returned. If the required features
  *     are provided but the evaluation results in no module name, then the empty string is
  *     returned.
  */
 public String evaluate(
     Features features, Set<String> discovered, boolean coerceUndefinedToFalse) {
   if (feature != null && discovered != null) {
     discovered.add(feature);
   }
   if (feature == null) {
     return nodeName;
   } else if (!coerceUndefinedToFalse && !features.contains(feature)) {
     return null;
   } else {
     if (features.isFeature(feature)) {
       return trueNode.evaluate(features, discovered, coerceUndefinedToFalse);
     } else {
       return falseNode.evaluate(features, discovered, coerceUndefinedToFalse);
     }
   }
 }
Esempio n. 6
0
 /**
  * Recursively resolves the current node with the specified features. Any conditionals for
  * features contained in <code>features</code> will be replaced with the result of the evaluation.
  *
  * @param features The features passed to the aggregator.
  * @param discovered A map in which all features encountered in the evaluation will be placed.
  *     This will not necessarily contain all features in the dependency expression. Only the ones
  *     in the evaluation chain will be included.
  * @param coerceUndefinedToFalse If true, then a feature not being defined will be treated the
  *     same as if the feature were defined with a value of false.
  * @return this node
  */
 public HasNode resolve(
     Features features, Set<String> discovered, boolean coerceUndefinedToFalse) {
   if (feature != null && discovered != null) {
     discovered.add(feature);
   }
   if (feature != null && (features.contains(feature) || coerceUndefinedToFalse)) {
     replaceWith(features.isFeature(feature) ? trueNode : falseNode);
     resolve(features, discovered, coerceUndefinedToFalse);
   }
   if (trueNode != null) {
     trueNode.resolve(features, discovered, coerceUndefinedToFalse);
   }
   if (falseNode != null) {
     falseNode.resolve(features, discovered, coerceUndefinedToFalse);
   }
   return this;
 }