Esempio n. 1
0
 private static RobotParser createParser(final RobotSuiteFile model) {
   final RobotProjectHolder holder =
       isNonFileModel(model)
           ? new RobotProjectHolder()
           : model.getProject().getRobotProjectHolder();
   final PathsProvider pathsProvider =
       isNonFileModel(model) ? null : model.getProject().createPathsProvider();
   return RobotParser.create(holder, RobotParserConfig.allImportsLazy(), pathsProvider);
 }
  @SuppressWarnings("unchecked")
  @Test
  public void globalVariablesAreLocated_onlyUntilDetectorWantsToContinue() throws Exception {
    final IFile sourceFile = projectProvider.createFile("source.robot", "");

    final RobotModel model = new RobotModel();
    final RobotSuiteFile suiteFile = model.createSuiteFile(sourceFile);
    final RobotProjectHolder projectHolder = suiteFile.getProject().getRobotProjectHolder();
    projectHolder.getGlobalVariables().clear();
    projectHolder
        .getGlobalVariables()
        .addAll(
            newArrayList(
                new ScalarRobotInternalVariable("global_scalar", null),
                new ListRobotInternalVariable("global_list", null),
                new DictionaryRobotInternalVariable("global_dict", null)));

    final Set<String> visitedVars = new HashSet<>();
    final VariableDefinitionLocator locator = new VariableDefinitionLocator(sourceFile, model);
    locator.locateVariableDefinition(limitedGlobalVarDetector(visitedVars));
    assertThat(visitedVars).containsOnly("global_scalar", "global_list");
  }