Skip to content

Commit

Permalink
fix bug for if-feature evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
lllyfeng committed Jun 18, 2024
1 parent 8c58208 commit c08fedc
Showing 1 changed file with 35 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,47 +144,53 @@ public boolean evaluate() {
YangSchema yangSchema = schemaContext.getYangSchema();
if (yangSchema == null) {
return true;
} else {
Module curModule = this.feature.getContext().getCurModule();
List<ModuleSet> moduleSets = yangSchema.getModuleSets();
}
if(this.feature == null){
validate();
if(this.feature == null){
return false;
}
}

for (ModuleSet moduleSet : moduleSets) {
boolean matchedModule = false;
Module curModule = this.feature.getContext().getCurModule();
List<ModuleSet> moduleSets = yangSchema.getModuleSets();

for (YangModuleDescription moduleDescription : moduleSet.getModules()) {
if (curModule instanceof MainModule) {
if (moduleDescription.getModuleId().equals(new ModuleId(curModule.getArgStr(), curModule.getCurRevisionDate().isPresent() ? curModule.getCurRevisionDate().get() : null))) {
matchedModule = true;
}
} else {
for (ModuleSet moduleSet : moduleSets) {
boolean matchedModule = false;

for (YangModuleDescription moduleDescription : moduleSet.getModules()) {
if (curModule instanceof MainModule) {
if (moduleDescription.getModuleId().equals(new ModuleId(curModule.getArgStr(), curModule.getCurRevisionDate().isPresent() ? curModule.getCurRevisionDate().get() : null))) {
matchedModule = true;
}
} else {

for (ModuleId subModuleDescription : moduleDescription.getSubModules()) {
if (subModuleDescription.equals(new ModuleId(curModule.getArgStr(), curModule.getCurRevisionDate().isPresent() ? curModule.getCurRevisionDate().get() : null))) {
matchedModule = true;
break;
}
for (ModuleId subModuleDescription : moduleDescription.getSubModules()) {
if (subModuleDescription.equals(new ModuleId(curModule.getArgStr(), curModule.getCurRevisionDate().isPresent() ? curModule.getCurRevisionDate().get() : null))) {
matchedModule = true;
break;
}
}
}

if (matchedModule) {
Iterator<String> iterator = moduleDescription.getFeatures().iterator();
if (matchedModule) {
Iterator<String> iterator = moduleDescription.getFeatures().iterator();

String featureStr;
do {
if (!iterator.hasNext()) {
return false;
}
String featureStr;
do {
if (!iterator.hasNext()) {
return false;
}

featureStr = iterator.next();
} while (!this.feature.getArgStr().equals(featureStr));
featureStr = iterator.next();
} while (!this.feature.getArgStr().equals(featureStr));

return true;
}
return true;
}
}

return false;
}

return false;
}

public ValidatorResult validate() {
Expand Down

0 comments on commit c08fedc

Please sign in to comment.