org.eclipse.xtext.common.types.JvmVisibility Java Examples

The following examples show how to use org.eclipse.xtext.common.types.JvmVisibility. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EnumerationParsingTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlParsing")
public void classmodifier_package() throws Exception {
	SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
			"package io.sarl.lang.tests.test",
			"public behavior EnclosingBehavior {",
			"  package enum E1 { CST1 }",
			"}"));
	assertEquals("io.sarl.lang.tests.test", mas.getPackage());
	SarlEnumeration enumeration = getEnumeration(mas);
	assertNotNull(enumeration);
	//
	assertEquals("E1", enumeration.getName());
	assertEquals(JvmVisibility.DEFAULT, enumeration.getVisibility());
	assertEquals(1, enumeration.getMembers().size());
	assertFalse(enumeration.isAnonymous());
	assertTrue(enumeration.isFinal());
	assertFalse(enumeration.isLocal());
	assertTrue(enumeration.isStatic());
}
 
Example #2
Source File: CreateXtendTypeQuickfixes.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
protected void newLocalXtendClassQuickfix(String typeName, XtextResource resource, Issue issue,
		IssueResolutionAcceptor issueResolutionAcceptor) {
	EObject eObject = resource.getEObject(issue.getUriToProblem().fragment());
	XtendTypeDeclaration xtendType = getAnnotationTarget(eObject);
	if(xtendType != null) {
		JvmDeclaredType inferredType = associations.getInferredType(xtendType);
		if(inferredType != null) {
			AbstractClassBuilder classBuilder = codeBuilderFactory.createClassBuilder(inferredType);
			classBuilder.setClassName(typeName);
			classBuilder.setVisibility(JvmVisibility.PUBLIC);
			classBuilder.setContext(xtendType);
			classBuilder.setImage("xtend_file.png");
			codeBuilderQuickfix.addQuickfix(classBuilder, "Create local Xtend class '" + typeName + "'", issue, issueResolutionAcceptor);
		}
	}
}
 
Example #3
Source File: InterfaceParsingTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlParsing")
public void classmodifier_package() throws Exception {
	SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
			"package io.sarl.lang.tests.test",
			"public capacity C1 { }",
			"public skill EnclosingSkill implements C1 {",
			"  package interface I1 { }",
			"}"));
	assertEquals("io.sarl.lang.tests.test", mas.getPackage());
	SarlInterface interf = getInterface(mas);
	assertNotNull(interf);
	//
	assertEquals("I1", interf.getName());
	assertNullOrEmpty(interf.getExtends());
	assertEquals(JvmVisibility.DEFAULT, interf.getVisibility());
	assertEquals(0, interf.getMembers().size());
	assertFalse(interf.isAnonymous());
	assertFalse(interf.isFinal());
	assertFalse(interf.isLocal());
	assertTrue(interf.isStatic());
	assertFalse(interf.isStrictFloatingPoint());
}
 
Example #4
Source File: EventParsingTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlParsing")
public void modifier_public() throws Exception {
	SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
			"package io.sarl.lang.tests.test",
			"event E1 {",
			"	public new { super(null) }",
			"}"));
	assertEquals(1, mas.getXtendTypes().size());
	//
	assertEquals("io.sarl.lang.tests.test", mas.getPackage());
	//
	SarlEvent event = (SarlEvent) mas.getXtendTypes().get(0);
	assertEquals("E1", event.getName());
	assertNull(event.getExtends());
	assertEquals(1, event.getMembers().size());
	//
	SarlConstructor cons = (SarlConstructor) event.getMembers().get(0);
	assertEquals(JvmVisibility.PUBLIC, cons.getVisibility());
	assertFalse(cons.isStatic());
	assertFalse(cons.isFinal());
}
 
Example #5
Source File: AgentParsingTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlParsing")
public void agentmodifier_package() throws Exception {
	SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
			"package io.sarl.lang.tests.test",
			"package agent A1 {}"
			));
	assertEquals(1, mas.getXtendTypes().size());
	//
	assertEquals("io.sarl.lang.tests.test", mas.getPackage());
	//
	SarlAgent agent1 = (SarlAgent) mas.getXtendTypes().get(0);
	assertEquals("A1", agent1.getName());
	assertNull(agent1.getExtends());
	assertEquals(JvmVisibility.DEFAULT, agent1.getVisibility());
	assertEquals(0, agent1.getMembers().size());
	assertFalse(agent1.isAbstract());
	assertFalse(agent1.isAnonymous());
	assertFalse(agent1.isFinal());
	assertFalse(agent1.isLocal());
	assertFalse(agent1.isStatic());
	assertFalse(agent1.isStrictFloatingPoint());
}
 
Example #6
Source File: EnumerationParsingTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlParsing")
public void classmodifier_public() throws Exception {
	SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
			"package io.sarl.lang.tests.test",
			"public capacity C1 { }",
			"public skill EnclosingSkill implements C1 {",
			"  public enum E1 { CST1 }",
			"}"));
	assertEquals("io.sarl.lang.tests.test", mas.getPackage());
	SarlEnumeration enumeration = getEnumeration(mas);
	assertNotNull(enumeration);
	//
	assertEquals("E1", enumeration.getName());
	assertEquals(JvmVisibility.PUBLIC, enumeration.getVisibility());
	assertEquals(1, enumeration.getMembers().size());
	assertFalse(enumeration.isAnonymous());
	assertTrue(enumeration.isFinal());
	assertFalse(enumeration.isLocal());
	assertTrue(enumeration.isStatic());
}
 
Example #7
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testMethods_privateSynchronizedMethod_01() {
	String typeName = Methods.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation method = getMethodFromType(type, Methods.class, "privateSynchronizedMethod()");
	assertSame(type, method.getDeclaringType());
	assertFalse(method.isAbstract());
	assertFalse(method.isFinal());
	assertFalse(method.isStatic());
	assertTrue(method.isSynchronized());
	assertFalse(method.isStrictFloatingPoint());
	assertFalse(method.isNative());
	assertEquals(JvmVisibility.PRIVATE, method.getVisibility());
	JvmType methodType = method.getReturnType().getType();
	assertEquals("void", methodType.getIdentifier());
}
 
Example #8
Source File: ClassParsingTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlParsing")
public void classmodifier_static() throws Exception {
	SarlScript mas = file(getParseHelper(), multilineString(
			"package io.sarl.lang.tests.test",
			"public behavior EnclosingBehavior {",
			"  static class C1 { }",
			"}"));
	assertEquals("io.sarl.lang.tests.test", mas.getPackage());
	SarlClass clazz = getClazz(mas);
	assertNotNull(clazz);
	//
	assertEquals("C1", clazz.getName());
	assertNull(clazz.getExtends());
	assertEquals(JvmVisibility.PUBLIC, clazz.getVisibility());
	assertEquals(0, clazz.getMembers().size());
	assertFalse(clazz.isAbstract());
	assertFalse(clazz.isAnonymous());
	assertFalse(clazz.isFinal());
	assertFalse(clazz.isLocal());
	assertTrue(clazz.isStatic());
	assertFalse(clazz.isStrictFloatingPoint());
}
 
Example #9
Source File: EnumerationParsingTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlParsing")
public void classmodifier_static() throws Exception {
	SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
			"package io.sarl.lang.tests.test",
			"public behavior EnclosingBehavior {",
			"  static enum E1 { CST1 }",
			"}"));
	assertEquals("io.sarl.lang.tests.test", mas.getPackage());
	SarlEnumeration enumeration = getEnumeration(mas);
	assertNotNull(enumeration);
	//
	assertEquals("E1", enumeration.getName());
	assertEquals(JvmVisibility.PUBLIC, enumeration.getVisibility());
	assertEquals(1, enumeration.getMembers().size());
	assertFalse(enumeration.isAnonymous());
	assertTrue(enumeration.isFinal());
	assertFalse(enumeration.isLocal());
	assertTrue(enumeration.isStatic());
}
 
Example #10
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testMethods_protectedFinalMethod_01() {
	String typeName = Methods.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation method = getMethodFromType(type, Methods.class, "protectedFinalMethod()");
	assertSame(type, method.getDeclaringType());
	assertFalse(method.isAbstract());
	assertTrue(method.isFinal());
	assertFalse(method.isStatic());
	assertFalse(method.isSynchronized());
	assertFalse(method.isStrictFloatingPoint());
	assertFalse(method.isNative());
	assertEquals(JvmVisibility.PROTECTED, method.getVisibility());
	JvmType methodType = method.getReturnType().getType();
	assertEquals("void", methodType.getIdentifier());
}
 
Example #11
Source File: CompilationUnitImpl.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public Visibility toVisibility(final JvmVisibility delegate) {
  Visibility _switchResult = null;
  if (delegate != null) {
    switch (delegate) {
      case DEFAULT:
        _switchResult = Visibility.DEFAULT;
        break;
      case PRIVATE:
        _switchResult = Visibility.PRIVATE;
        break;
      case PROTECTED:
        _switchResult = Visibility.PROTECTED;
        break;
      case PUBLIC:
        _switchResult = Visibility.PUBLIC;
        break;
      default:
        break;
    }
  }
  return _switchResult;
}
 
Example #12
Source File: EventParsingTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlParsing")
public void modifier_private() throws Exception {
	SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
			"package io.sarl.lang.tests.test",
			"event E1 {",
			"	private new { super(null) }",
			"}"));
	assertEquals(1, mas.getXtendTypes().size());
	//
	assertEquals("io.sarl.lang.tests.test", mas.getPackage());
	//
	SarlEvent event = (SarlEvent) mas.getXtendTypes().get(0);
	assertEquals("E1", event.getName());
	assertNull(event.getExtends());
	assertEquals(1, event.getMembers().size());
	//
	SarlConstructor cons = (SarlConstructor) event.getMembers().get(0);
	assertEquals(JvmVisibility.PRIVATE, cons.getVisibility());
	assertFalse(cons.isStatic());
	assertFalse(cons.isFinal());
}
 
Example #13
Source File: AnnotationTypeParsingTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlParsing")
public void classmodifier_private() throws Exception {
	SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
			"package io.sarl.lang.tests.test",
			"public capacity C1 { }",
			"public skill EnclosingSkill implements C1 {",
			"  private annotation A1 { }",
			"}"));
	assertEquals("io.sarl.lang.tests.test", mas.getPackage());
	SarlAnnotationType annotationType = getAnnotationType(mas);
	assertNotNull(annotationType);
	//
	assertEquals("A1", annotationType.getName());
	assertEquals(JvmVisibility.PRIVATE, annotationType.getVisibility());
	assertEquals(0, annotationType.getMembers().size());
	assertFalse(annotationType.isAnonymous());
	assertFalse(annotationType.isFinal());
	assertFalse(annotationType.isLocal());
	assertTrue(annotationType.isStatic());
}
 
Example #14
Source File: AgentParsingTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
public void modifier_final_var() throws Exception {
	SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
			"package io.sarl.lang.tests.test",
			"agent A1 {",
			"	final def name { }",
			"}"));
	assertEquals(1, mas.getXtendTypes().size());
	//
	assertEquals("io.sarl.lang.tests.test", mas.getPackage());
	//
	SarlAgent agent1 = (SarlAgent) mas.getXtendTypes().get(0);
	assertEquals("A1", agent1.getName());
	assertNull(agent1.getExtends());
	assertEquals(1, agent1.getMembers().size());
	//
	SarlAction act1 = (SarlAction) agent1.getMembers().get(0);
	assertEquals("name", act1.getName());
	assertEquals(JvmVisibility.PROTECTED, act1.getVisibility());
	assertFalse(act1.isAbstract());
	assertFalse(act1.isStatic());
	assertFalse(act1.isDispatch());
	assertTrue(act1.isFinal());
	assertFalse(act1.isSynchonized());
	assertFalse(act1.isStrictFloatingPoint());
}
 
Example #15
Source File: SkillParsingTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlParsing")
public void skillmodifier_package() throws Exception {
	SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
			"package io.sarl.lang.tests.test",
			"capacity C1 {}",
			"package skill S1 implements C1 {}"
			));
	assertEquals(2, mas.getXtendTypes().size());
	//
	assertEquals("io.sarl.lang.tests.test", mas.getPackage());
	//
	SarlSkill skill = (SarlSkill) mas.getXtendTypes().get(1);
	assertEquals("S1", skill.getName());
	assertNull(skill.getExtends());
	assertEquals(JvmVisibility.DEFAULT, skill.getVisibility());
	assertEquals(0, skill.getMembers().size());
	assertFalse(skill.isAbstract());
	assertFalse(skill.isFinal());
	assertFalse(skill.isStatic());
	assertFalse(skill.isStrictFloatingPoint());
}
 
Example #16
Source File: AnnotationTypeParsingTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlParsing")
public void classmodifier_private() throws Exception {
	SarlScript mas = file(getParseHelper(), multilineString(
			"package io.sarl.lang.tests.test",
			"public class EnclosingClass {",
			"  private annotation A1 { }",
			"}"));
	assertEquals("io.sarl.lang.tests.test", mas.getPackage());
	SarlAnnotationType annotationType = getAnnotationType(mas);
	assertNotNull(annotationType);
	//
	assertEquals("A1", annotationType.getName());
	assertEquals(JvmVisibility.PRIVATE, annotationType.getVisibility());
	assertEquals(0, annotationType.getMembers().size());
	assertFalse(annotationType.isAnonymous());
	assertFalse(annotationType.isFinal());
	assertFalse(annotationType.isLocal());
	assertTrue(annotationType.isStatic());
}
 
Example #17
Source File: EnumerationParsingTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlParsing")
public void classmodifier_protected() throws Exception {
	SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
			"package io.sarl.lang.tests.test",
			"public class EnclosingClass {",
			"  protected enum E1 { CST1 }",
			"}"));
	assertEquals("io.sarl.lang.tests.test", mas.getPackage());
	SarlEnumeration enumeration = getEnumeration(mas);
	assertNotNull(enumeration);
	//
	assertEquals("E1", enumeration.getName());
	assertEquals(JvmVisibility.PROTECTED, enumeration.getVisibility());
	assertEquals(1, enumeration.getMembers().size());
	assertFalse(enumeration.isAnonymous());
	assertTrue(enumeration.isFinal());
	assertFalse(enumeration.isLocal());
	assertTrue(enumeration.isStatic());
}
 
Example #18
Source File: AnnotationTypeParsingTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlParsing")
public void classmodifier_none() throws Exception {
	SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
			"package io.sarl.lang.tests.test",
			"public class EnclosingClass {",
			"  annotation A1 { }",
			"}"));
	assertEquals("io.sarl.lang.tests.test", mas.getPackage());
	SarlAnnotationType annotationType = getAnnotationType(mas);
	assertNotNull(annotationType);
	//
	assertEquals("A1", annotationType.getName());
	assertEquals(JvmVisibility.PUBLIC, annotationType.getVisibility());
	assertEquals(0, annotationType.getMembers().size());
	assertFalse(annotationType.isAnonymous());
	assertFalse(annotationType.isFinal());
	assertFalse(annotationType.isLocal());
	assertTrue(annotationType.isStatic());
}
 
Example #19
Source File: ClassParsingTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlParsing")
public void classmodifier_package() throws Exception {
	SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
			"package io.sarl.lang.tests.test",
			"public agent EnclosingAgent {",
			"  package static class C1 { }",
			"}"));
	assertEquals("io.sarl.lang.tests.test", mas.getPackage());
	SarlClass clazz = getClazz(mas);
	assertNotNull(clazz);
	//
	assertEquals("C1", clazz.getName());
	assertNull(clazz.getExtends());
	assertEquals(JvmVisibility.DEFAULT, clazz.getVisibility());
	assertEquals(0, clazz.getMembers().size());
	assertFalse(clazz.isAbstract());
	assertFalse(clazz.isAnonymous());
	assertFalse(clazz.isFinal());
	assertFalse(clazz.isLocal());
	assertTrue(clazz.isStatic());
	assertFalse(clazz.isStrictFloatingPoint());
}
 
Example #20
Source File: ClassParsingTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlParsing")
public void classmodifier_package() throws Exception {
	SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
			"package io.sarl.lang.tests.test",
			"public capacity C1 { }",
			"public skill EnclosingSkill implements C1 {",
			"  package static class C1 { }",
			"}"));
	assertEquals("io.sarl.lang.tests.test", mas.getPackage());
	SarlClass clazz = getClazz(mas);
	assertNotNull(clazz);
	//
	assertEquals("C1", clazz.getName());
	assertNull(clazz.getExtends());
	assertEquals(JvmVisibility.DEFAULT, clazz.getVisibility());
	assertEquals(0, clazz.getMembers().size());
	assertFalse(clazz.isAbstract());
	assertFalse(clazz.isAnonymous());
	assertFalse(clazz.isFinal());
	assertFalse(clazz.isLocal());
	assertTrue(clazz.isStatic());
	assertFalse(clazz.isStrictFloatingPoint());
}
 
Example #21
Source File: EnumerationParsingTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlParsing")
public void classmodifier_public() throws Exception {
	SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
			"package io.sarl.lang.tests.test",
			"public enum E1 { CST1 }"));
	assertEquals("io.sarl.lang.tests.test", mas.getPackage());
	SarlEnumeration enumeration = getEnumeration(mas);
	assertNotNull(enumeration);
	//
	assertEquals("E1", enumeration.getName());
	assertEquals(JvmVisibility.PUBLIC, enumeration.getVisibility());
	assertEquals(1, enumeration.getMembers().size());
	assertFalse(enumeration.isAnonymous());
	assertTrue(enumeration.isFinal());
	assertFalse(enumeration.isLocal());
	assertFalse(enumeration.isStatic());
}
 
Example #22
Source File: AnnotationTypeParsingTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlParsing")
public void classmodifier_private() throws Exception {
	SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
			"package io.sarl.lang.tests.test",
			"public behavior EnclosingBehavior {",
			"  private annotation A1 { }",
			"}"));
	assertEquals("io.sarl.lang.tests.test", mas.getPackage());
	SarlAnnotationType annotationType = getAnnotationType(mas);
	assertNotNull(annotationType);
	//
	assertEquals("A1", annotationType.getName());
	assertEquals(JvmVisibility.PRIVATE, annotationType.getVisibility());
	assertEquals(0, annotationType.getMembers().size());
	assertFalse(annotationType.isAnonymous());
	assertFalse(annotationType.isFinal());
	assertFalse(annotationType.isLocal());
	assertTrue(annotationType.isStatic());
}
 
Example #23
Source File: InterfaceParsingTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlParsing")
public void classmodifier_package() throws Exception {
	SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
			"package io.sarl.lang.tests.test",
			"public class EnclosingClass {",
			"  package interface I1 { }",
			"}"));
	assertEquals("io.sarl.lang.tests.test", mas.getPackage());
	SarlInterface interf = getInterface(mas);
	assertNotNull(interf);
	//
	assertEquals("I1", interf.getName());
	assertNullOrEmpty(interf.getExtends());
	assertEquals(JvmVisibility.DEFAULT, interf.getVisibility());
	assertEquals(0, interf.getMembers().size());
	assertFalse(interf.isAnonymous());
	assertFalse(interf.isFinal());
	assertFalse(interf.isLocal());
	assertTrue(interf.isStatic());
	assertFalse(interf.isStrictFloatingPoint());
}
 
Example #24
Source File: AbstractFieldBuilder.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public String getImage() {
  String _switchResult = null;
  JvmVisibility _visibility = this.getVisibility();
  if (_visibility != null) {
    switch (_visibility) {
      case PRIVATE:
        _switchResult = "field_private_obj.gif";
        break;
      case PROTECTED:
        _switchResult = "field_protected_obj.gif";
        break;
      case PUBLIC:
        _switchResult = "field_public_obj.gif";
        break;
      default:
        _switchResult = "field_default_obj.gif";
        break;
    }
  } else {
    _switchResult = "field_default_obj.gif";
  }
  return _switchResult;
}
 
Example #25
Source File: EnumerationParsingTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlParsing")
public void classmodifier_static() throws Exception {
	SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
			"package io.sarl.lang.tests.test",
			"public capacity C1 { }",
			"public skill EnclosingSkill implements C1 {",
			"  static enum E1 { CST1 }",
			"}"));
	assertEquals("io.sarl.lang.tests.test", mas.getPackage());
	SarlEnumeration enumeration = getEnumeration(mas);
	assertNotNull(enumeration);
	//
	assertEquals("E1", enumeration.getName());
	assertEquals(JvmVisibility.PUBLIC, enumeration.getVisibility());
	assertEquals(1, enumeration.getMembers().size());
	assertFalse(enumeration.isAnonymous());
	assertTrue(enumeration.isFinal());
	assertFalse(enumeration.isLocal());
	assertTrue(enumeration.isStatic());
}
 
Example #26
Source File: BehaviorParsingTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlParsing")
public void behaviormodifier_package() throws Exception {
	SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
			"package io.sarl.lang.tests.test",
			"package behavior B1 {}"
			));
	assertEquals(1, mas.getXtendTypes().size());
	//
	assertEquals("io.sarl.lang.tests.test", mas.getPackage());
	//
	SarlBehavior beh = (SarlBehavior) mas.getXtendTypes().get(0);
	assertEquals("B1", beh.getName());
	assertNull(beh.getExtends());
	assertEquals(JvmVisibility.DEFAULT, beh.getVisibility());
	assertEquals(0, beh.getMembers().size());
	assertFalse(beh.isAbstract());
	assertFalse(beh.isFinal());
	assertFalse(beh.isStrictFloatingPoint());
}
 
Example #27
Source File: EnumerationParsingTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlParsing")
public void classmodifier_package() throws Exception {
	SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
			"package io.sarl.lang.tests.test",
			"public capacity C1 { }",
			"public skill EnclosingSkill implements C1 {",
			"  package enum E1 { CST1 }",
			"}"));
	assertEquals("io.sarl.lang.tests.test", mas.getPackage());
	SarlEnumeration enumeration = getEnumeration(mas);
	assertNotNull(enumeration);
	//
	assertEquals("E1", enumeration.getName());
	assertEquals(JvmVisibility.DEFAULT, enumeration.getVisibility());
	assertEquals(1, enumeration.getMembers().size());
	assertFalse(enumeration.isAnonymous());
	assertTrue(enumeration.isFinal());
	assertFalse(enumeration.isLocal());
	assertTrue(enumeration.isStatic());
}
 
Example #28
Source File: InterfaceParsingTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlParsing")
public void classmodifier_none() throws Exception {
	SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
			"package io.sarl.lang.tests.test",
			"public agent EnclosingAgent {",
			"  interface I1 { }",
			"}"));
	assertEquals("io.sarl.lang.tests.test", mas.getPackage());
	SarlInterface interf = getInterface(mas);
	assertNotNull(interf);
	//
	assertEquals("I1", interf.getName());
	assertNullOrEmpty(interf.getExtends());
	assertEquals(JvmVisibility.PROTECTED, interf.getVisibility());
	assertEquals(0, interf.getMembers().size());
	assertFalse(interf.isAnonymous());
	assertFalse(interf.isFinal());
	assertFalse(interf.isLocal());
	assertTrue(interf.isStatic());
	assertFalse(interf.isStrictFloatingPoint());
}
 
Example #29
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testMethods_publicAbstractMethod_01() {
	String typeName = Methods.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmOperation method = getMethodFromType(type, Methods.class, "publicAbstractMethod()");
	assertSame(type, method.getDeclaringType());
	assertTrue(method.isAbstract());
	assertFalse(method.isFinal());
	assertFalse(method.isStatic());
	assertFalse(method.isSynchronized());
	assertFalse(method.isStrictFloatingPoint());
	assertFalse(method.isNative());
	assertEquals(JvmVisibility.PUBLIC, method.getVisibility());
	JvmType methodType = method.getReturnType().getType();
	assertEquals("void", methodType.getIdentifier());
}
 
Example #30
Source File: ClassParsingTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
@Tag("sarlParsing")
public void classmodifier_abstract() throws Exception {
	SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
			"package io.sarl.lang.tests.test",
			"abstract class C1 { }"));
	assertEquals("io.sarl.lang.tests.test", mas.getPackage());
	SarlClass clazz = getClazz(mas);
	assertNotNull(clazz);
	//
	assertEquals("C1", clazz.getName());
	assertNull(clazz.getExtends());
	assertEquals(JvmVisibility.PUBLIC, clazz.getVisibility());
	assertEquals(0, clazz.getMembers().size());
	assertTrue(clazz.isAbstract());
	assertFalse(clazz.isAnonymous());
	assertFalse(clazz.isFinal());
	assertFalse(clazz.isLocal());
	assertFalse(clazz.isStatic());
	assertFalse(clazz.isStrictFloatingPoint());
}