Package org.eclipse.xtext.resource

Examples of org.eclipse.xtext.resource.XtextResource


        "realize (\n" + //
        "File[\"$confdir/ping/amazon.cfg\"],\n" + //
        "File[\"$confdir/ping/amazon.cfg\"],\n" + //
        "File[\"$confdir/ping/amazon.cfg\"],\n" + //
        ")";
    XtextResource r = getResourceFromString(code);
    tester.validate(r.getContents().get(0)).assertOK();
  }
View Full Code Here


  }

  @Test
  public void test_variableNamedString_issue408() throws Exception {
    String code = "$string = 'gotcha'";
    XtextResource r = getResourceFromString(code);

    tester.validate(r.getContents().get(0)).assertWarning(IPPDiagnostics.ISSUE__ASSIGNMENT_TO_VAR_NAMED_STRING);
    resourceErrorDiagnostics(r).assertOK();

  }
View Full Code Here

  public void test_decimalDollarVariables_notOk() throws Exception {
    // if
    String code = "if 'abc' == 'abc' {\n" + //
        "notice(\"$1\")" + //
        "}\n"; //
    XtextResource r = getResourceFromString(code);
    tester.validate(r.getContents().get(0)).assertOK();
    resourceWarningDiagnostics(r).assertDiagnostic(IPPDiagnostics.ISSUE__UNKNOWN_REGEXP);
    resourceErrorDiagnostics(r).assertOK();

    // case
    code = "case 'abc' {\n" + //
        "abc:" + "{ notice(\"$1\") }" + //
        "}\n"; //
    r = getResourceFromString(code);
    tester.validate(r.getContents().get(0)).assertOK();
    resourceWarningDiagnostics(r).assertDiagnostic(IPPDiagnostics.ISSUE__UNKNOWN_REGEXP);
    resourceErrorDiagnostics(r).assertOK();

    // selector
    code = "$a = 'abc' ? {\n" + //
        "'abc' =>" + "$1\n" + //
        "}\n"; //
    r = getResourceFromString(code);
    AssertableDiagnostics asserter = tester.validate(r.getContents().get(0));
    asserter.assertAll(AssertableDiagnostics.warningCode(IPPDiagnostics.ISSUE__MISSING_DEFAULT));
    resourceWarningDiagnostics(r).assertAll(
      AssertableResourceDiagnostics.diagnostic(IPPDiagnostics.ISSUE__UNKNOWN_REGEXP));
    resourceErrorDiagnostics(r).assertOK();
  }
View Full Code Here

  public void test_decimalDollarVariables_ok() throws Exception {
    // if
    String code = "if 'abc' =~ /a(b)c/ {\n" + //
        "notice(\"$1\")" + //
        "}\n"; //
    XtextResource r = getResourceFromString(code);
    tester.validate(r.getContents().get(0)).assertOK();
    resourceWarningDiagnostics(r).assertOK();
    resourceErrorDiagnostics(r).assertOK();

    // case
    code = "case 'abc' {\n" + //
        "/a(b)c/:" + "{ notice(\"$1\") }" + //
        "}\n"; //
    r = getResourceFromString(code);
    tester.validate(r.getContents().get(0)).assertOK();
    resourceWarningDiagnostics(r).assertOK();
    resourceErrorDiagnostics(r).assertOK();

    // selector
    code = "$a = 'abc' ? {\n" + //
        "/a(b)c/ =>" + "$1\n" + //
        "}\n"; //
    r = getResourceFromString(code);
    AssertableDiagnostics asserter = tester.validate(r.getContents().get(0));
    asserter.assertAll(AssertableDiagnostics.warningCode(IPPDiagnostics.ISSUE__MISSING_DEFAULT));
    resourceWarningDiagnostics(r).assertOK();
    resourceErrorDiagnostics(r).assertOK();
  }
View Full Code Here

  public void test_decimalVariables_notOk() throws Exception {
    // if
    String code = "if 'abc' == 'abc' {\n" + //
        "notice(\"${1}\")" + //
        "}\n"; //
    XtextResource r = getResourceFromString(code);
    tester.validate(r.getContents().get(0)).assertOK();
    resourceWarningDiagnostics(r).assertDiagnostic(IPPDiagnostics.ISSUE__UNKNOWN_REGEXP);
    resourceErrorDiagnostics(r).assertOK();

    // case
    code = "case 'abc' {\n" + //
        "abc:" + "{ notice(\"${1}\") }" + //
        "}\n"; //
    r = getResourceFromString(code);
    tester.validate(r.getContents().get(0)).assertOK();
    resourceWarningDiagnostics(r).assertDiagnostic(IPPDiagnostics.ISSUE__UNKNOWN_REGEXP);
    resourceErrorDiagnostics(r).assertOK();

    // selector
    code = "$a = 'abc' ? {\n" + //
        "'abc' =>" + "\"${1}\"\n" + //
        "}\n"; //
    r = getResourceFromString(code);
    AssertableDiagnostics asserter = tester.validate(r.getContents().get(0));
    asserter.assertAll(AssertableDiagnostics.warningCode(IPPDiagnostics.ISSUE__MISSING_DEFAULT));
    resourceWarningDiagnostics(r).assertDiagnostic(IPPDiagnostics.ISSUE__UNKNOWN_REGEXP);
    resourceErrorDiagnostics(r).assertOK();
  }
View Full Code Here

  public void test_decimalVariables_ok() throws Exception {
    // if
    String code = "if 'abc' =~ /a(b)c/ {\n" + //
        "notice(\"${1}\")" + //
        "}\n"; //
    XtextResource r = getResourceFromString(code);
    tester.validate(r.getContents().get(0)).assertOK();
    resourceWarningDiagnostics(r).assertOK();
    resourceErrorDiagnostics(r).assertOK();

    // case
    code = "case 'abc' {\n" + //
        "/a(b)c/:" + "{ notice(\"${1}\") }" + //
        "}\n"; //
    r = getResourceFromString(code);
    tester.validate(r.getContents().get(0)).assertOK();
    resourceWarningDiagnostics(r).assertOK();
    resourceErrorDiagnostics(r).assertOK();

    // selector
    code = "$a = 'abc' ? {\n" + //
        "/a(b)c/ =>" + "\"${1}\"\n" + //
        "}\n"; //
    r = getResourceFromString(code);
    AssertableDiagnostics asserter = tester.validate(r.getContents().get(0));
    asserter.assertAll(AssertableDiagnostics.warningCode(IPPDiagnostics.ISSUE__MISSING_DEFAULT));
    resourceWarningDiagnostics(r).assertOK();
    resourceErrorDiagnostics(r).assertOK();
  }
View Full Code Here

  }

  @Test
  public void test_hyphenNotOk() throws Exception {
    String code = "$a-b = 10";
    XtextResource r = getResourceFromString(code);

    AssertableDiagnostics asserter = tester.validate(r.getContents().get(0));
    asserter.assertAny(
      AssertableDiagnostics.errorCode(IPPDiagnostics.ISSUE__NOT_ASSIGNABLE),
      AssertableDiagnostics.errorCode(IPPDiagnostics.ISSUE__NOT_NUMERIC));
    resourceWarningDiagnostics(r).assertDiagnostic(IPPDiagnostics.ISSUE__UNKNOWN_VARIABLE);
    resourceErrorDiagnostics(r).assertOK();
View Full Code Here

  public void test_variable_class_CGx_Gy() throws Exception {
    String code = "class a {\n" + //
        "$ref = $::x\n" + //
        "}\n"; //
    ;
    XtextResource r = getResourceFromString(code);
    tester.validate(r.getContents().get(0)).assertOK();
    resourceWarningDiagnostics(r).assertOK();
    resourceErrorDiagnostics(r).assertOK();
  }
View Full Code Here

  @Test
  public void test_variable_Gx_Gx() throws Exception {
    String code = "$x = 10\n" + //
        "$ref = $x\n" //
    ;
    XtextResource r = getResourceFromString(code);
    tester.validate(r.getContents().get(0)).assertOK();
    resourceWarningDiagnostics(r).assertOK();
    resourceErrorDiagnostics(r).assertOK();
  }
View Full Code Here

TOP

Related Classes of org.eclipse.xtext.resource.XtextResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.