repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
sarl/sarl | main/externalmaven/io.sarl.maven.docs.generator/src/main/java/io/sarl/maven/docs/AbstractDocumentationMojo.java | AbstractDocumentationMojo.toPackageFolder | protected static File toPackageFolder(String packageName) {
File file = null;
for (final String element : packageName.split("[.]")) { //$NON-NLS-1$
if (file == null) {
file = new File(element);
} else {
file = new File(file, element);
}
}
return file;
} | java | protected static File toPackageFolder(String packageName) {
File file = null;
for (final String element : packageName.split("[.]")) { //$NON-NLS-1$
if (file == null) {
file = new File(element);
} else {
file = new File(file, element);
}
}
return file;
} | [
"protected",
"static",
"File",
"toPackageFolder",
"(",
"String",
"packageName",
")",
"{",
"File",
"file",
"=",
"null",
";",
"for",
"(",
"final",
"String",
"element",
":",
"packageName",
".",
"split",
"(",
"\"[.]\"",
")",
")",
"{",
"//$NON-NLS-1$",
"if",
"(... | Convert a a package name for therelative file.
@param packageName the name.
@return the file. | [
"Convert",
"a",
"a",
"package",
"name",
"for",
"therelative",
"file",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/externalmaven/io.sarl.maven.docs.generator/src/main/java/io/sarl/maven/docs/AbstractDocumentationMojo.java#L519-L529 | train |
sarl/sarl | main/externalmaven/io.sarl.maven.docs.generator/src/main/java/io/sarl/maven/docs/AbstractDocumentationMojo.java | AbstractDocumentationMojo.getBootClassPath | protected String getBootClassPath() throws IOException {
final Toolchain toolchain = this.toolchainManager.getToolchainFromBuildContext("jdk", this.session); //$NON-NLS-1$
if (toolchain instanceof JavaToolchain && toolchain instanceof ToolchainPrivate) {
final JavaToolchain javaToolChain = (JavaToolchain) toolchain;
final ToolchainPrivate privateJavaToolChain = (ToolchainPrivate) toolchain;
String[] includes = {"jre/lib/*", "jre/lib/ext/*", "jre/lib/endorsed/*"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String[] excludes = new String[0];
final Xpp3Dom config = (Xpp3Dom) privateJavaToolChain.getModel().getConfiguration();
if (config != null) {
final Xpp3Dom bootClassPath = config.getChild("bootClassPath"); //$NON-NLS-1$
if (bootClassPath != null) {
final Xpp3Dom includeParent = bootClassPath.getChild("includes"); //$NON-NLS-1$
if (includeParent != null) {
includes = getValues(includeParent.getChildren("include")); //$NON-NLS-1$
}
final Xpp3Dom excludeParent = bootClassPath.getChild("excludes"); //$NON-NLS-1$
if (excludeParent != null) {
excludes = getValues(excludeParent.getChildren("exclude")); //$NON-NLS-1$
}
}
}
try {
return scanBootclasspath(Objects.toString(this.reflect.invoke(javaToolChain, "getJavaHome")), includes, excludes); //$NON-NLS-1$
} catch (Exception e) {
throw new IOException(e.getLocalizedMessage(), e);
}
}
return ""; //$NON-NLS-1$
} | java | protected String getBootClassPath() throws IOException {
final Toolchain toolchain = this.toolchainManager.getToolchainFromBuildContext("jdk", this.session); //$NON-NLS-1$
if (toolchain instanceof JavaToolchain && toolchain instanceof ToolchainPrivate) {
final JavaToolchain javaToolChain = (JavaToolchain) toolchain;
final ToolchainPrivate privateJavaToolChain = (ToolchainPrivate) toolchain;
String[] includes = {"jre/lib/*", "jre/lib/ext/*", "jre/lib/endorsed/*"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String[] excludes = new String[0];
final Xpp3Dom config = (Xpp3Dom) privateJavaToolChain.getModel().getConfiguration();
if (config != null) {
final Xpp3Dom bootClassPath = config.getChild("bootClassPath"); //$NON-NLS-1$
if (bootClassPath != null) {
final Xpp3Dom includeParent = bootClassPath.getChild("includes"); //$NON-NLS-1$
if (includeParent != null) {
includes = getValues(includeParent.getChildren("include")); //$NON-NLS-1$
}
final Xpp3Dom excludeParent = bootClassPath.getChild("excludes"); //$NON-NLS-1$
if (excludeParent != null) {
excludes = getValues(excludeParent.getChildren("exclude")); //$NON-NLS-1$
}
}
}
try {
return scanBootclasspath(Objects.toString(this.reflect.invoke(javaToolChain, "getJavaHome")), includes, excludes); //$NON-NLS-1$
} catch (Exception e) {
throw new IOException(e.getLocalizedMessage(), e);
}
}
return ""; //$NON-NLS-1$
} | [
"protected",
"String",
"getBootClassPath",
"(",
")",
"throws",
"IOException",
"{",
"final",
"Toolchain",
"toolchain",
"=",
"this",
".",
"toolchainManager",
".",
"getToolchainFromBuildContext",
"(",
"\"jdk\"",
",",
"this",
".",
"session",
")",
";",
"//$NON-NLS-1$",
... | Replies the boot classpath.
@return the boot classpath.
@throws IOException in case of error. | [
"Replies",
"the",
"boot",
"classpath",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/externalmaven/io.sarl.maven.docs.generator/src/main/java/io/sarl/maven/docs/AbstractDocumentationMojo.java#L563-L592 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ExpressionBuilderImpl.java | ExpressionBuilderImpl.fromString | @Pure
protected XExpression fromString(String expression) {
if (!Strings.isEmpty(expression)) {
ResourceSet resourceSet = this.context.eResource().getResourceSet();
URI uri = computeUnusedUri(resourceSet);
Resource resource = getResourceFactory().createResource(uri);
resourceSet.getResources().add(resource);
try (StringInputStream is = new StringInputStream(generateExpressionCode(expression))) {
resource.load(is, null);
SarlScript script = resource.getContents().isEmpty() ? null : (SarlScript) resource.getContents().get(0);
SarlEvent topElement = (SarlEvent) script.getXtendTypes().get(0);
SarlField member = (SarlField) topElement.getMembers().get(0);
return member.getInitialValue();
} catch (Throwable exception) {
throw new RuntimeException(exception);
} finally {
resourceSet.getResources().remove(resource);
}
}
throw new IllegalArgumentException("not a valid expression");
} | java | @Pure
protected XExpression fromString(String expression) {
if (!Strings.isEmpty(expression)) {
ResourceSet resourceSet = this.context.eResource().getResourceSet();
URI uri = computeUnusedUri(resourceSet);
Resource resource = getResourceFactory().createResource(uri);
resourceSet.getResources().add(resource);
try (StringInputStream is = new StringInputStream(generateExpressionCode(expression))) {
resource.load(is, null);
SarlScript script = resource.getContents().isEmpty() ? null : (SarlScript) resource.getContents().get(0);
SarlEvent topElement = (SarlEvent) script.getXtendTypes().get(0);
SarlField member = (SarlField) topElement.getMembers().get(0);
return member.getInitialValue();
} catch (Throwable exception) {
throw new RuntimeException(exception);
} finally {
resourceSet.getResources().remove(resource);
}
}
throw new IllegalArgumentException("not a valid expression");
} | [
"@",
"Pure",
"protected",
"XExpression",
"fromString",
"(",
"String",
"expression",
")",
"{",
"if",
"(",
"!",
"Strings",
".",
"isEmpty",
"(",
"expression",
")",
")",
"{",
"ResourceSet",
"resourceSet",
"=",
"this",
".",
"context",
".",
"eResource",
"(",
")"... | Create an expression but does not change the container.
@param expression the textual representation of the expression.
@return the expression. | [
"Create",
"an",
"expression",
"but",
"does",
"not",
"change",
"the",
"container",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ExpressionBuilderImpl.java#L158-L178 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ExpressionBuilderImpl.java | ExpressionBuilderImpl.getDefaultXExpressionForType | @Pure
public XExpression getDefaultXExpressionForType(String type) {
//TODO: Check if a similar function exists in the Xbase library.
XExpression expr = null;
if (type != null && !"void".equals(type) && !Void.class.getName().equals(type)) {
switch (type) {
case "boolean":
case "java.lang.Boolean":
XBooleanLiteral booleanLiteral = XbaseFactory.eINSTANCE.createXBooleanLiteral();
booleanLiteral.setIsTrue(false);
expr = booleanLiteral;
break;
case "float":
case "java.lang.Float":
XNumberLiteral numberLiteral = XbaseFactory.eINSTANCE.createXNumberLiteral();
numberLiteral.setValue("0.0f");
expr = numberLiteral;
break;
case "double":
case "java.lang.Double":
case "java.lang.BigDecimal":
numberLiteral = XbaseFactory.eINSTANCE.createXNumberLiteral();
numberLiteral.setValue("0.0");
expr = numberLiteral;
break;
case "int":
case "long":
case "java.lang.Integer":
case "java.lang.Long":
case "java.lang.BigInteger":
numberLiteral = XbaseFactory.eINSTANCE.createXNumberLiteral();
numberLiteral.setValue("0");
expr = numberLiteral;
break;
case "byte":
case "short":
case "char":
case "java.lang.Byte":
case "java.lang.Short":
case "java.lang.Character":
numberLiteral = XbaseFactory.eINSTANCE.createXNumberLiteral();
numberLiteral.setValue("0");
XCastedExpression castExpression = XbaseFactory.eINSTANCE.createXCastedExpression();
castExpression.setTarget(numberLiteral);
castExpression.setType(newTypeRef(this.context, type));
expr = numberLiteral;
break;
default:
expr = XbaseFactory.eINSTANCE.createXNullLiteral();
break;
}
}
return expr;
} | java | @Pure
public XExpression getDefaultXExpressionForType(String type) {
//TODO: Check if a similar function exists in the Xbase library.
XExpression expr = null;
if (type != null && !"void".equals(type) && !Void.class.getName().equals(type)) {
switch (type) {
case "boolean":
case "java.lang.Boolean":
XBooleanLiteral booleanLiteral = XbaseFactory.eINSTANCE.createXBooleanLiteral();
booleanLiteral.setIsTrue(false);
expr = booleanLiteral;
break;
case "float":
case "java.lang.Float":
XNumberLiteral numberLiteral = XbaseFactory.eINSTANCE.createXNumberLiteral();
numberLiteral.setValue("0.0f");
expr = numberLiteral;
break;
case "double":
case "java.lang.Double":
case "java.lang.BigDecimal":
numberLiteral = XbaseFactory.eINSTANCE.createXNumberLiteral();
numberLiteral.setValue("0.0");
expr = numberLiteral;
break;
case "int":
case "long":
case "java.lang.Integer":
case "java.lang.Long":
case "java.lang.BigInteger":
numberLiteral = XbaseFactory.eINSTANCE.createXNumberLiteral();
numberLiteral.setValue("0");
expr = numberLiteral;
break;
case "byte":
case "short":
case "char":
case "java.lang.Byte":
case "java.lang.Short":
case "java.lang.Character":
numberLiteral = XbaseFactory.eINSTANCE.createXNumberLiteral();
numberLiteral.setValue("0");
XCastedExpression castExpression = XbaseFactory.eINSTANCE.createXCastedExpression();
castExpression.setTarget(numberLiteral);
castExpression.setType(newTypeRef(this.context, type));
expr = numberLiteral;
break;
default:
expr = XbaseFactory.eINSTANCE.createXNullLiteral();
break;
}
}
return expr;
} | [
"@",
"Pure",
"public",
"XExpression",
"getDefaultXExpressionForType",
"(",
"String",
"type",
")",
"{",
"//TODO: Check if a similar function exists in the Xbase library.",
"XExpression",
"expr",
"=",
"null",
";",
"if",
"(",
"type",
"!=",
"null",
"&&",
"!",
"\"void\"",
... | Replies the XExpression for the default value associated to the given type.
@param type the type for which the default value should be determined.
@return the default value. | [
"Replies",
"the",
"XExpression",
"for",
"the",
"default",
"value",
"associated",
"to",
"the",
"given",
"type",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ExpressionBuilderImpl.java#L184-L237 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ExpressionBuilderImpl.java | ExpressionBuilderImpl.getDefaultValueForType | @Pure
public String getDefaultValueForType(String type) {
//TODO: Check if a similar function exists in the Xbase library.
String defaultValue = "";
if (!Strings.isEmpty(type) && !"void".equals(type)) {
switch (type) {
case "boolean":
defaultValue = "true";
break;
case "double":
defaultValue = "0.0";
break;
case "float":
defaultValue = "0.0f";
break;
case "int":
defaultValue = "0";
break;
case "long":
defaultValue = "0";
break;
case "byte":
defaultValue = "(0 as byte)";
break;
case "short":
defaultValue = "(0 as short)";
break;
case "char":
defaultValue = "(0 as char)";
break;
default:
defaultValue = "null";
break;
}
}
return defaultValue;
} | java | @Pure
public String getDefaultValueForType(String type) {
//TODO: Check if a similar function exists in the Xbase library.
String defaultValue = "";
if (!Strings.isEmpty(type) && !"void".equals(type)) {
switch (type) {
case "boolean":
defaultValue = "true";
break;
case "double":
defaultValue = "0.0";
break;
case "float":
defaultValue = "0.0f";
break;
case "int":
defaultValue = "0";
break;
case "long":
defaultValue = "0";
break;
case "byte":
defaultValue = "(0 as byte)";
break;
case "short":
defaultValue = "(0 as short)";
break;
case "char":
defaultValue = "(0 as char)";
break;
default:
defaultValue = "null";
break;
}
}
return defaultValue;
} | [
"@",
"Pure",
"public",
"String",
"getDefaultValueForType",
"(",
"String",
"type",
")",
"{",
"//TODO: Check if a similar function exists in the Xbase library.",
"String",
"defaultValue",
"=",
"\"\"",
";",
"if",
"(",
"!",
"Strings",
".",
"isEmpty",
"(",
"type",
")",
"... | Replies the default value for the given type.
@param type the type for which the default value should be determined.
@return the default value. | [
"Replies",
"the",
"default",
"value",
"for",
"the",
"given",
"type",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ExpressionBuilderImpl.java#L243-L279 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ExpressionBuilderImpl.java | ExpressionBuilderImpl.createReferenceToThis | public XFeatureCall createReferenceToThis() {
final XExpression expr = getXExpression();
XtendTypeDeclaration type = EcoreUtil2.getContainerOfType(expr, XtendTypeDeclaration.class);
JvmType jvmObject = getAssociatedElement(JvmType.class, type, expr.eResource());
final XFeatureCall thisFeature = XbaseFactory.eINSTANCE.createXFeatureCall();
thisFeature.setFeature(jvmObject);
return thisFeature;
} | java | public XFeatureCall createReferenceToThis() {
final XExpression expr = getXExpression();
XtendTypeDeclaration type = EcoreUtil2.getContainerOfType(expr, XtendTypeDeclaration.class);
JvmType jvmObject = getAssociatedElement(JvmType.class, type, expr.eResource());
final XFeatureCall thisFeature = XbaseFactory.eINSTANCE.createXFeatureCall();
thisFeature.setFeature(jvmObject);
return thisFeature;
} | [
"public",
"XFeatureCall",
"createReferenceToThis",
"(",
")",
"{",
"final",
"XExpression",
"expr",
"=",
"getXExpression",
"(",
")",
";",
"XtendTypeDeclaration",
"type",
"=",
"EcoreUtil2",
".",
"getContainerOfType",
"(",
"expr",
",",
"XtendTypeDeclaration",
".",
"clas... | Create a reference to "this" object or to the current type.
@return the reference. | [
"Create",
"a",
"reference",
"to",
"this",
"object",
"or",
"to",
"the",
"current",
"type",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ExpressionBuilderImpl.java#L315-L322 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ExpressionBuilderImpl.java | ExpressionBuilderImpl.createReferenceToSuper | public XFeatureCall createReferenceToSuper() {
final XExpression expr = getXExpression();
XtendTypeDeclaration type = EcoreUtil2.getContainerOfType(expr, XtendTypeDeclaration.class);
JvmType jvmObject = getAssociatedElement(JvmType.class, type, expr.eResource());
final XFeatureCall superFeature = XbaseFactory.eINSTANCE.createXFeatureCall();
JvmIdentifiableElement feature;
if (jvmObject instanceof JvmDeclaredType) {
feature = ((JvmDeclaredType) jvmObject).getExtendedClass().getType();
} else {
feature = findType(expr, getQualifiedName(type)).getType();
if (feature instanceof JvmDeclaredType) {
feature = ((JvmDeclaredType) feature).getExtendedClass().getType();
} else {
feature = null;
}
}
if (feature == null) {
return null;
}
superFeature.setFeature(feature);
return superFeature;
} | java | public XFeatureCall createReferenceToSuper() {
final XExpression expr = getXExpression();
XtendTypeDeclaration type = EcoreUtil2.getContainerOfType(expr, XtendTypeDeclaration.class);
JvmType jvmObject = getAssociatedElement(JvmType.class, type, expr.eResource());
final XFeatureCall superFeature = XbaseFactory.eINSTANCE.createXFeatureCall();
JvmIdentifiableElement feature;
if (jvmObject instanceof JvmDeclaredType) {
feature = ((JvmDeclaredType) jvmObject).getExtendedClass().getType();
} else {
feature = findType(expr, getQualifiedName(type)).getType();
if (feature instanceof JvmDeclaredType) {
feature = ((JvmDeclaredType) feature).getExtendedClass().getType();
} else {
feature = null;
}
}
if (feature == null) {
return null;
}
superFeature.setFeature(feature);
return superFeature;
} | [
"public",
"XFeatureCall",
"createReferenceToSuper",
"(",
")",
"{",
"final",
"XExpression",
"expr",
"=",
"getXExpression",
"(",
")",
";",
"XtendTypeDeclaration",
"type",
"=",
"EcoreUtil2",
".",
"getContainerOfType",
"(",
"expr",
",",
"XtendTypeDeclaration",
".",
"cla... | Create a reference to "super" object or to the super type.
@return the reference. | [
"Create",
"a",
"reference",
"to",
"super",
"object",
"or",
"to",
"the",
"super",
"type",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ExpressionBuilderImpl.java#L328-L350 | train |
sarl/sarl | sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/services/network/NetworkUtil.java | NetworkUtil.getLoopbackAddress | public static InetAddress getLoopbackAddress() {
try {
final Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
if (interfaces != null) {
NetworkInterface inter;
InetAddress adr;
Enumeration<InetAddress> addrs;
while (interfaces.hasMoreElements()) {
inter = interfaces.nextElement();
addrs = inter.getInetAddresses();
if (addrs != null) {
while (addrs.hasMoreElements()) {
adr = addrs.nextElement();
if (adr != null && adr.isLoopbackAddress() && (adr instanceof Inet4Address)) {
return adr;
}
}
}
}
}
} catch (SocketException e) {
//
}
return null;
} | java | public static InetAddress getLoopbackAddress() {
try {
final Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
if (interfaces != null) {
NetworkInterface inter;
InetAddress adr;
Enumeration<InetAddress> addrs;
while (interfaces.hasMoreElements()) {
inter = interfaces.nextElement();
addrs = inter.getInetAddresses();
if (addrs != null) {
while (addrs.hasMoreElements()) {
adr = addrs.nextElement();
if (adr != null && adr.isLoopbackAddress() && (adr instanceof Inet4Address)) {
return adr;
}
}
}
}
}
} catch (SocketException e) {
//
}
return null;
} | [
"public",
"static",
"InetAddress",
"getLoopbackAddress",
"(",
")",
"{",
"try",
"{",
"final",
"Enumeration",
"<",
"NetworkInterface",
">",
"interfaces",
"=",
"NetworkInterface",
".",
"getNetworkInterfaces",
"(",
")",
";",
"if",
"(",
"interfaces",
"!=",
"null",
")... | Replies the IPv4 loopback address.
@return the IPv4 loopback address or <code>null</code> if none. | [
"Replies",
"the",
"IPv4",
"loopback",
"address",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/services/network/NetworkUtil.java#L95-L119 | train |
sarl/sarl | sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/services/network/NetworkUtil.java | NetworkUtil.toURI | public static URI toURI(String uri) throws URISyntaxException {
final URI u = new URI(uri);
// Inspired by ZeroMQ
String adr = u.getAuthority();
if (adr == null) {
adr = u.getPath();
}
if (adr != null && adr.endsWith(":*")) { //$NON-NLS-1$
return new URI(u.getScheme(), u.getUserInfo(), adr.substring(0, adr.length() - 2), -1, null, u.getQuery(),
u.getFragment());
}
return u;
} | java | public static URI toURI(String uri) throws URISyntaxException {
final URI u = new URI(uri);
// Inspired by ZeroMQ
String adr = u.getAuthority();
if (adr == null) {
adr = u.getPath();
}
if (adr != null && adr.endsWith(":*")) { //$NON-NLS-1$
return new URI(u.getScheme(), u.getUserInfo(), adr.substring(0, adr.length() - 2), -1, null, u.getQuery(),
u.getFragment());
}
return u;
} | [
"public",
"static",
"URI",
"toURI",
"(",
"String",
"uri",
")",
"throws",
"URISyntaxException",
"{",
"final",
"URI",
"u",
"=",
"new",
"URI",
"(",
"uri",
")",
";",
"// Inspired by ZeroMQ",
"String",
"adr",
"=",
"u",
".",
"getAuthority",
"(",
")",
";",
"if"... | Convert a string URI to an object URI.
<p>This function support the syntax ":*" for the port.
@param uri the string representation of the URI to parse.
@return the URI.
@throws URISyntaxException - if the given string has invalid format. | [
"Convert",
"a",
"string",
"URI",
"to",
"an",
"object",
"URI",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/services/network/NetworkUtil.java#L150-L162 | train |
sarl/sarl | sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/services/network/NetworkUtil.java | NetworkUtil.toURI | public static URI toURI(InetAddress adr) {
try {
return new URI("tcp", adr.getHostAddress(), null, null); //$NON-NLS-1$
} catch (URISyntaxException e) {
throw new IOError(e);
}
} | java | public static URI toURI(InetAddress adr) {
try {
return new URI("tcp", adr.getHostAddress(), null, null); //$NON-NLS-1$
} catch (URISyntaxException e) {
throw new IOError(e);
}
} | [
"public",
"static",
"URI",
"toURI",
"(",
"InetAddress",
"adr",
")",
"{",
"try",
"{",
"return",
"new",
"URI",
"(",
"\"tcp\"",
",",
"adr",
".",
"getHostAddress",
"(",
")",
",",
"null",
",",
"null",
")",
";",
"//$NON-NLS-1$",
"}",
"catch",
"(",
"URISyntax... | Convert an inet address to an URI.
@param adr address to convert to URI.
@return the URI. | [
"Convert",
"an",
"inet",
"address",
"to",
"an",
"URI",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/services/network/NetworkUtil.java#L170-L176 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.toLightweightTypeReference | protected LightweightTypeReference toLightweightTypeReference(JvmType type, EObject context) {
final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(getServices(), context);
final LightweightTypeReferenceFactory factory = new LightweightTypeReferenceFactory(owner, false);
return factory.toLightweightReference(type);
} | java | protected LightweightTypeReference toLightweightTypeReference(JvmType type, EObject context) {
final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(getServices(), context);
final LightweightTypeReferenceFactory factory = new LightweightTypeReferenceFactory(owner, false);
return factory.toLightweightReference(type);
} | [
"protected",
"LightweightTypeReference",
"toLightweightTypeReference",
"(",
"JvmType",
"type",
",",
"EObject",
"context",
")",
"{",
"final",
"StandardTypeReferenceOwner",
"owner",
"=",
"new",
"StandardTypeReferenceOwner",
"(",
"getServices",
"(",
")",
",",
"context",
")... | Create a lightweight type reference from the given type.
@param type the type to point to.
@param context the context in which the reference is located.
@return the reference. | [
"Create",
"a",
"lightweight",
"type",
"reference",
"from",
"the",
"given",
"type",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L472-L476 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.isIgnored | protected boolean isIgnored(String issueCode, EObject currentObject) {
final IssueSeverities severities = getIssueSeverities(getContext(), currentObject);
return severities.isIgnored(issueCode);
} | java | protected boolean isIgnored(String issueCode, EObject currentObject) {
final IssueSeverities severities = getIssueSeverities(getContext(), currentObject);
return severities.isIgnored(issueCode);
} | [
"protected",
"boolean",
"isIgnored",
"(",
"String",
"issueCode",
",",
"EObject",
"currentObject",
")",
"{",
"final",
"IssueSeverities",
"severities",
"=",
"getIssueSeverities",
"(",
"getContext",
"(",
")",
",",
"currentObject",
")",
";",
"return",
"severities",
".... | Replies if the given issue is ignored for the given object.
@param issueCode the code if the issue.
@param currentObject the current object.
@return <code>true</code> if the issue is ignored.
@see #isIgnored(String) | [
"Replies",
"if",
"the",
"given",
"issue",
"is",
"ignored",
"for",
"the",
"given",
"object",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L506-L509 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.canonicalName | protected String canonicalName(EObject object) {
if (object instanceof JvmIdentifiableElement) {
return ((JvmIdentifiableElement) object).getQualifiedName();
}
final EObject jvmElement = this.associations.getPrimaryJvmElement(object);
if (jvmElement instanceof JvmIdentifiableElement) {
return ((JvmIdentifiableElement) jvmElement).getQualifiedName();
}
return null;
} | java | protected String canonicalName(EObject object) {
if (object instanceof JvmIdentifiableElement) {
return ((JvmIdentifiableElement) object).getQualifiedName();
}
final EObject jvmElement = this.associations.getPrimaryJvmElement(object);
if (jvmElement instanceof JvmIdentifiableElement) {
return ((JvmIdentifiableElement) jvmElement).getQualifiedName();
}
return null;
} | [
"protected",
"String",
"canonicalName",
"(",
"EObject",
"object",
")",
"{",
"if",
"(",
"object",
"instanceof",
"JvmIdentifiableElement",
")",
"{",
"return",
"(",
"(",
"JvmIdentifiableElement",
")",
"object",
")",
".",
"getQualifiedName",
"(",
")",
";",
"}",
"f... | Replies the canonical name of the given object.
@param object the object.
@return the canonical name or <code>null</code> if it cannot be computed. | [
"Replies",
"the",
"canonical",
"name",
"of",
"the",
"given",
"object",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L516-L525 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkSpaceUse | @Check
public void checkSpaceUse(SarlSpace space) {
error(MessageFormat.format(
Messages.SARLValidator_0,
this.grammarAccess.getSpaceKeyword()),
space,
null);
} | java | @Check
public void checkSpaceUse(SarlSpace space) {
error(MessageFormat.format(
Messages.SARLValidator_0,
this.grammarAccess.getSpaceKeyword()),
space,
null);
} | [
"@",
"Check",
"public",
"void",
"checkSpaceUse",
"(",
"SarlSpace",
"space",
")",
"{",
"error",
"(",
"MessageFormat",
".",
"format",
"(",
"Messages",
".",
"SARLValidator_0",
",",
"this",
".",
"grammarAccess",
".",
"getSpaceKeyword",
"(",
")",
")",
",",
"space... | Space keyword is reserved.
@param space the space to check. | [
"Space",
"keyword",
"is",
"reserved",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L531-L538 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkArtifactUse | @Check
public void checkArtifactUse(SarlArtifact artifact) {
error(MessageFormat.format(
Messages.SARLValidator_0,
this.grammarAccess.getSpaceKeyword()),
artifact,
null);
} | java | @Check
public void checkArtifactUse(SarlArtifact artifact) {
error(MessageFormat.format(
Messages.SARLValidator_0,
this.grammarAccess.getSpaceKeyword()),
artifact,
null);
} | [
"@",
"Check",
"public",
"void",
"checkArtifactUse",
"(",
"SarlArtifact",
"artifact",
")",
"{",
"error",
"(",
"MessageFormat",
".",
"format",
"(",
"Messages",
".",
"SARLValidator_0",
",",
"this",
".",
"grammarAccess",
".",
"getSpaceKeyword",
"(",
")",
")",
",",... | Artifact keyword is reserved.
@param artifact the artifact to check. | [
"Artifact",
"keyword",
"is",
"reserved",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L544-L551 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkEarlyExitEventInFires | @Check
public void checkEarlyExitEventInFires(SarlAction action) {
int i = 0;
for (final JvmTypeReference event : action.getFiredEvents()) {
if (!this.earlyExitComputer.isEarlyExitEvent(event)) {
warning(MessageFormat.format(
Messages.SARLValidator_95,
event.getSimpleName()),
action,
SarlPackage.eINSTANCE.getSarlAction_FiredEvents(),
i);
}
++i;
}
} | java | @Check
public void checkEarlyExitEventInFires(SarlAction action) {
int i = 0;
for (final JvmTypeReference event : action.getFiredEvents()) {
if (!this.earlyExitComputer.isEarlyExitEvent(event)) {
warning(MessageFormat.format(
Messages.SARLValidator_95,
event.getSimpleName()),
action,
SarlPackage.eINSTANCE.getSarlAction_FiredEvents(),
i);
}
++i;
}
} | [
"@",
"Check",
"public",
"void",
"checkEarlyExitEventInFires",
"(",
"SarlAction",
"action",
")",
"{",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"final",
"JvmTypeReference",
"event",
":",
"action",
".",
"getFiredEvents",
"(",
")",
")",
"{",
"if",
"(",
"!",
"t... | Emit a warning when the events after the "fires" keyword are not early-exit events.
@param action the action to check. | [
"Emit",
"a",
"warning",
"when",
"the",
"events",
"after",
"the",
"fires",
"keyword",
"are",
"not",
"early",
"-",
"exit",
"events",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L557-L571 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkRequiredCapacityUse | @Check
public void checkRequiredCapacityUse(SarlRequiredCapacity statement) {
warning(MessageFormat.format(
Messages.SARLValidator_0,
this.grammarAccess.getRequiresKeyword()),
statement,
null);
} | java | @Check
public void checkRequiredCapacityUse(SarlRequiredCapacity statement) {
warning(MessageFormat.format(
Messages.SARLValidator_0,
this.grammarAccess.getRequiresKeyword()),
statement,
null);
} | [
"@",
"Check",
"public",
"void",
"checkRequiredCapacityUse",
"(",
"SarlRequiredCapacity",
"statement",
")",
"{",
"warning",
"(",
"MessageFormat",
".",
"format",
"(",
"Messages",
".",
"SARLValidator_0",
",",
"this",
".",
"grammarAccess",
".",
"getRequiresKeyword",
"("... | Emit a warning when the "requires" keyword is used.
@param statement the statement to check. | [
"Emit",
"a",
"warning",
"when",
"the",
"requires",
"keyword",
"is",
"used",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L577-L584 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkModifiers | @Check
protected void checkModifiers(SarlAgent agent) {
this.agentModifierValidator.checkModifiers(agent,
MessageFormat.format(Messages.SARLValidator_9, agent.getName()));
} | java | @Check
protected void checkModifiers(SarlAgent agent) {
this.agentModifierValidator.checkModifiers(agent,
MessageFormat.format(Messages.SARLValidator_9, agent.getName()));
} | [
"@",
"Check",
"protected",
"void",
"checkModifiers",
"(",
"SarlAgent",
"agent",
")",
"{",
"this",
".",
"agentModifierValidator",
".",
"checkModifiers",
"(",
"agent",
",",
"MessageFormat",
".",
"format",
"(",
"Messages",
".",
"SARLValidator_9",
",",
"agent",
".",... | Check the modifiers for the SARL agents.
@param agent the agent. | [
"Check",
"the",
"modifiers",
"for",
"the",
"SARL",
"agents",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L778-L782 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkModifiers | @Check
protected void checkModifiers(SarlBehavior behavior) {
this.behaviorModifierValidator.checkModifiers(behavior,
MessageFormat.format(Messages.SARLValidator_9, behavior.getName()));
} | java | @Check
protected void checkModifiers(SarlBehavior behavior) {
this.behaviorModifierValidator.checkModifiers(behavior,
MessageFormat.format(Messages.SARLValidator_9, behavior.getName()));
} | [
"@",
"Check",
"protected",
"void",
"checkModifiers",
"(",
"SarlBehavior",
"behavior",
")",
"{",
"this",
".",
"behaviorModifierValidator",
".",
"checkModifiers",
"(",
"behavior",
",",
"MessageFormat",
".",
"format",
"(",
"Messages",
".",
"SARLValidator_9",
",",
"be... | Check the modifiers for the SARL behaviors.
@param behavior the behavior. | [
"Check",
"the",
"modifiers",
"for",
"the",
"SARL",
"behaviors",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L788-L792 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkModifiers | @Check
protected void checkModifiers(SarlCapacity capacity) {
this.capacityModifierValidator.checkModifiers(capacity,
MessageFormat.format(Messages.SARLValidator_9, capacity.getName()));
} | java | @Check
protected void checkModifiers(SarlCapacity capacity) {
this.capacityModifierValidator.checkModifiers(capacity,
MessageFormat.format(Messages.SARLValidator_9, capacity.getName()));
} | [
"@",
"Check",
"protected",
"void",
"checkModifiers",
"(",
"SarlCapacity",
"capacity",
")",
"{",
"this",
".",
"capacityModifierValidator",
".",
"checkModifiers",
"(",
"capacity",
",",
"MessageFormat",
".",
"format",
"(",
"Messages",
".",
"SARLValidator_9",
",",
"ca... | Check the modifiers for the SARL capacities.
@param capacity the capacity. | [
"Check",
"the",
"modifiers",
"for",
"the",
"SARL",
"capacities",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L798-L802 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkModifiers | @Check
protected void checkModifiers(SarlSkill skill) {
this.skillModifierValidator.checkModifiers(skill,
MessageFormat.format(Messages.SARLValidator_9, skill.getName()));
} | java | @Check
protected void checkModifiers(SarlSkill skill) {
this.skillModifierValidator.checkModifiers(skill,
MessageFormat.format(Messages.SARLValidator_9, skill.getName()));
} | [
"@",
"Check",
"protected",
"void",
"checkModifiers",
"(",
"SarlSkill",
"skill",
")",
"{",
"this",
".",
"skillModifierValidator",
".",
"checkModifiers",
"(",
"skill",
",",
"MessageFormat",
".",
"format",
"(",
"Messages",
".",
"SARLValidator_9",
",",
"skill",
".",... | Check the modifiers for the SARL skills.
@param skill the skill. | [
"Check",
"the",
"modifiers",
"for",
"the",
"SARL",
"skills",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L808-L812 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkContainerType | @Check
public void checkContainerType(SarlAgent agent) {
final XtendTypeDeclaration declaringType = agent.getDeclaringType();
if (declaringType != null) {
final String name = canonicalName(declaringType);
assert name != null;
error(MessageFormat.format(Messages.SARLValidator_28, name),
agent,
null,
INVALID_NESTED_DEFINITION);
}
} | java | @Check
public void checkContainerType(SarlAgent agent) {
final XtendTypeDeclaration declaringType = agent.getDeclaringType();
if (declaringType != null) {
final String name = canonicalName(declaringType);
assert name != null;
error(MessageFormat.format(Messages.SARLValidator_28, name),
agent,
null,
INVALID_NESTED_DEFINITION);
}
} | [
"@",
"Check",
"public",
"void",
"checkContainerType",
"(",
"SarlAgent",
"agent",
")",
"{",
"final",
"XtendTypeDeclaration",
"declaringType",
"=",
"agent",
".",
"getDeclaringType",
"(",
")",
";",
"if",
"(",
"declaringType",
"!=",
"null",
")",
"{",
"final",
"Str... | Check the container for the SARL agents.
@param agent the agent. | [
"Check",
"the",
"container",
"for",
"the",
"SARL",
"agents",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L873-L884 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkContainerType | @Check
public void checkContainerType(SarlBehavior behavior) {
final XtendTypeDeclaration declaringType = behavior.getDeclaringType();
if (declaringType != null) {
final String name = canonicalName(declaringType);
assert name != null;
error(MessageFormat.format(Messages.SARLValidator_29, name),
behavior,
null,
INVALID_NESTED_DEFINITION);
}
} | java | @Check
public void checkContainerType(SarlBehavior behavior) {
final XtendTypeDeclaration declaringType = behavior.getDeclaringType();
if (declaringType != null) {
final String name = canonicalName(declaringType);
assert name != null;
error(MessageFormat.format(Messages.SARLValidator_29, name),
behavior,
null,
INVALID_NESTED_DEFINITION);
}
} | [
"@",
"Check",
"public",
"void",
"checkContainerType",
"(",
"SarlBehavior",
"behavior",
")",
"{",
"final",
"XtendTypeDeclaration",
"declaringType",
"=",
"behavior",
".",
"getDeclaringType",
"(",
")",
";",
"if",
"(",
"declaringType",
"!=",
"null",
")",
"{",
"final... | Check the container for the SARL behaviors.
@param behavior the behavior. | [
"Check",
"the",
"container",
"for",
"the",
"SARL",
"behaviors",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L890-L901 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkContainerType | @Check
public void checkContainerType(SarlCapacity capacity) {
final XtendTypeDeclaration declaringType = capacity.getDeclaringType();
if (declaringType != null) {
final String name = canonicalName(declaringType);
assert name != null;
error(MessageFormat.format(Messages.SARLValidator_30, name),
capacity,
null,
INVALID_NESTED_DEFINITION);
}
} | java | @Check
public void checkContainerType(SarlCapacity capacity) {
final XtendTypeDeclaration declaringType = capacity.getDeclaringType();
if (declaringType != null) {
final String name = canonicalName(declaringType);
assert name != null;
error(MessageFormat.format(Messages.SARLValidator_30, name),
capacity,
null,
INVALID_NESTED_DEFINITION);
}
} | [
"@",
"Check",
"public",
"void",
"checkContainerType",
"(",
"SarlCapacity",
"capacity",
")",
"{",
"final",
"XtendTypeDeclaration",
"declaringType",
"=",
"capacity",
".",
"getDeclaringType",
"(",
")",
";",
"if",
"(",
"declaringType",
"!=",
"null",
")",
"{",
"final... | Check the container for the SARL capacities.
@param capacity the capacity. | [
"Check",
"the",
"container",
"for",
"the",
"SARL",
"capacities",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L907-L918 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkContainerType | @Check
public void checkContainerType(SarlSkill skill) {
final XtendTypeDeclaration declaringType = skill.getDeclaringType();
if (declaringType != null) {
final String name = canonicalName(declaringType);
assert name != null;
error(MessageFormat.format(Messages.SARLValidator_31, name),
skill,
null,
INVALID_NESTED_DEFINITION);
}
} | java | @Check
public void checkContainerType(SarlSkill skill) {
final XtendTypeDeclaration declaringType = skill.getDeclaringType();
if (declaringType != null) {
final String name = canonicalName(declaringType);
assert name != null;
error(MessageFormat.format(Messages.SARLValidator_31, name),
skill,
null,
INVALID_NESTED_DEFINITION);
}
} | [
"@",
"Check",
"public",
"void",
"checkContainerType",
"(",
"SarlSkill",
"skill",
")",
"{",
"final",
"XtendTypeDeclaration",
"declaringType",
"=",
"skill",
".",
"getDeclaringType",
"(",
")",
";",
"if",
"(",
"declaringType",
"!=",
"null",
")",
"{",
"final",
"Str... | Check the container for the SARL skills.
@param skill the skill. | [
"Check",
"the",
"container",
"for",
"the",
"SARL",
"skills",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L924-L935 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkFinalFieldInitialization | @Check
public void checkFinalFieldInitialization(SarlEvent event) {
final JvmGenericType inferredType = this.associations.getInferredType(event);
if (inferredType != null) {
checkFinalFieldInitialization(inferredType);
}
} | java | @Check
public void checkFinalFieldInitialization(SarlEvent event) {
final JvmGenericType inferredType = this.associations.getInferredType(event);
if (inferredType != null) {
checkFinalFieldInitialization(inferredType);
}
} | [
"@",
"Check",
"public",
"void",
"checkFinalFieldInitialization",
"(",
"SarlEvent",
"event",
")",
"{",
"final",
"JvmGenericType",
"inferredType",
"=",
"this",
".",
"associations",
".",
"getInferredType",
"(",
"event",
")",
";",
"if",
"(",
"inferredType",
"!=",
"n... | Check if all the fields are initialized in a SARL event.
@param event the event. | [
"Check",
"if",
"all",
"the",
"fields",
"are",
"initialized",
"in",
"a",
"SARL",
"event",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L958-L964 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkFinalFieldInitialization | @Check
public void checkFinalFieldInitialization(SarlBehavior behavior) {
final JvmGenericType inferredType = this.associations.getInferredType(behavior);
if (inferredType != null) {
checkFinalFieldInitialization(inferredType);
}
} | java | @Check
public void checkFinalFieldInitialization(SarlBehavior behavior) {
final JvmGenericType inferredType = this.associations.getInferredType(behavior);
if (inferredType != null) {
checkFinalFieldInitialization(inferredType);
}
} | [
"@",
"Check",
"public",
"void",
"checkFinalFieldInitialization",
"(",
"SarlBehavior",
"behavior",
")",
"{",
"final",
"JvmGenericType",
"inferredType",
"=",
"this",
".",
"associations",
".",
"getInferredType",
"(",
"behavior",
")",
";",
"if",
"(",
"inferredType",
"... | Check if all the fields are initialized in a SARL behavior.
@param behavior the behavior. | [
"Check",
"if",
"all",
"the",
"fields",
"are",
"initialized",
"in",
"a",
"SARL",
"behavior",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L970-L976 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkFinalFieldInitialization | @Check
public void checkFinalFieldInitialization(SarlSkill skill) {
final JvmGenericType inferredType = this.associations.getInferredType(skill);
if (inferredType != null) {
checkFinalFieldInitialization(inferredType);
}
} | java | @Check
public void checkFinalFieldInitialization(SarlSkill skill) {
final JvmGenericType inferredType = this.associations.getInferredType(skill);
if (inferredType != null) {
checkFinalFieldInitialization(inferredType);
}
} | [
"@",
"Check",
"public",
"void",
"checkFinalFieldInitialization",
"(",
"SarlSkill",
"skill",
")",
"{",
"final",
"JvmGenericType",
"inferredType",
"=",
"this",
".",
"associations",
".",
"getInferredType",
"(",
"skill",
")",
";",
"if",
"(",
"inferredType",
"!=",
"n... | Check if all the fields are initialized in a SARL skill.
@param skill the skill. | [
"Check",
"if",
"all",
"the",
"fields",
"are",
"initialized",
"in",
"a",
"SARL",
"skill",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L982-L988 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkFinalFieldInitialization | @Check
public void checkFinalFieldInitialization(SarlAgent agent) {
final JvmGenericType inferredType = this.associations.getInferredType(agent);
if (inferredType != null) {
checkFinalFieldInitialization(inferredType);
}
} | java | @Check
public void checkFinalFieldInitialization(SarlAgent agent) {
final JvmGenericType inferredType = this.associations.getInferredType(agent);
if (inferredType != null) {
checkFinalFieldInitialization(inferredType);
}
} | [
"@",
"Check",
"public",
"void",
"checkFinalFieldInitialization",
"(",
"SarlAgent",
"agent",
")",
"{",
"final",
"JvmGenericType",
"inferredType",
"=",
"this",
".",
"associations",
".",
"getInferredType",
"(",
"agent",
")",
";",
"if",
"(",
"inferredType",
"!=",
"n... | Check if all the fields are initialized in a SARL agent.
@param agent the agent. | [
"Check",
"if",
"all",
"the",
"fields",
"are",
"initialized",
"in",
"a",
"SARL",
"agent",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L994-L1000 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkSuperConstructor | @SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity", "checkstyle:nestedifdepth"})
protected void checkSuperConstructor(
XtendTypeDeclaration container,
EStructuralFeature feature,
Collection<ActionParameterTypes> defaultSignatures) {
final JvmDeclaredType jvmElement = this.associations.getInferredType(container);
if (jvmElement != null) {
final Map<ActionParameterTypes, JvmConstructor> superConstructors =
CollectionLiterals.newTreeMap((Comparator<ActionParameterTypes>) null);
final JvmTypeReference typeRef = jvmElement.getExtendedClass();
final JvmType supertype = (typeRef == null) ? null : typeRef.getType();
if (supertype instanceof JvmGenericType) {
final JvmGenericType jvmSuperElement = (JvmGenericType) supertype;
for (final JvmConstructor superConstructor : jvmSuperElement.getDeclaredConstructors()) {
final ActionParameterTypes sig = this.sarlActionSignatures.createParameterTypesFromJvmModel(
superConstructor.isVarArgs(), superConstructor.getParameters());
superConstructors.put(sig, superConstructor);
}
}
final ActionParameterTypes voidKey = this.sarlActionSignatures.createParameterTypesForVoid();
//boolean hasDeclaredConstructor = false;
for (final XtendMember member : container.getMembers()) {
if (member instanceof SarlConstructor) {
final SarlConstructor constructor = (SarlConstructor) member;
//hasDeclaredConstructor = true;
boolean invokeDefaultConstructor = true;
final XExpression body = constructor.getExpression();
if (body instanceof XBlockExpression) {
final XBlockExpression block = (XBlockExpression) body;
if (!block.getExpressions().isEmpty()) {
final XExpression firstStatement = block.getExpressions().get(0);
if (firstStatement instanceof XConstructorCall || isDelegateConstructorCall(firstStatement)) {
invokeDefaultConstructor = false;
}
}
} else if (body instanceof XConstructorCall || isDelegateConstructorCall(body)) {
invokeDefaultConstructor = false;
}
if (invokeDefaultConstructor && !superConstructors.containsKey(voidKey)) {
final List<String> issueData = new ArrayList<>();
for (final ActionParameterTypes defaultSignature : defaultSignatures) {
issueData.add(defaultSignature.toString());
}
error(Messages.SARLValidator_33,
member,
null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
MUST_INVOKE_SUPER_CONSTRUCTOR,
toArray(issueData, String.class));
}
}
}
// The following code is no more needed because of the constructor inheritance mechanism which
// is implemented into the JVM model inferrer.
/*if (!hasDeclaredConstructor) {
for (final ActionParameterTypes defaultSignature : defaultSignatures) {
if (!superConstructors.containsKey(defaultSignature)) {
final List<String> issueData = new ArrayList<>();
for (final JvmConstructor superConstructor : superConstructors.values()) {
issueData.add(EcoreUtil.getURI(superConstructor).toString());
issueData.add(doGetReadableSignature(container.getName(), superConstructor.getParameters()));
}
error(Messages.SARLValidator_33,
container, feature, MISSING_CONSTRUCTOR, toArray(issueData, String.class));
}
}
}*/
}
} | java | @SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity", "checkstyle:nestedifdepth"})
protected void checkSuperConstructor(
XtendTypeDeclaration container,
EStructuralFeature feature,
Collection<ActionParameterTypes> defaultSignatures) {
final JvmDeclaredType jvmElement = this.associations.getInferredType(container);
if (jvmElement != null) {
final Map<ActionParameterTypes, JvmConstructor> superConstructors =
CollectionLiterals.newTreeMap((Comparator<ActionParameterTypes>) null);
final JvmTypeReference typeRef = jvmElement.getExtendedClass();
final JvmType supertype = (typeRef == null) ? null : typeRef.getType();
if (supertype instanceof JvmGenericType) {
final JvmGenericType jvmSuperElement = (JvmGenericType) supertype;
for (final JvmConstructor superConstructor : jvmSuperElement.getDeclaredConstructors()) {
final ActionParameterTypes sig = this.sarlActionSignatures.createParameterTypesFromJvmModel(
superConstructor.isVarArgs(), superConstructor.getParameters());
superConstructors.put(sig, superConstructor);
}
}
final ActionParameterTypes voidKey = this.sarlActionSignatures.createParameterTypesForVoid();
//boolean hasDeclaredConstructor = false;
for (final XtendMember member : container.getMembers()) {
if (member instanceof SarlConstructor) {
final SarlConstructor constructor = (SarlConstructor) member;
//hasDeclaredConstructor = true;
boolean invokeDefaultConstructor = true;
final XExpression body = constructor.getExpression();
if (body instanceof XBlockExpression) {
final XBlockExpression block = (XBlockExpression) body;
if (!block.getExpressions().isEmpty()) {
final XExpression firstStatement = block.getExpressions().get(0);
if (firstStatement instanceof XConstructorCall || isDelegateConstructorCall(firstStatement)) {
invokeDefaultConstructor = false;
}
}
} else if (body instanceof XConstructorCall || isDelegateConstructorCall(body)) {
invokeDefaultConstructor = false;
}
if (invokeDefaultConstructor && !superConstructors.containsKey(voidKey)) {
final List<String> issueData = new ArrayList<>();
for (final ActionParameterTypes defaultSignature : defaultSignatures) {
issueData.add(defaultSignature.toString());
}
error(Messages.SARLValidator_33,
member,
null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
MUST_INVOKE_SUPER_CONSTRUCTOR,
toArray(issueData, String.class));
}
}
}
// The following code is no more needed because of the constructor inheritance mechanism which
// is implemented into the JVM model inferrer.
/*if (!hasDeclaredConstructor) {
for (final ActionParameterTypes defaultSignature : defaultSignatures) {
if (!superConstructors.containsKey(defaultSignature)) {
final List<String> issueData = new ArrayList<>();
for (final JvmConstructor superConstructor : superConstructors.values()) {
issueData.add(EcoreUtil.getURI(superConstructor).toString());
issueData.add(doGetReadableSignature(container.getName(), superConstructor.getParameters()));
}
error(Messages.SARLValidator_33,
container, feature, MISSING_CONSTRUCTOR, toArray(issueData, String.class));
}
}
}*/
}
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"checkstyle:cyclomaticcomplexity\"",
",",
"\"checkstyle:npathcomplexity\"",
",",
"\"checkstyle:nestedifdepth\"",
"}",
")",
"protected",
"void",
"checkSuperConstructor",
"(",
"XtendTypeDeclaration",
"container",
",",
"EStructuralFeature",
"fe... | Check the super constructors.
@param container the container.
@param feature the syntactic feature related to the supertypes.
@param defaultSignatures the signatures of the default constructors for the given container. | [
"Check",
"the",
"super",
"constructors",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L1008-L1079 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkForbiddenCalls | @Check(CheckType.FAST)
public void checkForbiddenCalls(XAbstractFeatureCall expression) {
if (this.featureCallValidator.isDisallowedCall(expression)) {
error(
MessageFormat.format(
Messages.SARLValidator_36,
expression.getFeature().getIdentifier()),
expression,
null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
FORBIDDEN_REFERENCE);
}
} | java | @Check(CheckType.FAST)
public void checkForbiddenCalls(XAbstractFeatureCall expression) {
if (this.featureCallValidator.isDisallowedCall(expression)) {
error(
MessageFormat.format(
Messages.SARLValidator_36,
expression.getFeature().getIdentifier()),
expression,
null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
FORBIDDEN_REFERENCE);
}
} | [
"@",
"Check",
"(",
"CheckType",
".",
"FAST",
")",
"public",
"void",
"checkForbiddenCalls",
"(",
"XAbstractFeatureCall",
"expression",
")",
"{",
"if",
"(",
"this",
".",
"featureCallValidator",
".",
"isDisallowedCall",
"(",
"expression",
")",
")",
"{",
"error",
... | Check if the call is forbidden.
<p>One example of a forbidden feature is {@link System#exit(int)}.
@param expression the expression. | [
"Check",
"if",
"the",
"call",
"is",
"forbidden",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L1168-L1180 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkDiscouragedCalls | @Check(CheckType.FAST)
public void checkDiscouragedCalls(XAbstractFeatureCall expression) {
if (!isIgnored(DISCOURAGED_REFERENCE)
&& this.featureCallValidator.isDiscouragedCall(expression)) {
addIssue(
MessageFormat.format(Messages.SARLValidator_37,
expression.getConcreteSyntaxFeatureName()),
expression,
DISCOURAGED_REFERENCE);
}
} | java | @Check(CheckType.FAST)
public void checkDiscouragedCalls(XAbstractFeatureCall expression) {
if (!isIgnored(DISCOURAGED_REFERENCE)
&& this.featureCallValidator.isDiscouragedCall(expression)) {
addIssue(
MessageFormat.format(Messages.SARLValidator_37,
expression.getConcreteSyntaxFeatureName()),
expression,
DISCOURAGED_REFERENCE);
}
} | [
"@",
"Check",
"(",
"CheckType",
".",
"FAST",
")",
"public",
"void",
"checkDiscouragedCalls",
"(",
"XAbstractFeatureCall",
"expression",
")",
"{",
"if",
"(",
"!",
"isIgnored",
"(",
"DISCOURAGED_REFERENCE",
")",
"&&",
"this",
".",
"featureCallValidator",
".",
"isD... | Check if the call is discouraged.
<p>One example of a discouraged feature is {@link System#err}.
@param expression the expression. | [
"Check",
"if",
"the",
"call",
"is",
"discouraged",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L1188-L1198 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkDefaultValueTypeCompatibleWithParameterType | @Check
public void checkDefaultValueTypeCompatibleWithParameterType(SarlFormalParameter param) {
final XExpression defaultValue = param.getDefaultValue();
if (defaultValue != null) {
final JvmTypeReference rawType = param.getParameterType();
assert rawType != null;
final LightweightTypeReference toType = toLightweightTypeReference(rawType, true);
if (toType == null) {
error(MessageFormat.format(
Messages.SARLValidator_20,
param.getName()),
param,
XtendPackage.Literals.XTEND_PARAMETER__PARAMETER_TYPE,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
INVALID_TYPE);
return;
}
LightweightTypeReference fromType = getExpectedType(defaultValue);
if (fromType == null) {
fromType = getActualType(defaultValue);
if (fromType == null) {
error(MessageFormat.format(
Messages.SARLValidator_21,
param.getName()),
param,
SARL_FORMAL_PARAMETER__DEFAULT_VALUE,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
INVALID_TYPE);
return;
}
}
if (!Utils.canCast(fromType, toType, true, false, true)) {
error(MessageFormat.format(
Messages.SARLValidator_38,
getNameOfTypes(fromType), canonicalName(toType)),
param,
SARL_FORMAL_PARAMETER__DEFAULT_VALUE,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
INCOMPATIBLE_TYPES,
canonicalName(fromType),
canonicalName(toType));
}
}
} | java | @Check
public void checkDefaultValueTypeCompatibleWithParameterType(SarlFormalParameter param) {
final XExpression defaultValue = param.getDefaultValue();
if (defaultValue != null) {
final JvmTypeReference rawType = param.getParameterType();
assert rawType != null;
final LightweightTypeReference toType = toLightweightTypeReference(rawType, true);
if (toType == null) {
error(MessageFormat.format(
Messages.SARLValidator_20,
param.getName()),
param,
XtendPackage.Literals.XTEND_PARAMETER__PARAMETER_TYPE,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
INVALID_TYPE);
return;
}
LightweightTypeReference fromType = getExpectedType(defaultValue);
if (fromType == null) {
fromType = getActualType(defaultValue);
if (fromType == null) {
error(MessageFormat.format(
Messages.SARLValidator_21,
param.getName()),
param,
SARL_FORMAL_PARAMETER__DEFAULT_VALUE,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
INVALID_TYPE);
return;
}
}
if (!Utils.canCast(fromType, toType, true, false, true)) {
error(MessageFormat.format(
Messages.SARLValidator_38,
getNameOfTypes(fromType), canonicalName(toType)),
param,
SARL_FORMAL_PARAMETER__DEFAULT_VALUE,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
INCOMPATIBLE_TYPES,
canonicalName(fromType),
canonicalName(toType));
}
}
} | [
"@",
"Check",
"public",
"void",
"checkDefaultValueTypeCompatibleWithParameterType",
"(",
"SarlFormalParameter",
"param",
")",
"{",
"final",
"XExpression",
"defaultValue",
"=",
"param",
".",
"getDefaultValue",
"(",
")",
";",
"if",
"(",
"defaultValue",
"!=",
"null",
"... | Check if the default values of the formal parameters have a compatible type with the formal parameter.
@param param the formal parameter to check. | [
"Check",
"if",
"the",
"default",
"values",
"of",
"the",
"formal",
"parameters",
"have",
"a",
"compatible",
"type",
"with",
"the",
"formal",
"parameter",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L1204-L1247 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkDefaultValueFieldReference | @Check
public void checkDefaultValueFieldReference(SarlFormalParameter param) {
final XExpression defaultValue = param.getDefaultValue();
if (defaultValue != null) {
final Iterator<XFeatureCall> iter;
if (defaultValue instanceof XFeatureCall) {
iter = Iterators.singletonIterator((XFeatureCall) defaultValue);
} else {
iter = Iterators.filter(defaultValue.eAllContents(), XFeatureCall.class);
}
while (iter.hasNext()) {
final XFeatureCall call = iter.next();
final JvmIdentifiableElement feature = call.getFeature();
String invalidFieldName = null;
if (feature instanceof XtendField) {
final XtendField field = (XtendField) feature;
if (!field.isFinal()) {
invalidFieldName = field.getName();
}
} else if (feature instanceof JvmField) {
final JvmField field = (JvmField) feature;
if (!field.isFinal()) {
invalidFieldName = field.getSimpleName();
}
}
if (invalidFieldName != null) {
error(MessageFormat.format(
Messages.SARLValidator_19,
invalidFieldName),
call,
XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
FORBIDDEN_REFERENCE);
}
}
}
} | java | @Check
public void checkDefaultValueFieldReference(SarlFormalParameter param) {
final XExpression defaultValue = param.getDefaultValue();
if (defaultValue != null) {
final Iterator<XFeatureCall> iter;
if (defaultValue instanceof XFeatureCall) {
iter = Iterators.singletonIterator((XFeatureCall) defaultValue);
} else {
iter = Iterators.filter(defaultValue.eAllContents(), XFeatureCall.class);
}
while (iter.hasNext()) {
final XFeatureCall call = iter.next();
final JvmIdentifiableElement feature = call.getFeature();
String invalidFieldName = null;
if (feature instanceof XtendField) {
final XtendField field = (XtendField) feature;
if (!field.isFinal()) {
invalidFieldName = field.getName();
}
} else if (feature instanceof JvmField) {
final JvmField field = (JvmField) feature;
if (!field.isFinal()) {
invalidFieldName = field.getSimpleName();
}
}
if (invalidFieldName != null) {
error(MessageFormat.format(
Messages.SARLValidator_19,
invalidFieldName),
call,
XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
FORBIDDEN_REFERENCE);
}
}
}
} | [
"@",
"Check",
"public",
"void",
"checkDefaultValueFieldReference",
"(",
"SarlFormalParameter",
"param",
")",
"{",
"final",
"XExpression",
"defaultValue",
"=",
"param",
".",
"getDefaultValue",
"(",
")",
";",
"if",
"(",
"defaultValue",
"!=",
"null",
")",
"{",
"fin... | Check if the default values has not a reference to the not final fields.
@param param the formal parameter to check. | [
"Check",
"if",
"the",
"default",
"values",
"has",
"not",
"a",
"reference",
"to",
"the",
"not",
"final",
"fields",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L1253-L1289 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkActionName | @Check(CheckType.FAST)
public void checkActionName(SarlAction action) {
final JvmOperation inferredType = this.associations.getDirectlyInferredOperation(action);
final QualifiedName name = QualifiedName.create(inferredType.getQualifiedName('.').split("\\.")); //$NON-NLS-1$
if (this.featureNames.isDisallowedName(name)) {
final String validName = Utils.fixHiddenMember(action.getName());
error(MessageFormat.format(
Messages.SARLValidator_39,
action.getName()),
action,
XTEND_FUNCTION__NAME,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
INVALID_MEMBER_NAME,
validName);
} else if (!isIgnored(DISCOURAGED_FUNCTION_NAME)
&& this.featureNames.isDiscouragedName(name)) {
warning(MessageFormat.format(
Messages.SARLValidator_39,
action.getName()),
action,
XTEND_FUNCTION__NAME,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
DISCOURAGED_FUNCTION_NAME);
}
} | java | @Check(CheckType.FAST)
public void checkActionName(SarlAction action) {
final JvmOperation inferredType = this.associations.getDirectlyInferredOperation(action);
final QualifiedName name = QualifiedName.create(inferredType.getQualifiedName('.').split("\\.")); //$NON-NLS-1$
if (this.featureNames.isDisallowedName(name)) {
final String validName = Utils.fixHiddenMember(action.getName());
error(MessageFormat.format(
Messages.SARLValidator_39,
action.getName()),
action,
XTEND_FUNCTION__NAME,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
INVALID_MEMBER_NAME,
validName);
} else if (!isIgnored(DISCOURAGED_FUNCTION_NAME)
&& this.featureNames.isDiscouragedName(name)) {
warning(MessageFormat.format(
Messages.SARLValidator_39,
action.getName()),
action,
XTEND_FUNCTION__NAME,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
DISCOURAGED_FUNCTION_NAME);
}
} | [
"@",
"Check",
"(",
"CheckType",
".",
"FAST",
")",
"public",
"void",
"checkActionName",
"(",
"SarlAction",
"action",
")",
"{",
"final",
"JvmOperation",
"inferredType",
"=",
"this",
".",
"associations",
".",
"getDirectlyInferredOperation",
"(",
"action",
")",
";",... | Check if the given action has a valid name.
@param action the action to test.
@see SARLFeatureNameValidator | [
"Check",
"if",
"the",
"given",
"action",
"has",
"a",
"valid",
"name",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L1296-L1320 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkFieldName | @Check(CheckType.FAST)
public void checkFieldName(SarlField field) {
final JvmField inferredType = this.associations.getJvmField(field);
final QualifiedName name = Utils.getQualifiedName(inferredType);
if (this.featureNames.isDisallowedName(name)) {
final String validName = Utils.fixHiddenMember(field.getName());
error(MessageFormat.format(
Messages.SARLValidator_41,
field.getName()),
field,
XTEND_FIELD__NAME,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
VARIABLE_NAME_DISALLOWED,
validName);
} else if (this.grammarAccess.getOccurrenceKeyword().equals(field.getName())) {
error(MessageFormat.format(
Messages.SARLValidator_41,
this.grammarAccess.getOccurrenceKeyword()),
field,
XTEND_FIELD__NAME,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
VARIABLE_NAME_DISALLOWED);
}
} | java | @Check(CheckType.FAST)
public void checkFieldName(SarlField field) {
final JvmField inferredType = this.associations.getJvmField(field);
final QualifiedName name = Utils.getQualifiedName(inferredType);
if (this.featureNames.isDisallowedName(name)) {
final String validName = Utils.fixHiddenMember(field.getName());
error(MessageFormat.format(
Messages.SARLValidator_41,
field.getName()),
field,
XTEND_FIELD__NAME,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
VARIABLE_NAME_DISALLOWED,
validName);
} else if (this.grammarAccess.getOccurrenceKeyword().equals(field.getName())) {
error(MessageFormat.format(
Messages.SARLValidator_41,
this.grammarAccess.getOccurrenceKeyword()),
field,
XTEND_FIELD__NAME,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
VARIABLE_NAME_DISALLOWED);
}
} | [
"@",
"Check",
"(",
"CheckType",
".",
"FAST",
")",
"public",
"void",
"checkFieldName",
"(",
"SarlField",
"field",
")",
"{",
"final",
"JvmField",
"inferredType",
"=",
"this",
".",
"associations",
".",
"getJvmField",
"(",
"field",
")",
";",
"final",
"QualifiedN... | Check if the given field has a valid name.
@param field the field to test.
@see SARLFeatureNameValidator | [
"Check",
"if",
"the",
"given",
"field",
"has",
"a",
"valid",
"name",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L1327-L1350 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkFieldNameShadowing | @Check
public void checkFieldNameShadowing(SarlField field) {
if (!isIgnored(VARIABLE_NAME_SHADOWING)
&& !Utils.isHiddenMember(field.getName())) {
final JvmField inferredField = this.associations.getJvmField(field);
final Map<String, JvmField> inheritedFields = new TreeMap<>();
Utils.populateInheritanceContext(
inferredField.getDeclaringType(),
null, null,
inheritedFields,
null, null,
this.sarlActionSignatures);
final JvmField inheritedField = inheritedFields.get(field.getName());
if (inheritedField != null) {
int nameIndex = 0;
String newName = field.getName() + nameIndex;
while (inheritedFields.containsKey(newName)) {
++nameIndex;
newName = field.getName() + nameIndex;
}
addIssue(MessageFormat.format(
Messages.SARLValidator_42,
field.getName(),
inferredField.getDeclaringType().getQualifiedName(),
inheritedField.getQualifiedName()),
field,
XTEND_FIELD__NAME,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
VARIABLE_NAME_SHADOWING,
newName);
}
}
} | java | @Check
public void checkFieldNameShadowing(SarlField field) {
if (!isIgnored(VARIABLE_NAME_SHADOWING)
&& !Utils.isHiddenMember(field.getName())) {
final JvmField inferredField = this.associations.getJvmField(field);
final Map<String, JvmField> inheritedFields = new TreeMap<>();
Utils.populateInheritanceContext(
inferredField.getDeclaringType(),
null, null,
inheritedFields,
null, null,
this.sarlActionSignatures);
final JvmField inheritedField = inheritedFields.get(field.getName());
if (inheritedField != null) {
int nameIndex = 0;
String newName = field.getName() + nameIndex;
while (inheritedFields.containsKey(newName)) {
++nameIndex;
newName = field.getName() + nameIndex;
}
addIssue(MessageFormat.format(
Messages.SARLValidator_42,
field.getName(),
inferredField.getDeclaringType().getQualifiedName(),
inheritedField.getQualifiedName()),
field,
XTEND_FIELD__NAME,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
VARIABLE_NAME_SHADOWING,
newName);
}
}
} | [
"@",
"Check",
"public",
"void",
"checkFieldNameShadowing",
"(",
"SarlField",
"field",
")",
"{",
"if",
"(",
"!",
"isIgnored",
"(",
"VARIABLE_NAME_SHADOWING",
")",
"&&",
"!",
"Utils",
".",
"isHiddenMember",
"(",
"field",
".",
"getName",
"(",
")",
")",
")",
"... | Check if the given field has a name that is shadowing an inherited field.
@param field the field to test. | [
"Check",
"if",
"the",
"given",
"field",
"has",
"a",
"name",
"that",
"is",
"shadowing",
"an",
"inherited",
"field",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L1356-L1389 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkParameterName | @Check(CheckType.FAST)
public void checkParameterName(SarlFormalParameter parameter) {
if (this.grammarAccess.getOccurrenceKeyword().equals(parameter.getName())) {
error(MessageFormat.format(
Messages.SARLValidator_14,
this.grammarAccess.getOccurrenceKeyword()),
parameter,
XtendPackage.Literals.XTEND_PARAMETER__NAME,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
VARIABLE_NAME_DISALLOWED);
}
} | java | @Check(CheckType.FAST)
public void checkParameterName(SarlFormalParameter parameter) {
if (this.grammarAccess.getOccurrenceKeyword().equals(parameter.getName())) {
error(MessageFormat.format(
Messages.SARLValidator_14,
this.grammarAccess.getOccurrenceKeyword()),
parameter,
XtendPackage.Literals.XTEND_PARAMETER__NAME,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
VARIABLE_NAME_DISALLOWED);
}
} | [
"@",
"Check",
"(",
"CheckType",
".",
"FAST",
")",
"public",
"void",
"checkParameterName",
"(",
"SarlFormalParameter",
"parameter",
")",
"{",
"if",
"(",
"this",
".",
"grammarAccess",
".",
"getOccurrenceKeyword",
"(",
")",
".",
"equals",
"(",
"parameter",
".",
... | Check if the given parameter has a valid name.
@param parameter the parameter to test.
@see SARLFeatureNameValidator | [
"Check",
"if",
"the",
"given",
"parameter",
"has",
"a",
"valid",
"name",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L1396-L1407 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkParameterName | @Check(CheckType.FAST)
public void checkParameterName(XVariableDeclaration variable) {
if (this.grammarAccess.getOccurrenceKeyword().equals(variable.getName())) {
error(MessageFormat.format(
Messages.SARLValidator_15,
this.grammarAccess.getOccurrenceKeyword()),
variable,
XbasePackage.Literals.XVARIABLE_DECLARATION__NAME,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
VARIABLE_NAME_DISALLOWED);
}
} | java | @Check(CheckType.FAST)
public void checkParameterName(XVariableDeclaration variable) {
if (this.grammarAccess.getOccurrenceKeyword().equals(variable.getName())) {
error(MessageFormat.format(
Messages.SARLValidator_15,
this.grammarAccess.getOccurrenceKeyword()),
variable,
XbasePackage.Literals.XVARIABLE_DECLARATION__NAME,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
VARIABLE_NAME_DISALLOWED);
}
} | [
"@",
"Check",
"(",
"CheckType",
".",
"FAST",
")",
"public",
"void",
"checkParameterName",
"(",
"XVariableDeclaration",
"variable",
")",
"{",
"if",
"(",
"this",
".",
"grammarAccess",
".",
"getOccurrenceKeyword",
"(",
")",
".",
"equals",
"(",
"variable",
".",
... | Check if the given local variable has a valid name.
@param variable the variable to test.
@see SARLFeatureNameValidator | [
"Check",
"if",
"the",
"given",
"local",
"variable",
"has",
"a",
"valid",
"name",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L1414-L1425 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkRedundantImplementedInterfaces | @Check
public void checkRedundantImplementedInterfaces(SarlSkill skill) {
checkRedundantInterfaces(
skill,
SARL_SKILL__IMPLEMENTS,
skill.getImplements(),
Utils.singletonList(skill.getExtends()));
} | java | @Check
public void checkRedundantImplementedInterfaces(SarlSkill skill) {
checkRedundantInterfaces(
skill,
SARL_SKILL__IMPLEMENTS,
skill.getImplements(),
Utils.singletonList(skill.getExtends()));
} | [
"@",
"Check",
"public",
"void",
"checkRedundantImplementedInterfaces",
"(",
"SarlSkill",
"skill",
")",
"{",
"checkRedundantInterfaces",
"(",
"skill",
",",
"SARL_SKILL__IMPLEMENTS",
",",
"skill",
".",
"getImplements",
"(",
")",
",",
"Utils",
".",
"singletonList",
"("... | Check if implemented interfaces of a skill are redundant.
@param skill the skill. | [
"Check",
"if",
"implemented",
"interfaces",
"of",
"a",
"skill",
"are",
"redundant",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L1599-L1606 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkRedundantImplementedInterfaces | @Check
public void checkRedundantImplementedInterfaces(SarlClass xtendClass) {
checkRedundantInterfaces(
xtendClass,
XTEND_CLASS__IMPLEMENTS,
xtendClass.getImplements(),
Utils.singletonList(xtendClass.getExtends()));
} | java | @Check
public void checkRedundantImplementedInterfaces(SarlClass xtendClass) {
checkRedundantInterfaces(
xtendClass,
XTEND_CLASS__IMPLEMENTS,
xtendClass.getImplements(),
Utils.singletonList(xtendClass.getExtends()));
} | [
"@",
"Check",
"public",
"void",
"checkRedundantImplementedInterfaces",
"(",
"SarlClass",
"xtendClass",
")",
"{",
"checkRedundantInterfaces",
"(",
"xtendClass",
",",
"XTEND_CLASS__IMPLEMENTS",
",",
"xtendClass",
".",
"getImplements",
"(",
")",
",",
"Utils",
".",
"singl... | Check if implemented interfaces of a Xtend Class are redundant.
@param xtendClass the class. | [
"Check",
"if",
"implemented",
"interfaces",
"of",
"a",
"Xtend",
"Class",
"are",
"redundant",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L1612-L1619 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkRedundantImplementedInterfaces | @Check
public void checkRedundantImplementedInterfaces(SarlInterface xtendInterface) {
checkRedundantInterfaces(
xtendInterface,
XTEND_INTERFACE__EXTENDS,
xtendInterface.getExtends(),
Collections.<JvmTypeReference>emptyList());
} | java | @Check
public void checkRedundantImplementedInterfaces(SarlInterface xtendInterface) {
checkRedundantInterfaces(
xtendInterface,
XTEND_INTERFACE__EXTENDS,
xtendInterface.getExtends(),
Collections.<JvmTypeReference>emptyList());
} | [
"@",
"Check",
"public",
"void",
"checkRedundantImplementedInterfaces",
"(",
"SarlInterface",
"xtendInterface",
")",
"{",
"checkRedundantInterfaces",
"(",
"xtendInterface",
",",
"XTEND_INTERFACE__EXTENDS",
",",
"xtendInterface",
".",
"getExtends",
"(",
")",
",",
"Collectio... | Check if implemented interfaces of a Xtend Interface are redundant.
@param xtendInterface the interface. | [
"Check",
"if",
"implemented",
"interfaces",
"of",
"a",
"Xtend",
"Interface",
"are",
"redundant",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L1625-L1632 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkBehaviorUnitGuardType | @Check(CheckType.FAST)
public void checkBehaviorUnitGuardType(SarlBehaviorUnit behaviorUnit) {
final XExpression guard = behaviorUnit.getGuard();
if (guard != null) {
if (this.operationHelper.hasSideEffects(null, guard)) {
error(Messages.SARLValidator_53,
guard,
null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
INVALID_INNER_EXPRESSION);
return;
}
if (guard instanceof XBooleanLiteral) {
final XBooleanLiteral booleanLiteral = (XBooleanLiteral) guard;
if (booleanLiteral.isIsTrue()) {
if (!isIgnored(DISCOURAGED_BOOLEAN_EXPRESSION)) {
addIssue(Messages.SARLValidator_54,
booleanLiteral,
null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
DISCOURAGED_BOOLEAN_EXPRESSION);
}
} else if (!isIgnored(UNREACHABLE_BEHAVIOR_UNIT)) {
addIssue(Messages.SARLValidator_55,
behaviorUnit,
null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
UNREACHABLE_BEHAVIOR_UNIT,
behaviorUnit.getName().getSimpleName());
}
return;
}
final LightweightTypeReference fromType = getActualType(guard);
if (!fromType.isAssignableFrom(Boolean.TYPE)) {
error(MessageFormat.format(
Messages.SARLValidator_38,
getNameOfTypes(fromType), boolean.class.getName()),
guard,
null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
INCOMPATIBLE_TYPES);
}
}
} | java | @Check(CheckType.FAST)
public void checkBehaviorUnitGuardType(SarlBehaviorUnit behaviorUnit) {
final XExpression guard = behaviorUnit.getGuard();
if (guard != null) {
if (this.operationHelper.hasSideEffects(null, guard)) {
error(Messages.SARLValidator_53,
guard,
null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
INVALID_INNER_EXPRESSION);
return;
}
if (guard instanceof XBooleanLiteral) {
final XBooleanLiteral booleanLiteral = (XBooleanLiteral) guard;
if (booleanLiteral.isIsTrue()) {
if (!isIgnored(DISCOURAGED_BOOLEAN_EXPRESSION)) {
addIssue(Messages.SARLValidator_54,
booleanLiteral,
null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
DISCOURAGED_BOOLEAN_EXPRESSION);
}
} else if (!isIgnored(UNREACHABLE_BEHAVIOR_UNIT)) {
addIssue(Messages.SARLValidator_55,
behaviorUnit,
null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
UNREACHABLE_BEHAVIOR_UNIT,
behaviorUnit.getName().getSimpleName());
}
return;
}
final LightweightTypeReference fromType = getActualType(guard);
if (!fromType.isAssignableFrom(Boolean.TYPE)) {
error(MessageFormat.format(
Messages.SARLValidator_38,
getNameOfTypes(fromType), boolean.class.getName()),
guard,
null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
INCOMPATIBLE_TYPES);
}
}
} | [
"@",
"Check",
"(",
"CheckType",
".",
"FAST",
")",
"public",
"void",
"checkBehaviorUnitGuardType",
"(",
"SarlBehaviorUnit",
"behaviorUnit",
")",
"{",
"final",
"XExpression",
"guard",
"=",
"behaviorUnit",
".",
"getGuard",
"(",
")",
";",
"if",
"(",
"guard",
"!=",... | Check the type of the behavior unit's guard.
@param behaviorUnit the behavior unit. | [
"Check",
"the",
"type",
"of",
"the",
"behavior",
"unit",
"s",
"guard",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L1638-L1682 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkCapacityTypeForUses | @Check(CheckType.FAST)
public void checkCapacityTypeForUses(SarlCapacityUses uses) {
for (final JvmParameterizedTypeReference usedType : uses.getCapacities()) {
final LightweightTypeReference ref = toLightweightTypeReference(usedType);
if (ref != null && !this.inheritanceHelper.isSarlCapacity(ref)) {
error(MessageFormat.format(
Messages.SARLValidator_57,
usedType.getQualifiedName(),
Messages.SARLValidator_58,
this.grammarAccess.getUsesKeyword()),
usedType,
null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
INVALID_CAPACITY_TYPE,
usedType.getSimpleName());
}
}
} | java | @Check(CheckType.FAST)
public void checkCapacityTypeForUses(SarlCapacityUses uses) {
for (final JvmParameterizedTypeReference usedType : uses.getCapacities()) {
final LightweightTypeReference ref = toLightweightTypeReference(usedType);
if (ref != null && !this.inheritanceHelper.isSarlCapacity(ref)) {
error(MessageFormat.format(
Messages.SARLValidator_57,
usedType.getQualifiedName(),
Messages.SARLValidator_58,
this.grammarAccess.getUsesKeyword()),
usedType,
null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
INVALID_CAPACITY_TYPE,
usedType.getSimpleName());
}
}
} | [
"@",
"Check",
"(",
"CheckType",
".",
"FAST",
")",
"public",
"void",
"checkCapacityTypeForUses",
"(",
"SarlCapacityUses",
"uses",
")",
"{",
"for",
"(",
"final",
"JvmParameterizedTypeReference",
"usedType",
":",
"uses",
".",
"getCapacities",
"(",
")",
")",
"{",
... | Check the type of the capacity uses.
@param uses the capacity uses. | [
"Check",
"the",
"type",
"of",
"the",
"capacity",
"uses",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L1688-L1705 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkActionFires | @Check(CheckType.FAST)
public void checkActionFires(SarlAction action) {
for (final JvmTypeReference event : action.getFiredEvents()) {
final LightweightTypeReference ref = toLightweightTypeReference(event);
if (ref != null && !this.inheritanceHelper.isSarlEvent(ref)) {
error(MessageFormat.format(
Messages.SARLValidator_57,
event.getQualifiedName(),
Messages.SARLValidator_62,
this.grammarAccess.getFiresKeyword()),
event,
null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
INVALID_FIRING_EVENT_TYPE,
event.getSimpleName());
}
}
} | java | @Check(CheckType.FAST)
public void checkActionFires(SarlAction action) {
for (final JvmTypeReference event : action.getFiredEvents()) {
final LightweightTypeReference ref = toLightweightTypeReference(event);
if (ref != null && !this.inheritanceHelper.isSarlEvent(ref)) {
error(MessageFormat.format(
Messages.SARLValidator_57,
event.getQualifiedName(),
Messages.SARLValidator_62,
this.grammarAccess.getFiresKeyword()),
event,
null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
INVALID_FIRING_EVENT_TYPE,
event.getSimpleName());
}
}
} | [
"@",
"Check",
"(",
"CheckType",
".",
"FAST",
")",
"public",
"void",
"checkActionFires",
"(",
"SarlAction",
"action",
")",
"{",
"for",
"(",
"final",
"JvmTypeReference",
"event",
":",
"action",
".",
"getFiredEvents",
"(",
")",
")",
"{",
"final",
"LightweightTy... | Check the types of the parameters of the "fires" statement.
@param action the signature that contains the "fires" statement. | [
"Check",
"the",
"types",
"of",
"the",
"parameters",
"of",
"the",
"fires",
"statement",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L1711-L1728 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkSuperTypes | @Check(CheckType.FAST)
public void checkSuperTypes(SarlCapacity capacity) {
checkSuperTypes(
capacity,
SARL_CAPACITY__EXTENDS,
capacity.getExtends(),
Capacity.class,
false);
} | java | @Check(CheckType.FAST)
public void checkSuperTypes(SarlCapacity capacity) {
checkSuperTypes(
capacity,
SARL_CAPACITY__EXTENDS,
capacity.getExtends(),
Capacity.class,
false);
} | [
"@",
"Check",
"(",
"CheckType",
".",
"FAST",
")",
"public",
"void",
"checkSuperTypes",
"(",
"SarlCapacity",
"capacity",
")",
"{",
"checkSuperTypes",
"(",
"capacity",
",",
"SARL_CAPACITY__EXTENDS",
",",
"capacity",
".",
"getExtends",
"(",
")",
",",
"Capacity",
... | Check if the supertype of the given capacity is a subtype of Capacity.
@param capacity the type to test. | [
"Check",
"if",
"the",
"supertype",
"of",
"the",
"given",
"capacity",
"is",
"a",
"subtype",
"of",
"Capacity",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L1838-L1846 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkSuperType | @Check(CheckType.FAST)
public void checkSuperType(SarlSkill skill) {
final int nbSuperTypes = checkSuperTypes(
skill,
SARL_SKILL__EXTENDS,
Utils.singletonList(skill.getExtends()),
Skill.class,
false);
checkImplementedTypes(
skill,
SARL_SKILL__IMPLEMENTS,
skill.getImplements(),
Capacity.class,
nbSuperTypes > 0 ? 0 : 1,
true);
} | java | @Check(CheckType.FAST)
public void checkSuperType(SarlSkill skill) {
final int nbSuperTypes = checkSuperTypes(
skill,
SARL_SKILL__EXTENDS,
Utils.singletonList(skill.getExtends()),
Skill.class,
false);
checkImplementedTypes(
skill,
SARL_SKILL__IMPLEMENTS,
skill.getImplements(),
Capacity.class,
nbSuperTypes > 0 ? 0 : 1,
true);
} | [
"@",
"Check",
"(",
"CheckType",
".",
"FAST",
")",
"public",
"void",
"checkSuperType",
"(",
"SarlSkill",
"skill",
")",
"{",
"final",
"int",
"nbSuperTypes",
"=",
"checkSuperTypes",
"(",
"skill",
",",
"SARL_SKILL__EXTENDS",
",",
"Utils",
".",
"singletonList",
"("... | Check if the supertype of the given skill is a subtype of Skill.
@param skill the type to test. | [
"Check",
"if",
"the",
"supertype",
"of",
"the",
"given",
"skill",
"is",
"a",
"subtype",
"of",
"Skill",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L1852-L1867 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkSuperType | @Check(CheckType.FAST)
public void checkSuperType(SarlEvent event) {
checkSuperTypes(
event,
SARL_EVENT__EXTENDS,
Utils.singletonList(event.getExtends()),
Event.class,
false);
} | java | @Check(CheckType.FAST)
public void checkSuperType(SarlEvent event) {
checkSuperTypes(
event,
SARL_EVENT__EXTENDS,
Utils.singletonList(event.getExtends()),
Event.class,
false);
} | [
"@",
"Check",
"(",
"CheckType",
".",
"FAST",
")",
"public",
"void",
"checkSuperType",
"(",
"SarlEvent",
"event",
")",
"{",
"checkSuperTypes",
"(",
"event",
",",
"SARL_EVENT__EXTENDS",
",",
"Utils",
".",
"singletonList",
"(",
"event",
".",
"getExtends",
"(",
... | Check if the supertype of the given event is a subtype of Event.
@param event the type to test. | [
"Check",
"if",
"the",
"supertype",
"of",
"the",
"given",
"event",
"is",
"a",
"subtype",
"of",
"Event",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L1873-L1881 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkSuperType | @Check(CheckType.FAST)
public void checkSuperType(SarlBehavior behavior) {
checkSuperTypes(
behavior,
SARL_BEHAVIOR__EXTENDS,
Utils.singletonList(behavior.getExtends()),
Behavior.class,
false);
} | java | @Check(CheckType.FAST)
public void checkSuperType(SarlBehavior behavior) {
checkSuperTypes(
behavior,
SARL_BEHAVIOR__EXTENDS,
Utils.singletonList(behavior.getExtends()),
Behavior.class,
false);
} | [
"@",
"Check",
"(",
"CheckType",
".",
"FAST",
")",
"public",
"void",
"checkSuperType",
"(",
"SarlBehavior",
"behavior",
")",
"{",
"checkSuperTypes",
"(",
"behavior",
",",
"SARL_BEHAVIOR__EXTENDS",
",",
"Utils",
".",
"singletonList",
"(",
"behavior",
".",
"getExte... | Check if the supertype of the given behavior is a subtype of Behavior.
@param behavior the type to test. | [
"Check",
"if",
"the",
"supertype",
"of",
"the",
"given",
"behavior",
"is",
"a",
"subtype",
"of",
"Behavior",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L1887-L1895 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkSuperType | @Check(CheckType.FAST)
public void checkSuperType(SarlAgent agent) {
checkSuperTypes(
agent,
SARL_AGENT__EXTENDS,
Utils.singletonList(agent.getExtends()),
Agent.class,
false);
} | java | @Check(CheckType.FAST)
public void checkSuperType(SarlAgent agent) {
checkSuperTypes(
agent,
SARL_AGENT__EXTENDS,
Utils.singletonList(agent.getExtends()),
Agent.class,
false);
} | [
"@",
"Check",
"(",
"CheckType",
".",
"FAST",
")",
"public",
"void",
"checkSuperType",
"(",
"SarlAgent",
"agent",
")",
"{",
"checkSuperTypes",
"(",
"agent",
",",
"SARL_AGENT__EXTENDS",
",",
"Utils",
".",
"singletonList",
"(",
"agent",
".",
"getExtends",
"(",
... | Check if the supertype of the given agent is a subtype of Agent.
@param agent the type to test. | [
"Check",
"if",
"the",
"supertype",
"of",
"the",
"given",
"agent",
"is",
"a",
"subtype",
"of",
"Agent",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L1901-L1909 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkImplementedTypes | protected boolean checkImplementedTypes(
XtendTypeDeclaration element,
EReference feature,
List<? extends JvmTypeReference> implementedTypes,
Class<?> expectedType,
int mandatoryNumberOfTypes,
boolean onlySubTypes) {
boolean success = true;
int nb = 0;
int index = 0;
for (final JvmTypeReference superType : implementedTypes) {
final LightweightTypeReference ref = toLightweightTypeReference(superType);
if (ref != null
&& (!ref.isInterfaceType() || !ref.isSubtypeOf(expectedType)
|| (onlySubTypes && ref.isType(expectedType)))) {
final String msg;
if (onlySubTypes) {
msg = Messages.SARLValidator_72;
} else {
msg = Messages.SARLValidator_73;
}
error(MessageFormat.format(
msg,
superType.getQualifiedName(),
expectedType.getName(),
element.getName()),
element,
feature,
index,
INVALID_IMPLEMENTED_TYPE,
superType.getSimpleName());
success = false;
} else {
++nb;
}
++index;
}
if (nb < mandatoryNumberOfTypes) {
error(MessageFormat.format(
Messages.SARLValidator_74,
expectedType.getName(),
element.getName()),
element,
feature,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
MISSING_TYPE);
success = false;
}
return success;
} | java | protected boolean checkImplementedTypes(
XtendTypeDeclaration element,
EReference feature,
List<? extends JvmTypeReference> implementedTypes,
Class<?> expectedType,
int mandatoryNumberOfTypes,
boolean onlySubTypes) {
boolean success = true;
int nb = 0;
int index = 0;
for (final JvmTypeReference superType : implementedTypes) {
final LightweightTypeReference ref = toLightweightTypeReference(superType);
if (ref != null
&& (!ref.isInterfaceType() || !ref.isSubtypeOf(expectedType)
|| (onlySubTypes && ref.isType(expectedType)))) {
final String msg;
if (onlySubTypes) {
msg = Messages.SARLValidator_72;
} else {
msg = Messages.SARLValidator_73;
}
error(MessageFormat.format(
msg,
superType.getQualifiedName(),
expectedType.getName(),
element.getName()),
element,
feature,
index,
INVALID_IMPLEMENTED_TYPE,
superType.getSimpleName());
success = false;
} else {
++nb;
}
++index;
}
if (nb < mandatoryNumberOfTypes) {
error(MessageFormat.format(
Messages.SARLValidator_74,
expectedType.getName(),
element.getName()),
element,
feature,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
MISSING_TYPE);
success = false;
}
return success;
} | [
"protected",
"boolean",
"checkImplementedTypes",
"(",
"XtendTypeDeclaration",
"element",
",",
"EReference",
"feature",
",",
"List",
"<",
"?",
"extends",
"JvmTypeReference",
">",
"implementedTypes",
",",
"Class",
"<",
"?",
">",
"expectedType",
",",
"int",
"mandatoryN... | Check the implemeted type.
@param element the child type.
@param feature the syntactic feature related to the supertypes.
@param implementedTypes the current super types.
@param expectedType the expected root type.
@param mandatoryNumberOfTypes the minimal number of implemented types.
@param onlySubTypes if <code>true</code> only the subtype of the <code>expectedType</code> are valid;
<code>false</code> if the <code>expectedType</code> is allowed.
@return the count of supertypes. | [
"Check",
"the",
"implemeted",
"type",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L1922-L1971 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkBehaviorUnitEventType | @Check(CheckType.FAST)
public void checkBehaviorUnitEventType(SarlBehaviorUnit behaviorUnit) {
final JvmTypeReference event = behaviorUnit.getName();
final LightweightTypeReference ref = toLightweightTypeReference(event);
if (ref == null || !this.inheritanceHelper.isSarlEvent(ref)) {
error(MessageFormat.format(
Messages.SARLValidator_75,
event.getQualifiedName(),
Messages.SARLValidator_62,
this.grammarAccess.getOnKeyword()),
event,
null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
TYPE_BOUNDS_MISMATCH);
}
} | java | @Check(CheckType.FAST)
public void checkBehaviorUnitEventType(SarlBehaviorUnit behaviorUnit) {
final JvmTypeReference event = behaviorUnit.getName();
final LightweightTypeReference ref = toLightweightTypeReference(event);
if (ref == null || !this.inheritanceHelper.isSarlEvent(ref)) {
error(MessageFormat.format(
Messages.SARLValidator_75,
event.getQualifiedName(),
Messages.SARLValidator_62,
this.grammarAccess.getOnKeyword()),
event,
null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
TYPE_BOUNDS_MISMATCH);
}
} | [
"@",
"Check",
"(",
"CheckType",
".",
"FAST",
")",
"public",
"void",
"checkBehaviorUnitEventType",
"(",
"SarlBehaviorUnit",
"behaviorUnit",
")",
"{",
"final",
"JvmTypeReference",
"event",
"=",
"behaviorUnit",
".",
"getName",
"(",
")",
";",
"final",
"LightweightType... | Check if the parameter of the bahavior unit is an event.
@param behaviorUnit the behavior unit to test. | [
"Check",
"if",
"the",
"parameter",
"of",
"the",
"bahavior",
"unit",
"is",
"an",
"event",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L1977-L1992 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkCapacityFeatures | @Check(CheckType.FAST)
public void checkCapacityFeatures(SarlCapacity capacity) {
if (capacity.getMembers().isEmpty()) {
if (!isIgnored(DISCOURAGED_CAPACITY_DEFINITION)) {
addIssue(Messages.SARLValidator_77,
capacity,
null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
DISCOURAGED_CAPACITY_DEFINITION,
capacity.getName(),
"aFunction"); //$NON-NLS-1$
}
}
} | java | @Check(CheckType.FAST)
public void checkCapacityFeatures(SarlCapacity capacity) {
if (capacity.getMembers().isEmpty()) {
if (!isIgnored(DISCOURAGED_CAPACITY_DEFINITION)) {
addIssue(Messages.SARLValidator_77,
capacity,
null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
DISCOURAGED_CAPACITY_DEFINITION,
capacity.getName(),
"aFunction"); //$NON-NLS-1$
}
}
} | [
"@",
"Check",
"(",
"CheckType",
".",
"FAST",
")",
"public",
"void",
"checkCapacityFeatures",
"(",
"SarlCapacity",
"capacity",
")",
"{",
"if",
"(",
"capacity",
".",
"getMembers",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"!",
"isIgnored",
... | Check if a capacity has a feature defined inside.
@param capacity the capacity to test. | [
"Check",
"if",
"a",
"capacity",
"has",
"a",
"feature",
"defined",
"inside",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L1998-L2011 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkUnusedCapacities | @Check(CheckType.NORMAL)
public void checkUnusedCapacities(SarlCapacityUses uses) {
if (!isIgnored(UNUSED_AGENT_CAPACITY)) {
final XtendTypeDeclaration container = uses.getDeclaringType();
final JvmDeclaredType jvmContainer = (JvmDeclaredType) this.associations.getPrimaryJvmElement(container);
final Map<String, JvmOperation> importedFeatures = CollectionLiterals.newHashMap();
for (final JvmOperation operation : jvmContainer.getDeclaredOperations()) {
if (Utils.isNameForHiddenCapacityImplementationCallingMethod(operation.getSimpleName())) {
importedFeatures.put(operation.getSimpleName(), operation);
}
}
final boolean isSkill = container instanceof SarlSkill;
int index = 0;
for (final JvmTypeReference capacity : uses.getCapacities()) {
final LightweightTypeReference lreference = toLightweightTypeReference(capacity);
if (isSkill && lreference.isAssignableFrom(jvmContainer)) {
addIssue(MessageFormat.format(
Messages.SARLValidator_22,
capacity.getSimpleName()),
uses,
SARL_CAPACITY_USES__CAPACITIES,
index, UNUSED_AGENT_CAPACITY,
capacity.getSimpleName());
} else {
final String fieldName = Utils.createNameForHiddenCapacityImplementationAttribute(capacity.getIdentifier());
final String operationName = Utils.createNameForHiddenCapacityImplementationCallingMethodFromFieldName(fieldName);
final JvmOperation operation = importedFeatures.get(operationName);
if (operation != null && !isLocallyUsed(operation, container)) {
addIssue(MessageFormat.format(
Messages.SARLValidator_78,
capacity.getSimpleName()),
uses,
SARL_CAPACITY_USES__CAPACITIES,
index, UNUSED_AGENT_CAPACITY,
capacity.getSimpleName());
}
}
++index;
}
}
} | java | @Check(CheckType.NORMAL)
public void checkUnusedCapacities(SarlCapacityUses uses) {
if (!isIgnored(UNUSED_AGENT_CAPACITY)) {
final XtendTypeDeclaration container = uses.getDeclaringType();
final JvmDeclaredType jvmContainer = (JvmDeclaredType) this.associations.getPrimaryJvmElement(container);
final Map<String, JvmOperation> importedFeatures = CollectionLiterals.newHashMap();
for (final JvmOperation operation : jvmContainer.getDeclaredOperations()) {
if (Utils.isNameForHiddenCapacityImplementationCallingMethod(operation.getSimpleName())) {
importedFeatures.put(operation.getSimpleName(), operation);
}
}
final boolean isSkill = container instanceof SarlSkill;
int index = 0;
for (final JvmTypeReference capacity : uses.getCapacities()) {
final LightweightTypeReference lreference = toLightweightTypeReference(capacity);
if (isSkill && lreference.isAssignableFrom(jvmContainer)) {
addIssue(MessageFormat.format(
Messages.SARLValidator_22,
capacity.getSimpleName()),
uses,
SARL_CAPACITY_USES__CAPACITIES,
index, UNUSED_AGENT_CAPACITY,
capacity.getSimpleName());
} else {
final String fieldName = Utils.createNameForHiddenCapacityImplementationAttribute(capacity.getIdentifier());
final String operationName = Utils.createNameForHiddenCapacityImplementationCallingMethodFromFieldName(fieldName);
final JvmOperation operation = importedFeatures.get(operationName);
if (operation != null && !isLocallyUsed(operation, container)) {
addIssue(MessageFormat.format(
Messages.SARLValidator_78,
capacity.getSimpleName()),
uses,
SARL_CAPACITY_USES__CAPACITIES,
index, UNUSED_AGENT_CAPACITY,
capacity.getSimpleName());
}
}
++index;
}
}
} | [
"@",
"Check",
"(",
"CheckType",
".",
"NORMAL",
")",
"public",
"void",
"checkUnusedCapacities",
"(",
"SarlCapacityUses",
"uses",
")",
"{",
"if",
"(",
"!",
"isIgnored",
"(",
"UNUSED_AGENT_CAPACITY",
")",
")",
"{",
"final",
"XtendTypeDeclaration",
"container",
"=",... | Check for unused capacities.
@param uses the capacity use declaration. | [
"Check",
"for",
"unused",
"capacities",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L2017-L2058 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkMultipleCapacityUses | @Check(CheckType.NORMAL)
public void checkMultipleCapacityUses(SarlCapacityUses uses) {
if (!isIgnored(REDUNDANT_CAPACITY_USE)) {
final XtendTypeDeclaration declaringType = uses.getDeclaringType();
if (declaringType != null) {
final Set<String> previousCapacityUses = doGetPreviousCapacities(uses,
declaringType.getMembers().iterator());
int index = 0;
for (final JvmTypeReference capacity : uses.getCapacities()) {
if (previousCapacityUses.contains(capacity.getIdentifier())) {
addIssue(MessageFormat.format(
Messages.SARLValidator_79,
capacity.getSimpleName()),
uses,
SARL_CAPACITY_USES__CAPACITIES,
index,
REDUNDANT_CAPACITY_USE,
capacity.getSimpleName());
} else {
previousCapacityUses.add(capacity.getIdentifier());
}
++index;
}
}
}
} | java | @Check(CheckType.NORMAL)
public void checkMultipleCapacityUses(SarlCapacityUses uses) {
if (!isIgnored(REDUNDANT_CAPACITY_USE)) {
final XtendTypeDeclaration declaringType = uses.getDeclaringType();
if (declaringType != null) {
final Set<String> previousCapacityUses = doGetPreviousCapacities(uses,
declaringType.getMembers().iterator());
int index = 0;
for (final JvmTypeReference capacity : uses.getCapacities()) {
if (previousCapacityUses.contains(capacity.getIdentifier())) {
addIssue(MessageFormat.format(
Messages.SARLValidator_79,
capacity.getSimpleName()),
uses,
SARL_CAPACITY_USES__CAPACITIES,
index,
REDUNDANT_CAPACITY_USE,
capacity.getSimpleName());
} else {
previousCapacityUses.add(capacity.getIdentifier());
}
++index;
}
}
}
} | [
"@",
"Check",
"(",
"CheckType",
".",
"NORMAL",
")",
"public",
"void",
"checkMultipleCapacityUses",
"(",
"SarlCapacityUses",
"uses",
")",
"{",
"if",
"(",
"!",
"isIgnored",
"(",
"REDUNDANT_CAPACITY_USE",
")",
")",
"{",
"final",
"XtendTypeDeclaration",
"declaringType... | Check for multiple capacity use declaration.
@param uses the capacity use declaration. | [
"Check",
"for",
"multiple",
"capacity",
"use",
"declaration",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L2083-L2108 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkReservedAnnotation | @Check
public void checkReservedAnnotation(XtendAnnotationTarget annotationTarget) {
if (!isIgnored(USED_RESERVED_SARL_ANNOTATION)) {
if (annotationTarget.getAnnotations().isEmpty() || !isRelevantAnnotationTarget(annotationTarget)) {
return;
}
final QualifiedName reservedPackage = this.qualifiedNameConverter.toQualifiedName(
EarlyExit.class.getPackage().getName());
final String earlyExitAnnotation = EarlyExit.class.getName();
for (final XAnnotation annotation : annotationTarget.getAnnotations()) {
final JvmType type = annotation.getAnnotationType();
if (type != null && !type.eIsProxy()) {
if (Objects.equal(type.getIdentifier(), earlyExitAnnotation)) {
// Special case: EarlyExit is allowed on events for declaring early-exit events
if (!(annotationTarget instanceof SarlEvent)) {
addIssue(
MessageFormat.format(Messages.SARLValidator_87, type.getSimpleName()),
annotation,
USED_RESERVED_SARL_ANNOTATION);
}
} else {
final QualifiedName annotationName = this.qualifiedNameConverter.toQualifiedName(
type.getIdentifier());
if (annotationName.startsWith(reservedPackage)) {
addIssue(
MessageFormat.format(Messages.SARLValidator_87, type.getSimpleName()),
annotation,
USED_RESERVED_SARL_ANNOTATION);
}
}
}
}
}
} | java | @Check
public void checkReservedAnnotation(XtendAnnotationTarget annotationTarget) {
if (!isIgnored(USED_RESERVED_SARL_ANNOTATION)) {
if (annotationTarget.getAnnotations().isEmpty() || !isRelevantAnnotationTarget(annotationTarget)) {
return;
}
final QualifiedName reservedPackage = this.qualifiedNameConverter.toQualifiedName(
EarlyExit.class.getPackage().getName());
final String earlyExitAnnotation = EarlyExit.class.getName();
for (final XAnnotation annotation : annotationTarget.getAnnotations()) {
final JvmType type = annotation.getAnnotationType();
if (type != null && !type.eIsProxy()) {
if (Objects.equal(type.getIdentifier(), earlyExitAnnotation)) {
// Special case: EarlyExit is allowed on events for declaring early-exit events
if (!(annotationTarget instanceof SarlEvent)) {
addIssue(
MessageFormat.format(Messages.SARLValidator_87, type.getSimpleName()),
annotation,
USED_RESERVED_SARL_ANNOTATION);
}
} else {
final QualifiedName annotationName = this.qualifiedNameConverter.toQualifiedName(
type.getIdentifier());
if (annotationName.startsWith(reservedPackage)) {
addIssue(
MessageFormat.format(Messages.SARLValidator_87, type.getSimpleName()),
annotation,
USED_RESERVED_SARL_ANNOTATION);
}
}
}
}
}
} | [
"@",
"Check",
"public",
"void",
"checkReservedAnnotation",
"(",
"XtendAnnotationTarget",
"annotationTarget",
")",
"{",
"if",
"(",
"!",
"isIgnored",
"(",
"USED_RESERVED_SARL_ANNOTATION",
")",
")",
"{",
"if",
"(",
"annotationTarget",
".",
"getAnnotations",
"(",
")",
... | Check for reserved annotations.
@param annotationTarget thee target to test. | [
"Check",
"for",
"reserved",
"annotations",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L2197-L2230 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.getRootOfMemberFeatureCallSequence | protected static XMemberFeatureCall getRootOfMemberFeatureCallSequence(EObject leaf, EObject container,
Procedure1<XMemberFeatureCall> feedback) {
EObject call = leaf;
EObject obj = EcoreUtil2.getContainerOfType(leaf.eContainer(), XExpression.class);
while (obj != null && (container == null || obj != container)) {
if (!(obj instanceof XMemberFeatureCall)) {
obj = null;
} else {
final EObject previous = call;
final XMemberFeatureCall fcall = (XMemberFeatureCall) obj;
call = fcall;
if (fcall.getActualReceiver() == previous) {
// Sequence of calls, with the '.' char.
if (feedback != null) {
feedback.apply(fcall);
}
obj = EcoreUtil2.getContainerOfType(call.eContainer(), XExpression.class);
} else if (fcall.getActualArguments().contains(previous)) {
// The sequence is an argument of a function call.
call = previous;
obj = null;
} else {
obj = null;
}
}
}
return call instanceof XMemberFeatureCall ? (XMemberFeatureCall) call : null;
} | java | protected static XMemberFeatureCall getRootOfMemberFeatureCallSequence(EObject leaf, EObject container,
Procedure1<XMemberFeatureCall> feedback) {
EObject call = leaf;
EObject obj = EcoreUtil2.getContainerOfType(leaf.eContainer(), XExpression.class);
while (obj != null && (container == null || obj != container)) {
if (!(obj instanceof XMemberFeatureCall)) {
obj = null;
} else {
final EObject previous = call;
final XMemberFeatureCall fcall = (XMemberFeatureCall) obj;
call = fcall;
if (fcall.getActualReceiver() == previous) {
// Sequence of calls, with the '.' char.
if (feedback != null) {
feedback.apply(fcall);
}
obj = EcoreUtil2.getContainerOfType(call.eContainer(), XExpression.class);
} else if (fcall.getActualArguments().contains(previous)) {
// The sequence is an argument of a function call.
call = previous;
obj = null;
} else {
obj = null;
}
}
}
return call instanceof XMemberFeatureCall ? (XMemberFeatureCall) call : null;
} | [
"protected",
"static",
"XMemberFeatureCall",
"getRootOfMemberFeatureCallSequence",
"(",
"EObject",
"leaf",
",",
"EObject",
"container",
",",
"Procedure1",
"<",
"XMemberFeatureCall",
">",
"feedback",
")",
"{",
"EObject",
"call",
"=",
"leaf",
";",
"EObject",
"obj",
"=... | Replies the member feature call that is the root of a sequence of member feature calls.
<p>While the current feature call is the actual receiver of a member feature call, and not an argument,
the sequence is still active. Otherwise, the sequence is stopped.
@param leaf the expression at the leaf of the feature call.
@param container the top most container that cannot be part of the sequence. Could be {@code null}.
@param feedback the function that is invoked on each discovered member feature call within the sequence. Could be {@code null}.
@return the root of a member feature call sequence. | [
"Replies",
"the",
"member",
"feature",
"call",
"that",
"is",
"the",
"root",
"of",
"a",
"sequence",
"of",
"member",
"feature",
"calls",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L2267-L2294 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.getParamTypeReferences | protected List<LightweightTypeReference> getParamTypeReferences(JvmExecutable jvmExecutable,
boolean wrapFromPrimitives, boolean wrapToPrimitives) {
assert (wrapFromPrimitives && !wrapToPrimitives) || (wrapToPrimitives && !wrapFromPrimitives);
final List<LightweightTypeReference> types = newArrayList();
for (final JvmFormalParameter parameter : jvmExecutable.getParameters()) {
LightweightTypeReference typeReference = toLightweightTypeReference(parameter.getParameterType());
if (wrapFromPrimitives) {
typeReference = typeReference.getWrapperTypeIfPrimitive();
} else if (wrapToPrimitives) {
typeReference = typeReference.getPrimitiveIfWrapperType();
}
types.add(typeReference);
}
return types;
} | java | protected List<LightweightTypeReference> getParamTypeReferences(JvmExecutable jvmExecutable,
boolean wrapFromPrimitives, boolean wrapToPrimitives) {
assert (wrapFromPrimitives && !wrapToPrimitives) || (wrapToPrimitives && !wrapFromPrimitives);
final List<LightweightTypeReference> types = newArrayList();
for (final JvmFormalParameter parameter : jvmExecutable.getParameters()) {
LightweightTypeReference typeReference = toLightweightTypeReference(parameter.getParameterType());
if (wrapFromPrimitives) {
typeReference = typeReference.getWrapperTypeIfPrimitive();
} else if (wrapToPrimitives) {
typeReference = typeReference.getPrimitiveIfWrapperType();
}
types.add(typeReference);
}
return types;
} | [
"protected",
"List",
"<",
"LightweightTypeReference",
">",
"getParamTypeReferences",
"(",
"JvmExecutable",
"jvmExecutable",
",",
"boolean",
"wrapFromPrimitives",
",",
"boolean",
"wrapToPrimitives",
")",
"{",
"assert",
"(",
"wrapFromPrimitives",
"&&",
"!",
"wrapToPrimitive... | Retrieve the types of the formal parameters of the given JVM executable object.
@param jvmExecutable the JVM executable.
@param wrapFromPrimitives indicates if the primitive types must be wrapped to object type equivalent.
@param wrapToPrimitives indicates if the object types must be wrapped to primitive type equivalent.
@return the list of types.
@since 0.8
@see #getParamTypes(JvmOperation, boolean) | [
"Retrieve",
"the",
"types",
"of",
"the",
"formal",
"parameters",
"of",
"the",
"given",
"JVM",
"executable",
"object",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L2429-L2443 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkUnmodifiableEventAccess | @Check
public void checkUnmodifiableEventAccess(SarlBehaviorUnit unit) {
final boolean enable1 = !isIgnored(DISCOURAGED_OCCURRENCE_READONLY_USE);
final XExpression root = unit.getExpression();
final String occurrenceKw = this.grammarAccess.getOccurrenceKeyword();
for (final XFeatureCall child : EcoreUtil2.getAllContentsOfType(root, XFeatureCall.class)) {
if (occurrenceKw.equals(child.getFeature().getIdentifier())) {
checkUnmodifiableFeatureAccess(enable1, child, occurrenceKw);
}
}
} | java | @Check
public void checkUnmodifiableEventAccess(SarlBehaviorUnit unit) {
final boolean enable1 = !isIgnored(DISCOURAGED_OCCURRENCE_READONLY_USE);
final XExpression root = unit.getExpression();
final String occurrenceKw = this.grammarAccess.getOccurrenceKeyword();
for (final XFeatureCall child : EcoreUtil2.getAllContentsOfType(root, XFeatureCall.class)) {
if (occurrenceKw.equals(child.getFeature().getIdentifier())) {
checkUnmodifiableFeatureAccess(enable1, child, occurrenceKw);
}
}
} | [
"@",
"Check",
"public",
"void",
"checkUnmodifiableEventAccess",
"(",
"SarlBehaviorUnit",
"unit",
")",
"{",
"final",
"boolean",
"enable1",
"=",
"!",
"isIgnored",
"(",
"DISCOURAGED_OCCURRENCE_READONLY_USE",
")",
";",
"final",
"XExpression",
"root",
"=",
"unit",
".",
... | Check for usage of the event functions in the behavior units.
@param unit the unit to analyze. | [
"Check",
"for",
"usage",
"of",
"the",
"event",
"functions",
"in",
"the",
"behavior",
"units",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L2449-L2459 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkBreakKeywordUse | @Check
public void checkBreakKeywordUse(SarlBreakExpression expression) {
final EObject container = Utils.getFirstContainerForPredicate(expression,
it -> !(it instanceof XExpression) || it instanceof XAbstractWhileExpression
|| it instanceof XBasicForLoopExpression || it instanceof XForLoopExpression);
if (container instanceof XExpression) {
if (!isIgnored(DISCOURAGED_LOOP_BREAKING_KEYWORD_USE)
&& container instanceof XBasicForLoopExpression) {
addIssue(
MessageFormat.format(Messages.SARLValidator_17, this.grammarAccess.getBreakKeyword()),
expression,
null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
DISCOURAGED_LOOP_BREAKING_KEYWORD_USE);
}
} else {
error(MessageFormat.format(Messages.SARLValidator_18, this.grammarAccess.getBreakKeyword()),
expression,
null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
INVALID_USE_OF_LOOP_BREAKING_KEYWORD);
}
} | java | @Check
public void checkBreakKeywordUse(SarlBreakExpression expression) {
final EObject container = Utils.getFirstContainerForPredicate(expression,
it -> !(it instanceof XExpression) || it instanceof XAbstractWhileExpression
|| it instanceof XBasicForLoopExpression || it instanceof XForLoopExpression);
if (container instanceof XExpression) {
if (!isIgnored(DISCOURAGED_LOOP_BREAKING_KEYWORD_USE)
&& container instanceof XBasicForLoopExpression) {
addIssue(
MessageFormat.format(Messages.SARLValidator_17, this.grammarAccess.getBreakKeyword()),
expression,
null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
DISCOURAGED_LOOP_BREAKING_KEYWORD_USE);
}
} else {
error(MessageFormat.format(Messages.SARLValidator_18, this.grammarAccess.getBreakKeyword()),
expression,
null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
INVALID_USE_OF_LOOP_BREAKING_KEYWORD);
}
} | [
"@",
"Check",
"public",
"void",
"checkBreakKeywordUse",
"(",
"SarlBreakExpression",
"expression",
")",
"{",
"final",
"EObject",
"container",
"=",
"Utils",
".",
"getFirstContainerForPredicate",
"(",
"expression",
",",
"it",
"->",
"!",
"(",
"it",
"instanceof",
"XExp... | Check for usage of break inside loops.
@param expression the expression to analyze. | [
"Check",
"for",
"usage",
"of",
"break",
"inside",
"loops",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L2465-L2487 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkStaticConstructorPrototype | @Check
public void checkStaticConstructorPrototype(XtendConstructor constructor) {
if (constructor.isStatic()) {
if (!constructor.getAnnotations().isEmpty()) {
error(Messages.SARLValidator_23,
constructor,
XtendPackage.eINSTANCE.getXtendAnnotationTarget_Annotations(),
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
ANNOTATION_WRONG_TARGET);
}
if (!constructor.getTypeParameters().isEmpty()) {
error(Messages.SARLValidator_24,
constructor,
XtendPackage.eINSTANCE.getXtendExecutable_TypeParameters(),
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
CONSTRUCTOR_TYPE_PARAMS_NOT_SUPPORTED);
}
if (!constructor.getParameters().isEmpty()) {
error(Messages.SARLValidator_26,
constructor,
XtendPackage.eINSTANCE.getXtendExecutable_Parameters(),
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
UNEXPECTED_FORMAL_PARAMETER);
}
if (!constructor.getExceptions().isEmpty()) {
error(Messages.SARLValidator_27,
constructor,
XtendPackage.eINSTANCE.getXtendExecutable_Parameters(),
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
UNEXPECTED_EXCEPTION_THROW);
}
if (constructor.getExpression() == null) {
error(Messages.SARLValidator_83,
constructor,
XtendPackage.eINSTANCE.getXtendExecutable_Expression(),
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
MISSING_BODY);
}
}
} | java | @Check
public void checkStaticConstructorPrototype(XtendConstructor constructor) {
if (constructor.isStatic()) {
if (!constructor.getAnnotations().isEmpty()) {
error(Messages.SARLValidator_23,
constructor,
XtendPackage.eINSTANCE.getXtendAnnotationTarget_Annotations(),
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
ANNOTATION_WRONG_TARGET);
}
if (!constructor.getTypeParameters().isEmpty()) {
error(Messages.SARLValidator_24,
constructor,
XtendPackage.eINSTANCE.getXtendExecutable_TypeParameters(),
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
CONSTRUCTOR_TYPE_PARAMS_NOT_SUPPORTED);
}
if (!constructor.getParameters().isEmpty()) {
error(Messages.SARLValidator_26,
constructor,
XtendPackage.eINSTANCE.getXtendExecutable_Parameters(),
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
UNEXPECTED_FORMAL_PARAMETER);
}
if (!constructor.getExceptions().isEmpty()) {
error(Messages.SARLValidator_27,
constructor,
XtendPackage.eINSTANCE.getXtendExecutable_Parameters(),
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
UNEXPECTED_EXCEPTION_THROW);
}
if (constructor.getExpression() == null) {
error(Messages.SARLValidator_83,
constructor,
XtendPackage.eINSTANCE.getXtendExecutable_Expression(),
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
MISSING_BODY);
}
}
} | [
"@",
"Check",
"public",
"void",
"checkStaticConstructorPrototype",
"(",
"XtendConstructor",
"constructor",
")",
"{",
"if",
"(",
"constructor",
".",
"isStatic",
"(",
")",
")",
"{",
"if",
"(",
"!",
"constructor",
".",
"getAnnotations",
"(",
")",
".",
"isEmpty",
... | Check for a valid prototype of a static constructor.
@param constructor the constructor to analyze. | [
"Check",
"for",
"a",
"valid",
"prototype",
"of",
"a",
"static",
"constructor",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L2572-L2611 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkUnsynchronizedField | @Check
@SuppressWarnings({"checkstyle:nestedifdepth", "checkstyle:npathcomplexity", "checkstyle:cyclomaticcomplexity"})
public void checkUnsynchronizedField(XtendField field) {
if (doCheckValidMemberName(field) && !isIgnored(POTENTIAL_FIELD_SYNCHRONIZATION_PROBLEM)) {
final JvmField jvmField = this.associations.getJvmField(field);
if (jvmField == null || jvmField.eContainer() == null || jvmField.isConstant() || jvmField.isFinal()) {
return;
}
final EObject scope = getOutermostType(field);
if ((scope instanceof SarlAgent || scope instanceof SarlBehavior
|| scope instanceof SarlSkill) && isLocallyAssigned(jvmField, scope)) {
final Collection<Setting> usages = XbaseUsageCrossReferencer.find(jvmField, scope);
final Set<XtendMember> blocks = new HashSet<>();
boolean isAccessibleFromOutside = jvmField.getVisibility() != JvmVisibility.PRIVATE;
final Collection<Setting> pbUsages = new ArrayList<>();
for (final Setting usage : usages) {
final XtendMember member = EcoreUtil2.getContainerOfType(usage.getEObject(), XtendMember.class);
if (member instanceof XtendFunction) {
final XtendFunction fct = (XtendFunction) member;
blocks.add(member);
if (member.getVisibility() != JvmVisibility.PRIVATE) {
isAccessibleFromOutside = true;
}
if (!fct.isSynchonized()) {
pbUsages.add(usage);
}
} else if (member instanceof SarlBehaviorUnit) {
blocks.add(member);
isAccessibleFromOutside = true;
pbUsages.add(usage);
}
}
for (final Setting usage : pbUsages) {
boolean synchronizationIssue = false;
if (isAccessibleFromOutside || blocks.size() > 1) {
synchronizationIssue = true;
} else {
// TODO: Refine the function call detection
synchronizationIssue = true;
}
// Check if the field is already locally synchronized
if (synchronizationIssue) {
final XSynchronizedExpression syncExpr = EcoreUtil2.getContainerOfType(
usage.getEObject(), XSynchronizedExpression.class);
if (syncExpr != null) {
synchronizationIssue = false;
}
}
if (synchronizationIssue
&& !isIgnored(POTENTIAL_FIELD_SYNCHRONIZATION_PROBLEM,
usage.getEObject())) {
addIssue(
MessageFormat.format(Messages.SARLValidator_91, field.getName()),
usage.getEObject(),
usage.getEStructuralFeature(),
POTENTIAL_FIELD_SYNCHRONIZATION_PROBLEM);
}
}
}
}
} | java | @Check
@SuppressWarnings({"checkstyle:nestedifdepth", "checkstyle:npathcomplexity", "checkstyle:cyclomaticcomplexity"})
public void checkUnsynchronizedField(XtendField field) {
if (doCheckValidMemberName(field) && !isIgnored(POTENTIAL_FIELD_SYNCHRONIZATION_PROBLEM)) {
final JvmField jvmField = this.associations.getJvmField(field);
if (jvmField == null || jvmField.eContainer() == null || jvmField.isConstant() || jvmField.isFinal()) {
return;
}
final EObject scope = getOutermostType(field);
if ((scope instanceof SarlAgent || scope instanceof SarlBehavior
|| scope instanceof SarlSkill) && isLocallyAssigned(jvmField, scope)) {
final Collection<Setting> usages = XbaseUsageCrossReferencer.find(jvmField, scope);
final Set<XtendMember> blocks = new HashSet<>();
boolean isAccessibleFromOutside = jvmField.getVisibility() != JvmVisibility.PRIVATE;
final Collection<Setting> pbUsages = new ArrayList<>();
for (final Setting usage : usages) {
final XtendMember member = EcoreUtil2.getContainerOfType(usage.getEObject(), XtendMember.class);
if (member instanceof XtendFunction) {
final XtendFunction fct = (XtendFunction) member;
blocks.add(member);
if (member.getVisibility() != JvmVisibility.PRIVATE) {
isAccessibleFromOutside = true;
}
if (!fct.isSynchonized()) {
pbUsages.add(usage);
}
} else if (member instanceof SarlBehaviorUnit) {
blocks.add(member);
isAccessibleFromOutside = true;
pbUsages.add(usage);
}
}
for (final Setting usage : pbUsages) {
boolean synchronizationIssue = false;
if (isAccessibleFromOutside || blocks.size() > 1) {
synchronizationIssue = true;
} else {
// TODO: Refine the function call detection
synchronizationIssue = true;
}
// Check if the field is already locally synchronized
if (synchronizationIssue) {
final XSynchronizedExpression syncExpr = EcoreUtil2.getContainerOfType(
usage.getEObject(), XSynchronizedExpression.class);
if (syncExpr != null) {
synchronizationIssue = false;
}
}
if (synchronizationIssue
&& !isIgnored(POTENTIAL_FIELD_SYNCHRONIZATION_PROBLEM,
usage.getEObject())) {
addIssue(
MessageFormat.format(Messages.SARLValidator_91, field.getName()),
usage.getEObject(),
usage.getEStructuralFeature(),
POTENTIAL_FIELD_SYNCHRONIZATION_PROBLEM);
}
}
}
}
} | [
"@",
"Check",
"@",
"SuppressWarnings",
"(",
"{",
"\"checkstyle:nestedifdepth\"",
",",
"\"checkstyle:npathcomplexity\"",
",",
"\"checkstyle:cyclomaticcomplexity\"",
"}",
")",
"public",
"void",
"checkUnsynchronizedField",
"(",
"XtendField",
"field",
")",
"{",
"if",
"(",
"... | Check if a field needs to be synchronized.
@param field the field.
@since 0.7 | [
"Check",
"if",
"a",
"field",
"needs",
"to",
"be",
"synchronized",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L2618-L2678 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.isLocallyAssigned | protected boolean isLocallyAssigned(EObject target, EObject containerToFindUsage) {
if (this.readAndWriteTracking.isAssigned(target)) {
return true;
}
final Collection<Setting> usages = XbaseUsageCrossReferencer.find(target, containerToFindUsage);
// field are assigned when they are not used as the left operand of an assignment operator.
for (final Setting usage : usages) {
final EObject object = usage.getEObject();
if (object instanceof XAssignment) {
final XAssignment assignment = (XAssignment) object;
if (assignment.getFeature() == target) {
// Mark the field as assigned in order to be faster during the next assignment test.
this.readAndWriteTracking.markAssignmentAccess(target);
return true;
}
}
}
return false;
} | java | protected boolean isLocallyAssigned(EObject target, EObject containerToFindUsage) {
if (this.readAndWriteTracking.isAssigned(target)) {
return true;
}
final Collection<Setting> usages = XbaseUsageCrossReferencer.find(target, containerToFindUsage);
// field are assigned when they are not used as the left operand of an assignment operator.
for (final Setting usage : usages) {
final EObject object = usage.getEObject();
if (object instanceof XAssignment) {
final XAssignment assignment = (XAssignment) object;
if (assignment.getFeature() == target) {
// Mark the field as assigned in order to be faster during the next assignment test.
this.readAndWriteTracking.markAssignmentAccess(target);
return true;
}
}
}
return false;
} | [
"protected",
"boolean",
"isLocallyAssigned",
"(",
"EObject",
"target",
",",
"EObject",
"containerToFindUsage",
")",
"{",
"if",
"(",
"this",
".",
"readAndWriteTracking",
".",
"isAssigned",
"(",
"target",
")",
")",
"{",
"return",
"true",
";",
"}",
"final",
"Coll... | Replies if the given object is locally assigned.
<p>An object is locally assigned when it is the left operand of an assignment operation.
@param target the object to test.
@param containerToFindUsage the container in which the usages should be find.
@return {@code true} if the given object is assigned.
@since 0.7 | [
"Replies",
"if",
"the",
"given",
"object",
"is",
"locally",
"assigned",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L2718-L2736 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.isOOType | @SuppressWarnings("static-method")
protected boolean isOOType(XtendTypeDeclaration type) {
return type instanceof XtendClass
|| type instanceof XtendInterface
|| type instanceof XtendEnum
|| type instanceof XtendAnnotationType;
} | java | @SuppressWarnings("static-method")
protected boolean isOOType(XtendTypeDeclaration type) {
return type instanceof XtendClass
|| type instanceof XtendInterface
|| type instanceof XtendEnum
|| type instanceof XtendAnnotationType;
} | [
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"protected",
"boolean",
"isOOType",
"(",
"XtendTypeDeclaration",
"type",
")",
"{",
"return",
"type",
"instanceof",
"XtendClass",
"||",
"type",
"instanceof",
"XtendInterface",
"||",
"type",
"instanceof",
"XtendEnu... | Replies if the given element is an object oriented type.
@param type the type to test.
@return {@code true} if the type is an object oriented type. | [
"Replies",
"if",
"the",
"given",
"element",
"is",
"an",
"object",
"oriented",
"type",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L2844-L2850 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.isOOActiveAnnotation | @SuppressWarnings("static-method")
protected boolean isOOActiveAnnotation(XAnnotation annotation) {
final String name = annotation.getAnnotationType().getQualifiedName();
return Strings.equal(Accessors.class.getName(), name)
|| Strings.equal(Data.class.getName(), name)
|| Strings.equal(Delegate.class.getName(), name)
|| Strings.equal(ToString.class.getName(), name);
} | java | @SuppressWarnings("static-method")
protected boolean isOOActiveAnnotation(XAnnotation annotation) {
final String name = annotation.getAnnotationType().getQualifiedName();
return Strings.equal(Accessors.class.getName(), name)
|| Strings.equal(Data.class.getName(), name)
|| Strings.equal(Delegate.class.getName(), name)
|| Strings.equal(ToString.class.getName(), name);
} | [
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"protected",
"boolean",
"isOOActiveAnnotation",
"(",
"XAnnotation",
"annotation",
")",
"{",
"final",
"String",
"name",
"=",
"annotation",
".",
"getAnnotationType",
"(",
")",
".",
"getQualifiedName",
"(",
")",
... | Replies if the given annotation is an active annotation for object-oriented elements.
@param annotation the annotation.
@return {@code true} if the annotation should be used only for OO elements.
@see #isAOActiveAnnotation(XAnnotation) | [
"Replies",
"if",
"the",
"given",
"annotation",
"is",
"an",
"active",
"annotation",
"for",
"object",
"-",
"oriented",
"elements",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L2858-L2865 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.isAOActiveAnnotation | @SuppressWarnings("static-method")
protected boolean isAOActiveAnnotation(XAnnotation annotation) {
final String name = annotation.getAnnotationType().getQualifiedName();
return Strings.equal(Accessors.class.getName(), name);
} | java | @SuppressWarnings("static-method")
protected boolean isAOActiveAnnotation(XAnnotation annotation) {
final String name = annotation.getAnnotationType().getQualifiedName();
return Strings.equal(Accessors.class.getName(), name);
} | [
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"protected",
"boolean",
"isAOActiveAnnotation",
"(",
"XAnnotation",
"annotation",
")",
"{",
"final",
"String",
"name",
"=",
"annotation",
".",
"getAnnotationType",
"(",
")",
".",
"getQualifiedName",
"(",
")",
... | Replies if the given container can receive an active annotation.
@param annotation the annotation.
@return {@code true} if the annotation should be used only for OO elements.
@see #isOOActiveAnnotation(XAnnotation)
@see #isAOActiveAnnotationReceiver(XtendTypeDeclaration) | [
"Replies",
"if",
"the",
"given",
"container",
"can",
"receive",
"an",
"active",
"annotation",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L2874-L2878 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.isAOActiveAnnotationReceiver | @SuppressWarnings("static-method")
protected boolean isAOActiveAnnotationReceiver(XtendTypeDeclaration container) {
return container instanceof SarlAgent
|| container instanceof SarlBehavior
|| container instanceof SarlSkill;
} | java | @SuppressWarnings("static-method")
protected boolean isAOActiveAnnotationReceiver(XtendTypeDeclaration container) {
return container instanceof SarlAgent
|| container instanceof SarlBehavior
|| container instanceof SarlSkill;
} | [
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"protected",
"boolean",
"isAOActiveAnnotationReceiver",
"(",
"XtendTypeDeclaration",
"container",
")",
"{",
"return",
"container",
"instanceof",
"SarlAgent",
"||",
"container",
"instanceof",
"SarlBehavior",
"||",
"co... | Replies if the given annotation is an active annotation for agent-oriented elements.
@param container the container to test.
@return {@code true} if the container could receive an active annotation.
@see #isOOActiveAnnotation(XAnnotation)
@see #isAOActiveAnnotation(XAnnotation) | [
"Replies",
"if",
"the",
"given",
"annotation",
"is",
"an",
"active",
"annotation",
"for",
"agent",
"-",
"oriented",
"elements",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L2887-L2892 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.isForbiddenActiveAnnotation | @SuppressWarnings("static-method")
protected boolean isForbiddenActiveAnnotation(XAnnotation annotation) {
final String name = annotation.getAnnotationType().getQualifiedName();
return Strings.equal(EqualsHashCode.class.getName(), name)
|| Strings.equal(FinalFieldsConstructor.class.getName(), name);
} | java | @SuppressWarnings("static-method")
protected boolean isForbiddenActiveAnnotation(XAnnotation annotation) {
final String name = annotation.getAnnotationType().getQualifiedName();
return Strings.equal(EqualsHashCode.class.getName(), name)
|| Strings.equal(FinalFieldsConstructor.class.getName(), name);
} | [
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"protected",
"boolean",
"isForbiddenActiveAnnotation",
"(",
"XAnnotation",
"annotation",
")",
"{",
"final",
"String",
"name",
"=",
"annotation",
".",
"getAnnotationType",
"(",
")",
".",
"getQualifiedName",
"(",
... | Replies if the given annotation is a forbidden active annotation.
@param annotation the annotation.
@return {@code true} if the annotation is forbidden. | [
"Replies",
"if",
"the",
"given",
"annotation",
"is",
"a",
"forbidden",
"active",
"annotation",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L2899-L2904 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.checkTopElementsAreUnique | @Check
public void checkTopElementsAreUnique(SarlScript script) {
final Multimap<String, XtendTypeDeclaration> name2type = HashMultimap.create();
for (final XtendTypeDeclaration declaration : script.getXtendTypes()) {
final String name = declaration.getName();
if (!Strings.isEmpty(name)) {
name2type.put(name, declaration);
}
}
for (final String name: name2type.keySet()) {
final Collection<XtendTypeDeclaration> types = name2type.get(name);
if (types.size() > 1) {
for (final XtendTypeDeclaration type: types) {
error(
MessageFormat.format(Messages.SARLValidator_93, name),
type,
XtendPackage.Literals.XTEND_TYPE_DECLARATION__NAME,
DUPLICATE_TYPE_NAME);
}
}
}
} | java | @Check
public void checkTopElementsAreUnique(SarlScript script) {
final Multimap<String, XtendTypeDeclaration> name2type = HashMultimap.create();
for (final XtendTypeDeclaration declaration : script.getXtendTypes()) {
final String name = declaration.getName();
if (!Strings.isEmpty(name)) {
name2type.put(name, declaration);
}
}
for (final String name: name2type.keySet()) {
final Collection<XtendTypeDeclaration> types = name2type.get(name);
if (types.size() > 1) {
for (final XtendTypeDeclaration type: types) {
error(
MessageFormat.format(Messages.SARLValidator_93, name),
type,
XtendPackage.Literals.XTEND_TYPE_DECLARATION__NAME,
DUPLICATE_TYPE_NAME);
}
}
}
} | [
"@",
"Check",
"public",
"void",
"checkTopElementsAreUnique",
"(",
"SarlScript",
"script",
")",
"{",
"final",
"Multimap",
"<",
"String",
",",
"XtendTypeDeclaration",
">",
"name2type",
"=",
"HashMultimap",
".",
"create",
"(",
")",
";",
"for",
"(",
"final",
"Xten... | Check the top elements within a script are not duplicated.
@param script the SARL script | [
"Check",
"the",
"top",
"elements",
"within",
"a",
"script",
"are",
"not",
"duplicated",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L2910-L2931 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.isDefaultValuedParameterFunction | @SuppressWarnings("static-method")
protected boolean isDefaultValuedParameterFunction(XtendFunction function) {
for (final XtendParameter parameter : function.getParameters()) {
if (parameter instanceof SarlFormalParameter) {
final SarlFormalParameter sarlParameter = (SarlFormalParameter) parameter;
if (sarlParameter.getDefaultValue() != null) {
return true;
}
}
}
return false;
} | java | @SuppressWarnings("static-method")
protected boolean isDefaultValuedParameterFunction(XtendFunction function) {
for (final XtendParameter parameter : function.getParameters()) {
if (parameter instanceof SarlFormalParameter) {
final SarlFormalParameter sarlParameter = (SarlFormalParameter) parameter;
if (sarlParameter.getDefaultValue() != null) {
return true;
}
}
}
return false;
} | [
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"protected",
"boolean",
"isDefaultValuedParameterFunction",
"(",
"XtendFunction",
"function",
")",
"{",
"for",
"(",
"final",
"XtendParameter",
"parameter",
":",
"function",
".",
"getParameters",
"(",
")",
")",
... | Replies if the given function has a default value for one of its parameters.
@param function the function to test.
@return {@code true} if one parameter has a default value. | [
"Replies",
"if",
"the",
"given",
"function",
"has",
"a",
"default",
"value",
"for",
"one",
"of",
"its",
"parameters",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L2938-L2949 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java | SARLValidator.reportCastWarnings | protected void reportCastWarnings(JvmTypeReference concreteSyntax, LightweightTypeReference toType, LightweightTypeReference fromType) {
if (!isIgnored(OBSOLETE_CAST) && toType.isAssignableFrom(fromType)) {
addIssue(MessageFormat.format(Messages.SARLValidator_96, fromType.getHumanReadableName(),
toType.getHumanReadableName()), concreteSyntax, OBSOLETE_CAST);
}
} | java | protected void reportCastWarnings(JvmTypeReference concreteSyntax, LightweightTypeReference toType, LightweightTypeReference fromType) {
if (!isIgnored(OBSOLETE_CAST) && toType.isAssignableFrom(fromType)) {
addIssue(MessageFormat.format(Messages.SARLValidator_96, fromType.getHumanReadableName(),
toType.getHumanReadableName()), concreteSyntax, OBSOLETE_CAST);
}
} | [
"protected",
"void",
"reportCastWarnings",
"(",
"JvmTypeReference",
"concreteSyntax",
",",
"LightweightTypeReference",
"toType",
",",
"LightweightTypeReference",
"fromType",
")",
"{",
"if",
"(",
"!",
"isIgnored",
"(",
"OBSOLETE_CAST",
")",
"&&",
"toType",
".",
"isAssi... | Report the warnings associated to the casted expressions.
@param concreteSyntax the type specified into the casted expression.
@param toType the type specified into the casted expression.
@param fromType the type of the source expression. | [
"Report",
"the",
"warnings",
"associated",
"to",
"the",
"casted",
"expressions",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/validation/SARLValidator.java#L3036-L3041 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ScriptBuilderImpl.java | ScriptBuilderImpl.finalizeScript | public void finalizeScript() {
if (this.isFinalized) {
throw new IllegalStateException("already finalized");
}
this.isFinalized = true;
ImportManager concreteImports = new ImportManager(true);
XImportSection importSection = getScript().getImportSection();
if (importSection != null) {
for (XImportDeclaration decl : importSection.getImportDeclarations()) {
concreteImports.addImportFor(decl.getImportedType());
}
}
for (String importName : getImportManager().getImports()) {
JvmType type = findType(getScript(), importName).getType();
if (concreteImports.addImportFor(type) && type instanceof JvmDeclaredType) {
XImportDeclaration declaration = XtypeFactory.eINSTANCE.createXImportDeclaration();
declaration.setImportedType((JvmDeclaredType) type);
if (importSection == null) {
importSection = XtypeFactory.eINSTANCE.createXImportSection();
getScript().setImportSection(importSection);
}
importSection.getImportDeclarations().add(declaration);
}
}
Resource resource = getScript().eResource();
if (resource instanceof DerivedStateAwareResource) {
((DerivedStateAwareResource) resource).discardDerivedState();
}
} | java | public void finalizeScript() {
if (this.isFinalized) {
throw new IllegalStateException("already finalized");
}
this.isFinalized = true;
ImportManager concreteImports = new ImportManager(true);
XImportSection importSection = getScript().getImportSection();
if (importSection != null) {
for (XImportDeclaration decl : importSection.getImportDeclarations()) {
concreteImports.addImportFor(decl.getImportedType());
}
}
for (String importName : getImportManager().getImports()) {
JvmType type = findType(getScript(), importName).getType();
if (concreteImports.addImportFor(type) && type instanceof JvmDeclaredType) {
XImportDeclaration declaration = XtypeFactory.eINSTANCE.createXImportDeclaration();
declaration.setImportedType((JvmDeclaredType) type);
if (importSection == null) {
importSection = XtypeFactory.eINSTANCE.createXImportSection();
getScript().setImportSection(importSection);
}
importSection.getImportDeclarations().add(declaration);
}
}
Resource resource = getScript().eResource();
if (resource instanceof DerivedStateAwareResource) {
((DerivedStateAwareResource) resource).discardDerivedState();
}
} | [
"public",
"void",
"finalizeScript",
"(",
")",
"{",
"if",
"(",
"this",
".",
"isFinalized",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"already finalized\"",
")",
";",
"}",
"this",
".",
"isFinalized",
"=",
"true",
";",
"ImportManager",
"concreteIm... | Finalize the script.
<p>The finalization includes: <ul>
<li>The import section is created.</li>
</ul> | [
"Finalize",
"the",
"script",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ScriptBuilderImpl.java#L89-L117 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ScriptBuilderImpl.java | ScriptBuilderImpl.addSarlEvent | public ISarlEventBuilder addSarlEvent(String name) {
ISarlEventBuilder builder = this.sarlEventProvider.get();
builder.eInit(getScript(), name, getTypeResolutionContext());
return builder;
} | java | public ISarlEventBuilder addSarlEvent(String name) {
ISarlEventBuilder builder = this.sarlEventProvider.get();
builder.eInit(getScript(), name, getTypeResolutionContext());
return builder;
} | [
"public",
"ISarlEventBuilder",
"addSarlEvent",
"(",
"String",
"name",
")",
"{",
"ISarlEventBuilder",
"builder",
"=",
"this",
".",
"sarlEventProvider",
".",
"get",
"(",
")",
";",
"builder",
".",
"eInit",
"(",
"getScript",
"(",
")",
",",
"name",
",",
"getTypeR... | Create a SarlEvent builder.
@param name the name of the SarlEvent.
@return the builder. | [
"Create",
"a",
"SarlEvent",
"builder",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ScriptBuilderImpl.java#L138-L142 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ScriptBuilderImpl.java | ScriptBuilderImpl.addSarlCapacity | public ISarlCapacityBuilder addSarlCapacity(String name) {
ISarlCapacityBuilder builder = this.sarlCapacityProvider.get();
builder.eInit(getScript(), name, getTypeResolutionContext());
return builder;
} | java | public ISarlCapacityBuilder addSarlCapacity(String name) {
ISarlCapacityBuilder builder = this.sarlCapacityProvider.get();
builder.eInit(getScript(), name, getTypeResolutionContext());
return builder;
} | [
"public",
"ISarlCapacityBuilder",
"addSarlCapacity",
"(",
"String",
"name",
")",
"{",
"ISarlCapacityBuilder",
"builder",
"=",
"this",
".",
"sarlCapacityProvider",
".",
"get",
"(",
")",
";",
"builder",
".",
"eInit",
"(",
"getScript",
"(",
")",
",",
"name",
",",... | Create a SarlCapacity builder.
@param name the name of the SarlCapacity.
@return the builder. | [
"Create",
"a",
"SarlCapacity",
"builder",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ScriptBuilderImpl.java#L151-L155 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ScriptBuilderImpl.java | ScriptBuilderImpl.addSarlAgent | public ISarlAgentBuilder addSarlAgent(String name) {
ISarlAgentBuilder builder = this.sarlAgentProvider.get();
builder.eInit(getScript(), name, getTypeResolutionContext());
return builder;
} | java | public ISarlAgentBuilder addSarlAgent(String name) {
ISarlAgentBuilder builder = this.sarlAgentProvider.get();
builder.eInit(getScript(), name, getTypeResolutionContext());
return builder;
} | [
"public",
"ISarlAgentBuilder",
"addSarlAgent",
"(",
"String",
"name",
")",
"{",
"ISarlAgentBuilder",
"builder",
"=",
"this",
".",
"sarlAgentProvider",
".",
"get",
"(",
")",
";",
"builder",
".",
"eInit",
"(",
"getScript",
"(",
")",
",",
"name",
",",
"getTypeR... | Create a SarlAgent builder.
@param name the name of the SarlAgent.
@return the builder. | [
"Create",
"a",
"SarlAgent",
"builder",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ScriptBuilderImpl.java#L164-L168 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ScriptBuilderImpl.java | ScriptBuilderImpl.addSarlBehavior | public ISarlBehaviorBuilder addSarlBehavior(String name) {
ISarlBehaviorBuilder builder = this.sarlBehaviorProvider.get();
builder.eInit(getScript(), name, getTypeResolutionContext());
return builder;
} | java | public ISarlBehaviorBuilder addSarlBehavior(String name) {
ISarlBehaviorBuilder builder = this.sarlBehaviorProvider.get();
builder.eInit(getScript(), name, getTypeResolutionContext());
return builder;
} | [
"public",
"ISarlBehaviorBuilder",
"addSarlBehavior",
"(",
"String",
"name",
")",
"{",
"ISarlBehaviorBuilder",
"builder",
"=",
"this",
".",
"sarlBehaviorProvider",
".",
"get",
"(",
")",
";",
"builder",
".",
"eInit",
"(",
"getScript",
"(",
")",
",",
"name",
",",... | Create a SarlBehavior builder.
@param name the name of the SarlBehavior.
@return the builder. | [
"Create",
"a",
"SarlBehavior",
"builder",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ScriptBuilderImpl.java#L177-L181 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ScriptBuilderImpl.java | ScriptBuilderImpl.addSarlSkill | public ISarlSkillBuilder addSarlSkill(String name) {
ISarlSkillBuilder builder = this.sarlSkillProvider.get();
builder.eInit(getScript(), name, getTypeResolutionContext());
return builder;
} | java | public ISarlSkillBuilder addSarlSkill(String name) {
ISarlSkillBuilder builder = this.sarlSkillProvider.get();
builder.eInit(getScript(), name, getTypeResolutionContext());
return builder;
} | [
"public",
"ISarlSkillBuilder",
"addSarlSkill",
"(",
"String",
"name",
")",
"{",
"ISarlSkillBuilder",
"builder",
"=",
"this",
".",
"sarlSkillProvider",
".",
"get",
"(",
")",
";",
"builder",
".",
"eInit",
"(",
"getScript",
"(",
")",
",",
"name",
",",
"getTypeR... | Create a SarlSkill builder.
@param name the name of the SarlSkill.
@return the builder. | [
"Create",
"a",
"SarlSkill",
"builder",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ScriptBuilderImpl.java#L190-L194 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ScriptBuilderImpl.java | ScriptBuilderImpl.addSarlSpace | public ISarlSpaceBuilder addSarlSpace(String name) {
ISarlSpaceBuilder builder = this.sarlSpaceProvider.get();
builder.eInit(getScript(), name, getTypeResolutionContext());
return builder;
} | java | public ISarlSpaceBuilder addSarlSpace(String name) {
ISarlSpaceBuilder builder = this.sarlSpaceProvider.get();
builder.eInit(getScript(), name, getTypeResolutionContext());
return builder;
} | [
"public",
"ISarlSpaceBuilder",
"addSarlSpace",
"(",
"String",
"name",
")",
"{",
"ISarlSpaceBuilder",
"builder",
"=",
"this",
".",
"sarlSpaceProvider",
".",
"get",
"(",
")",
";",
"builder",
".",
"eInit",
"(",
"getScript",
"(",
")",
",",
"name",
",",
"getTypeR... | Create a SarlSpace builder.
@param name the name of the SarlSpace.
@return the builder. | [
"Create",
"a",
"SarlSpace",
"builder",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ScriptBuilderImpl.java#L203-L207 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ScriptBuilderImpl.java | ScriptBuilderImpl.addSarlArtifact | public ISarlArtifactBuilder addSarlArtifact(String name) {
ISarlArtifactBuilder builder = this.sarlArtifactProvider.get();
builder.eInit(getScript(), name, getTypeResolutionContext());
return builder;
} | java | public ISarlArtifactBuilder addSarlArtifact(String name) {
ISarlArtifactBuilder builder = this.sarlArtifactProvider.get();
builder.eInit(getScript(), name, getTypeResolutionContext());
return builder;
} | [
"public",
"ISarlArtifactBuilder",
"addSarlArtifact",
"(",
"String",
"name",
")",
"{",
"ISarlArtifactBuilder",
"builder",
"=",
"this",
".",
"sarlArtifactProvider",
".",
"get",
"(",
")",
";",
"builder",
".",
"eInit",
"(",
"getScript",
"(",
")",
",",
"name",
",",... | Create a SarlArtifact builder.
@param name the name of the SarlArtifact.
@return the builder. | [
"Create",
"a",
"SarlArtifact",
"builder",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ScriptBuilderImpl.java#L216-L220 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ScriptBuilderImpl.java | ScriptBuilderImpl.addSarlClass | public ISarlClassBuilder addSarlClass(String name) {
ISarlClassBuilder builder = this.sarlClassProvider.get();
builder.eInit(getScript(), name, getTypeResolutionContext());
return builder;
} | java | public ISarlClassBuilder addSarlClass(String name) {
ISarlClassBuilder builder = this.sarlClassProvider.get();
builder.eInit(getScript(), name, getTypeResolutionContext());
return builder;
} | [
"public",
"ISarlClassBuilder",
"addSarlClass",
"(",
"String",
"name",
")",
"{",
"ISarlClassBuilder",
"builder",
"=",
"this",
".",
"sarlClassProvider",
".",
"get",
"(",
")",
";",
"builder",
".",
"eInit",
"(",
"getScript",
"(",
")",
",",
"name",
",",
"getTypeR... | Create a SarlClass builder.
@param name the name of the SarlClass.
@return the builder. | [
"Create",
"a",
"SarlClass",
"builder",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ScriptBuilderImpl.java#L229-L233 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ScriptBuilderImpl.java | ScriptBuilderImpl.addSarlInterface | public ISarlInterfaceBuilder addSarlInterface(String name) {
ISarlInterfaceBuilder builder = this.sarlInterfaceProvider.get();
builder.eInit(getScript(), name, getTypeResolutionContext());
return builder;
} | java | public ISarlInterfaceBuilder addSarlInterface(String name) {
ISarlInterfaceBuilder builder = this.sarlInterfaceProvider.get();
builder.eInit(getScript(), name, getTypeResolutionContext());
return builder;
} | [
"public",
"ISarlInterfaceBuilder",
"addSarlInterface",
"(",
"String",
"name",
")",
"{",
"ISarlInterfaceBuilder",
"builder",
"=",
"this",
".",
"sarlInterfaceProvider",
".",
"get",
"(",
")",
";",
"builder",
".",
"eInit",
"(",
"getScript",
"(",
")",
",",
"name",
... | Create a SarlInterface builder.
@param name the name of the SarlInterface.
@return the builder. | [
"Create",
"a",
"SarlInterface",
"builder",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ScriptBuilderImpl.java#L242-L246 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ScriptBuilderImpl.java | ScriptBuilderImpl.addSarlEnumeration | public ISarlEnumerationBuilder addSarlEnumeration(String name) {
ISarlEnumerationBuilder builder = this.sarlEnumerationProvider.get();
builder.eInit(getScript(), name, getTypeResolutionContext());
return builder;
} | java | public ISarlEnumerationBuilder addSarlEnumeration(String name) {
ISarlEnumerationBuilder builder = this.sarlEnumerationProvider.get();
builder.eInit(getScript(), name, getTypeResolutionContext());
return builder;
} | [
"public",
"ISarlEnumerationBuilder",
"addSarlEnumeration",
"(",
"String",
"name",
")",
"{",
"ISarlEnumerationBuilder",
"builder",
"=",
"this",
".",
"sarlEnumerationProvider",
".",
"get",
"(",
")",
";",
"builder",
".",
"eInit",
"(",
"getScript",
"(",
")",
",",
"n... | Create a SarlEnumeration builder.
@param name the name of the SarlEnumeration.
@return the builder. | [
"Create",
"a",
"SarlEnumeration",
"builder",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ScriptBuilderImpl.java#L255-L259 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ScriptBuilderImpl.java | ScriptBuilderImpl.addSarlAnnotationType | public ISarlAnnotationTypeBuilder addSarlAnnotationType(String name) {
ISarlAnnotationTypeBuilder builder = this.sarlAnnotationTypeProvider.get();
builder.eInit(getScript(), name, getTypeResolutionContext());
return builder;
} | java | public ISarlAnnotationTypeBuilder addSarlAnnotationType(String name) {
ISarlAnnotationTypeBuilder builder = this.sarlAnnotationTypeProvider.get();
builder.eInit(getScript(), name, getTypeResolutionContext());
return builder;
} | [
"public",
"ISarlAnnotationTypeBuilder",
"addSarlAnnotationType",
"(",
"String",
"name",
")",
"{",
"ISarlAnnotationTypeBuilder",
"builder",
"=",
"this",
".",
"sarlAnnotationTypeProvider",
".",
"get",
"(",
")",
";",
"builder",
".",
"eInit",
"(",
"getScript",
"(",
")",... | Create a SarlAnnotationType builder.
@param name the name of the SarlAnnotationType.
@return the builder. | [
"Create",
"a",
"SarlAnnotationType",
"builder",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/ScriptBuilderImpl.java#L268-L272 | train |
sarl/sarl | main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/launching/dialog/SARLAgentMainLaunchConfigurationTab.java | SARLAgentMainLaunchConfigurationTab.createAgentNameEditor | protected void createAgentNameEditor(Composite parent, String text) {
final Group group = SWTFactory.createGroup(parent, text, 2, 1, GridData.FILL_HORIZONTAL);
this.agentNameTextField = SWTFactory.createSingleText(group, 1);
this.agentNameTextField.addModifyListener(new ModifyListener() {
@SuppressWarnings("synthetic-access")
@Override
public void modifyText(ModifyEvent event) {
SARLAgentMainLaunchConfigurationTab.this.lastAgentNameError = null;
updateLaunchConfigurationDialog();
}
});
ControlAccessibleListener.addListener(this.agentNameTextField, group.getText());
this.agentNameSearchButton = createPushButton(group, Messages.MainLaunchConfigurationTab_1, null);
this.agentNameSearchButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent event) {
//
}
@Override
public void widgetSelected(SelectionEvent event) {
handleAgentNameSearchButtonSelected();
}
});
} | java | protected void createAgentNameEditor(Composite parent, String text) {
final Group group = SWTFactory.createGroup(parent, text, 2, 1, GridData.FILL_HORIZONTAL);
this.agentNameTextField = SWTFactory.createSingleText(group, 1);
this.agentNameTextField.addModifyListener(new ModifyListener() {
@SuppressWarnings("synthetic-access")
@Override
public void modifyText(ModifyEvent event) {
SARLAgentMainLaunchConfigurationTab.this.lastAgentNameError = null;
updateLaunchConfigurationDialog();
}
});
ControlAccessibleListener.addListener(this.agentNameTextField, group.getText());
this.agentNameSearchButton = createPushButton(group, Messages.MainLaunchConfigurationTab_1, null);
this.agentNameSearchButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent event) {
//
}
@Override
public void widgetSelected(SelectionEvent event) {
handleAgentNameSearchButtonSelected();
}
});
} | [
"protected",
"void",
"createAgentNameEditor",
"(",
"Composite",
"parent",
",",
"String",
"text",
")",
"{",
"final",
"Group",
"group",
"=",
"SWTFactory",
".",
"createGroup",
"(",
"parent",
",",
"text",
",",
"2",
",",
"1",
",",
"GridData",
".",
"FILL_HORIZONTA... | Creates the widgets for specifying a agent name.
@param parent the parent composite.
@param text the label of the group. | [
"Creates",
"the",
"widgets",
"for",
"specifying",
"a",
"agent",
"name",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/launching/dialog/SARLAgentMainLaunchConfigurationTab.java#L164-L188 | train |
sarl/sarl | main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/launching/dialog/SARLAgentMainLaunchConfigurationTab.java | SARLAgentMainLaunchConfigurationTab.createContextIdentifierTypeEditor | protected void createContextIdentifierTypeEditor(Composite parent, String text) {
final Group group = SWTFactory.createGroup(parent, text, 1, 1, GridData.FILL_HORIZONTAL);
this.defaultContextIdentifierButton = createRadioButton(group, Messages.MainLaunchConfigurationTab_11);
this.defaultContextIdentifierButton.addSelectionListener(this.defaultListener);
this.randomContextIdentifierButton = createRadioButton(group, Messages.MainLaunchConfigurationTab_12);
this.randomContextIdentifierButton.addSelectionListener(this.defaultListener);
this.bootContextIdentifierButton = createRadioButton(group, Messages.MainLaunchConfigurationTab_13);
this.bootContextIdentifierButton.addSelectionListener(this.defaultListener);
} | java | protected void createContextIdentifierTypeEditor(Composite parent, String text) {
final Group group = SWTFactory.createGroup(parent, text, 1, 1, GridData.FILL_HORIZONTAL);
this.defaultContextIdentifierButton = createRadioButton(group, Messages.MainLaunchConfigurationTab_11);
this.defaultContextIdentifierButton.addSelectionListener(this.defaultListener);
this.randomContextIdentifierButton = createRadioButton(group, Messages.MainLaunchConfigurationTab_12);
this.randomContextIdentifierButton.addSelectionListener(this.defaultListener);
this.bootContextIdentifierButton = createRadioButton(group, Messages.MainLaunchConfigurationTab_13);
this.bootContextIdentifierButton.addSelectionListener(this.defaultListener);
} | [
"protected",
"void",
"createContextIdentifierTypeEditor",
"(",
"Composite",
"parent",
",",
"String",
"text",
")",
"{",
"final",
"Group",
"group",
"=",
"SWTFactory",
".",
"createGroup",
"(",
"parent",
",",
"text",
",",
"1",
",",
"1",
",",
"GridData",
".",
"FI... | Creates the widgets for configuring the context identifier.
@param parent the parent composite.
@param text the label of the group. | [
"Creates",
"the",
"widgets",
"for",
"configuring",
"the",
"context",
"identifier",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/launching/dialog/SARLAgentMainLaunchConfigurationTab.java#L196-L204 | train |
sarl/sarl | main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/launching/dialog/SARLAgentMainLaunchConfigurationTab.java | SARLAgentMainLaunchConfigurationTab.getSelectedContextIdentifierType | protected RootContextIdentifierType getSelectedContextIdentifierType() {
if (this.randomContextIdentifierButton.getSelection()) {
return RootContextIdentifierType.RANDOM_CONTEXT_ID;
}
if (this.bootContextIdentifierButton.getSelection()) {
return RootContextIdentifierType.BOOT_AGENT_CONTEXT_ID;
}
return RootContextIdentifierType.DEFAULT_CONTEXT_ID;
} | java | protected RootContextIdentifierType getSelectedContextIdentifierType() {
if (this.randomContextIdentifierButton.getSelection()) {
return RootContextIdentifierType.RANDOM_CONTEXT_ID;
}
if (this.bootContextIdentifierButton.getSelection()) {
return RootContextIdentifierType.BOOT_AGENT_CONTEXT_ID;
}
return RootContextIdentifierType.DEFAULT_CONTEXT_ID;
} | [
"protected",
"RootContextIdentifierType",
"getSelectedContextIdentifierType",
"(",
")",
"{",
"if",
"(",
"this",
".",
"randomContextIdentifierButton",
".",
"getSelection",
"(",
")",
")",
"{",
"return",
"RootContextIdentifierType",
".",
"RANDOM_CONTEXT_ID",
";",
"}",
"if"... | Replies the type of context identifier selected by the user.
@return the type of context identifier. | [
"Replies",
"the",
"type",
"of",
"context",
"identifier",
"selected",
"by",
"the",
"user",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/launching/dialog/SARLAgentMainLaunchConfigurationTab.java#L210-L218 | train |
sarl/sarl | main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/launching/dialog/SARLAgentMainLaunchConfigurationTab.java | SARLAgentMainLaunchConfigurationTab.updateContextIdentifierTypeFromConfig | protected void updateContextIdentifierTypeFromConfig(ILaunchConfiguration config) {
final RootContextIdentifierType type = this.accessor.getDefaultContextIdentifier(config);
assert type != null;
switch (type) {
case RANDOM_CONTEXT_ID:
this.randomContextIdentifierButton.setSelection(true);
break;
case BOOT_AGENT_CONTEXT_ID:
this.bootContextIdentifierButton.setSelection(true);
break;
case DEFAULT_CONTEXT_ID:
default:
this.defaultContextIdentifierButton.setSelection(true);
break;
}
} | java | protected void updateContextIdentifierTypeFromConfig(ILaunchConfiguration config) {
final RootContextIdentifierType type = this.accessor.getDefaultContextIdentifier(config);
assert type != null;
switch (type) {
case RANDOM_CONTEXT_ID:
this.randomContextIdentifierButton.setSelection(true);
break;
case BOOT_AGENT_CONTEXT_ID:
this.bootContextIdentifierButton.setSelection(true);
break;
case DEFAULT_CONTEXT_ID:
default:
this.defaultContextIdentifierButton.setSelection(true);
break;
}
} | [
"protected",
"void",
"updateContextIdentifierTypeFromConfig",
"(",
"ILaunchConfiguration",
"config",
")",
"{",
"final",
"RootContextIdentifierType",
"type",
"=",
"this",
".",
"accessor",
".",
"getDefaultContextIdentifier",
"(",
"config",
")",
";",
"assert",
"type",
"!="... | Loads the context identifier type from the launch configuration's preference store.
@param config the config to load the agent name from | [
"Loads",
"the",
"context",
"identifier",
"type",
"from",
"the",
"launch",
"configuration",
"s",
"preference",
"store",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/launching/dialog/SARLAgentMainLaunchConfigurationTab.java#L255-L270 | train |
sarl/sarl | main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/launching/dialog/SARLAgentMainLaunchConfigurationTab.java | SARLAgentMainLaunchConfigurationTab.updateAgentNameFromConfig | protected void updateAgentNameFromConfig(ILaunchConfiguration config) {
final String agentName = this.accessor.getAgent(config);
this.agentNameTextField.setText(Strings.nullToEmpty(agentName));
} | java | protected void updateAgentNameFromConfig(ILaunchConfiguration config) {
final String agentName = this.accessor.getAgent(config);
this.agentNameTextField.setText(Strings.nullToEmpty(agentName));
} | [
"protected",
"void",
"updateAgentNameFromConfig",
"(",
"ILaunchConfiguration",
"config",
")",
"{",
"final",
"String",
"agentName",
"=",
"this",
".",
"accessor",
".",
"getAgent",
"(",
"config",
")",
";",
"this",
".",
"agentNameTextField",
".",
"setText",
"(",
"St... | Loads the agent name from the launch configuration's preference store.
@param config the config to load the agent name from | [
"Loads",
"the",
"agent",
"name",
"from",
"the",
"launch",
"configuration",
"s",
"preference",
"store",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/launching/dialog/SARLAgentMainLaunchConfigurationTab.java#L297-L300 | train |
sarl/sarl | main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/launching/dialog/SARLAgentMainLaunchConfigurationTab.java | SARLAgentMainLaunchConfigurationTab.isValidAgentName | protected boolean isValidAgentName() {
if (this.lastAgentNameError != null) {
final boolean isValid = Strings.isNullOrEmpty(this.lastAgentNameError);
if (!isValid) {
setErrorMessage(this.lastAgentNameError);
}
return isValid;
}
final String name = this.agentNameTextField.getText();
if (Strings.isNullOrEmpty(name)) {
this.lastAgentNameError = Messages.MainLaunchConfigurationTab_2;
setErrorMessage(this.lastAgentNameError);
return false;
}
if (!isAgentNameDefined(name)) {
this.lastAgentNameError = MessageFormat.format(Messages.MainLaunchConfigurationTab_8, name);
setErrorMessage(this.lastAgentNameError);
return false;
}
this.lastAgentNameError = Utilities.EMPTY_STRING;
return true;
} | java | protected boolean isValidAgentName() {
if (this.lastAgentNameError != null) {
final boolean isValid = Strings.isNullOrEmpty(this.lastAgentNameError);
if (!isValid) {
setErrorMessage(this.lastAgentNameError);
}
return isValid;
}
final String name = this.agentNameTextField.getText();
if (Strings.isNullOrEmpty(name)) {
this.lastAgentNameError = Messages.MainLaunchConfigurationTab_2;
setErrorMessage(this.lastAgentNameError);
return false;
}
if (!isAgentNameDefined(name)) {
this.lastAgentNameError = MessageFormat.format(Messages.MainLaunchConfigurationTab_8, name);
setErrorMessage(this.lastAgentNameError);
return false;
}
this.lastAgentNameError = Utilities.EMPTY_STRING;
return true;
} | [
"protected",
"boolean",
"isValidAgentName",
"(",
")",
"{",
"if",
"(",
"this",
".",
"lastAgentNameError",
"!=",
"null",
")",
"{",
"final",
"boolean",
"isValid",
"=",
"Strings",
".",
"isNullOrEmpty",
"(",
"this",
".",
"lastAgentNameError",
")",
";",
"if",
"(",... | Replies if the agent name is valid.
@return the validity state. | [
"Replies",
"if",
"the",
"agent",
"name",
"is",
"valid",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/launching/dialog/SARLAgentMainLaunchConfigurationTab.java#L332-L353 | train |
sarl/sarl | main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/launching/dialog/SARLAgentMainLaunchConfigurationTab.java | SARLAgentMainLaunchConfigurationTab.isValidProjectName | protected boolean isValidProjectName() {
final String name = this.fProjText.getText();
if (Strings.isNullOrEmpty(name)) {
setErrorMessage(Messages.MainLaunchConfigurationTab_3);
return false;
}
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IStatus status = workspace.validateName(name, IResource.PROJECT);
if (status.isOK()) {
final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
if (!project.exists()) {
setErrorMessage(MessageFormat.format(
Messages.MainLaunchConfigurationTab_4, name));
return false;
}
if (!project.isOpen()) {
setErrorMessage(MessageFormat.format(
Messages.MainLaunchConfigurationTab_5, name));
return false;
}
} else {
setErrorMessage(MessageFormat.format(
Messages.MainLaunchConfigurationTab_6, status.getMessage()));
return false;
}
return true;
} | java | protected boolean isValidProjectName() {
final String name = this.fProjText.getText();
if (Strings.isNullOrEmpty(name)) {
setErrorMessage(Messages.MainLaunchConfigurationTab_3);
return false;
}
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IStatus status = workspace.validateName(name, IResource.PROJECT);
if (status.isOK()) {
final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
if (!project.exists()) {
setErrorMessage(MessageFormat.format(
Messages.MainLaunchConfigurationTab_4, name));
return false;
}
if (!project.isOpen()) {
setErrorMessage(MessageFormat.format(
Messages.MainLaunchConfigurationTab_5, name));
return false;
}
} else {
setErrorMessage(MessageFormat.format(
Messages.MainLaunchConfigurationTab_6, status.getMessage()));
return false;
}
return true;
} | [
"protected",
"boolean",
"isValidProjectName",
"(",
")",
"{",
"final",
"String",
"name",
"=",
"this",
".",
"fProjText",
".",
"getText",
"(",
")",
";",
"if",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"name",
")",
")",
"{",
"setErrorMessage",
"(",
"Messages"... | Replies if the project name is valid.
<p>Copied from JDT.
@return the validity state. | [
"Replies",
"if",
"the",
"project",
"name",
"is",
"valid",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/launching/dialog/SARLAgentMainLaunchConfigurationTab.java#L361-L387 | train |
sarl/sarl | main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/launching/dialog/SARLAgentMainLaunchConfigurationTab.java | SARLAgentMainLaunchConfigurationTab.initializeAgentName | protected void initializeAgentName(IJavaElement javaElement, ILaunchConfigurationWorkingCopy config) {
String name = extractNameFromJavaElement(javaElement);
// Set the attribute
this.configurator.setAgent(config, name);
// Rename the launch configuration
if (name.length() > 0) {
final int index = name.lastIndexOf('.');
if (index > 0) {
name = name.substring(index + 1);
}
name = getLaunchConfigurationDialog().generateName(name);
config.rename(name);
}
} | java | protected void initializeAgentName(IJavaElement javaElement, ILaunchConfigurationWorkingCopy config) {
String name = extractNameFromJavaElement(javaElement);
// Set the attribute
this.configurator.setAgent(config, name);
// Rename the launch configuration
if (name.length() > 0) {
final int index = name.lastIndexOf('.');
if (index > 0) {
name = name.substring(index + 1);
}
name = getLaunchConfigurationDialog().generateName(name);
config.rename(name);
}
} | [
"protected",
"void",
"initializeAgentName",
"(",
"IJavaElement",
"javaElement",
",",
"ILaunchConfigurationWorkingCopy",
"config",
")",
"{",
"String",
"name",
"=",
"extractNameFromJavaElement",
"(",
"javaElement",
")",
";",
"// Set the attribute",
"this",
".",
"configurato... | Reset the given configuration with the agent name attributes associated
to the given element.
@param javaElement the element from which information may be retrieved.
@param config the config to set with the agent name. | [
"Reset",
"the",
"given",
"configuration",
"with",
"the",
"agent",
"name",
"attributes",
"associated",
"to",
"the",
"given",
"element",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/launching/dialog/SARLAgentMainLaunchConfigurationTab.java#L473-L488 | train |
sarl/sarl | main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/launching/dialog/SARLAgentMainLaunchConfigurationTab.java | SARLAgentMainLaunchConfigurationTab.handleAgentNameSearchButtonSelected | protected void handleAgentNameSearchButtonSelected() {
final IType[] types = searchAgentNames();
// Ask to the user
final DebugTypeSelectionDialog mmsd = new DebugTypeSelectionDialog(getShell(),
types, ""); //$NON-NLS-1$
if (mmsd.open() == Window.CANCEL) {
return;
}
final IType type = (IType) mmsd.getFirstResult();
if (type != null) {
this.agentNameTextField.setText(type.getFullyQualifiedName());
this.fProjText.setText(type.getJavaProject().getElementName());
}
} | java | protected void handleAgentNameSearchButtonSelected() {
final IType[] types = searchAgentNames();
// Ask to the user
final DebugTypeSelectionDialog mmsd = new DebugTypeSelectionDialog(getShell(),
types, ""); //$NON-NLS-1$
if (mmsd.open() == Window.CANCEL) {
return;
}
final IType type = (IType) mmsd.getFirstResult();
if (type != null) {
this.agentNameTextField.setText(type.getFullyQualifiedName());
this.fProjText.setText(type.getJavaProject().getElementName());
}
} | [
"protected",
"void",
"handleAgentNameSearchButtonSelected",
"(",
")",
"{",
"final",
"IType",
"[",
"]",
"types",
"=",
"searchAgentNames",
"(",
")",
";",
"// Ask to the user",
"final",
"DebugTypeSelectionDialog",
"mmsd",
"=",
"new",
"DebugTypeSelectionDialog",
"(",
"get... | Invoked when the search button for the agent agent was clocked. | [
"Invoked",
"when",
"the",
"search",
"button",
"for",
"the",
"agent",
"agent",
"was",
"clocked",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/launching/dialog/SARLAgentMainLaunchConfigurationTab.java#L556-L569 | train |
sarl/sarl | main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/properties/RuntimeEnvironmentPropertyPage.java | RuntimeEnvironmentPropertyPage.saveProjectSpecificOptions | @SuppressWarnings("static-method")
protected boolean saveProjectSpecificOptions(IProject project, boolean useSpecificOptions) {
if (project != null) {
try {
project.setPersistentProperty(
qualify(PROPERTY_NAME_HAS_PROJECT_SPECIFIC),
Boolean.toString(useSpecificOptions));
return true;
} catch (CoreException e) {
SARLEclipsePlugin.getDefault().log(e);
}
}
return false;
} | java | @SuppressWarnings("static-method")
protected boolean saveProjectSpecificOptions(IProject project, boolean useSpecificOptions) {
if (project != null) {
try {
project.setPersistentProperty(
qualify(PROPERTY_NAME_HAS_PROJECT_SPECIFIC),
Boolean.toString(useSpecificOptions));
return true;
} catch (CoreException e) {
SARLEclipsePlugin.getDefault().log(e);
}
}
return false;
} | [
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"protected",
"boolean",
"saveProjectSpecificOptions",
"(",
"IProject",
"project",
",",
"boolean",
"useSpecificOptions",
")",
"{",
"if",
"(",
"project",
"!=",
"null",
")",
"{",
"try",
"{",
"project",
".",
"s... | Save the flag that indicates if the specific project options must be
used.
@param project the project.
@param useSpecificOptions indicates if the specific options must be used.
@return <code>true</code> if the property was saved successfully. | [
"Save",
"the",
"flag",
"that",
"indicates",
"if",
"the",
"specific",
"project",
"options",
"must",
"be",
"used",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/properties/RuntimeEnvironmentPropertyPage.java#L149-L162 | train |
sarl/sarl | main/coreplugins/io.sarl.m2e/src/io/sarl/m2e/utils/M2EUtilities.java | M2EUtilities.compareOsgiVersions | public static int compareOsgiVersions(String v1, String v2) {
return Version.parseVersion(v1).compareTo(Version.parseVersion(v2));
} | java | public static int compareOsgiVersions(String v1, String v2) {
return Version.parseVersion(v1).compareTo(Version.parseVersion(v2));
} | [
"public",
"static",
"int",
"compareOsgiVersions",
"(",
"String",
"v1",
",",
"String",
"v2",
")",
"{",
"return",
"Version",
".",
"parseVersion",
"(",
"v1",
")",
".",
"compareTo",
"(",
"Version",
".",
"parseVersion",
"(",
"v2",
")",
")",
";",
"}"
] | Compare two OSGI versions.
@param v1 first OSGI version.
@param v2 second OSGI version.
@return an integer that the sign indicates if v1 is lower, equal ot greater than v2. | [
"Compare",
"two",
"OSGI",
"versions",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.m2e/src/io/sarl/m2e/utils/M2EUtilities.java#L63-L65 | train |
sarl/sarl | main/coreplugins/io.sarl.m2e/src/io/sarl/m2e/utils/M2EUtilities.java | M2EUtilities.compareMavenVersions | public static int compareMavenVersions(String v1, String v2) {
return parseMavenVersion(v1).compareTo(parseMavenVersion(v2));
} | java | public static int compareMavenVersions(String v1, String v2) {
return parseMavenVersion(v1).compareTo(parseMavenVersion(v2));
} | [
"public",
"static",
"int",
"compareMavenVersions",
"(",
"String",
"v1",
",",
"String",
"v2",
")",
"{",
"return",
"parseMavenVersion",
"(",
"v1",
")",
".",
"compareTo",
"(",
"parseMavenVersion",
"(",
"v2",
")",
")",
";",
"}"
] | Compare two Maven versions.
@param v1 first Maven version.
@param v2 second Maven version.
@return an integer that the sign indicates if v1 is lower, equal ot greater than v2. | [
"Compare",
"two",
"Maven",
"versions",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.m2e/src/io/sarl/m2e/utils/M2EUtilities.java#L73-L75 | train |
sarl/sarl | main/coreplugins/io.sarl.m2e/src/io/sarl/m2e/utils/M2EUtilities.java | M2EUtilities.parseMavenVersion | public static Version parseMavenVersion(String version) {
if (Strings.isNullOrEmpty(version)) {
return new Version(0, 0, 0);
}
// Detect the snapshot
final boolean isSnapshot;
final String coreVersion;
Matcher matcher = Artifact.VERSION_FILE_PATTERN.matcher(version);
if (matcher.matches()) {
coreVersion = matcher.group(1);
isSnapshot = true;
} else {
matcher = SNAPSHOT_VERSION_PATTERN.matcher(version);
if (matcher.matches()) {
coreVersion = matcher.group(1);
isSnapshot = true;
} else {
coreVersion = version;
isSnapshot = false;
}
}
// Parse the numbers
final String[] parts = coreVersion.split("[.]"); //$NON-NLS-1$
final int[] numbers = new int[] {0, 0, 0};
int i = 0;
while (i < numbers.length && i < parts.length) {
try {
numbers[i] = Integer.parseInt(parts[i]);
++i;
} catch (Exception exception) {
// Force the exit of the loop since a number cannot be find.
i = numbers.length;
}
}
// Reply
if (isSnapshot) {
return new Version(numbers[0], numbers[1], numbers[2], SNAPSHOT_QUALIFIER);
}
return new Version(numbers[0], numbers[1], numbers[2]);
} | java | public static Version parseMavenVersion(String version) {
if (Strings.isNullOrEmpty(version)) {
return new Version(0, 0, 0);
}
// Detect the snapshot
final boolean isSnapshot;
final String coreVersion;
Matcher matcher = Artifact.VERSION_FILE_PATTERN.matcher(version);
if (matcher.matches()) {
coreVersion = matcher.group(1);
isSnapshot = true;
} else {
matcher = SNAPSHOT_VERSION_PATTERN.matcher(version);
if (matcher.matches()) {
coreVersion = matcher.group(1);
isSnapshot = true;
} else {
coreVersion = version;
isSnapshot = false;
}
}
// Parse the numbers
final String[] parts = coreVersion.split("[.]"); //$NON-NLS-1$
final int[] numbers = new int[] {0, 0, 0};
int i = 0;
while (i < numbers.length && i < parts.length) {
try {
numbers[i] = Integer.parseInt(parts[i]);
++i;
} catch (Exception exception) {
// Force the exit of the loop since a number cannot be find.
i = numbers.length;
}
}
// Reply
if (isSnapshot) {
return new Version(numbers[0], numbers[1], numbers[2], SNAPSHOT_QUALIFIER);
}
return new Version(numbers[0], numbers[1], numbers[2]);
} | [
"public",
"static",
"Version",
"parseMavenVersion",
"(",
"String",
"version",
")",
"{",
"if",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"version",
")",
")",
"{",
"return",
"new",
"Version",
"(",
"0",
",",
"0",
",",
"0",
")",
";",
"}",
"// Detect the sna... | Maven version parser.
@param version the version string.
@return the version. | [
"Maven",
"version",
"parser",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.m2e/src/io/sarl/m2e/utils/M2EUtilities.java#L82-L123 | train |
sarl/sarl | main/coreplugins/io.sarl.lang.core/src/io/sarl/lang/core/SREutils.java | SREutils.getInternalSkill | @Pure
public static <S extends Capacity> S getInternalSkill(Agent agent, Class<S> type) {
return agent.getSkill(type);
} | java | @Pure
public static <S extends Capacity> S getInternalSkill(Agent agent, Class<S> type) {
return agent.getSkill(type);
} | [
"@",
"Pure",
"public",
"static",
"<",
"S",
"extends",
"Capacity",
">",
"S",
"getInternalSkill",
"(",
"Agent",
"agent",
",",
"Class",
"<",
"S",
">",
"type",
")",
"{",
"return",
"agent",
".",
"getSkill",
"(",
"type",
")",
";",
"}"
] | Replies the internal skill of an agent.
@param <S> the type of the capacity.
@param agent the agent.
@param type the type of the capacity.
@return the skill.
@throws UnimplementedCapacityException if the agent has not a skill for the given capacity.
@since 0.6 | [
"Replies",
"the",
"internal",
"skill",
"of",
"an",
"agent",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.core/src/io/sarl/lang/core/SREutils.java#L139-L142 | train |
sarl/sarl | sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/services/network/NetworkConfig.java | NetworkConfig.getStringEncodingCharset | public static Charset getStringEncodingCharset() {
if (currentStringEncoding == null) {
final String value = JanusConfig.getSystemProperty(BYTE_ARRAY_STRING_CHARSET_NAME, null);
if (value != null) {
try {
currentStringEncoding = Charset.forName(value);
if (currentStringEncoding == null) {
currentStringEncoding = BYTE_ARRAY_STRING_CHARSET_VALUE;
}
} catch (Throwable exception) {
currentStringEncoding = BYTE_ARRAY_STRING_CHARSET_VALUE;
}
} else {
currentStringEncoding = BYTE_ARRAY_STRING_CHARSET_VALUE;
}
}
return currentStringEncoding;
} | java | public static Charset getStringEncodingCharset() {
if (currentStringEncoding == null) {
final String value = JanusConfig.getSystemProperty(BYTE_ARRAY_STRING_CHARSET_NAME, null);
if (value != null) {
try {
currentStringEncoding = Charset.forName(value);
if (currentStringEncoding == null) {
currentStringEncoding = BYTE_ARRAY_STRING_CHARSET_VALUE;
}
} catch (Throwable exception) {
currentStringEncoding = BYTE_ARRAY_STRING_CHARSET_VALUE;
}
} else {
currentStringEncoding = BYTE_ARRAY_STRING_CHARSET_VALUE;
}
}
return currentStringEncoding;
} | [
"public",
"static",
"Charset",
"getStringEncodingCharset",
"(",
")",
"{",
"if",
"(",
"currentStringEncoding",
"==",
"null",
")",
"{",
"final",
"String",
"value",
"=",
"JanusConfig",
".",
"getSystemProperty",
"(",
"BYTE_ARRAY_STRING_CHARSET_NAME",
",",
"null",
")",
... | Replies the charset that must be used for encoding the strings.
@return the encoding charset. | [
"Replies",
"the",
"charset",
"that",
"must",
"be",
"used",
"for",
"encoding",
"the",
"strings",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/services/network/NetworkConfig.java#L97-L114 | train |
sarl/sarl | main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/codebuilder/fragments/AbstractMemberBuilderFragment.java | AbstractMemberBuilderFragment.generateIMemberBuilder | protected void generateIMemberBuilder(MemberDescription description) {
if (description.isTopElement()) {
return;
}
final TypeReference builder = description.getElementDescription().getBuilderInterfaceType();
final StringConcatenationClient content = new StringConcatenationClient() {
@Override
protected void appendTo(TargetStringConcatenation it) {
it.append("/** Builder of a " + getLanguageName() //$NON-NLS-1$
+ " " + description.getElementDescription().getName() + "."); //$NON-NLS-1$ //$NON-NLS-2$
it.newLine();
it.append(" */"); //$NON-NLS-1$
it.newLine();
it.append("@SuppressWarnings(\"all\")"); //$NON-NLS-1$
it.newLine();
it.append("public interface "); //$NON-NLS-1$
it.append(builder.getSimpleName());
it.append(" {"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append(generateMembers(description, true, false));
it.append("}"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
}
};
final JavaFileAccess javaFile = getFileAccessFactory().createJavaFile(builder, content);
javaFile.writeTo(getSrcGen());
} | java | protected void generateIMemberBuilder(MemberDescription description) {
if (description.isTopElement()) {
return;
}
final TypeReference builder = description.getElementDescription().getBuilderInterfaceType();
final StringConcatenationClient content = new StringConcatenationClient() {
@Override
protected void appendTo(TargetStringConcatenation it) {
it.append("/** Builder of a " + getLanguageName() //$NON-NLS-1$
+ " " + description.getElementDescription().getName() + "."); //$NON-NLS-1$ //$NON-NLS-2$
it.newLine();
it.append(" */"); //$NON-NLS-1$
it.newLine();
it.append("@SuppressWarnings(\"all\")"); //$NON-NLS-1$
it.newLine();
it.append("public interface "); //$NON-NLS-1$
it.append(builder.getSimpleName());
it.append(" {"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append(generateMembers(description, true, false));
it.append("}"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
}
};
final JavaFileAccess javaFile = getFileAccessFactory().createJavaFile(builder, content);
javaFile.writeTo(getSrcGen());
} | [
"protected",
"void",
"generateIMemberBuilder",
"(",
"MemberDescription",
"description",
")",
"{",
"if",
"(",
"description",
".",
"isTopElement",
"(",
")",
")",
"{",
"return",
";",
"}",
"final",
"TypeReference",
"builder",
"=",
"description",
".",
"getElementDescri... | Generate the member builder interface.
@param description the description of the member. | [
"Generate",
"the",
"member",
"builder",
"interface",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/codebuilder/fragments/AbstractMemberBuilderFragment.java#L102-L130 | train |
sarl/sarl | main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/codebuilder/fragments/AbstractMemberBuilderFragment.java | AbstractMemberBuilderFragment.generateMemberAppender | protected void generateMemberAppender(MemberDescription description) {
if (description.isTopElement()) {
return;
}
final TypeReference appender = description.getElementDescription().getAppenderType();
final String generatedFieldAccessor = getGeneratedMemberAccessor(description);
final StringConcatenationClient content = new StringConcatenationClient() {
@Override
protected void appendTo(TargetStringConcatenation it) {
it.append("/** Source appender of a " + getLanguageName() //$NON-NLS-1$
+ " " + description.getElementDescription().getName() + "."); //$NON-NLS-1$ //$NON-NLS-2$
it.newLine();
it.append(" */"); //$NON-NLS-1$
it.newLine();
it.append("@SuppressWarnings(\"all\")"); //$NON-NLS-1$
it.newLine();
it.append("public class "); //$NON-NLS-1$
it.append(appender.getSimpleName());
it.append(" extends "); //$NON-NLS-1$
it.append(getCodeElementExtractor().getAbstractAppenderImpl());
it.append(" implements "); //$NON-NLS-1$
it.append(description.getElementDescription().getBuilderInterfaceType());
it.append(" {"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append(generateAppenderMembers(appender.getSimpleName(),
description.getElementDescription().getBuilderInterfaceType(), generatedFieldAccessor));
it.append(generateMembers(description, false, true));
it.append("}"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
}
};
final JavaFileAccess javaFile = getFileAccessFactory().createJavaFile(appender, content);
javaFile.writeTo(getSrcGen());
} | java | protected void generateMemberAppender(MemberDescription description) {
if (description.isTopElement()) {
return;
}
final TypeReference appender = description.getElementDescription().getAppenderType();
final String generatedFieldAccessor = getGeneratedMemberAccessor(description);
final StringConcatenationClient content = new StringConcatenationClient() {
@Override
protected void appendTo(TargetStringConcatenation it) {
it.append("/** Source appender of a " + getLanguageName() //$NON-NLS-1$
+ " " + description.getElementDescription().getName() + "."); //$NON-NLS-1$ //$NON-NLS-2$
it.newLine();
it.append(" */"); //$NON-NLS-1$
it.newLine();
it.append("@SuppressWarnings(\"all\")"); //$NON-NLS-1$
it.newLine();
it.append("public class "); //$NON-NLS-1$
it.append(appender.getSimpleName());
it.append(" extends "); //$NON-NLS-1$
it.append(getCodeElementExtractor().getAbstractAppenderImpl());
it.append(" implements "); //$NON-NLS-1$
it.append(description.getElementDescription().getBuilderInterfaceType());
it.append(" {"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append(generateAppenderMembers(appender.getSimpleName(),
description.getElementDescription().getBuilderInterfaceType(), generatedFieldAccessor));
it.append(generateMembers(description, false, true));
it.append("}"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
}
};
final JavaFileAccess javaFile = getFileAccessFactory().createJavaFile(appender, content);
javaFile.writeTo(getSrcGen());
} | [
"protected",
"void",
"generateMemberAppender",
"(",
"MemberDescription",
"description",
")",
"{",
"if",
"(",
"description",
".",
"isTopElement",
"(",
")",
")",
"{",
"return",
";",
"}",
"final",
"TypeReference",
"appender",
"=",
"description",
".",
"getElementDescr... | Generate the member appender.
@param description the description of the member. | [
"Generate",
"the",
"member",
"appender",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/codebuilder/fragments/AbstractMemberBuilderFragment.java#L175-L210 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.