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/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/codebuilder/fragments/AbstractMemberBuilderFragment.java
AbstractMemberBuilderFragment.getGeneratedMemberAccessor
@SuppressWarnings("static-method") protected String getGeneratedMemberAccessor(MemberDescription description) { return "get" //$NON-NLS-1$ + Strings.toFirstUpper(description.getElementDescription().getElementType().getSimpleName()) + "()"; //$NON-NLS-1$ }
java
@SuppressWarnings("static-method") protected String getGeneratedMemberAccessor(MemberDescription description) { return "get" //$NON-NLS-1$ + Strings.toFirstUpper(description.getElementDescription().getElementType().getSimpleName()) + "()"; //$NON-NLS-1$ }
[ "@", "SuppressWarnings", "(", "\"static-method\"", ")", "protected", "String", "getGeneratedMemberAccessor", "(", "MemberDescription", "description", ")", "{", "return", "\"get\"", "//$NON-NLS-1$", "+", "Strings", ".", "toFirstUpper", "(", "description", ".", "getElemen...
Replies the name of the accessor that replies the generated member. @param description the description of the member to generate. @return the accessor name.
[ "Replies", "the", "name", "of", "the", "accessor", "that", "replies", "the", "generated", "member", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/codebuilder/fragments/AbstractMemberBuilderFragment.java#L217-L221
train
sarl/sarl
main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/binding/BindingFactory.java
BindingFactory.bindAnnotatedWith
protected Binding bindAnnotatedWith(TypeReference bind, TypeReference annotatedWith, TypeReference to, String functionName) { final StringConcatenationClient client = new StringConcatenationClient() { @Override protected void appendTo(TargetStringConcatenation builder) { builder.append("binder.bind("); //$NON-NLS-1$ builder.append(bind); builder.append(".class).annotatedWith("); //$NON-NLS-1$ builder.append(annotatedWith); builder.append(".class).to("); //$NON-NLS-1$ builder.append(to); builder.append(".class);"); //$NON-NLS-1$ } }; String fctname = functionName; if (Strings.isEmpty(fctname)) { fctname = bind.getSimpleName(); } final BindKey key = new GuiceModuleAccess.BindKey(formatFunctionName(fctname), null, false, false); final BindValue statements = new BindValue(null, null, false, Collections.singletonList(client)); return new Binding(key, statements, true, this.name); }
java
protected Binding bindAnnotatedWith(TypeReference bind, TypeReference annotatedWith, TypeReference to, String functionName) { final StringConcatenationClient client = new StringConcatenationClient() { @Override protected void appendTo(TargetStringConcatenation builder) { builder.append("binder.bind("); //$NON-NLS-1$ builder.append(bind); builder.append(".class).annotatedWith("); //$NON-NLS-1$ builder.append(annotatedWith); builder.append(".class).to("); //$NON-NLS-1$ builder.append(to); builder.append(".class);"); //$NON-NLS-1$ } }; String fctname = functionName; if (Strings.isEmpty(fctname)) { fctname = bind.getSimpleName(); } final BindKey key = new GuiceModuleAccess.BindKey(formatFunctionName(fctname), null, false, false); final BindValue statements = new BindValue(null, null, false, Collections.singletonList(client)); return new Binding(key, statements, true, this.name); }
[ "protected", "Binding", "bindAnnotatedWith", "(", "TypeReference", "bind", ",", "TypeReference", "annotatedWith", ",", "TypeReference", "to", ",", "String", "functionName", ")", "{", "final", "StringConcatenationClient", "client", "=", "new", "StringConcatenationClient", ...
Bind an annotated element. @param bind the type to bind. @param annotatedWith the annotation to consider. @param to the target type. @param functionName the optional function name. @return the binding element.
[ "Bind", "an", "annotated", "element", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/binding/BindingFactory.java#L91-L112
train
sarl/sarl
main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/binding/BindingFactory.java
BindingFactory.bindAnnotatedWithNameToInstance
protected Binding bindAnnotatedWithNameToInstance(TypeReference bind, String name, String to, String functionName) { String tmpName = Strings.emptyIfNull(name); if (tmpName.startsWith(REFERENCE_PREFIX)) { tmpName = tmpName.substring(REFERENCE_PREFIX.length()).trim(); } else { tmpName = "\"" + tmpName + "\""; //$NON-NLS-1$//$NON-NLS-2$ } final String unferencedName = tmpName; final StringConcatenationClient client = new StringConcatenationClient() { @Override protected void appendTo(TargetStringConcatenation builder) { builder.append("binder.bind("); //$NON-NLS-1$ builder.append(bind); builder.append(".class).annotatedWith(Names.named("); //$NON-NLS-1$ builder.append(unferencedName); builder.append(")).toInstance("); //$NON-NLS-1$ builder.append(to); builder.append(".class);"); //$NON-NLS-1$ } }; String fctname = functionName; if (Strings.isEmpty(fctname)) { fctname = name; } final BindKey key = new GuiceModuleAccess.BindKey(formatFunctionName(fctname), null, false, false); final BindValue statements = new BindValue(null, null, false, Collections.singletonList(client)); return new Binding(key, statements, true, this.name); }
java
protected Binding bindAnnotatedWithNameToInstance(TypeReference bind, String name, String to, String functionName) { String tmpName = Strings.emptyIfNull(name); if (tmpName.startsWith(REFERENCE_PREFIX)) { tmpName = tmpName.substring(REFERENCE_PREFIX.length()).trim(); } else { tmpName = "\"" + tmpName + "\""; //$NON-NLS-1$//$NON-NLS-2$ } final String unferencedName = tmpName; final StringConcatenationClient client = new StringConcatenationClient() { @Override protected void appendTo(TargetStringConcatenation builder) { builder.append("binder.bind("); //$NON-NLS-1$ builder.append(bind); builder.append(".class).annotatedWith(Names.named("); //$NON-NLS-1$ builder.append(unferencedName); builder.append(")).toInstance("); //$NON-NLS-1$ builder.append(to); builder.append(".class);"); //$NON-NLS-1$ } }; String fctname = functionName; if (Strings.isEmpty(fctname)) { fctname = name; } final BindKey key = new GuiceModuleAccess.BindKey(formatFunctionName(fctname), null, false, false); final BindValue statements = new BindValue(null, null, false, Collections.singletonList(client)); return new Binding(key, statements, true, this.name); }
[ "protected", "Binding", "bindAnnotatedWithNameToInstance", "(", "TypeReference", "bind", ",", "String", "name", ",", "String", "to", ",", "String", "functionName", ")", "{", "String", "tmpName", "=", "Strings", ".", "emptyIfNull", "(", "name", ")", ";", "if", ...
Bind a type annotated with a name of the given value. @param bind the type to bind. @param name the name to consider. @param to the instance. @param functionName the optional function name. @return the binding element.
[ "Bind", "a", "type", "annotated", "with", "a", "name", "of", "the", "given", "value", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/binding/BindingFactory.java#L191-L219
train
sarl/sarl
main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/binding/BindingFactory.java
BindingFactory.bindToInstance
protected Binding bindToInstance(TypeReference bind, String functionName, String instanceExpression, boolean isSingleton, boolean isEager) { final BindKey type; final BindValue value; if (!Strings.isEmpty(functionName) && functionName.startsWith(CONFIGURE_PREFIX)) { final String fname = functionName.substring(CONFIGURE_PREFIX.length()); type = new BindKey(Strings.toFirstUpper(fname), null, isSingleton, isEager); final StringConcatenationClient client = new StringConcatenationClient() { @Override protected void appendTo(TargetStringConcatenation builder) { builder.append("binder.bind("); //$NON-NLS-1$ builder.append(bind); builder.append(".class).toInstance("); //$NON-NLS-1$ builder.append(instanceExpression); builder.append(");"); //$NON-NLS-1$ } }; value = new BindValue(null, null, false, Collections.singletonList(client)); } else { String fname = functionName; if (fname != null && fname.startsWith(BIND_PREFIX)) { fname = fname.substring(BIND_PREFIX.length()); } type = new BindKey(Strings.toFirstUpper(fname), bind, isSingleton, isEager); final StringConcatenationClient client = new StringConcatenationClient() { @Override protected void appendTo(TargetStringConcatenation builder) { builder.append(instanceExpression); } }; value = new BindValue(client, null, false, Collections.emptyList()); } return new Binding(type, value, true, this.name); }
java
protected Binding bindToInstance(TypeReference bind, String functionName, String instanceExpression, boolean isSingleton, boolean isEager) { final BindKey type; final BindValue value; if (!Strings.isEmpty(functionName) && functionName.startsWith(CONFIGURE_PREFIX)) { final String fname = functionName.substring(CONFIGURE_PREFIX.length()); type = new BindKey(Strings.toFirstUpper(fname), null, isSingleton, isEager); final StringConcatenationClient client = new StringConcatenationClient() { @Override protected void appendTo(TargetStringConcatenation builder) { builder.append("binder.bind("); //$NON-NLS-1$ builder.append(bind); builder.append(".class).toInstance("); //$NON-NLS-1$ builder.append(instanceExpression); builder.append(");"); //$NON-NLS-1$ } }; value = new BindValue(null, null, false, Collections.singletonList(client)); } else { String fname = functionName; if (fname != null && fname.startsWith(BIND_PREFIX)) { fname = fname.substring(BIND_PREFIX.length()); } type = new BindKey(Strings.toFirstUpper(fname), bind, isSingleton, isEager); final StringConcatenationClient client = new StringConcatenationClient() { @Override protected void appendTo(TargetStringConcatenation builder) { builder.append(instanceExpression); } }; value = new BindValue(client, null, false, Collections.emptyList()); } return new Binding(type, value, true, this.name); }
[ "protected", "Binding", "bindToInstance", "(", "TypeReference", "bind", ",", "String", "functionName", ",", "String", "instanceExpression", ",", "boolean", "isSingleton", ",", "boolean", "isEager", ")", "{", "final", "BindKey", "type", ";", "final", "BindValue", "...
Bind a type to an instance expression. @param bind the type to bind. @param functionName the name of the binding function. It may be <code>null</code> for the default name. @param instanceExpression the expression that represents the instance. @param isSingleton indicates if the instance is a singleton. @param isEager indicates if the instance is an eager singleton. @return the binding element.
[ "Bind", "a", "type", "to", "an", "instance", "expression", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/binding/BindingFactory.java#L230-L263
train
sarl/sarl
main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/binding/BindingFactory.java
BindingFactory.add
public void add(Binding binding, boolean override) { final Set<Binding> moduleBindings = this.module.get().getBindings(); final Binding otherBinding = findBinding(moduleBindings, binding); if (!override) { if (otherBinding != null) { throw new IllegalArgumentException(MessageFormat.format( "Forbidden override of {0} by {1}.", //$NON-NLS-1$ otherBinding, binding)); } } else if (otherBinding != null) { this.removableBindings.add(otherBinding); } if (!this.bindings.add(binding)) { throw new IllegalArgumentException( MessageFormat.format("Duplicate binding for {0} in {1}", binding.getKey(), this.name)); //$NON-NLS-1$ } }
java
public void add(Binding binding, boolean override) { final Set<Binding> moduleBindings = this.module.get().getBindings(); final Binding otherBinding = findBinding(moduleBindings, binding); if (!override) { if (otherBinding != null) { throw new IllegalArgumentException(MessageFormat.format( "Forbidden override of {0} by {1}.", //$NON-NLS-1$ otherBinding, binding)); } } else if (otherBinding != null) { this.removableBindings.add(otherBinding); } if (!this.bindings.add(binding)) { throw new IllegalArgumentException( MessageFormat.format("Duplicate binding for {0} in {1}", binding.getKey(), this.name)); //$NON-NLS-1$ } }
[ "public", "void", "add", "(", "Binding", "binding", ",", "boolean", "override", ")", "{", "final", "Set", "<", "Binding", ">", "moduleBindings", "=", "this", ".", "module", ".", "get", "(", ")", ".", "getBindings", "(", ")", ";", "final", "Binding", "o...
Add the binding. @param binding the binding to add. @param override indicates if the binding could override an existing element.
[ "Add", "the", "binding", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/binding/BindingFactory.java#L343-L359
train
sarl/sarl
main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/binding/BindingFactory.java
BindingFactory.contributeToModule
public void contributeToModule() { final GuiceModuleAccess module = this.module.get(); if (!this.removableBindings.isEmpty()) { // Ok, we are broking the Java secutiry manager. // But it's for having something working! try { final Field field = module.getClass().getDeclaredField("bindings"); //$NON-NLS-1$ final boolean accessible = field.isAccessible(); try { field.setAccessible(true); final Collection<?> hiddenBindings = (Collection<?>) field.get(module); hiddenBindings.removeAll(this.removableBindings); } finally { field.setAccessible(accessible); } } catch (Exception exception) { throw new IllegalStateException(exception); } } module.addAll(this.bindings); }
java
public void contributeToModule() { final GuiceModuleAccess module = this.module.get(); if (!this.removableBindings.isEmpty()) { // Ok, we are broking the Java secutiry manager. // But it's for having something working! try { final Field field = module.getClass().getDeclaredField("bindings"); //$NON-NLS-1$ final boolean accessible = field.isAccessible(); try { field.setAccessible(true); final Collection<?> hiddenBindings = (Collection<?>) field.get(module); hiddenBindings.removeAll(this.removableBindings); } finally { field.setAccessible(accessible); } } catch (Exception exception) { throw new IllegalStateException(exception); } } module.addAll(this.bindings); }
[ "public", "void", "contributeToModule", "(", ")", "{", "final", "GuiceModuleAccess", "module", "=", "this", ".", "module", ".", "get", "(", ")", ";", "if", "(", "!", "this", ".", "removableBindings", ".", "isEmpty", "(", ")", ")", "{", "// Ok, we are broki...
Put the bindings to the associated module.
[ "Put", "the", "bindings", "to", "the", "associated", "module", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/binding/BindingFactory.java#L363-L383
train
sarl/sarl
main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/binding/BindingFactory.java
BindingFactory.toBinding
public Binding toBinding(BindingElement element) { final TypeReference typeReference = typeRef(element.getBind()); final String annotatedWith = element.getAnnotatedWith(); final String annotatedWithName = element.getAnnotatedWithName(); if (!Strings.isEmpty(annotatedWith)) { final TypeReference annotationType = typeRef(annotatedWith); if (element.isInstance()) { return bindAnnotatedWithToInstance(typeReference, annotationType, element.getTo(), element.getFunctionName()); } final TypeReference typeReference2 = typeRef(element.getTo()); return bindAnnotatedWith(typeReference, annotationType, typeReference2, element.getFunctionName()); } if (!Strings.isEmpty(annotatedWithName)) { if (element.isInstance()) { return bindAnnotatedWithNameToInstance(typeReference, annotatedWithName, element.getTo(), element.getFunctionName()); } final TypeReference typeReference2 = typeRef(element.getTo()); return bindAnnotatedWithName(typeReference, annotatedWithName, typeReference2, element.getFunctionName()); } if (element.isInstance()) { return bindToInstance(typeReference, element.getFunctionName(), element.getTo(), element.isSingleton(), element.isEager()); } final TypeReference typeReference2 = typeRef(element.getTo()); return bindToType( typeReference, element.getFunctionName(), typeReference2, element.isSingleton(), element.isEager(), element.isProvider()); }
java
public Binding toBinding(BindingElement element) { final TypeReference typeReference = typeRef(element.getBind()); final String annotatedWith = element.getAnnotatedWith(); final String annotatedWithName = element.getAnnotatedWithName(); if (!Strings.isEmpty(annotatedWith)) { final TypeReference annotationType = typeRef(annotatedWith); if (element.isInstance()) { return bindAnnotatedWithToInstance(typeReference, annotationType, element.getTo(), element.getFunctionName()); } final TypeReference typeReference2 = typeRef(element.getTo()); return bindAnnotatedWith(typeReference, annotationType, typeReference2, element.getFunctionName()); } if (!Strings.isEmpty(annotatedWithName)) { if (element.isInstance()) { return bindAnnotatedWithNameToInstance(typeReference, annotatedWithName, element.getTo(), element.getFunctionName()); } final TypeReference typeReference2 = typeRef(element.getTo()); return bindAnnotatedWithName(typeReference, annotatedWithName, typeReference2, element.getFunctionName()); } if (element.isInstance()) { return bindToInstance(typeReference, element.getFunctionName(), element.getTo(), element.isSingleton(), element.isEager()); } final TypeReference typeReference2 = typeRef(element.getTo()); return bindToType( typeReference, element.getFunctionName(), typeReference2, element.isSingleton(), element.isEager(), element.isProvider()); }
[ "public", "Binding", "toBinding", "(", "BindingElement", "element", ")", "{", "final", "TypeReference", "typeReference", "=", "typeRef", "(", "element", ".", "getBind", "(", ")", ")", ";", "final", "String", "annotatedWith", "=", "element", ".", "getAnnotatedWit...
Convert a binding element to a Guive binding. @param element the element to convert. @return the Guice binding.
[ "Convert", "a", "binding", "element", "to", "a", "Guive", "binding", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/binding/BindingFactory.java#L405-L444
train
sarl/sarl
main/coreplugins/io.sarl.m2e/src/io/sarl/m2e/wizards/importproject/EnableSarlMavenNatureAction.java
EnableSarlMavenNatureAction.enableNature
protected void enableNature(IProject project) { final IFile pom = project.getFile(IMavenConstants.POM_FILE_NAME); final Job job; if (pom.exists()) { job = createJobForMavenProject(project); } else { job = createJobForJavaProject(project); } if (job != null) { job.schedule(); } }
java
protected void enableNature(IProject project) { final IFile pom = project.getFile(IMavenConstants.POM_FILE_NAME); final Job job; if (pom.exists()) { job = createJobForMavenProject(project); } else { job = createJobForJavaProject(project); } if (job != null) { job.schedule(); } }
[ "protected", "void", "enableNature", "(", "IProject", "project", ")", "{", "final", "IFile", "pom", "=", "project", ".", "getFile", "(", "IMavenConstants", ".", "POM_FILE_NAME", ")", ";", "final", "Job", "job", ";", "if", "(", "pom", ".", "exists", "(", ...
Enable the SARL Maven nature. @param project the project.
[ "Enable", "the", "SARL", "Maven", "nature", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.m2e/src/io/sarl/m2e/wizards/importproject/EnableSarlMavenNatureAction.java#L122-L133
train
sarl/sarl
main/coreplugins/io.sarl.m2e/src/io/sarl/m2e/wizards/importproject/EnableSarlMavenNatureAction.java
EnableSarlMavenNatureAction.createJobForMavenProject
@SuppressWarnings("static-method") protected Job createJobForMavenProject(IProject project) { return new Job(Messages.EnableSarlMavenNatureAction_0) { @Override protected IStatus run(IProgressMonitor monitor) { final SubMonitor mon = SubMonitor.convert(monitor, 3); try { // The project should be a Maven project. final IPath descriptionFilename = project.getFile(new Path(IProjectDescription.DESCRIPTION_FILE_NAME)).getLocation(); final File projectDescriptionFile = descriptionFilename.toFile(); final IPath classpathFilename = project.getFile(new Path(FILENAME_CLASSPATH)).getLocation(); final File classpathFile = classpathFilename.toFile(); // Project was open by the super class. Close it because Maven fails when a project already exists. project.close(mon.newChild(1)); // Delete the Eclipse project and classpath definitions because Maven fails when a project already exists. project.delete(false, true, mon.newChild(1)); if (projectDescriptionFile.exists()) { projectDescriptionFile.delete(); } if (classpathFile.exists()) { classpathFile.delete(); } // Import MavenImportUtils.importMavenProject( project.getWorkspace().getRoot(), project.getName(), true, mon.newChild(1)); } catch (CoreException exception) { SARLMavenEclipsePlugin.getDefault().log(exception); } return Status.OK_STATUS; } }; }
java
@SuppressWarnings("static-method") protected Job createJobForMavenProject(IProject project) { return new Job(Messages.EnableSarlMavenNatureAction_0) { @Override protected IStatus run(IProgressMonitor monitor) { final SubMonitor mon = SubMonitor.convert(monitor, 3); try { // The project should be a Maven project. final IPath descriptionFilename = project.getFile(new Path(IProjectDescription.DESCRIPTION_FILE_NAME)).getLocation(); final File projectDescriptionFile = descriptionFilename.toFile(); final IPath classpathFilename = project.getFile(new Path(FILENAME_CLASSPATH)).getLocation(); final File classpathFile = classpathFilename.toFile(); // Project was open by the super class. Close it because Maven fails when a project already exists. project.close(mon.newChild(1)); // Delete the Eclipse project and classpath definitions because Maven fails when a project already exists. project.delete(false, true, mon.newChild(1)); if (projectDescriptionFile.exists()) { projectDescriptionFile.delete(); } if (classpathFile.exists()) { classpathFile.delete(); } // Import MavenImportUtils.importMavenProject( project.getWorkspace().getRoot(), project.getName(), true, mon.newChild(1)); } catch (CoreException exception) { SARLMavenEclipsePlugin.getDefault().log(exception); } return Status.OK_STATUS; } }; }
[ "@", "SuppressWarnings", "(", "\"static-method\"", ")", "protected", "Job", "createJobForMavenProject", "(", "IProject", "project", ")", "{", "return", "new", "Job", "(", "Messages", ".", "EnableSarlMavenNatureAction_0", ")", "{", "@", "Override", "protected", "ISta...
Create the configuration job for a Maven project. @param project the project to configure. @return the job.
[ "Create", "the", "configuration", "job", "for", "a", "Maven", "project", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.m2e/src/io/sarl/m2e/wizards/importproject/EnableSarlMavenNatureAction.java#L140-L175
train
sarl/sarl
main/coreplugins/io.sarl.m2e/src/io/sarl/m2e/wizards/importproject/EnableSarlMavenNatureAction.java
EnableSarlMavenNatureAction.createJobForJavaProject
@SuppressWarnings("static-method") protected Job createJobForJavaProject(IProject project) { return new Job(Messages.EnableSarlMavenNatureAction_0) { @Override protected IStatus run(IProgressMonitor monitor) { final SubMonitor mon = SubMonitor.convert(monitor, 3); // Force the project configuration to SARL. SARLProjectConfigurator.configureSARLProject( // Project to configure project, // Add SARL natures true, // Force java configuration true, // Create folders true, // Monitor mon.newChild(3)); return Status.OK_STATUS; } }; }
java
@SuppressWarnings("static-method") protected Job createJobForJavaProject(IProject project) { return new Job(Messages.EnableSarlMavenNatureAction_0) { @Override protected IStatus run(IProgressMonitor monitor) { final SubMonitor mon = SubMonitor.convert(monitor, 3); // Force the project configuration to SARL. SARLProjectConfigurator.configureSARLProject( // Project to configure project, // Add SARL natures true, // Force java configuration true, // Create folders true, // Monitor mon.newChild(3)); return Status.OK_STATUS; } }; }
[ "@", "SuppressWarnings", "(", "\"static-method\"", ")", "protected", "Job", "createJobForJavaProject", "(", "IProject", "project", ")", "{", "return", "new", "Job", "(", "Messages", ".", "EnableSarlMavenNatureAction_0", ")", "{", "@", "Override", "protected", "IStat...
Create the configuration job for a Java project. @param project the project to configure. @return the job.
[ "Create", "the", "configuration", "job", "for", "a", "Java", "project", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.m2e/src/io/sarl/m2e/wizards/importproject/EnableSarlMavenNatureAction.java#L182-L204
train
sarl/sarl
sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/jdk/spawn/StandardSpawnService.java
StandardSpawnService.fireAgentSpawnedOutsideAgent
protected void fireAgentSpawnedOutsideAgent(UUID spawningAgent, AgentContext context, Class<? extends Agent> agentClazz, List<Agent> agents, Object... initializationParameters) { // Notify the listeners on the spawn events (not restricted to a single agent) for (final SpawnServiceListener l : this.globalListeners.getListeners(SpawnServiceListener.class)) { l.agentSpawned(spawningAgent, context, agents, initializationParameters); } // Send the event in the default space. final EventSpace defSpace = context.getDefaultSpace(); assert defSpace != null : "A context does not contain a default space"; //$NON-NLS-1$ final UUID spawner = spawningAgent == null ? context.getID() : spawningAgent; final Address source = new Address(defSpace.getSpaceID(), spawner); assert source != null; final Collection<UUID> spawnedAgentIds = Collections3.serializableCollection( Collections2.transform(agents, it -> it.getID())); final AgentSpawned event = new AgentSpawned(source, agentClazz.getName(), spawnedAgentIds); final Scope<Address> scope = address -> { final UUID receiver = address.getUUID(); return !spawnedAgentIds.parallelStream().anyMatch(it -> it.equals(receiver)); }; // Event must not be received by the spawned agent. defSpace.emit( // No need to give an event source because it is explicitly set above. null, event, scope); }
java
protected void fireAgentSpawnedOutsideAgent(UUID spawningAgent, AgentContext context, Class<? extends Agent> agentClazz, List<Agent> agents, Object... initializationParameters) { // Notify the listeners on the spawn events (not restricted to a single agent) for (final SpawnServiceListener l : this.globalListeners.getListeners(SpawnServiceListener.class)) { l.agentSpawned(spawningAgent, context, agents, initializationParameters); } // Send the event in the default space. final EventSpace defSpace = context.getDefaultSpace(); assert defSpace != null : "A context does not contain a default space"; //$NON-NLS-1$ final UUID spawner = spawningAgent == null ? context.getID() : spawningAgent; final Address source = new Address(defSpace.getSpaceID(), spawner); assert source != null; final Collection<UUID> spawnedAgentIds = Collections3.serializableCollection( Collections2.transform(agents, it -> it.getID())); final AgentSpawned event = new AgentSpawned(source, agentClazz.getName(), spawnedAgentIds); final Scope<Address> scope = address -> { final UUID receiver = address.getUUID(); return !spawnedAgentIds.parallelStream().anyMatch(it -> it.equals(receiver)); }; // Event must not be received by the spawned agent. defSpace.emit( // No need to give an event source because it is explicitly set above. null, event, scope); }
[ "protected", "void", "fireAgentSpawnedOutsideAgent", "(", "UUID", "spawningAgent", ",", "AgentContext", "context", ",", "Class", "<", "?", "extends", "Agent", ">", "agentClazz", ",", "List", "<", "Agent", ">", "agents", ",", "Object", "...", "initializationParamet...
Notify the listeners about the agents' spawning. @param spawningAgent the spawning agent. @param context the context in which the agents were spawned. @param agentClazz the type of the spwnaed agents. @param agents the spawned agents. @param initializationParameters the initialization parameters.
[ "Notify", "the", "listeners", "about", "the", "agents", "spawning", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/jdk/spawn/StandardSpawnService.java#L213-L239
train
sarl/sarl
sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/jdk/spawn/StandardSpawnService.java
StandardSpawnService.fireAgentSpawnedInAgent
protected void fireAgentSpawnedInAgent(UUID spawningAgent, AgentContext context, Agent agent, Object... initializationParameters) { // Notify the listeners on the lifecycle events inside // the just spawned agent. // Usually, only BICs and the AgentLifeCycleSupport in // io.janusproject.kernel.bic.StandardBuiltinCapacitiesProvider // is invoked. final ListenerCollection<SpawnServiceListener> list; synchronized (this.agentLifecycleListeners) { list = this.agentLifecycleListeners.get(agent.getID()); } if (list != null) { final List<Agent> singleton = Collections.singletonList(agent); for (final SpawnServiceListener l : list.getListeners(SpawnServiceListener.class)) { l.agentSpawned(spawningAgent, context, singleton, initializationParameters); } } }
java
protected void fireAgentSpawnedInAgent(UUID spawningAgent, AgentContext context, Agent agent, Object... initializationParameters) { // Notify the listeners on the lifecycle events inside // the just spawned agent. // Usually, only BICs and the AgentLifeCycleSupport in // io.janusproject.kernel.bic.StandardBuiltinCapacitiesProvider // is invoked. final ListenerCollection<SpawnServiceListener> list; synchronized (this.agentLifecycleListeners) { list = this.agentLifecycleListeners.get(agent.getID()); } if (list != null) { final List<Agent> singleton = Collections.singletonList(agent); for (final SpawnServiceListener l : list.getListeners(SpawnServiceListener.class)) { l.agentSpawned(spawningAgent, context, singleton, initializationParameters); } } }
[ "protected", "void", "fireAgentSpawnedInAgent", "(", "UUID", "spawningAgent", ",", "AgentContext", "context", ",", "Agent", "agent", ",", "Object", "...", "initializationParameters", ")", "{", "// Notify the listeners on the lifecycle events inside", "// the just spawned agent....
Notify the agent's listeners about its spawning. @param spawningAgent the spawning agent. @param context the context in which the agent was spawned. @param agent the spawned agent. @param initializationParameters the initialization parameters.
[ "Notify", "the", "agent", "s", "listeners", "about", "its", "spawning", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/jdk/spawn/StandardSpawnService.java#L248-L264
train
sarl/sarl
sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/jdk/spawn/StandardSpawnService.java
StandardSpawnService.getAgents
public SynchronizedSet<UUID> getAgents() { final Object mutex = getAgentRepositoryMutex(); synchronized (mutex) { return Collections3.synchronizedSet(this.agents.keySet(), mutex); } }
java
public SynchronizedSet<UUID> getAgents() { final Object mutex = getAgentRepositoryMutex(); synchronized (mutex) { return Collections3.synchronizedSet(this.agents.keySet(), mutex); } }
[ "public", "SynchronizedSet", "<", "UUID", ">", "getAgents", "(", ")", "{", "final", "Object", "mutex", "=", "getAgentRepositoryMutex", "(", ")", ";", "synchronized", "(", "mutex", ")", "{", "return", "Collections3", ".", "synchronizedSet", "(", "this", ".", ...
Replies the registered agents. @return the registered agents.
[ "Replies", "the", "registered", "agents", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/jdk/spawn/StandardSpawnService.java#L330-L335
train
sarl/sarl
sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/jdk/spawn/StandardSpawnService.java
StandardSpawnService.getAgent
Agent getAgent(UUID id) { assert id != null; synchronized (getAgentRepositoryMutex()) { return this.agents.get(id); } }
java
Agent getAgent(UUID id) { assert id != null; synchronized (getAgentRepositoryMutex()) { return this.agents.get(id); } }
[ "Agent", "getAgent", "(", "UUID", "id", ")", "{", "assert", "id", "!=", "null", ";", "synchronized", "(", "getAgentRepositoryMutex", "(", ")", ")", "{", "return", "this", ".", "agents", ".", "get", "(", "id", ")", ";", "}", "}" ]
Replies the registered agent. @param id is the identifier of the agent. @return the registered agent, or <code>null</code>.
[ "Replies", "the", "registered", "agent", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/jdk/spawn/StandardSpawnService.java#L344-L349
train
sarl/sarl
sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/jdk/spawn/StandardSpawnService.java
StandardSpawnService.canKillAgent
@SuppressWarnings("static-method") public boolean canKillAgent(Agent agent) { try { final AgentContext ac = BuiltinCapacityUtil.getContextIn(agent); if (ac != null) { final SynchronizedSet<UUID> participants = ac.getDefaultSpace().getParticipants(); if (participants != null) { synchronized (participants.mutex()) { if (participants.size() > 1 || (participants.size() == 1 && !participants.contains(agent.getID()))) { return false; } } } } return true; } catch (Throwable exception) { return false; } }
java
@SuppressWarnings("static-method") public boolean canKillAgent(Agent agent) { try { final AgentContext ac = BuiltinCapacityUtil.getContextIn(agent); if (ac != null) { final SynchronizedSet<UUID> participants = ac.getDefaultSpace().getParticipants(); if (participants != null) { synchronized (participants.mutex()) { if (participants.size() > 1 || (participants.size() == 1 && !participants.contains(agent.getID()))) { return false; } } } } return true; } catch (Throwable exception) { return false; } }
[ "@", "SuppressWarnings", "(", "\"static-method\"", ")", "public", "boolean", "canKillAgent", "(", "Agent", "agent", ")", "{", "try", "{", "final", "AgentContext", "ac", "=", "BuiltinCapacityUtil", ".", "getContextIn", "(", "agent", ")", ";", "if", "(", "ac", ...
Replies if the given agent can be killed. @param agent - agent to test. @return <code>true</code> if the given agent can be killed, otherwise <code>false</code>.
[ "Replies", "if", "the", "given", "agent", "can", "be", "killed", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/jdk/spawn/StandardSpawnService.java#L421-L440
train
sarl/sarl
sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/jdk/spawn/StandardSpawnService.java
StandardSpawnService.fireAgentDestroyed
@SuppressWarnings({"checkstyle:npathcomplexity"}) protected void fireAgentDestroyed(Agent agent) { final ListenerCollection<SpawnServiceListener> list; synchronized (getAgentLifecycleListenerMutex()) { list = this.agentLifecycleListeners.get(agent.getID()); } final SpawnServiceListener[] ilisteners; if (list != null) { ilisteners = list.getListeners(SpawnServiceListener.class); } else { ilisteners = null; } final SpawnServiceListener[] ilisteners2 = this.globalListeners.getListeners(SpawnServiceListener.class); // Retrieve the agent's contexts final List<Pair<AgentContext, Address>> contextRegistrations = new ArrayList<>(); try { final SynchronizedIterable<AgentContext> allContexts = BuiltinCapacityUtil.getContextsOf(agent); synchronized (allContexts.mutex()) { for (final AgentContext context : allContexts) { final EventSpace defSpace = context.getDefaultSpace(); final Address address = defSpace.getAddress(agent.getID()); contextRegistrations.add(Pair.of(context, address)); } } } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } // Local agent and framework destruction if (ilisteners != null) { for (final SpawnServiceListener l : ilisteners) { l.agentDestroy(agent); } } for (final SpawnServiceListener l : ilisteners2) { l.agentDestroy(agent); } // Fire AgentKilled into the associated contexts try { final UUID killedAgentId = agent.getID(); final Scope<Address> scope = address -> { final UUID receiver = address.getUUID(); return !receiver.equals(killedAgentId); }; final String killedAgentType = agent.getClass().getName(); for (final Pair<AgentContext, Address> registration : contextRegistrations) { final EventSpace defSpace = registration.getKey().getDefaultSpace(); defSpace.emit( // No need to give an event source because it is explicitly set below. null, new AgentKilled( registration.getValue(), killedAgentId, killedAgentType), scope); } } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } }
java
@SuppressWarnings({"checkstyle:npathcomplexity"}) protected void fireAgentDestroyed(Agent agent) { final ListenerCollection<SpawnServiceListener> list; synchronized (getAgentLifecycleListenerMutex()) { list = this.agentLifecycleListeners.get(agent.getID()); } final SpawnServiceListener[] ilisteners; if (list != null) { ilisteners = list.getListeners(SpawnServiceListener.class); } else { ilisteners = null; } final SpawnServiceListener[] ilisteners2 = this.globalListeners.getListeners(SpawnServiceListener.class); // Retrieve the agent's contexts final List<Pair<AgentContext, Address>> contextRegistrations = new ArrayList<>(); try { final SynchronizedIterable<AgentContext> allContexts = BuiltinCapacityUtil.getContextsOf(agent); synchronized (allContexts.mutex()) { for (final AgentContext context : allContexts) { final EventSpace defSpace = context.getDefaultSpace(); final Address address = defSpace.getAddress(agent.getID()); contextRegistrations.add(Pair.of(context, address)); } } } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } // Local agent and framework destruction if (ilisteners != null) { for (final SpawnServiceListener l : ilisteners) { l.agentDestroy(agent); } } for (final SpawnServiceListener l : ilisteners2) { l.agentDestroy(agent); } // Fire AgentKilled into the associated contexts try { final UUID killedAgentId = agent.getID(); final Scope<Address> scope = address -> { final UUID receiver = address.getUUID(); return !receiver.equals(killedAgentId); }; final String killedAgentType = agent.getClass().getName(); for (final Pair<AgentContext, Address> registration : contextRegistrations) { final EventSpace defSpace = registration.getKey().getDefaultSpace(); defSpace.emit( // No need to give an event source because it is explicitly set below. null, new AgentKilled( registration.getValue(), killedAgentId, killedAgentType), scope); } } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } }
[ "@", "SuppressWarnings", "(", "{", "\"checkstyle:npathcomplexity\"", "}", ")", "protected", "void", "fireAgentDestroyed", "(", "Agent", "agent", ")", "{", "final", "ListenerCollection", "<", "SpawnServiceListener", ">", "list", ";", "synchronized", "(", "getAgentLifec...
Notifies the listeners about the agent destruction. @param agent - the destroyed agent.
[ "Notifies", "the", "listeners", "about", "the", "agent", "destruction", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/jdk/spawn/StandardSpawnService.java#L448-L508
train
sarl/sarl
main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/log/IssueInformationPage.java
IssueInformationPage.initFields
protected void initFields() { final IEclipsePreferences prefs = SARLEclipsePlugin.getDefault().getPreferences(); this.trackerLogin.setText(prefs.get(PREFERENCE_LOGIN, "")); //$NON-NLS-1$ }
java
protected void initFields() { final IEclipsePreferences prefs = SARLEclipsePlugin.getDefault().getPreferences(); this.trackerLogin.setText(prefs.get(PREFERENCE_LOGIN, "")); //$NON-NLS-1$ }
[ "protected", "void", "initFields", "(", ")", "{", "final", "IEclipsePreferences", "prefs", "=", "SARLEclipsePlugin", ".", "getDefault", "(", ")", ".", "getPreferences", "(", ")", ";", "this", ".", "trackerLogin", ".", "setText", "(", "prefs", ".", "get", "("...
Set the initial values to the fields.
[ "Set", "the", "initial", "values", "to", "the", "fields", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/log/IssueInformationPage.java#L195-L198
train
sarl/sarl
main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/log/IssueInformationPage.java
IssueInformationPage.updatePageStatus
protected void updatePageStatus() { final boolean ok; if (Strings.isEmpty(this.titleField.getText())) { ok = false; setMessage(Messages.IssueInformationPage_5, IMessageProvider.ERROR); } else if (Strings.isEmpty(this.trackerLogin.getText())) { ok = false; setMessage(Messages.IssueInformationPage_6, IMessageProvider.ERROR); } else if (Strings.isEmpty(this.trackerPassword.getText())) { ok = false; setMessage(Messages.IssueInformationPage_7, IMessageProvider.ERROR); } else { ok = true; if (Strings.isEmpty(this.descriptionField.getText())) { setMessage(Messages.IssueInformationPage_8, IMessageProvider.WARNING); } else { setMessage(null, IMessageProvider.NONE); } } setPageComplete(ok); }
java
protected void updatePageStatus() { final boolean ok; if (Strings.isEmpty(this.titleField.getText())) { ok = false; setMessage(Messages.IssueInformationPage_5, IMessageProvider.ERROR); } else if (Strings.isEmpty(this.trackerLogin.getText())) { ok = false; setMessage(Messages.IssueInformationPage_6, IMessageProvider.ERROR); } else if (Strings.isEmpty(this.trackerPassword.getText())) { ok = false; setMessage(Messages.IssueInformationPage_7, IMessageProvider.ERROR); } else { ok = true; if (Strings.isEmpty(this.descriptionField.getText())) { setMessage(Messages.IssueInformationPage_8, IMessageProvider.WARNING); } else { setMessage(null, IMessageProvider.NONE); } } setPageComplete(ok); }
[ "protected", "void", "updatePageStatus", "(", ")", "{", "final", "boolean", "ok", ";", "if", "(", "Strings", ".", "isEmpty", "(", "this", ".", "titleField", ".", "getText", "(", ")", ")", ")", "{", "ok", "=", "false", ";", "setMessage", "(", "Messages"...
Update the page status and change the "finish" state button.
[ "Update", "the", "page", "status", "and", "change", "the", "finish", "state", "button", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/log/IssueInformationPage.java#L202-L222
train
sarl/sarl
main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/log/IssueInformationPage.java
IssueInformationPage.performFinish
public boolean performFinish() { final IEclipsePreferences prefs = SARLEclipsePlugin.getDefault().getPreferences(); final String login = this.trackerLogin.getText(); if (Strings.isEmpty(login)) { prefs.remove(PREFERENCE_LOGIN); } else { prefs.put(PREFERENCE_LOGIN, login); } try { prefs.sync(); return true; } catch (BackingStoreException e) { ErrorDialog.openError(getShell(), e.getLocalizedMessage(), e.getLocalizedMessage(), SARLEclipsePlugin.getDefault().createStatus(IStatus.ERROR, e)); return false; } }
java
public boolean performFinish() { final IEclipsePreferences prefs = SARLEclipsePlugin.getDefault().getPreferences(); final String login = this.trackerLogin.getText(); if (Strings.isEmpty(login)) { prefs.remove(PREFERENCE_LOGIN); } else { prefs.put(PREFERENCE_LOGIN, login); } try { prefs.sync(); return true; } catch (BackingStoreException e) { ErrorDialog.openError(getShell(), e.getLocalizedMessage(), e.getLocalizedMessage(), SARLEclipsePlugin.getDefault().createStatus(IStatus.ERROR, e)); return false; } }
[ "public", "boolean", "performFinish", "(", ")", "{", "final", "IEclipsePreferences", "prefs", "=", "SARLEclipsePlugin", ".", "getDefault", "(", ")", ".", "getPreferences", "(", ")", ";", "final", "String", "login", "=", "this", ".", "trackerLogin", ".", "getTe...
Invoked when the wizard is closed with the "Finish" button. @return {@code true} for closing the wizard; {@code false} for keeping it open.
[ "Invoked", "when", "the", "wizard", "is", "closed", "with", "the", "Finish", "button", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/log/IssueInformationPage.java#L228-L244
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/formatting2/FormatterFacade.java
FormatterFacade.format
@Pure public String format(String sarlCode, ResourceSet resourceSet) { try { final URI createURI = URI.createURI("synthetic://to-be-formatted." + this.fileExtension); //$NON-NLS-1$ final Resource res = this.resourceFactory.createResource(createURI); if (res instanceof XtextResource) { final XtextResource resource = (XtextResource) res; final EList<Resource> resources = resourceSet.getResources(); resources.add(resource); try (StringInputStream stringInputStream = new StringInputStream(sarlCode)) { resource.load(stringInputStream, Collections.emptyMap()); return formatResource(resource); } finally { resources.remove(resource); } } return sarlCode; } catch (Exception exception) { throw Exceptions.sneakyThrow(exception); } }
java
@Pure public String format(String sarlCode, ResourceSet resourceSet) { try { final URI createURI = URI.createURI("synthetic://to-be-formatted." + this.fileExtension); //$NON-NLS-1$ final Resource res = this.resourceFactory.createResource(createURI); if (res instanceof XtextResource) { final XtextResource resource = (XtextResource) res; final EList<Resource> resources = resourceSet.getResources(); resources.add(resource); try (StringInputStream stringInputStream = new StringInputStream(sarlCode)) { resource.load(stringInputStream, Collections.emptyMap()); return formatResource(resource); } finally { resources.remove(resource); } } return sarlCode; } catch (Exception exception) { throw Exceptions.sneakyThrow(exception); } }
[ "@", "Pure", "public", "String", "format", "(", "String", "sarlCode", ",", "ResourceSet", "resourceSet", ")", "{", "try", "{", "final", "URI", "createURI", "=", "URI", ".", "createURI", "(", "\"synthetic://to-be-formatted.\"", "+", "this", ".", "fileExtension", ...
Format the given code. @param sarlCode the code to format. @param resourceSet the resource set that sohuld contains the code. This resource set may be used for resolving types by the underlying code. @return the code to format.
[ "Format", "the", "given", "code", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/formatting2/FormatterFacade.java#L95-L115
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/typesystem/SARLExpressionHelper.java
SARLExpressionHelper.toBooleanPrimitiveWrapperConstant
@SuppressWarnings("static-method") public Boolean toBooleanPrimitiveWrapperConstant(XExpression expression) { if (expression instanceof XBooleanLiteral) { return ((XBooleanLiteral) expression).isIsTrue() ? Boolean.TRUE : Boolean.FALSE; } if (expression instanceof XMemberFeatureCall) { final XMemberFeatureCall call = (XMemberFeatureCall) expression; final XExpression receiver = call.getMemberCallTarget(); if (receiver instanceof XFeatureCall) { final XFeatureCall call2 = (XFeatureCall) receiver; final String call2Identifier = call2.getConcreteSyntaxFeatureName(); if (Boolean.class.getSimpleName().equals(call2Identifier) || Boolean.class.getName().equals(call2Identifier)) { final String callIdentifier = call.getConcreteSyntaxFeatureName(); if ("TRUE".equals(callIdentifier)) { //$NON-NLS-1$ return Boolean.TRUE; } else if ("FALSE".equals(callIdentifier)) { //$NON-NLS-1$ return Boolean.FALSE; } } } } return null; }
java
@SuppressWarnings("static-method") public Boolean toBooleanPrimitiveWrapperConstant(XExpression expression) { if (expression instanceof XBooleanLiteral) { return ((XBooleanLiteral) expression).isIsTrue() ? Boolean.TRUE : Boolean.FALSE; } if (expression instanceof XMemberFeatureCall) { final XMemberFeatureCall call = (XMemberFeatureCall) expression; final XExpression receiver = call.getMemberCallTarget(); if (receiver instanceof XFeatureCall) { final XFeatureCall call2 = (XFeatureCall) receiver; final String call2Identifier = call2.getConcreteSyntaxFeatureName(); if (Boolean.class.getSimpleName().equals(call2Identifier) || Boolean.class.getName().equals(call2Identifier)) { final String callIdentifier = call.getConcreteSyntaxFeatureName(); if ("TRUE".equals(callIdentifier)) { //$NON-NLS-1$ return Boolean.TRUE; } else if ("FALSE".equals(callIdentifier)) { //$NON-NLS-1$ return Boolean.FALSE; } } } } return null; }
[ "@", "SuppressWarnings", "(", "\"static-method\"", ")", "public", "Boolean", "toBooleanPrimitiveWrapperConstant", "(", "XExpression", "expression", ")", "{", "if", "(", "expression", "instanceof", "XBooleanLiteral", ")", "{", "return", "(", "(", "XBooleanLiteral", ")"...
Convert the boolean constant to the object equivalent if possible. @param expression the expression to convert. @return one of the boolean constants {@link Boolean#TRUE} or {@link Boolean#FALSE}, or {@code null} if the expression is not a constant boolean expression.
[ "Convert", "the", "boolean", "constant", "to", "the", "object", "equivalent", "if", "possible", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/typesystem/SARLExpressionHelper.java#L99-L121
train
sarl/sarl
main/coreplugins/io.sarl.lang.core/src/io/sarl/lang/core/Event.java
Event.isFrom
@Pure public boolean isFrom(UUID entityId) { final Address iSource = getSource(); return (entityId != null) && (iSource != null) && entityId.equals(iSource.getUUID()); }
java
@Pure public boolean isFrom(UUID entityId) { final Address iSource = getSource(); return (entityId != null) && (iSource != null) && entityId.equals(iSource.getUUID()); }
[ "@", "Pure", "public", "boolean", "isFrom", "(", "UUID", "entityId", ")", "{", "final", "Address", "iSource", "=", "getSource", "(", ")", ";", "return", "(", "entityId", "!=", "null", ")", "&&", "(", "iSource", "!=", "null", ")", "&&", "entityId", ".",...
Replies if the event was emitted by an entity with the given identifier. @param entityId the identifier of the emitter to test. @return <code>true</code> if the given event was emitted by an entity with the given identifier; otherwise <code>false</code>. @since 0.2
[ "Replies", "if", "the", "event", "was", "emitted", "by", "an", "entity", "with", "the", "given", "identifier", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.core/src/io/sarl/lang/core/Event.java#L143-L148
train
sarl/sarl
contribs/io.sarl.pythongenerator/io.sarl.pythongenerator.generator/src/io/sarl/pythongenerator/generator/generator/PyExpressionGenerator.java
PyExpressionGenerator.generateClosureDefinition
protected void generateClosureDefinition(XClosure closure, IAppendable it, IExtraLanguageGeneratorContext context) { if (!it.hasName(closure)) { final LightweightTypeReference closureType0 = getExpectedType(closure); LightweightTypeReference closureType = closureType0; if (closureType0.isFunctionType()) { final FunctionTypeReference fctRef = closureType0.tryConvertToFunctionTypeReference(true); if (fctRef != null) { closureType = Utils.toLightweightTypeReference(fctRef.getType(), this.typeServices).getRawTypeReference(); } } final String closureName = it.declareSyntheticVariable(closure, "__Jclosure_" //$NON-NLS-1$ + closureType.getSimpleName()); final JvmDeclaredType rawType = (JvmDeclaredType) closureType.getType(); final JvmOperation function = rawType.getDeclaredOperations().iterator().next(); // Add the object type as super type because of an issue in the Python language. final JvmTypeReference objType = getTypeReferences().getTypeForName(Object.class, closure); it.openPseudoScope(); it.append("class ").append(closureName).append("(") //$NON-NLS-1$//$NON-NLS-2$ .append(closureType).append(",").append(objType.getType()).append("):") //$NON-NLS-1$ //$NON-NLS-2$ .increaseIndentation().newLine().append("def ") //$NON-NLS-1$ .append(function.getSimpleName()).append("(") //$NON-NLS-1$ .append(getExtraLanguageKeywordProvider().getThisKeywordLambda().apply()); for (final JvmFormalParameter param : closure.getFormalParameters()) { it.append(", "); //$NON-NLS-1$ final String name = it.declareUniqueNameVariable(param, param.getName()); it.append(name); } it.append("):"); //$NON-NLS-1$ it.increaseIndentation().newLine(); if (closure.getExpression() != null) { LightweightTypeReference returnType = closureType0; if (returnType.isFunctionType()) { final FunctionTypeReference fctRef = returnType.tryConvertToFunctionTypeReference(true); if (fctRef != null) { returnType = fctRef.getReturnType(); } else { returnType = null; } } else { returnType = null; } //LightweightTypeReference returnType = getClosureOperationReturnType(type, operation); generate(closure.getExpression(), returnType, it, context); } else { it.append("pass"); //$NON-NLS-1$ } it.decreaseIndentation().decreaseIndentation().newLine(); it.closeScope(); } }
java
protected void generateClosureDefinition(XClosure closure, IAppendable it, IExtraLanguageGeneratorContext context) { if (!it.hasName(closure)) { final LightweightTypeReference closureType0 = getExpectedType(closure); LightweightTypeReference closureType = closureType0; if (closureType0.isFunctionType()) { final FunctionTypeReference fctRef = closureType0.tryConvertToFunctionTypeReference(true); if (fctRef != null) { closureType = Utils.toLightweightTypeReference(fctRef.getType(), this.typeServices).getRawTypeReference(); } } final String closureName = it.declareSyntheticVariable(closure, "__Jclosure_" //$NON-NLS-1$ + closureType.getSimpleName()); final JvmDeclaredType rawType = (JvmDeclaredType) closureType.getType(); final JvmOperation function = rawType.getDeclaredOperations().iterator().next(); // Add the object type as super type because of an issue in the Python language. final JvmTypeReference objType = getTypeReferences().getTypeForName(Object.class, closure); it.openPseudoScope(); it.append("class ").append(closureName).append("(") //$NON-NLS-1$//$NON-NLS-2$ .append(closureType).append(",").append(objType.getType()).append("):") //$NON-NLS-1$ //$NON-NLS-2$ .increaseIndentation().newLine().append("def ") //$NON-NLS-1$ .append(function.getSimpleName()).append("(") //$NON-NLS-1$ .append(getExtraLanguageKeywordProvider().getThisKeywordLambda().apply()); for (final JvmFormalParameter param : closure.getFormalParameters()) { it.append(", "); //$NON-NLS-1$ final String name = it.declareUniqueNameVariable(param, param.getName()); it.append(name); } it.append("):"); //$NON-NLS-1$ it.increaseIndentation().newLine(); if (closure.getExpression() != null) { LightweightTypeReference returnType = closureType0; if (returnType.isFunctionType()) { final FunctionTypeReference fctRef = returnType.tryConvertToFunctionTypeReference(true); if (fctRef != null) { returnType = fctRef.getReturnType(); } else { returnType = null; } } else { returnType = null; } //LightweightTypeReference returnType = getClosureOperationReturnType(type, operation); generate(closure.getExpression(), returnType, it, context); } else { it.append("pass"); //$NON-NLS-1$ } it.decreaseIndentation().decreaseIndentation().newLine(); it.closeScope(); } }
[ "protected", "void", "generateClosureDefinition", "(", "XClosure", "closure", ",", "IAppendable", "it", ",", "IExtraLanguageGeneratorContext", "context", ")", "{", "if", "(", "!", "it", ".", "hasName", "(", "closure", ")", ")", "{", "final", "LightweightTypeRefere...
Generate the closure definition. @param closure the closure. @param it the target for the generated content. @param context the context.
[ "Generate", "the", "closure", "definition", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/contribs/io.sarl.pythongenerator/io.sarl.pythongenerator.generator/src/io/sarl/pythongenerator/generator/generator/PyExpressionGenerator.java#L154-L203
train
sarl/sarl
contribs/io.sarl.pythongenerator/io.sarl.pythongenerator.generator/src/io/sarl/pythongenerator/generator/generator/PyExpressionGenerator.java
PyExpressionGenerator.generateAnonymousClassDefinition
protected void generateAnonymousClassDefinition(AnonymousClass anonClass, IAppendable it, IExtraLanguageGeneratorContext context) { if (!it.hasName(anonClass) && it instanceof PyAppendable) { final LightweightTypeReference jvmAnonType = getExpectedType(anonClass); final String anonName = it.declareSyntheticVariable(anonClass, jvmAnonType.getSimpleName()); QualifiedName anonQualifiedName = QualifiedName.create( jvmAnonType.getType().getQualifiedName().split(Pattern.quote("."))); //$NON-NLS-1$ anonQualifiedName = anonQualifiedName.skipLast(1); if (anonQualifiedName.isEmpty()) { // The type resolver does not include the enclosing class. assert anonClass.getDeclaringType() == null : "The Xtend API has changed the AnonymousClass definition!"; //$NON-NLS-1$ final XtendTypeDeclaration container = EcoreUtil2.getContainerOfType(anonClass.eContainer(), XtendTypeDeclaration.class); anonQualifiedName = anonQualifiedName.append(this.qualifiedNameProvider.getFullyQualifiedName(container)); } anonQualifiedName = anonQualifiedName.append(anonName); it.openPseudoScope(); final IRootGenerator rootGenerator = context.getRootGenerator(); assert rootGenerator instanceof PyGenerator; final List<JvmTypeReference> types = new ArrayList<>(); for (final JvmTypeReference superType : anonClass.getConstructorCall().getConstructor().getDeclaringType().getSuperTypes()) { if (!Object.class.getCanonicalName().equals(superType.getIdentifier())) { types.add(superType); } } ((PyGenerator) rootGenerator).generateTypeDeclaration( anonQualifiedName.toString(), anonName, false, types, getTypeBuilder().getDocumentation(anonClass), false, anonClass.getMembers(), (PyAppendable) it, context, null); it.closeScope(); } }
java
protected void generateAnonymousClassDefinition(AnonymousClass anonClass, IAppendable it, IExtraLanguageGeneratorContext context) { if (!it.hasName(anonClass) && it instanceof PyAppendable) { final LightweightTypeReference jvmAnonType = getExpectedType(anonClass); final String anonName = it.declareSyntheticVariable(anonClass, jvmAnonType.getSimpleName()); QualifiedName anonQualifiedName = QualifiedName.create( jvmAnonType.getType().getQualifiedName().split(Pattern.quote("."))); //$NON-NLS-1$ anonQualifiedName = anonQualifiedName.skipLast(1); if (anonQualifiedName.isEmpty()) { // The type resolver does not include the enclosing class. assert anonClass.getDeclaringType() == null : "The Xtend API has changed the AnonymousClass definition!"; //$NON-NLS-1$ final XtendTypeDeclaration container = EcoreUtil2.getContainerOfType(anonClass.eContainer(), XtendTypeDeclaration.class); anonQualifiedName = anonQualifiedName.append(this.qualifiedNameProvider.getFullyQualifiedName(container)); } anonQualifiedName = anonQualifiedName.append(anonName); it.openPseudoScope(); final IRootGenerator rootGenerator = context.getRootGenerator(); assert rootGenerator instanceof PyGenerator; final List<JvmTypeReference> types = new ArrayList<>(); for (final JvmTypeReference superType : anonClass.getConstructorCall().getConstructor().getDeclaringType().getSuperTypes()) { if (!Object.class.getCanonicalName().equals(superType.getIdentifier())) { types.add(superType); } } ((PyGenerator) rootGenerator).generateTypeDeclaration( anonQualifiedName.toString(), anonName, false, types, getTypeBuilder().getDocumentation(anonClass), false, anonClass.getMembers(), (PyAppendable) it, context, null); it.closeScope(); } }
[ "protected", "void", "generateAnonymousClassDefinition", "(", "AnonymousClass", "anonClass", ",", "IAppendable", "it", ",", "IExtraLanguageGeneratorContext", "context", ")", "{", "if", "(", "!", "it", ".", "hasName", "(", "anonClass", ")", "&&", "it", "instanceof", ...
Generate the anonymous class definition. @param anonClass the anonymous class. @param it the target for the generated content. @param context the context.
[ "Generate", "the", "anonymous", "class", "definition", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/contribs/io.sarl.pythongenerator/io.sarl.pythongenerator.generator/src/io/sarl/pythongenerator/generator/generator/PyExpressionGenerator.java#L211-L247
train
sarl/sarl
contribs/io.sarl.pythongenerator/io.sarl.pythongenerator.generator/src/io/sarl/pythongenerator/generator/generator/PyExpressionGenerator.java
PyExpressionGenerator.toDefaultValue
@SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:booleanexpressioncomplexity", "checkstyle:npathcomplexity"}) public static String toDefaultValue(JvmTypeReference type) { final String id = type.getIdentifier(); if (!"void".equals(id)) { //$NON-NLS-1$ if (Strings.equal(Boolean.class.getName(), id) || Strings.equal(Boolean.TYPE.getName(), id)) { return "False"; //$NON-NLS-1$ } if (Strings.equal(Float.class.getName(), id) || Strings.equal(Float.TYPE.getName(), id) || Strings.equal(Double.class.getName(), id) || Strings.equal(Double.TYPE.getName(), id)) { return "0.0"; //$NON-NLS-1$ } if (Strings.equal(Integer.class.getName(), id) || Strings.equal(Integer.TYPE.getName(), id) || Strings.equal(Long.class.getName(), id) || Strings.equal(Long.TYPE.getName(), id) || Strings.equal(Byte.class.getName(), id) || Strings.equal(Byte.TYPE.getName(), id) || Strings.equal(Short.class.getName(), id) || Strings.equal(Short.TYPE.getName(), id)) { return "0"; //$NON-NLS-1$ } if (Strings.equal(Character.class.getName(), id) || Strings.equal(Character.TYPE.getName(), id)) { return "\"\\0\""; //$NON-NLS-1$ } } return "None"; //$NON-NLS-1$ }
java
@SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:booleanexpressioncomplexity", "checkstyle:npathcomplexity"}) public static String toDefaultValue(JvmTypeReference type) { final String id = type.getIdentifier(); if (!"void".equals(id)) { //$NON-NLS-1$ if (Strings.equal(Boolean.class.getName(), id) || Strings.equal(Boolean.TYPE.getName(), id)) { return "False"; //$NON-NLS-1$ } if (Strings.equal(Float.class.getName(), id) || Strings.equal(Float.TYPE.getName(), id) || Strings.equal(Double.class.getName(), id) || Strings.equal(Double.TYPE.getName(), id)) { return "0.0"; //$NON-NLS-1$ } if (Strings.equal(Integer.class.getName(), id) || Strings.equal(Integer.TYPE.getName(), id) || Strings.equal(Long.class.getName(), id) || Strings.equal(Long.TYPE.getName(), id) || Strings.equal(Byte.class.getName(), id) || Strings.equal(Byte.TYPE.getName(), id) || Strings.equal(Short.class.getName(), id) || Strings.equal(Short.TYPE.getName(), id)) { return "0"; //$NON-NLS-1$ } if (Strings.equal(Character.class.getName(), id) || Strings.equal(Character.TYPE.getName(), id)) { return "\"\\0\""; //$NON-NLS-1$ } } return "None"; //$NON-NLS-1$ }
[ "@", "SuppressWarnings", "(", "{", "\"checkstyle:cyclomaticcomplexity\"", ",", "\"checkstyle:booleanexpressioncomplexity\"", ",", "\"checkstyle:npathcomplexity\"", "}", ")", "public", "static", "String", "toDefaultValue", "(", "JvmTypeReference", "type", ")", "{", "final", ...
Replies the Python default value for the given type. @param type the type. @return the default value.
[ "Replies", "the", "Python", "default", "value", "for", "the", "given", "type", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/contribs/io.sarl.pythongenerator/io.sarl.pythongenerator.generator/src/io/sarl/pythongenerator/generator/generator/PyExpressionGenerator.java#L997-L1020
train
sarl/sarl
contribs/io.sarl.pythongenerator/io.sarl.pythongenerator.generator/src/io/sarl/pythongenerator/generator/generator/PyExpressionGenerator.java
PyExpressionGenerator.newFeatureCallGenerator
protected PyFeatureCallGenerator newFeatureCallGenerator(IExtraLanguageGeneratorContext context, IAppendable it) { return new PyFeatureCallGenerator(context, (ExtraLanguageAppendable) it); }
java
protected PyFeatureCallGenerator newFeatureCallGenerator(IExtraLanguageGeneratorContext context, IAppendable it) { return new PyFeatureCallGenerator(context, (ExtraLanguageAppendable) it); }
[ "protected", "PyFeatureCallGenerator", "newFeatureCallGenerator", "(", "IExtraLanguageGeneratorContext", "context", ",", "IAppendable", "it", ")", "{", "return", "new", "PyFeatureCallGenerator", "(", "context", ",", "(", "ExtraLanguageAppendable", ")", "it", ")", ";", "...
Generate a feature call. @param context the generation context. @param it the code receiver. @return the generator
[ "Generate", "a", "feature", "call", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/contribs/io.sarl.pythongenerator/io.sarl.pythongenerator.generator/src/io/sarl/pythongenerator/generator/generator/PyExpressionGenerator.java#L1028-L1030
train
sarl/sarl
main/internalmaven/sarl-maven-plugin/src/main/java/io/sarl/maven/compiler/AbstractSarlBatchCompilerMojo.java
AbstractSarlBatchCompilerMojo.readSarlEclipseSetting
protected String readSarlEclipseSetting(String sourceDirectory) { if (this.propertiesFileLocation != null) { final File file = new File(this.propertiesFileLocation); if (file.canRead()) { final Properties sarlSettings = new Properties(); try (FileInputStream stream = new FileInputStream(file)) { sarlSettings.load(stream); final String sarlOutputDirProp = sarlSettings.getProperty("outlet.DEFAULT_OUTPUT.directory", null); //$NON-NLS-1$ if (sarlOutputDirProp != null) { final File srcDir = new File(sourceDirectory); getLog().debug(MessageFormat.format(Messages.AbstractSarlBatchCompilerMojo_7, srcDir.getPath(), srcDir.exists())); if (srcDir.exists() && srcDir.getParent() != null) { final String path = new File(srcDir.getParent(), sarlOutputDirProp).getPath(); getLog().debug(MessageFormat.format(Messages.AbstractSarlBatchCompilerMojo_8, sarlOutputDirProp)); return path; } } } catch (FileNotFoundException e) { getLog().warn(e); } catch (IOException e) { getLog().warn(e); } } else { getLog().debug(MessageFormat.format(Messages.AbstractSarlBatchCompilerMojo_9, this.propertiesFileLocation)); } } return null; }
java
protected String readSarlEclipseSetting(String sourceDirectory) { if (this.propertiesFileLocation != null) { final File file = new File(this.propertiesFileLocation); if (file.canRead()) { final Properties sarlSettings = new Properties(); try (FileInputStream stream = new FileInputStream(file)) { sarlSettings.load(stream); final String sarlOutputDirProp = sarlSettings.getProperty("outlet.DEFAULT_OUTPUT.directory", null); //$NON-NLS-1$ if (sarlOutputDirProp != null) { final File srcDir = new File(sourceDirectory); getLog().debug(MessageFormat.format(Messages.AbstractSarlBatchCompilerMojo_7, srcDir.getPath(), srcDir.exists())); if (srcDir.exists() && srcDir.getParent() != null) { final String path = new File(srcDir.getParent(), sarlOutputDirProp).getPath(); getLog().debug(MessageFormat.format(Messages.AbstractSarlBatchCompilerMojo_8, sarlOutputDirProp)); return path; } } } catch (FileNotFoundException e) { getLog().warn(e); } catch (IOException e) { getLog().warn(e); } } else { getLog().debug(MessageFormat.format(Messages.AbstractSarlBatchCompilerMojo_9, this.propertiesFileLocation)); } } return null; }
[ "protected", "String", "readSarlEclipseSetting", "(", "String", "sourceDirectory", ")", "{", "if", "(", "this", ".", "propertiesFileLocation", "!=", "null", ")", "{", "final", "File", "file", "=", "new", "File", "(", "this", ".", "propertiesFileLocation", ")", ...
Read the SARL Eclipse settings for the project if existing. @param sourceDirectory the source directory. @return the path from the settings.
[ "Read", "the", "SARL", "Eclipse", "settings", "for", "the", "project", "if", "existing", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/internalmaven/sarl-maven-plugin/src/main/java/io/sarl/maven/compiler/AbstractSarlBatchCompilerMojo.java#L390-L418
train
sarl/sarl
main/internalmaven/sarl-maven-plugin/src/main/java/io/sarl/maven/compiler/AbstractSarlBatchCompilerMojo.java
AbstractSarlBatchCompilerMojo.getClassPath
protected List<File> getClassPath() throws MojoExecutionException { if (this.bufferedClasspath == null) { final Set<String> classPath = new LinkedHashSet<>(); final MavenProject project = getProject(); classPath.add(project.getBuild().getSourceDirectory()); try { classPath.addAll(project.getCompileClasspathElements()); } catch (DependencyResolutionRequiredException e) { throw new MojoExecutionException(e.getLocalizedMessage(), e); } for (final Artifact dep : project.getArtifacts()) { classPath.add(dep.getFile().getAbsolutePath()); } classPath.remove(project.getBuild().getOutputDirectory()); final List<File> files = new ArrayList<>(); for (final String filename : classPath) { final File file = new File(filename); if (file.exists()) { files.add(file); } else { getLog().warn(MessageFormat.format(Messages.AbstractSarlBatchCompilerMojo_10, filename)); } } this.bufferedClasspath = files; } return this.bufferedClasspath; }
java
protected List<File> getClassPath() throws MojoExecutionException { if (this.bufferedClasspath == null) { final Set<String> classPath = new LinkedHashSet<>(); final MavenProject project = getProject(); classPath.add(project.getBuild().getSourceDirectory()); try { classPath.addAll(project.getCompileClasspathElements()); } catch (DependencyResolutionRequiredException e) { throw new MojoExecutionException(e.getLocalizedMessage(), e); } for (final Artifact dep : project.getArtifacts()) { classPath.add(dep.getFile().getAbsolutePath()); } classPath.remove(project.getBuild().getOutputDirectory()); final List<File> files = new ArrayList<>(); for (final String filename : classPath) { final File file = new File(filename); if (file.exists()) { files.add(file); } else { getLog().warn(MessageFormat.format(Messages.AbstractSarlBatchCompilerMojo_10, filename)); } } this.bufferedClasspath = files; } return this.bufferedClasspath; }
[ "protected", "List", "<", "File", ">", "getClassPath", "(", ")", "throws", "MojoExecutionException", "{", "if", "(", "this", ".", "bufferedClasspath", "==", "null", ")", "{", "final", "Set", "<", "String", ">", "classPath", "=", "new", "LinkedHashSet", "<>",...
Replies the classpath for the standard code. @return the current classpath. @throws MojoExecutionException on failure. @see #getTestClassPath()
[ "Replies", "the", "classpath", "for", "the", "standard", "code", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/internalmaven/sarl-maven-plugin/src/main/java/io/sarl/maven/compiler/AbstractSarlBatchCompilerMojo.java#L426-L452
train
sarl/sarl
main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/wizards/sarlapp/FixedFatJarExportWizard.java
FixedFatJarExportWizard.executeExportOperation
protected boolean executeExportOperation(IJarExportRunnable op, IStatus wizardPageStatus) { try { getContainer().run(true, true, op); } catch (InterruptedException e) { return false; } catch (InvocationTargetException ex) { if (ex.getTargetException() != null) { ExceptionHandler.handle(ex, getShell(), FatJarPackagerMessages.JarPackageWizard_jarExportError_title, FatJarPackagerMessages.JarPackageWizard_jarExportError_message); return false; } } IStatus status= op.getStatus(); if (!status.isOK()) { if (!wizardPageStatus.isOK()) { if (!(status instanceof MultiStatus)) status= new MultiStatus(status.getPlugin(), status.getCode(), status.getMessage(), status.getException()); ((MultiStatus) status).add(wizardPageStatus); } ErrorDialog.openError(getShell(), FatJarPackagerMessages.JarPackageWizard_jarExport_title, null, status); return !(status.matches(IStatus.ERROR)); } else if (!wizardPageStatus.isOK()) { ErrorDialog.openError(getShell(), FatJarPackagerMessages.JarPackageWizard_jarExport_title, null, wizardPageStatus); } return true; }
java
protected boolean executeExportOperation(IJarExportRunnable op, IStatus wizardPageStatus) { try { getContainer().run(true, true, op); } catch (InterruptedException e) { return false; } catch (InvocationTargetException ex) { if (ex.getTargetException() != null) { ExceptionHandler.handle(ex, getShell(), FatJarPackagerMessages.JarPackageWizard_jarExportError_title, FatJarPackagerMessages.JarPackageWizard_jarExportError_message); return false; } } IStatus status= op.getStatus(); if (!status.isOK()) { if (!wizardPageStatus.isOK()) { if (!(status instanceof MultiStatus)) status= new MultiStatus(status.getPlugin(), status.getCode(), status.getMessage(), status.getException()); ((MultiStatus) status).add(wizardPageStatus); } ErrorDialog.openError(getShell(), FatJarPackagerMessages.JarPackageWizard_jarExport_title, null, status); return !(status.matches(IStatus.ERROR)); } else if (!wizardPageStatus.isOK()) { ErrorDialog.openError(getShell(), FatJarPackagerMessages.JarPackageWizard_jarExport_title, null, wizardPageStatus); } return true; }
[ "protected", "boolean", "executeExportOperation", "(", "IJarExportRunnable", "op", ",", "IStatus", "wizardPageStatus", ")", "{", "try", "{", "getContainer", "(", ")", ".", "run", "(", "true", ",", "true", ",", "op", ")", ";", "}", "catch", "(", "InterruptedE...
Exports the JAR package. @param op the operation to run @param wizardPageStatus the status returned by the wizard page @return a boolean indicating success or failure
[ "Exports", "the", "JAR", "package", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/wizards/sarlapp/FixedFatJarExportWizard.java#L125-L150
train
sarl/sarl
main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/wizards/sarlapp/FixedFatJarExportWizard.java
FixedFatJarExportWizard.init
public void init(IWorkbench workbench, JarPackageData jarPackage) { Assert.isNotNull(workbench); Assert.isNotNull(jarPackage); fJarPackage= jarPackage; setInitializeFromJarPackage(true); setWindowTitle(FatJarPackagerMessages.JarPackageWizard_windowTitle); setDefaultPageImageDescriptor(JavaPluginImages.DESC_WIZBAN_FAT_JAR_PACKAGER); setNeedsProgressMonitor(true); }
java
public void init(IWorkbench workbench, JarPackageData jarPackage) { Assert.isNotNull(workbench); Assert.isNotNull(jarPackage); fJarPackage= jarPackage; setInitializeFromJarPackage(true); setWindowTitle(FatJarPackagerMessages.JarPackageWizard_windowTitle); setDefaultPageImageDescriptor(JavaPluginImages.DESC_WIZBAN_FAT_JAR_PACKAGER); setNeedsProgressMonitor(true); }
[ "public", "void", "init", "(", "IWorkbench", "workbench", ",", "JarPackageData", "jarPackage", ")", "{", "Assert", ".", "isNotNull", "(", "workbench", ")", ";", "Assert", ".", "isNotNull", "(", "jarPackage", ")", ";", "fJarPackage", "=", "jarPackage", ";", "...
Initializes this wizard from the given JAR package description. @param workbench the workbench which launched this wizard @param jarPackage the JAR package description used to initialize this wizard
[ "Initializes", "this", "wizard", "from", "the", "given", "JAR", "package", "description", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/wizards/sarlapp/FixedFatJarExportWizard.java#L203-L211
train
sarl/sarl
main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/labeling/SARLDiagnosticLabelDecorator.java
SARLDiagnosticLabelDecorator.convertToImage
protected Image convertToImage(Object imageDescription) { if (imageDescription instanceof Image) { return (Image) imageDescription; } else if (imageDescription instanceof ImageDescriptor) { return this.imageHelper.getImage((ImageDescriptor) imageDescription); } else if (imageDescription instanceof String) { return this.imageHelper.getImage((String) imageDescription); } return null; }
java
protected Image convertToImage(Object imageDescription) { if (imageDescription instanceof Image) { return (Image) imageDescription; } else if (imageDescription instanceof ImageDescriptor) { return this.imageHelper.getImage((ImageDescriptor) imageDescription); } else if (imageDescription instanceof String) { return this.imageHelper.getImage((String) imageDescription); } return null; }
[ "protected", "Image", "convertToImage", "(", "Object", "imageDescription", ")", "{", "if", "(", "imageDescription", "instanceof", "Image", ")", "{", "return", "(", "Image", ")", "imageDescription", ";", "}", "else", "if", "(", "imageDescription", "instanceof", "...
Replies the image that corresponds to the given object. @param imageDescription a {@link String}, an {@link ImageDescriptor} or an {@link Image} @return the {@link Image} associated with the description or <code>null</code>
[ "Replies", "the", "image", "that", "corresponds", "to", "the", "given", "object", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/labeling/SARLDiagnosticLabelDecorator.java#L92-L101
train
sarl/sarl
main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/labeling/SARLDiagnosticLabelDecorator.java
SARLDiagnosticLabelDecorator.getIssueAdornment
@SuppressWarnings("static-method") protected int getIssueAdornment(XtendMember element) { final ICompositeNode node = NodeModelUtils.getNode(element); if (node == null) { return 0; } // Error markers are more important than warning markers. // Order of checks: // - parser error (from the resource) or semantic error (from Diagnostician) // - parser warning or semantic warning final Resource resource = element.eResource(); if (!resource.getURI().isArchive()) { if (hasParserIssue(node, resource.getErrors())) { return JavaElementImageDescriptor.ERROR; } final Diagnostic diagnostic = Diagnostician.INSTANCE.validate(element); switch (diagnostic.getSeverity()) { case Diagnostic.ERROR: return JavaElementImageDescriptor.ERROR; case Diagnostic.WARNING: return JavaElementImageDescriptor.WARNING; default: } if (hasParserIssue(node, resource.getWarnings())) { return JavaElementImageDescriptor.WARNING; } } return 0; }
java
@SuppressWarnings("static-method") protected int getIssueAdornment(XtendMember element) { final ICompositeNode node = NodeModelUtils.getNode(element); if (node == null) { return 0; } // Error markers are more important than warning markers. // Order of checks: // - parser error (from the resource) or semantic error (from Diagnostician) // - parser warning or semantic warning final Resource resource = element.eResource(); if (!resource.getURI().isArchive()) { if (hasParserIssue(node, resource.getErrors())) { return JavaElementImageDescriptor.ERROR; } final Diagnostic diagnostic = Diagnostician.INSTANCE.validate(element); switch (diagnostic.getSeverity()) { case Diagnostic.ERROR: return JavaElementImageDescriptor.ERROR; case Diagnostic.WARNING: return JavaElementImageDescriptor.WARNING; default: } if (hasParserIssue(node, resource.getWarnings())) { return JavaElementImageDescriptor.WARNING; } } return 0; }
[ "@", "SuppressWarnings", "(", "\"static-method\"", ")", "protected", "int", "getIssueAdornment", "(", "XtendMember", "element", ")", "{", "final", "ICompositeNode", "node", "=", "NodeModelUtils", ".", "getNode", "(", "element", ")", ";", "if", "(", "node", "==",...
Replies the diagnotic adornment for the given element. @param element the model element. @return the adornment.
[ "Replies", "the", "diagnotic", "adornment", "for", "the", "given", "element", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/labeling/SARLDiagnosticLabelDecorator.java#L126-L154
train
sarl/sarl
main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/wizards/elements/FieldInitializerUtil.java
FieldInitializerUtil.getSelectedResource
@SuppressWarnings("static-method") public IJavaElement getSelectedResource(IStructuredSelection selection) { IJavaElement elem = null; if (selection != null && !selection.isEmpty()) { final Object object = selection.getFirstElement(); if (object instanceof IAdaptable) { final IAdaptable adaptable = (IAdaptable) object; elem = adaptable.getAdapter(IJavaElement.class); if (elem == null) { elem = getPackage(adaptable); } } } if (elem == null) { final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IWorkbenchPart part = activePage.getActivePart(); if (part instanceof ContentOutline) { part = activePage.getActiveEditor(); } if (part instanceof XtextEditor) { final IXtextDocument doc = ((XtextEditor) part).getDocument(); final IFile file = doc.getAdapter(IFile.class); elem = getPackage(file); } } if (elem == null || elem.getElementType() == IJavaElement.JAVA_MODEL) { try { final IJavaProject[] projects = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects(); if (projects.length == 1) { elem = projects[0]; } } catch (JavaModelException e) { throw new RuntimeException(e.getMessage()); } } return elem; }
java
@SuppressWarnings("static-method") public IJavaElement getSelectedResource(IStructuredSelection selection) { IJavaElement elem = null; if (selection != null && !selection.isEmpty()) { final Object object = selection.getFirstElement(); if (object instanceof IAdaptable) { final IAdaptable adaptable = (IAdaptable) object; elem = adaptable.getAdapter(IJavaElement.class); if (elem == null) { elem = getPackage(adaptable); } } } if (elem == null) { final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IWorkbenchPart part = activePage.getActivePart(); if (part instanceof ContentOutline) { part = activePage.getActiveEditor(); } if (part instanceof XtextEditor) { final IXtextDocument doc = ((XtextEditor) part).getDocument(); final IFile file = doc.getAdapter(IFile.class); elem = getPackage(file); } } if (elem == null || elem.getElementType() == IJavaElement.JAVA_MODEL) { try { final IJavaProject[] projects = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects(); if (projects.length == 1) { elem = projects[0]; } } catch (JavaModelException e) { throw new RuntimeException(e.getMessage()); } } return elem; }
[ "@", "SuppressWarnings", "(", "\"static-method\"", ")", "public", "IJavaElement", "getSelectedResource", "(", "IStructuredSelection", "selection", ")", "{", "IJavaElement", "elem", "=", "null", ";", "if", "(", "selection", "!=", "null", "&&", "!", "selection", "."...
Replies the Java element that corresponds to the given selection. @param selection the current selection. @return the Java element.
[ "Replies", "the", "Java", "element", "that", "corresponds", "to", "the", "given", "selection", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/wizards/elements/FieldInitializerUtil.java#L56-L92
train
sarl/sarl
main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/keywords/GrammarKeywordAccessFragment2.java
GrammarKeywordAccessFragment2.getBasePackage
@Pure public String getBasePackage() { final Grammar grammar = getGrammar(); final String basePackage = this.naming.getRuntimeBasePackage(grammar); return basePackage + ".services"; //$NON-NLS-1$ }
java
@Pure public String getBasePackage() { final Grammar grammar = getGrammar(); final String basePackage = this.naming.getRuntimeBasePackage(grammar); return basePackage + ".services"; //$NON-NLS-1$ }
[ "@", "Pure", "public", "String", "getBasePackage", "(", ")", "{", "final", "Grammar", "grammar", "=", "getGrammar", "(", ")", ";", "final", "String", "basePackage", "=", "this", ".", "naming", ".", "getRuntimeBasePackage", "(", "grammar", ")", ";", "return",...
Replies the base package for the language. @return the base package.
[ "Replies", "the", "base", "package", "for", "the", "language", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/keywords/GrammarKeywordAccessFragment2.java#L106-L111
train
sarl/sarl
main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/keywords/GrammarKeywordAccessFragment2.java
GrammarKeywordAccessFragment2.getAllKeywords
protected static Iterable<Keyword> getAllKeywords(Grammar grammar) { final Map<String, Keyword> keywords = new HashMap<>(); final List<ParserRule> rules = GrammarUtil.allParserRules(grammar); for (final ParserRule parserRule : rules) { final List<Keyword> list = typeSelect(eAllContentsAsList(parserRule), Keyword.class); for (final Keyword keyword : list) { keywords.put(keyword.getValue(), keyword); } } final List<EnumRule> enumRules = GrammarUtil.allEnumRules(grammar); for (final EnumRule enumRule : enumRules) { final List<Keyword> list = typeSelect(eAllContentsAsList(enumRule), Keyword.class); for (final Keyword keyword : list) { keywords.put(keyword.getValue(), keyword); } } return keywords.values(); }
java
protected static Iterable<Keyword> getAllKeywords(Grammar grammar) { final Map<String, Keyword> keywords = new HashMap<>(); final List<ParserRule> rules = GrammarUtil.allParserRules(grammar); for (final ParserRule parserRule : rules) { final List<Keyword> list = typeSelect(eAllContentsAsList(parserRule), Keyword.class); for (final Keyword keyword : list) { keywords.put(keyword.getValue(), keyword); } } final List<EnumRule> enumRules = GrammarUtil.allEnumRules(grammar); for (final EnumRule enumRule : enumRules) { final List<Keyword> list = typeSelect(eAllContentsAsList(enumRule), Keyword.class); for (final Keyword keyword : list) { keywords.put(keyword.getValue(), keyword); } } return keywords.values(); }
[ "protected", "static", "Iterable", "<", "Keyword", ">", "getAllKeywords", "(", "Grammar", "grammar", ")", "{", "final", "Map", "<", "String", ",", "Keyword", ">", "keywords", "=", "new", "HashMap", "<>", "(", ")", ";", "final", "List", "<", "ParserRule", ...
Replies the keywords in the given grammar. @param grammar the grammar. @return the keywords.
[ "Replies", "the", "keywords", "in", "the", "given", "grammar", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/keywords/GrammarKeywordAccessFragment2.java#L261-L278
train
sarl/sarl
main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/keywords/GrammarKeywordAccessFragment2.java
GrammarKeywordAccessFragment2.generateKeyword
protected StringConcatenationClient generateKeyword(final String keyword, final String comment, Map<String, String> getters) { final String fieldName = keyword.toUpperCase().replaceAll("[^a-zA-Z0-9_]+", "_"); //$NON-NLS-1$ //$NON-NLS-2$ final String methodName = Strings.toFirstUpper(keyword.replaceAll("[^a-zA-Z0-9_]+", "_")) //$NON-NLS-1$ //$NON-NLS-2$ + "Keyword"; //$NON-NLS-1$ if (getters != null) { getters.put(methodName, keyword); } return new StringConcatenationClient() { @Override protected void appendTo(TargetStringConcatenation it) { it.append("\tprivate static final String "); //$NON-NLS-1$ it.append(fieldName); it.append(" = \""); //$NON-NLS-1$ it.append(Strings.convertToJavaString(keyword)); it.append("\";"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Keyword: {@code "); //$NON-NLS-1$ it.append(protectCommentKeyword(keyword)); it.append("}."); //$NON-NLS-1$ it.newLine(); if (!Strings.isEmpty(comment)) { it.append("\t * Source: "); //$NON-NLS-1$ it.append(comment); it.newLine(); } it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\tpublic String get"); //$NON-NLS-1$ it.append(methodName); it.append("() {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn "); //$NON-NLS-1$ it.append(fieldName); it.append(";"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); } }; }
java
protected StringConcatenationClient generateKeyword(final String keyword, final String comment, Map<String, String> getters) { final String fieldName = keyword.toUpperCase().replaceAll("[^a-zA-Z0-9_]+", "_"); //$NON-NLS-1$ //$NON-NLS-2$ final String methodName = Strings.toFirstUpper(keyword.replaceAll("[^a-zA-Z0-9_]+", "_")) //$NON-NLS-1$ //$NON-NLS-2$ + "Keyword"; //$NON-NLS-1$ if (getters != null) { getters.put(methodName, keyword); } return new StringConcatenationClient() { @Override protected void appendTo(TargetStringConcatenation it) { it.append("\tprivate static final String "); //$NON-NLS-1$ it.append(fieldName); it.append(" = \""); //$NON-NLS-1$ it.append(Strings.convertToJavaString(keyword)); it.append("\";"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); it.append("\t/** Keyword: {@code "); //$NON-NLS-1$ it.append(protectCommentKeyword(keyword)); it.append("}."); //$NON-NLS-1$ it.newLine(); if (!Strings.isEmpty(comment)) { it.append("\t * Source: "); //$NON-NLS-1$ it.append(comment); it.newLine(); } it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\tpublic String get"); //$NON-NLS-1$ it.append(methodName); it.append("() {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn "); //$NON-NLS-1$ it.append(fieldName); it.append(";"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); } }; }
[ "protected", "StringConcatenationClient", "generateKeyword", "(", "final", "String", "keyword", ",", "final", "String", "comment", ",", "Map", "<", "String", ",", "String", ">", "getters", ")", "{", "final", "String", "fieldName", "=", "keyword", ".", "toUpperCa...
Generate a basic keyword. @param keyword the keyword to add. @param comment a comment for the javadoc. @param getters filled by this function with the getters' names. @return the content.
[ "Generate", "a", "basic", "keyword", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/keywords/GrammarKeywordAccessFragment2.java#L287-L328
train
sarl/sarl
main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/keywords/GrammarKeywordAccessFragment2.java
GrammarKeywordAccessFragment2.generateKeyword
protected StringConcatenationClient generateKeyword(final Keyword keyword, final String comment, Map<String, String> getters) { try { final String methodName = getIdentifier(keyword); final String accessor = GrammarKeywordAccessFragment2.this.grammarAccessExtensions.gaAccessor(keyword); if (!Strings.isEmpty(methodName) && !Strings.isEmpty(accessor)) { if (getters != null) { getters.put(methodName, keyword.getValue()); } return new StringConcatenationClient() { @Override protected void appendTo(TargetStringConcatenation it) { it.append("\t/** Keyword: {@code "); //$NON-NLS-1$ it.append(protectCommentKeyword(keyword.getValue())); it.append("}."); //$NON-NLS-1$ it.newLine(); if (!Strings.isEmpty(comment)) { it.append("\t * Source: "); //$NON-NLS-1$ it.append(comment); it.newLine(); } it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\tpublic String get"); //$NON-NLS-1$ it.append(methodName); it.append("() {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn this.grammarAccess."); //$NON-NLS-1$ it.append(accessor); it.append(".getValue();"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); } }; } } catch (Exception e) { // } return null; }
java
protected StringConcatenationClient generateKeyword(final Keyword keyword, final String comment, Map<String, String> getters) { try { final String methodName = getIdentifier(keyword); final String accessor = GrammarKeywordAccessFragment2.this.grammarAccessExtensions.gaAccessor(keyword); if (!Strings.isEmpty(methodName) && !Strings.isEmpty(accessor)) { if (getters != null) { getters.put(methodName, keyword.getValue()); } return new StringConcatenationClient() { @Override protected void appendTo(TargetStringConcatenation it) { it.append("\t/** Keyword: {@code "); //$NON-NLS-1$ it.append(protectCommentKeyword(keyword.getValue())); it.append("}."); //$NON-NLS-1$ it.newLine(); if (!Strings.isEmpty(comment)) { it.append("\t * Source: "); //$NON-NLS-1$ it.append(comment); it.newLine(); } it.append("\t */"); //$NON-NLS-1$ it.newLine(); it.append("\tpublic String get"); //$NON-NLS-1$ it.append(methodName); it.append("() {"); //$NON-NLS-1$ it.newLine(); it.append("\t\treturn this.grammarAccess."); //$NON-NLS-1$ it.append(accessor); it.append(".getValue();"); //$NON-NLS-1$ it.newLine(); it.append("\t}"); //$NON-NLS-1$ it.newLineIfNotEmpty(); it.newLine(); } }; } } catch (Exception e) { // } return null; }
[ "protected", "StringConcatenationClient", "generateKeyword", "(", "final", "Keyword", "keyword", ",", "final", "String", "comment", ",", "Map", "<", "String", ",", "String", ">", "getters", ")", "{", "try", "{", "final", "String", "methodName", "=", "getIdentifi...
Generate a grammar keyword. @param keyword the keyword to add. @param comment a comment for the javadoc. @param getters filled by this function with the getters' names. @return the content.
[ "Generate", "a", "grammar", "keyword", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/keywords/GrammarKeywordAccessFragment2.java#L337-L378
train
sarl/sarl
main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/keywords/GrammarKeywordAccessFragment2.java
GrammarKeywordAccessFragment2.protectCommentKeyword
@SuppressWarnings("static-method") protected String protectCommentKeyword(String keyword) { if ("*/".equals(keyword)) { //$NON-NLS-1$ return "* /"; //$NON-NLS-1$ } if ("/*".equals(keyword)) { //$NON-NLS-1$ return "/ *"; //$NON-NLS-1$ } if ("//".equals(keyword)) { //$NON-NLS-1$ return "/ /"; //$NON-NLS-1$ } return keyword; }
java
@SuppressWarnings("static-method") protected String protectCommentKeyword(String keyword) { if ("*/".equals(keyword)) { //$NON-NLS-1$ return "* /"; //$NON-NLS-1$ } if ("/*".equals(keyword)) { //$NON-NLS-1$ return "/ *"; //$NON-NLS-1$ } if ("//".equals(keyword)) { //$NON-NLS-1$ return "/ /"; //$NON-NLS-1$ } return keyword; }
[ "@", "SuppressWarnings", "(", "\"static-method\"", ")", "protected", "String", "protectCommentKeyword", "(", "String", "keyword", ")", "{", "if", "(", "\"*/\"", ".", "equals", "(", "keyword", ")", ")", "{", "//$NON-NLS-1$", "return", "\"* /\"", ";", "//$NON-NLS-...
Protect the keywword for Java comments. @param keyword the keyword to protect. @return the protected keyword.
[ "Protect", "the", "keywword", "for", "Java", "comments", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/keywords/GrammarKeywordAccessFragment2.java#L395-L407
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/typesystem/SARLTypeComputer.java
SARLTypeComputer.isIgnorableCallToFeature
@SuppressWarnings({"checkstyle:npathcomplexity", "checkstyle:cyclomaticcomplexity"}) protected boolean isIgnorableCallToFeature(ILinkingCandidate candidate) { final JvmIdentifiableElement feature = candidate.getFeature(); // // @Deprecated // if (feature instanceof JvmOperation) { JvmAnnotationTarget target = (JvmOperation) feature; JvmAnnotationReference reference = this.annotationLookup.findAnnotation(target, Deprecated.class); if (reference == null) { do { target = EcoreUtil2.getContainerOfType(target.eContainer(), JvmAnnotationTarget.class); if (target != null) { reference = this.annotationLookup.findAnnotation(target, Deprecated.class); } } while (reference == null && target != null); } if (reference != null) { return true; } } return false; }
java
@SuppressWarnings({"checkstyle:npathcomplexity", "checkstyle:cyclomaticcomplexity"}) protected boolean isIgnorableCallToFeature(ILinkingCandidate candidate) { final JvmIdentifiableElement feature = candidate.getFeature(); // // @Deprecated // if (feature instanceof JvmOperation) { JvmAnnotationTarget target = (JvmOperation) feature; JvmAnnotationReference reference = this.annotationLookup.findAnnotation(target, Deprecated.class); if (reference == null) { do { target = EcoreUtil2.getContainerOfType(target.eContainer(), JvmAnnotationTarget.class); if (target != null) { reference = this.annotationLookup.findAnnotation(target, Deprecated.class); } } while (reference == null && target != null); } if (reference != null) { return true; } } return false; }
[ "@", "SuppressWarnings", "(", "{", "\"checkstyle:npathcomplexity\"", ",", "\"checkstyle:cyclomaticcomplexity\"", "}", ")", "protected", "boolean", "isIgnorableCallToFeature", "(", "ILinkingCandidate", "candidate", ")", "{", "final", "JvmIdentifiableElement", "feature", "=", ...
Replies if ambiguity could be removed for the given feature. @param candidate the candidate. @return {@code true} if ambiguity could be removed.
[ "Replies", "if", "ambiguity", "could", "be", "removed", "for", "the", "given", "feature", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/typesystem/SARLTypeComputer.java#L114-L136
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/typesystem/SARLTypeComputer.java
SARLTypeComputer._computeTypes
protected void _computeTypes(SarlBreakExpression object, ITypeComputationState state) { final LightweightTypeReference primitiveVoid = getPrimitiveVoid(state); state.acceptActualType(primitiveVoid); }
java
protected void _computeTypes(SarlBreakExpression object, ITypeComputationState state) { final LightweightTypeReference primitiveVoid = getPrimitiveVoid(state); state.acceptActualType(primitiveVoid); }
[ "protected", "void", "_computeTypes", "(", "SarlBreakExpression", "object", ",", "ITypeComputationState", "state", ")", "{", "final", "LightweightTypeReference", "primitiveVoid", "=", "getPrimitiveVoid", "(", "state", ")", ";", "state", ".", "acceptActualType", "(", "...
Compute the type of a break expression. @param object the expression. @param state the state of the type resolver.
[ "Compute", "the", "type", "of", "a", "break", "expression", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/typesystem/SARLTypeComputer.java#L170-L173
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/typesystem/SARLTypeComputer.java
SARLTypeComputer._computeTypes
protected void _computeTypes(SarlAssertExpression object, ITypeComputationState state) { state.withExpectation(getTypeForName(Boolean.class, state)).computeTypes(object.getCondition()); }
java
protected void _computeTypes(SarlAssertExpression object, ITypeComputationState state) { state.withExpectation(getTypeForName(Boolean.class, state)).computeTypes(object.getCondition()); }
[ "protected", "void", "_computeTypes", "(", "SarlAssertExpression", "object", ",", "ITypeComputationState", "state", ")", "{", "state", ".", "withExpectation", "(", "getTypeForName", "(", "Boolean", ".", "class", ",", "state", ")", ")", ".", "computeTypes", "(", ...
Compute the type of an assert expression. @param object the expression. @param state the state of the type resolver.
[ "Compute", "the", "type", "of", "an", "assert", "expression", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/typesystem/SARLTypeComputer.java#L191-L193
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/typesystem/SARLTypeComputer.java
SARLTypeComputer._computeTypes
@SuppressWarnings("checkstyle:nestedifdepth") protected void _computeTypes(SarlCastedExpression cast, ITypeComputationState state) { if (state instanceof AbstractTypeComputationState) { final JvmTypeReference type = cast.getType(); if (type != null) { state.withNonVoidExpectation().computeTypes(cast.getTarget()); // Set the linked feature try { final AbstractTypeComputationState computationState = (AbstractTypeComputationState) state; final CastedExpressionTypeComputationState astate = new CastedExpressionTypeComputationState( cast, computationState, this.castOperationValidator); astate.resetFeature(cast); if (astate.isCastOperatorLinkingEnabled(cast)) { final List<? extends ILinkingCandidate> candidates = astate.getLinkingCandidates(cast); if (!candidates.isEmpty()) { final ILinkingCandidate best = getBestCandidate(candidates); if (best != null) { best.applyToModel(computationState.getResolvedTypes()); } } } } catch (Throwable exception) { final Throwable cause = Throwables.getRootCause(exception); state.addDiagnostic(new EObjectDiagnosticImpl( Severity.ERROR, IssueCodes.INTERNAL_ERROR, cause.getLocalizedMessage(), cast, null, -1, null)); } state.acceptActualType(state.getReferenceOwner().toLightweightTypeReference(type)); } else { state.computeTypes(cast.getTarget()); } } else { super._computeTypes(cast, state); } }
java
@SuppressWarnings("checkstyle:nestedifdepth") protected void _computeTypes(SarlCastedExpression cast, ITypeComputationState state) { if (state instanceof AbstractTypeComputationState) { final JvmTypeReference type = cast.getType(); if (type != null) { state.withNonVoidExpectation().computeTypes(cast.getTarget()); // Set the linked feature try { final AbstractTypeComputationState computationState = (AbstractTypeComputationState) state; final CastedExpressionTypeComputationState astate = new CastedExpressionTypeComputationState( cast, computationState, this.castOperationValidator); astate.resetFeature(cast); if (astate.isCastOperatorLinkingEnabled(cast)) { final List<? extends ILinkingCandidate> candidates = astate.getLinkingCandidates(cast); if (!candidates.isEmpty()) { final ILinkingCandidate best = getBestCandidate(candidates); if (best != null) { best.applyToModel(computationState.getResolvedTypes()); } } } } catch (Throwable exception) { final Throwable cause = Throwables.getRootCause(exception); state.addDiagnostic(new EObjectDiagnosticImpl( Severity.ERROR, IssueCodes.INTERNAL_ERROR, cause.getLocalizedMessage(), cast, null, -1, null)); } state.acceptActualType(state.getReferenceOwner().toLightweightTypeReference(type)); } else { state.computeTypes(cast.getTarget()); } } else { super._computeTypes(cast, state); } }
[ "@", "SuppressWarnings", "(", "\"checkstyle:nestedifdepth\"", ")", "protected", "void", "_computeTypes", "(", "SarlCastedExpression", "cast", ",", "ITypeComputationState", "state", ")", "{", "if", "(", "state", "instanceof", "AbstractTypeComputationState", ")", "{", "fi...
Compute the type of a casted expression. @param cast the expression. @param state the state of the type resolver.
[ "Compute", "the", "type", "of", "a", "casted", "expression", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/typesystem/SARLTypeComputer.java#L200-L241
train
sarl/sarl
sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/util/AbstractMapView.java
AbstractMapView.fireEntryRemoved
@SuppressWarnings("unchecked") protected void fireEntryRemoved(K key, V value) { if (this.listeners != null) { for (final DMapListener<? super K, ? super V> listener : this.listeners.getListeners(DMapListener.class)) { listener.entryRemoved(key, value); } } }
java
@SuppressWarnings("unchecked") protected void fireEntryRemoved(K key, V value) { if (this.listeners != null) { for (final DMapListener<? super K, ? super V> listener : this.listeners.getListeners(DMapListener.class)) { listener.entryRemoved(key, value); } } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "protected", "void", "fireEntryRemoved", "(", "K", "key", ",", "V", "value", ")", "{", "if", "(", "this", ".", "listeners", "!=", "null", ")", "{", "for", "(", "final", "DMapListener", "<", "?", "super"...
Fire the removal event. @param key the removed key. @param value the removed value.
[ "Fire", "the", "removal", "event", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/util/AbstractMapView.java#L73-L80
train
sarl/sarl
sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/util/AbstractMapView.java
AbstractMapView.fireEntryUpdated
@SuppressWarnings("unchecked") protected void fireEntryUpdated(K key, V value) { for (final DMapListener<? super K, ? super V> listener : this.listeners.getListeners(DMapListener.class)) { listener.entryUpdated(key, value); } }
java
@SuppressWarnings("unchecked") protected void fireEntryUpdated(K key, V value) { for (final DMapListener<? super K, ? super V> listener : this.listeners.getListeners(DMapListener.class)) { listener.entryUpdated(key, value); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "protected", "void", "fireEntryUpdated", "(", "K", "key", ",", "V", "value", ")", "{", "for", "(", "final", "DMapListener", "<", "?", "super", "K", ",", "?", "super", "V", ">", "listener", ":", "this", ...
Fire the update event. @param key the updated key. @param value the new value.
[ "Fire", "the", "update", "event", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/util/AbstractMapView.java#L88-L93
train
sarl/sarl
sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/util/AbstractMapView.java
AbstractMapView.fireCleared
@SuppressWarnings("unchecked") protected void fireCleared(boolean localClearing) { for (final DMapListener<? super K, ? super V> listener : this.listeners.getListeners(DMapListener.class)) { listener.mapCleared(localClearing); } }
java
@SuppressWarnings("unchecked") protected void fireCleared(boolean localClearing) { for (final DMapListener<? super K, ? super V> listener : this.listeners.getListeners(DMapListener.class)) { listener.mapCleared(localClearing); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "protected", "void", "fireCleared", "(", "boolean", "localClearing", ")", "{", "for", "(", "final", "DMapListener", "<", "?", "super", "K", ",", "?", "super", "V", ">", "listener", ":", "this", ".", "list...
Fire the clearing event. @param localClearing indicates if the clearing is done on the local node (if <code>true</code>), or on all the nodes (if <code>false</code>).
[ "Fire", "the", "clearing", "event", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/util/AbstractMapView.java#L101-L106
train
sarl/sarl
main/externalmaven/io.sarl.maven.sre/src/main/java/io/sarl/maven/sre/AbstractSREMojo.java
AbstractSREMojo.createSREConfiguration
protected Xpp3Dom createSREConfiguration() throws MojoExecutionException, MojoFailureException { final Xpp3Dom xmlConfiguration = new Xpp3Dom("configuration"); //$NON-NLS-1$ final Xpp3Dom xmlArchive = new Xpp3Dom("archive"); //$NON-NLS-1$ xmlConfiguration.addChild(xmlArchive); final String mainClass = getMainClass(); if (mainClass.isEmpty()) { throw new MojoFailureException("the main class of the SRE is missed"); //$NON-NLS-1$ } final Xpp3Dom xmlManifest = new Xpp3Dom("manifest"); //$NON-NLS-1$ xmlArchive.addChild(xmlManifest); final Xpp3Dom xmlManifestMainClass = new Xpp3Dom("mainClass"); //$NON-NLS-1$ xmlManifestMainClass.setValue(mainClass); xmlManifest.addChild(xmlManifestMainClass); final Xpp3Dom xmlSections = new Xpp3Dom("manifestSections"); //$NON-NLS-1$ xmlArchive.addChild(xmlSections); final Xpp3Dom xmlSection = new Xpp3Dom("manifestSection"); //$NON-NLS-1$ xmlSections.addChild(xmlSection); final Xpp3Dom xmlSectionName = new Xpp3Dom("name"); //$NON-NLS-1$ xmlSectionName.setValue(SREConstants.MANIFEST_SECTION_SRE); xmlSection.addChild(xmlSectionName); final Xpp3Dom xmlManifestEntries = new Xpp3Dom("manifestEntries"); //$NON-NLS-1$ xmlSection.addChild(xmlManifestEntries); ManifestUpdater updater = getManifestUpdater(); if (updater == null) { updater = new ManifestUpdater() { @Override public void addSREAttribute(String name, String value) { assert name != null && !name.isEmpty(); if (value != null && !value.isEmpty()) { getLog().debug("Adding to SRE manifest: " + name + " = " + value); //$NON-NLS-1$//$NON-NLS-2$ final Xpp3Dom xmlManifestEntry = new Xpp3Dom(name); xmlManifestEntry.setValue(value); xmlManifestEntries.addChild(xmlManifestEntry); } } @Override public void addMainAttribute(String name, String value) { // } }; } buildManifest(updater, mainClass); return xmlConfiguration; }
java
protected Xpp3Dom createSREConfiguration() throws MojoExecutionException, MojoFailureException { final Xpp3Dom xmlConfiguration = new Xpp3Dom("configuration"); //$NON-NLS-1$ final Xpp3Dom xmlArchive = new Xpp3Dom("archive"); //$NON-NLS-1$ xmlConfiguration.addChild(xmlArchive); final String mainClass = getMainClass(); if (mainClass.isEmpty()) { throw new MojoFailureException("the main class of the SRE is missed"); //$NON-NLS-1$ } final Xpp3Dom xmlManifest = new Xpp3Dom("manifest"); //$NON-NLS-1$ xmlArchive.addChild(xmlManifest); final Xpp3Dom xmlManifestMainClass = new Xpp3Dom("mainClass"); //$NON-NLS-1$ xmlManifestMainClass.setValue(mainClass); xmlManifest.addChild(xmlManifestMainClass); final Xpp3Dom xmlSections = new Xpp3Dom("manifestSections"); //$NON-NLS-1$ xmlArchive.addChild(xmlSections); final Xpp3Dom xmlSection = new Xpp3Dom("manifestSection"); //$NON-NLS-1$ xmlSections.addChild(xmlSection); final Xpp3Dom xmlSectionName = new Xpp3Dom("name"); //$NON-NLS-1$ xmlSectionName.setValue(SREConstants.MANIFEST_SECTION_SRE); xmlSection.addChild(xmlSectionName); final Xpp3Dom xmlManifestEntries = new Xpp3Dom("manifestEntries"); //$NON-NLS-1$ xmlSection.addChild(xmlManifestEntries); ManifestUpdater updater = getManifestUpdater(); if (updater == null) { updater = new ManifestUpdater() { @Override public void addSREAttribute(String name, String value) { assert name != null && !name.isEmpty(); if (value != null && !value.isEmpty()) { getLog().debug("Adding to SRE manifest: " + name + " = " + value); //$NON-NLS-1$//$NON-NLS-2$ final Xpp3Dom xmlManifestEntry = new Xpp3Dom(name); xmlManifestEntry.setValue(value); xmlManifestEntries.addChild(xmlManifestEntry); } } @Override public void addMainAttribute(String name, String value) { // } }; } buildManifest(updater, mainClass); return xmlConfiguration; }
[ "protected", "Xpp3Dom", "createSREConfiguration", "(", ")", "throws", "MojoExecutionException", ",", "MojoFailureException", "{", "final", "Xpp3Dom", "xmlConfiguration", "=", "new", "Xpp3Dom", "(", "\"configuration\"", ")", ";", "//$NON-NLS-1$", "final", "Xpp3Dom", "xml...
Create the configuration of the SRE with the maven archive format. @return the created manifest. @throws MojoExecutionException if the mojo fails. @throws MojoFailureException if the generation fails.
[ "Create", "the", "configuration", "of", "the", "SRE", "with", "the", "maven", "archive", "format", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/externalmaven/io.sarl.maven.sre/src/main/java/io/sarl/maven/sre/AbstractSREMojo.java#L375-L426
train
sarl/sarl
sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/bic/InternalEventBusSkill.java
InternalEventBusSkill.runInitializationStage
private void runInitializationStage(Event event) { // Immediate synchronous dispatching of Initialize event try { setOwnerState(OwnerState.INITIALIZING); try { this.eventDispatcher.immediateDispatch(event); } finally { setOwnerState(OwnerState.ALIVE); } this.agentAsEventListener.fireEnqueuedEvents(this); if (this.agentAsEventListener.isKilled.get()) { this.agentAsEventListener.killOwner(InternalEventBusSkill.this); } } catch (Exception e) { // Log the exception final Logging loggingCapacity = getLoggingSkill(); if (loggingCapacity != null) { loggingCapacity.error(Messages.InternalEventBusSkill_3, e); } else { final LogRecord record = new LogRecord(Level.SEVERE, Messages.InternalEventBusSkill_3); this.logger.getKernelLogger().log( this.logger.prepareLogRecord(record, this.logger.getKernelLogger().getName(), Throwables.getRootCause(e))); } // If we have an exception within the agent's initialization, we kill the agent. setOwnerState(OwnerState.ALIVE); // Asynchronous kill of the event. this.agentAsEventListener.killOrMarkAsKilled(); } }
java
private void runInitializationStage(Event event) { // Immediate synchronous dispatching of Initialize event try { setOwnerState(OwnerState.INITIALIZING); try { this.eventDispatcher.immediateDispatch(event); } finally { setOwnerState(OwnerState.ALIVE); } this.agentAsEventListener.fireEnqueuedEvents(this); if (this.agentAsEventListener.isKilled.get()) { this.agentAsEventListener.killOwner(InternalEventBusSkill.this); } } catch (Exception e) { // Log the exception final Logging loggingCapacity = getLoggingSkill(); if (loggingCapacity != null) { loggingCapacity.error(Messages.InternalEventBusSkill_3, e); } else { final LogRecord record = new LogRecord(Level.SEVERE, Messages.InternalEventBusSkill_3); this.logger.getKernelLogger().log( this.logger.prepareLogRecord(record, this.logger.getKernelLogger().getName(), Throwables.getRootCause(e))); } // If we have an exception within the agent's initialization, we kill the agent. setOwnerState(OwnerState.ALIVE); // Asynchronous kill of the event. this.agentAsEventListener.killOrMarkAsKilled(); } }
[ "private", "void", "runInitializationStage", "(", "Event", "event", ")", "{", "// Immediate synchronous dispatching of Initialize event", "try", "{", "setOwnerState", "(", "OwnerState", ".", "INITIALIZING", ")", ";", "try", "{", "this", ".", "eventDispatcher", ".", "i...
This function runs the initialization of the agent. @param event the {@link Initialize} occurrence.
[ "This", "function", "runs", "the", "initialization", "of", "the", "agent", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/bic/InternalEventBusSkill.java#L237-L266
train
sarl/sarl
sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/bic/InternalEventBusSkill.java
InternalEventBusSkill.runDestructionStage
private void runDestructionStage(Event event) { // Immediate synchronous dispatching of Destroy event try { setOwnerState(OwnerState.DYING); try { this.eventDispatcher.immediateDispatch(event); } finally { setOwnerState(OwnerState.DEAD); } } catch (Exception e) { // Log the exception final Logging loggingCapacity = getLoggingSkill(); if (loggingCapacity != null) { loggingCapacity.error(Messages.InternalEventBusSkill_4, e); } else { final LogRecord record = new LogRecord(Level.SEVERE, Messages.InternalEventBusSkill_4); this.logger.getKernelLogger().log( this.logger.prepareLogRecord(record, this.logger.getKernelLogger().getName(), Throwables.getRootCause(e))); } } }
java
private void runDestructionStage(Event event) { // Immediate synchronous dispatching of Destroy event try { setOwnerState(OwnerState.DYING); try { this.eventDispatcher.immediateDispatch(event); } finally { setOwnerState(OwnerState.DEAD); } } catch (Exception e) { // Log the exception final Logging loggingCapacity = getLoggingSkill(); if (loggingCapacity != null) { loggingCapacity.error(Messages.InternalEventBusSkill_4, e); } else { final LogRecord record = new LogRecord(Level.SEVERE, Messages.InternalEventBusSkill_4); this.logger.getKernelLogger().log( this.logger.prepareLogRecord(record, this.logger.getKernelLogger().getName(), Throwables.getRootCause(e))); } } }
[ "private", "void", "runDestructionStage", "(", "Event", "event", ")", "{", "// Immediate synchronous dispatching of Destroy event", "try", "{", "setOwnerState", "(", "OwnerState", ".", "DYING", ")", ";", "try", "{", "this", ".", "eventDispatcher", ".", "immediateDispa...
This function runs the destruction of the agent. @param event the {@link Destroy} occurrence.
[ "This", "function", "runs", "the", "destruction", "of", "the", "agent", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/bic/InternalEventBusSkill.java#L272-L293
train
sarl/sarl
main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/highlighting/SARLHighlightingCalculator.java
SARLHighlightingCalculator.isCapacityMethodCall
protected boolean isCapacityMethodCall(JvmOperation feature) { if (feature != null) { final JvmDeclaredType container = feature.getDeclaringType(); if (container instanceof JvmGenericType) { return this.inheritanceHelper.isSarlCapacity((JvmGenericType) container); } } return false; }
java
protected boolean isCapacityMethodCall(JvmOperation feature) { if (feature != null) { final JvmDeclaredType container = feature.getDeclaringType(); if (container instanceof JvmGenericType) { return this.inheritanceHelper.isSarlCapacity((JvmGenericType) container); } } return false; }
[ "protected", "boolean", "isCapacityMethodCall", "(", "JvmOperation", "feature", ")", "{", "if", "(", "feature", "!=", "null", ")", "{", "final", "JvmDeclaredType", "container", "=", "feature", ".", "getDeclaringType", "(", ")", ";", "if", "(", "container", "in...
Replies if the given call is for a capacity function call. @param feature the feature to test. @return {@code true} if the feature is capacity(s method.
[ "Replies", "if", "the", "given", "call", "is", "for", "a", "capacity", "function", "call", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/highlighting/SARLHighlightingCalculator.java#L87-L95
train
sarl/sarl
main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/contentassist/SARLProposalProvider.java
SARLProposalProvider.completeJavaTypes
protected void completeJavaTypes(ContentAssistContext context, ITypesProposalProvider.Filter filter, ICompletionProposalAcceptor acceptor) { completeJavaTypes(context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, true, getQualifiedNameValueConverter(), filter, acceptor); }
java
protected void completeJavaTypes(ContentAssistContext context, ITypesProposalProvider.Filter filter, ICompletionProposalAcceptor acceptor) { completeJavaTypes(context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, true, getQualifiedNameValueConverter(), filter, acceptor); }
[ "protected", "void", "completeJavaTypes", "(", "ContentAssistContext", "context", ",", "ITypesProposalProvider", ".", "Filter", "filter", ",", "ICompletionProposalAcceptor", "acceptor", ")", "{", "completeJavaTypes", "(", "context", ",", "TypesPackage", ".", "Literals", ...
Complete for Java types. @param context the completion context. @param filter the filter for the types. @param acceptor the proposal acceptor.
[ "Complete", "for", "Java", "types", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/contentassist/SARLProposalProvider.java#L136-L144
train
sarl/sarl
main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/contentassist/SARLProposalProvider.java
SARLProposalProvider.completeSarlEvents
protected void completeSarlEvents(boolean allowEventType, boolean isExtensionFilter, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { if (isSarlProposalEnabled()) { completeSubJavaTypes(Event.class, allowEventType, context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, getQualifiedNameValueConverter(), isExtensionFilter ? createExtensionFilter(context, IJavaSearchConstants.CLASS) : createVisibilityFilter(context, IJavaSearchConstants.CLASS), acceptor); } }
java
protected void completeSarlEvents(boolean allowEventType, boolean isExtensionFilter, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { if (isSarlProposalEnabled()) { completeSubJavaTypes(Event.class, allowEventType, context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, getQualifiedNameValueConverter(), isExtensionFilter ? createExtensionFilter(context, IJavaSearchConstants.CLASS) : createVisibilityFilter(context, IJavaSearchConstants.CLASS), acceptor); } }
[ "protected", "void", "completeSarlEvents", "(", "boolean", "allowEventType", ",", "boolean", "isExtensionFilter", ",", "ContentAssistContext", "context", ",", "ICompletionProposalAcceptor", "acceptor", ")", "{", "if", "(", "isSarlProposalEnabled", "(", ")", ")", "{", ...
Complete for obtaining SARL events if the proposals are enabled. @param allowEventType is <code>true</code> for enabling the {@link Event} type to be in the proposals. @param isExtensionFilter indicates if the type filter is for "extends" or only based on visibility. @param context the completion context. @param acceptor the proposal acceptor. @see #isSarlProposalEnabled()
[ "Complete", "for", "obtaining", "SARL", "events", "if", "the", "proposals", "are", "enabled", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/contentassist/SARLProposalProvider.java#L154-L163
train
sarl/sarl
main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/contentassist/SARLProposalProvider.java
SARLProposalProvider.completeSarlCapacities
protected void completeSarlCapacities(boolean allowCapacityType, boolean isExtensionFilter, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { if (isSarlProposalEnabled()) { completeSubJavaTypes(Capacity.class, allowCapacityType, context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, getQualifiedNameValueConverter(), isExtensionFilter ? createExtensionFilter(context, IJavaSearchConstants.INSTANCEOF_TYPE_REFERENCE) : createVisibilityFilter(context, IJavaSearchConstants.INTERFACE), acceptor); } }
java
protected void completeSarlCapacities(boolean allowCapacityType, boolean isExtensionFilter, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { if (isSarlProposalEnabled()) { completeSubJavaTypes(Capacity.class, allowCapacityType, context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, getQualifiedNameValueConverter(), isExtensionFilter ? createExtensionFilter(context, IJavaSearchConstants.INSTANCEOF_TYPE_REFERENCE) : createVisibilityFilter(context, IJavaSearchConstants.INTERFACE), acceptor); } }
[ "protected", "void", "completeSarlCapacities", "(", "boolean", "allowCapacityType", ",", "boolean", "isExtensionFilter", ",", "ContentAssistContext", "context", ",", "ICompletionProposalAcceptor", "acceptor", ")", "{", "if", "(", "isSarlProposalEnabled", "(", ")", ")", ...
Complete for obtaining SARL capacities if the proposals are enabled. @param allowCapacityType is <code>true</code> for enabling the {@link Capacity} type to be in the proposals. @param isExtensionFilter indicates if the type filter is for "extends" or only based on visibility. @param context the completion context. @param acceptor the proposal acceptor. @see #isSarlProposalEnabled()
[ "Complete", "for", "obtaining", "SARL", "capacities", "if", "the", "proposals", "are", "enabled", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/contentassist/SARLProposalProvider.java#L173-L182
train
sarl/sarl
main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/contentassist/SARLProposalProvider.java
SARLProposalProvider.completeSarlAgents
protected void completeSarlAgents(boolean allowAgentType, boolean isExtensionFilter, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { if (isSarlProposalEnabled()) { completeSubJavaTypes(Agent.class, allowAgentType, context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, getQualifiedNameValueConverter(), isExtensionFilter ? createExtensionFilter(context, IJavaSearchConstants.CLASS) : createVisibilityFilter(context, IJavaSearchConstants.CLASS), acceptor); } }
java
protected void completeSarlAgents(boolean allowAgentType, boolean isExtensionFilter, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { if (isSarlProposalEnabled()) { completeSubJavaTypes(Agent.class, allowAgentType, context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, getQualifiedNameValueConverter(), isExtensionFilter ? createExtensionFilter(context, IJavaSearchConstants.CLASS) : createVisibilityFilter(context, IJavaSearchConstants.CLASS), acceptor); } }
[ "protected", "void", "completeSarlAgents", "(", "boolean", "allowAgentType", ",", "boolean", "isExtensionFilter", ",", "ContentAssistContext", "context", ",", "ICompletionProposalAcceptor", "acceptor", ")", "{", "if", "(", "isSarlProposalEnabled", "(", ")", ")", "{", ...
Complete for obtaining SARL agents if the proposals are enabled. @param allowAgentType is <code>true</code> for enabling the {@link Agent} type to be in the proposals. @param isExtensionFilter indicates if the type filter is for "extends" or only based on visibility. @param context the completion context. @param acceptor the proposal acceptor. @see #isSarlProposalEnabled()
[ "Complete", "for", "obtaining", "SARL", "agents", "if", "the", "proposals", "are", "enabled", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/contentassist/SARLProposalProvider.java#L192-L201
train
sarl/sarl
main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/contentassist/SARLProposalProvider.java
SARLProposalProvider.completeSarlBehaviors
protected void completeSarlBehaviors(boolean allowBehaviorType, boolean isExtensionFilter, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { if (isSarlProposalEnabled()) { completeSubJavaTypes(Behavior.class, allowBehaviorType, context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, getQualifiedNameValueConverter(), isExtensionFilter ? createExtensionFilter(context, IJavaSearchConstants.CLASS) : createVisibilityFilter(context, IJavaSearchConstants.CLASS), acceptor); } }
java
protected void completeSarlBehaviors(boolean allowBehaviorType, boolean isExtensionFilter, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { if (isSarlProposalEnabled()) { completeSubJavaTypes(Behavior.class, allowBehaviorType, context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, getQualifiedNameValueConverter(), isExtensionFilter ? createExtensionFilter(context, IJavaSearchConstants.CLASS) : createVisibilityFilter(context, IJavaSearchConstants.CLASS), acceptor); } }
[ "protected", "void", "completeSarlBehaviors", "(", "boolean", "allowBehaviorType", ",", "boolean", "isExtensionFilter", ",", "ContentAssistContext", "context", ",", "ICompletionProposalAcceptor", "acceptor", ")", "{", "if", "(", "isSarlProposalEnabled", "(", ")", ")", "...
Complete for obtaining SARL behaviors if the proposals are enabled. @param allowBehaviorType is <code>true</code> for enabling the {@link Behavior} type to be in the proposals. @param isExtensionFilter indicates if the type filter is for "extends" or only based on visibility. @param context the completion context. @param acceptor the proposal acceptor. @see #isSarlProposalEnabled()
[ "Complete", "for", "obtaining", "SARL", "behaviors", "if", "the", "proposals", "are", "enabled", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/contentassist/SARLProposalProvider.java#L211-L220
train
sarl/sarl
main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/contentassist/SARLProposalProvider.java
SARLProposalProvider.completeSarlSkills
protected void completeSarlSkills(boolean allowSkillType, boolean isExtensionFilter, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { if (isSarlProposalEnabled()) { completeSubJavaTypes(Skill.class, allowSkillType, context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, getQualifiedNameValueConverter(), isExtensionFilter ? createExtensionFilter(context, IJavaSearchConstants.CLASS) : createVisibilityFilter(context, IJavaSearchConstants.CLASS), acceptor); } }
java
protected void completeSarlSkills(boolean allowSkillType, boolean isExtensionFilter, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { if (isSarlProposalEnabled()) { completeSubJavaTypes(Skill.class, allowSkillType, context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, getQualifiedNameValueConverter(), isExtensionFilter ? createExtensionFilter(context, IJavaSearchConstants.CLASS) : createVisibilityFilter(context, IJavaSearchConstants.CLASS), acceptor); } }
[ "protected", "void", "completeSarlSkills", "(", "boolean", "allowSkillType", ",", "boolean", "isExtensionFilter", ",", "ContentAssistContext", "context", ",", "ICompletionProposalAcceptor", "acceptor", ")", "{", "if", "(", "isSarlProposalEnabled", "(", ")", ")", "{", ...
Complete for obtaining SARL skills if proposals are enabled. @param allowSkillType is <code>true</code> for enabling the {@link Skill} type to be in the proposals. @param isExtensionFilter indicates if the type filter is for "extends" or only based on visibility. @param context the completion context. @param acceptor the proposal acceptor. @see #isSarlProposalEnabled()
[ "Complete", "for", "obtaining", "SARL", "skills", "if", "proposals", "are", "enabled", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/contentassist/SARLProposalProvider.java#L230-L239
train
sarl/sarl
main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/contentassist/SARLProposalProvider.java
SARLProposalProvider.completeExceptions
protected void completeExceptions(boolean allowExceptionType, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { if (isSarlProposalEnabled()) { completeSubJavaTypes(Exception.class, allowExceptionType, context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, getQualifiedNameValueConverter(), createVisibilityFilter(context, IJavaSearchConstants.CLASS), acceptor); } }
java
protected void completeExceptions(boolean allowExceptionType, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { if (isSarlProposalEnabled()) { completeSubJavaTypes(Exception.class, allowExceptionType, context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, getQualifiedNameValueConverter(), createVisibilityFilter(context, IJavaSearchConstants.CLASS), acceptor); } }
[ "protected", "void", "completeExceptions", "(", "boolean", "allowExceptionType", ",", "ContentAssistContext", "context", ",", "ICompletionProposalAcceptor", "acceptor", ")", "{", "if", "(", "isSarlProposalEnabled", "(", ")", ")", "{", "completeSubJavaTypes", "(", "Excep...
Complete for obtaining exception types if proposals are enabled. @param allowExceptionType is <code>true</code> for enabling the {@link Exception} type to be in the proposals. @param context the completion context. @param acceptor the proposal acceptor. @see #isSarlProposalEnabled()
[ "Complete", "for", "obtaining", "exception", "types", "if", "proposals", "are", "enabled", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/contentassist/SARLProposalProvider.java#L248-L256
train
sarl/sarl
main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/contentassist/SARLProposalProvider.java
SARLProposalProvider.completeSubJavaTypes
protected void completeSubJavaTypes(Class<?> superType, boolean allowSuperTypeItself, ContentAssistContext context, EReference reference, IValueConverter<String> valueConverter, final ITypesProposalProvider.Filter filter, ICompletionProposalAcceptor acceptor) { assert superType != null; final INode lastCompleteNode = context.getLastCompleteNode(); if (lastCompleteNode instanceof ILeafNode && !((ILeafNode) lastCompleteNode).isHidden()) { if (lastCompleteNode.getLength() > 0 && lastCompleteNode.getTotalEndOffset() == context.getOffset()) { final String text = lastCompleteNode.getText(); final char lastChar = text.charAt(text.length() - 1); if (Character.isJavaIdentifierPart(lastChar)) { return; } } } final ITypesProposalProvider.Filter subTypeFilter; if (allowSuperTypeItself) { subTypeFilter = filter; } else { final String superTypeQualifiedName = superType.getName(); subTypeFilter = new ITypesProposalProvider.Filter() { @Override public boolean accept(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path) { final String fullName = JavaModelUtil.concatenateName(packageName, simpleTypeName); if (Objects.equals(superTypeQualifiedName, fullName)) { return false; } return filter.accept(modifiers, packageName, simpleTypeName, enclosingTypeNames, path); } @Override public int getSearchFor() { return filter.getSearchFor(); } }; } getTypesProposalProvider().createSubTypeProposals( this.typeReferences.findDeclaredType(superType, context.getCurrentModel()), this, context, reference, subTypeFilter, valueConverter, acceptor); }
java
protected void completeSubJavaTypes(Class<?> superType, boolean allowSuperTypeItself, ContentAssistContext context, EReference reference, IValueConverter<String> valueConverter, final ITypesProposalProvider.Filter filter, ICompletionProposalAcceptor acceptor) { assert superType != null; final INode lastCompleteNode = context.getLastCompleteNode(); if (lastCompleteNode instanceof ILeafNode && !((ILeafNode) lastCompleteNode).isHidden()) { if (lastCompleteNode.getLength() > 0 && lastCompleteNode.getTotalEndOffset() == context.getOffset()) { final String text = lastCompleteNode.getText(); final char lastChar = text.charAt(text.length() - 1); if (Character.isJavaIdentifierPart(lastChar)) { return; } } } final ITypesProposalProvider.Filter subTypeFilter; if (allowSuperTypeItself) { subTypeFilter = filter; } else { final String superTypeQualifiedName = superType.getName(); subTypeFilter = new ITypesProposalProvider.Filter() { @Override public boolean accept(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path) { final String fullName = JavaModelUtil.concatenateName(packageName, simpleTypeName); if (Objects.equals(superTypeQualifiedName, fullName)) { return false; } return filter.accept(modifiers, packageName, simpleTypeName, enclosingTypeNames, path); } @Override public int getSearchFor() { return filter.getSearchFor(); } }; } getTypesProposalProvider().createSubTypeProposals( this.typeReferences.findDeclaredType(superType, context.getCurrentModel()), this, context, reference, subTypeFilter, valueConverter, acceptor); }
[ "protected", "void", "completeSubJavaTypes", "(", "Class", "<", "?", ">", "superType", ",", "boolean", "allowSuperTypeItself", ",", "ContentAssistContext", "context", ",", "EReference", "reference", ",", "IValueConverter", "<", "String", ">", "valueConverter", ",", ...
Complete for obtaining SARL types that are subtypes of the given type. @param superType the super-type. @param allowSuperTypeItself indicates if the super-type itself is allowed to be in the proposals. @param context the content assist context. @param reference the reference to the rule part to be complete. @param valueConverter the converter of the proposed values. @param filter the filter of the proposed values. @param acceptor the proposal acceptor.
[ "Complete", "for", "obtaining", "SARL", "types", "that", "are", "subtypes", "of", "the", "given", "type", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/contentassist/SARLProposalProvider.java#L268-L314
train
sarl/sarl
main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/contentassist/SARLProposalProvider.java
SARLProposalProvider.getExpectedPackageName
protected String getExpectedPackageName(EObject model) { final URI fileURI = model.eResource().getURI(); for (final Pair<IStorage, IProject> storage: this.storage2UriMapper.getStorages(fileURI)) { if (storage.getFirst() instanceof IFile) { final IPath fileWorkspacePath = storage.getFirst().getFullPath(); final IJavaProject javaProject = JavaCore.create(storage.getSecond()); return extractProjectPath(fileWorkspacePath, javaProject); } } return null; }
java
protected String getExpectedPackageName(EObject model) { final URI fileURI = model.eResource().getURI(); for (final Pair<IStorage, IProject> storage: this.storage2UriMapper.getStorages(fileURI)) { if (storage.getFirst() instanceof IFile) { final IPath fileWorkspacePath = storage.getFirst().getFullPath(); final IJavaProject javaProject = JavaCore.create(storage.getSecond()); return extractProjectPath(fileWorkspacePath, javaProject); } } return null; }
[ "protected", "String", "getExpectedPackageName", "(", "EObject", "model", ")", "{", "final", "URI", "fileURI", "=", "model", ".", "eResource", "(", ")", ".", "getURI", "(", ")", ";", "for", "(", "final", "Pair", "<", "IStorage", ",", "IProject", ">", "st...
Replies the expected package for the given model. @param model the model. @return the expected package name.
[ "Replies", "the", "expected", "package", "for", "the", "given", "model", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/contentassist/SARLProposalProvider.java#L337-L347
train
sarl/sarl
main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/contentassist/SARLProposalProvider.java
SARLProposalProvider.completeExtends
protected void completeExtends(EObject model, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { if (isSarlProposalEnabled()) { if (model instanceof SarlAgent) { completeSarlAgents(false, true, context, acceptor); } else if (model instanceof SarlBehavior) { completeSarlBehaviors(false, true, context, acceptor); } else if (model instanceof SarlCapacity) { completeSarlCapacities(false, true, context, acceptor); } else if (model instanceof SarlSkill) { completeSarlSkills(false, true, context, acceptor); } else if (model instanceof SarlEvent) { completeSarlEvents(false, true, context, acceptor); } else if (model instanceof SarlClass) { completeJavaTypes( context, createExtensionFilter(context, IJavaSearchConstants.CLASS), acceptor); } else if (model instanceof SarlInterface) { completeJavaTypes( context, createExtensionFilter(context, IJavaSearchConstants.INTERFACE), acceptor); } } }
java
protected void completeExtends(EObject model, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { if (isSarlProposalEnabled()) { if (model instanceof SarlAgent) { completeSarlAgents(false, true, context, acceptor); } else if (model instanceof SarlBehavior) { completeSarlBehaviors(false, true, context, acceptor); } else if (model instanceof SarlCapacity) { completeSarlCapacities(false, true, context, acceptor); } else if (model instanceof SarlSkill) { completeSarlSkills(false, true, context, acceptor); } else if (model instanceof SarlEvent) { completeSarlEvents(false, true, context, acceptor); } else if (model instanceof SarlClass) { completeJavaTypes( context, createExtensionFilter(context, IJavaSearchConstants.CLASS), acceptor); } else if (model instanceof SarlInterface) { completeJavaTypes( context, createExtensionFilter(context, IJavaSearchConstants.INTERFACE), acceptor); } } }
[ "protected", "void", "completeExtends", "(", "EObject", "model", ",", "ContentAssistContext", "context", ",", "ICompletionProposalAcceptor", "acceptor", ")", "{", "if", "(", "isSarlProposalEnabled", "(", ")", ")", "{", "if", "(", "model", "instanceof", "SarlAgent", ...
Complete the "extends" if the proposals are enabled. @param model the model. @param context the context. @param acceptor the proposal acceptor. @see #isSarlProposalEnabled()
[ "Complete", "the", "extends", "if", "the", "proposals", "are", "enabled", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/contentassist/SARLProposalProvider.java#L379-L404
train
sarl/sarl
main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/outline/SARLOutlineTreeProvider.java
SARLOutlineTreeProvider._createChildren
protected void _createChildren(DocumentRootNode parentNode, SarlScript modelElement) { if (!Strings.isNullOrEmpty(modelElement.getPackage())) { // Create the node for the package declaration. createEStructuralFeatureNode( parentNode, modelElement, XtendPackage.Literals.XTEND_FILE__PACKAGE, this.imageDispatcher.invoke(getClass().getPackage()), // Do not use the text dispatcher below for avoiding to obtain // the filename of the script. modelElement.getPackage(), true); } // Create the nodes for the import declarations. /*if (modelElement.getImportSection() != null && !modelElement.getImportSection().getImportDeclarations().isEmpty()) { createNode(parentNode, modelElement.getImportSection()); }*/ // Create a node per type declaration. for (final XtendTypeDeclaration topElement : modelElement.getXtendTypes()) { createNode(parentNode, topElement); } }
java
protected void _createChildren(DocumentRootNode parentNode, SarlScript modelElement) { if (!Strings.isNullOrEmpty(modelElement.getPackage())) { // Create the node for the package declaration. createEStructuralFeatureNode( parentNode, modelElement, XtendPackage.Literals.XTEND_FILE__PACKAGE, this.imageDispatcher.invoke(getClass().getPackage()), // Do not use the text dispatcher below for avoiding to obtain // the filename of the script. modelElement.getPackage(), true); } // Create the nodes for the import declarations. /*if (modelElement.getImportSection() != null && !modelElement.getImportSection().getImportDeclarations().isEmpty()) { createNode(parentNode, modelElement.getImportSection()); }*/ // Create a node per type declaration. for (final XtendTypeDeclaration topElement : modelElement.getXtendTypes()) { createNode(parentNode, topElement); } }
[ "protected", "void", "_createChildren", "(", "DocumentRootNode", "parentNode", ",", "SarlScript", "modelElement", ")", "{", "if", "(", "!", "Strings", ".", "isNullOrEmpty", "(", "modelElement", ".", "getPackage", "(", ")", ")", ")", "{", "// Create the node for th...
Create a node for the SARL script. @param parentNode the parent node. @param modelElement the feature container for which a node should be created.
[ "Create", "a", "node", "for", "the", "SARL", "script", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/outline/SARLOutlineTreeProvider.java#L103-L123
train
sarl/sarl
main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/outline/SARLOutlineTreeProvider.java
SARLOutlineTreeProvider._createNode
@SuppressWarnings("checkstyle:cyclomaticcomplexity") protected void _createNode(DocumentRootNode parentNode, XtendTypeDeclaration modelElement) { // // The text region is set to the model element, not to the model element's name as in the // default implementation of createStructuralFeatureNode(). // The text region computation is overridden in order to have a correct link to the editor. // final boolean isFeatureSet = modelElement.eIsSet(XtendPackage.Literals.XTEND_TYPE_DECLARATION__NAME); final EStructuralFeatureNode elementNode = new EStructuralFeatureNode( modelElement, XtendPackage.Literals.XTEND_TYPE_DECLARATION__NAME, parentNode, this.imageDispatcher.invoke(modelElement), this.textDispatcher.invoke(modelElement), modelElement.getMembers().isEmpty() || !isFeatureSet); final EObject primarySourceElement = this.associations.getPrimarySourceElement(modelElement); final ICompositeNode parserNode = NodeModelUtils.getNode( (primarySourceElement == null) ? modelElement : primarySourceElement); elementNode.setTextRegion(parserNode.getTextRegion()); // boolean hasConstructor = false; if (!modelElement.getMembers().isEmpty()) { EObjectNode capacityUseNode = null; EObjectNode capacityRequirementNode = null; for (final EObject feature : modelElement.getMembers()) { if (feature instanceof SarlConstructor) { hasConstructor = true; createNode(elementNode, feature); } else if (feature instanceof SarlField) { final SarlField field = (SarlField) feature; createNode(elementNode, field); createAutomaticAccessors(elementNode, field); } else if (feature instanceof SarlAction || feature instanceof SarlBehaviorUnit || feature instanceof XtendTypeDeclaration) { createNode(elementNode, feature); } else if (feature instanceof SarlCapacityUses) { capacityUseNode = createCapacityUseNode(elementNode, (SarlCapacityUses) feature, capacityUseNode); } else if (feature instanceof SarlRequiredCapacity) { capacityRequirementNode = createRequiredCapacityNode(elementNode, (SarlRequiredCapacity) feature, capacityRequirementNode); } } } if (!hasConstructor && modelElement instanceof XtendClass) { createInheritedConstructors(elementNode, (XtendClass) modelElement); } }
java
@SuppressWarnings("checkstyle:cyclomaticcomplexity") protected void _createNode(DocumentRootNode parentNode, XtendTypeDeclaration modelElement) { // // The text region is set to the model element, not to the model element's name as in the // default implementation of createStructuralFeatureNode(). // The text region computation is overridden in order to have a correct link to the editor. // final boolean isFeatureSet = modelElement.eIsSet(XtendPackage.Literals.XTEND_TYPE_DECLARATION__NAME); final EStructuralFeatureNode elementNode = new EStructuralFeatureNode( modelElement, XtendPackage.Literals.XTEND_TYPE_DECLARATION__NAME, parentNode, this.imageDispatcher.invoke(modelElement), this.textDispatcher.invoke(modelElement), modelElement.getMembers().isEmpty() || !isFeatureSet); final EObject primarySourceElement = this.associations.getPrimarySourceElement(modelElement); final ICompositeNode parserNode = NodeModelUtils.getNode( (primarySourceElement == null) ? modelElement : primarySourceElement); elementNode.setTextRegion(parserNode.getTextRegion()); // boolean hasConstructor = false; if (!modelElement.getMembers().isEmpty()) { EObjectNode capacityUseNode = null; EObjectNode capacityRequirementNode = null; for (final EObject feature : modelElement.getMembers()) { if (feature instanceof SarlConstructor) { hasConstructor = true; createNode(elementNode, feature); } else if (feature instanceof SarlField) { final SarlField field = (SarlField) feature; createNode(elementNode, field); createAutomaticAccessors(elementNode, field); } else if (feature instanceof SarlAction || feature instanceof SarlBehaviorUnit || feature instanceof XtendTypeDeclaration) { createNode(elementNode, feature); } else if (feature instanceof SarlCapacityUses) { capacityUseNode = createCapacityUseNode(elementNode, (SarlCapacityUses) feature, capacityUseNode); } else if (feature instanceof SarlRequiredCapacity) { capacityRequirementNode = createRequiredCapacityNode(elementNode, (SarlRequiredCapacity) feature, capacityRequirementNode); } } } if (!hasConstructor && modelElement instanceof XtendClass) { createInheritedConstructors(elementNode, (XtendClass) modelElement); } }
[ "@", "SuppressWarnings", "(", "\"checkstyle:cyclomaticcomplexity\"", ")", "protected", "void", "_createNode", "(", "DocumentRootNode", "parentNode", ",", "XtendTypeDeclaration", "modelElement", ")", "{", "//", "// The text region is set to the model element, not to the model elemen...
Create a node for the given feature container. @param parentNode the parent node. @param modelElement the feature container for which a node should be created.
[ "Create", "a", "node", "for", "the", "given", "feature", "container", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/outline/SARLOutlineTreeProvider.java#L130-L178
train
sarl/sarl
main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/outline/SARLOutlineTreeProvider.java
SARLOutlineTreeProvider._image
protected Image _image(XtendMember modelElement) { final Image img = super._image(modelElement); return this.diagnoticDecorator.decorateImage(img, modelElement); }
java
protected Image _image(XtendMember modelElement) { final Image img = super._image(modelElement); return this.diagnoticDecorator.decorateImage(img, modelElement); }
[ "protected", "Image", "_image", "(", "XtendMember", "modelElement", ")", "{", "final", "Image", "img", "=", "super", ".", "_image", "(", "modelElement", ")", ";", "return", "this", ".", "diagnoticDecorator", ".", "decorateImage", "(", "img", ",", "modelElement...
Get the image for the Xtend members. @param modelElement the member. @return the image.
[ "Get", "the", "image", "for", "the", "Xtend", "members", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/outline/SARLOutlineTreeProvider.java#L395-L398
train
sarl/sarl
main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/SarlConstructorBuilderImpl.java
SarlConstructorBuilderImpl.addParameter
public IFormalParameterBuilder addParameter(String name) { IFormalParameterBuilder builder = this.parameterProvider.get(); builder.eInit(this.sarlConstructor, name, getTypeResolutionContext()); return builder; }
java
public IFormalParameterBuilder addParameter(String name) { IFormalParameterBuilder builder = this.parameterProvider.get(); builder.eInit(this.sarlConstructor, name, getTypeResolutionContext()); return builder; }
[ "public", "IFormalParameterBuilder", "addParameter", "(", "String", "name", ")", "{", "IFormalParameterBuilder", "builder", "=", "this", ".", "parameterProvider", ".", "get", "(", ")", ";", "builder", ".", "eInit", "(", "this", ".", "sarlConstructor", ",", "name...
Add a formal parameter. @param name the name of the formal parameter.
[ "Add", "a", "formal", "parameter", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/builders/SarlConstructorBuilderImpl.java#L113-L117
train
sarl/sarl
main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/util/AbstractSarlScriptInteractiveSelector.java
AbstractSarlScriptInteractiveSelector.isValidResource
@SuppressWarnings("static-method") protected boolean isValidResource(IResource resource) { return resource.isAccessible() && !resource.isHidden() && !resource.isPhantom() && !resource.isDerived(); }
java
@SuppressWarnings("static-method") protected boolean isValidResource(IResource resource) { return resource.isAccessible() && !resource.isHidden() && !resource.isPhantom() && !resource.isDerived(); }
[ "@", "SuppressWarnings", "(", "\"static-method\"", ")", "protected", "boolean", "isValidResource", "(", "IResource", "resource", ")", "{", "return", "resource", ".", "isAccessible", "(", ")", "&&", "!", "resource", ".", "isHidden", "(", ")", "&&", "!", "resour...
Replies if the given resource could be considered for discovering an agent to be launched. @param resource the resource. @return {@code true} if the resource could be explored.
[ "Replies", "if", "the", "given", "resource", "could", "be", "considered", "for", "discovering", "an", "agent", "to", "be", "launched", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/util/AbstractSarlScriptInteractiveSelector.java#L113-L116
train
sarl/sarl
main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/util/AbstractSarlScriptInteractiveSelector.java
AbstractSarlScriptInteractiveSelector.searchAndSelect
public ElementDescription searchAndSelect(boolean showEmptySelectionError, Object... scope) { try { final List<ElementDescription> elements = findElements(scope, PlatformUI.getWorkbench().getProgressService()); ElementDescription element = null; if (elements == null || elements.isEmpty()) { if (showEmptySelectionError) { SARLEclipsePlugin.getDefault().openError(getShell(), Messages.AbstractSarlScriptInteractiveSelector_1, MessageFormat.format(Messages.AbstractSarlScriptInteractiveSelector_2, getElementLabel()), null); } } else if (elements.size() > 1) { element = chooseElement(elements); } else { element = elements.get(0); } return element; } catch (InterruptedException exception) { // } catch (Exception exception) { SARLEclipsePlugin.getDefault().openError(getShell(), Messages.AbstractSarlScriptInteractiveSelector_1, null, exception); } return null; }
java
public ElementDescription searchAndSelect(boolean showEmptySelectionError, Object... scope) { try { final List<ElementDescription> elements = findElements(scope, PlatformUI.getWorkbench().getProgressService()); ElementDescription element = null; if (elements == null || elements.isEmpty()) { if (showEmptySelectionError) { SARLEclipsePlugin.getDefault().openError(getShell(), Messages.AbstractSarlScriptInteractiveSelector_1, MessageFormat.format(Messages.AbstractSarlScriptInteractiveSelector_2, getElementLabel()), null); } } else if (elements.size() > 1) { element = chooseElement(elements); } else { element = elements.get(0); } return element; } catch (InterruptedException exception) { // } catch (Exception exception) { SARLEclipsePlugin.getDefault().openError(getShell(), Messages.AbstractSarlScriptInteractiveSelector_1, null, exception); } return null; }
[ "public", "ElementDescription", "searchAndSelect", "(", "boolean", "showEmptySelectionError", ",", "Object", "...", "scope", ")", "{", "try", "{", "final", "List", "<", "ElementDescription", ">", "elements", "=", "findElements", "(", "scope", ",", "PlatformUI", "....
Search the elements based on the given scope, and select one. If more than one element was found, the user selects interactively one. @param showEmptySelectionError indicates if this function shows an error when the selection is empty. @param scope the elements to consider for an element type that can be launched. @return the selected element; or {@code null} if there is no selection.
[ "Search", "the", "elements", "based", "on", "the", "given", "scope", "and", "select", "one", ".", "If", "more", "than", "one", "element", "was", "found", "the", "user", "selects", "interactively", "one", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/util/AbstractSarlScriptInteractiveSelector.java#L277-L301
train
sarl/sarl
main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/util/AbstractSarlScriptInteractiveSelector.java
AbstractSarlScriptInteractiveSelector.chooseElement
private ElementDescription chooseElement(List<ElementDescription> elements) { final ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new LabelProvider()); dialog.setElements(elements.toArray()); dialog.setTitle(MessageFormat.format(Messages.AbstractSarlScriptInteractiveSelector_3, getElementLabel())); dialog.setMessage(MessageFormat.format(Messages.AbstractSarlScriptInteractiveSelector_3, getElementLongLabel())); dialog.setMultipleSelection(false); final int result = dialog.open(); if (result == Window.OK) { return (ElementDescription) dialog.getFirstResult(); } return null; }
java
private ElementDescription chooseElement(List<ElementDescription> elements) { final ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new LabelProvider()); dialog.setElements(elements.toArray()); dialog.setTitle(MessageFormat.format(Messages.AbstractSarlScriptInteractiveSelector_3, getElementLabel())); dialog.setMessage(MessageFormat.format(Messages.AbstractSarlScriptInteractiveSelector_3, getElementLongLabel())); dialog.setMultipleSelection(false); final int result = dialog.open(); if (result == Window.OK) { return (ElementDescription) dialog.getFirstResult(); } return null; }
[ "private", "ElementDescription", "chooseElement", "(", "List", "<", "ElementDescription", ">", "elements", ")", "{", "final", "ElementListSelectionDialog", "dialog", "=", "new", "ElementListSelectionDialog", "(", "getShell", "(", ")", ",", "new", "LabelProvider", "(",...
Prompts the user to select an element from the given element types. @param elements the element types to choose from. @return the selected element or <code>null</code> if none.
[ "Prompts", "the", "user", "to", "select", "an", "element", "from", "the", "given", "element", "types", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/util/AbstractSarlScriptInteractiveSelector.java#L327-L340
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/typesystem/cast/CastOperatorLinkingCandidate.java
CastOperatorLinkingCandidate.getValidationDescription
public String getValidationDescription() { final JvmOperation feature = getOperation(); String message = null; if (!getDeclaredTypeParameters().isEmpty()) { message = MessageFormat.format(Messages.CastOperatorLinkingCandidate_0, getFeatureTypeParametersAsString(true), feature.getSimpleName(), getFeatureParameterTypesAsString(), feature.getDeclaringType().getSimpleName()); } else { message = MessageFormat.format(Messages.CastOperatorLinkingCandidate_1, feature.getSimpleName(), getFeatureParameterTypesAsString(), feature.getDeclaringType().getSimpleName()); } return message; }
java
public String getValidationDescription() { final JvmOperation feature = getOperation(); String message = null; if (!getDeclaredTypeParameters().isEmpty()) { message = MessageFormat.format(Messages.CastOperatorLinkingCandidate_0, getFeatureTypeParametersAsString(true), feature.getSimpleName(), getFeatureParameterTypesAsString(), feature.getDeclaringType().getSimpleName()); } else { message = MessageFormat.format(Messages.CastOperatorLinkingCandidate_1, feature.getSimpleName(), getFeatureParameterTypesAsString(), feature.getDeclaringType().getSimpleName()); } return message; }
[ "public", "String", "getValidationDescription", "(", ")", "{", "final", "JvmOperation", "feature", "=", "getOperation", "(", ")", ";", "String", "message", "=", "null", ";", "if", "(", "!", "getDeclaredTypeParameters", "(", ")", ".", "isEmpty", "(", ")", ")"...
Replies the string representation of the candidate. @return the description of the candidate.
[ "Replies", "the", "string", "representation", "of", "the", "candidate", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/typesystem/cast/CastOperatorLinkingCandidate.java#L389-L405
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.annotationClassRef
private JvmAnnotationReference annotationClassRef(Class<? extends Annotation> type, List<? extends JvmTypeReference> values) { try { final JvmAnnotationReference annot = this._annotationTypesBuilder.annotationRef(type); final JvmTypeAnnotationValue annotationValue = this.services.getTypesFactory().createJvmTypeAnnotationValue(); for (final JvmTypeReference value : values) { annotationValue.getValues().add(this.typeBuilder.cloneWithProxies(value)); } annot.getExplicitValues().add(annotationValue); return annot; } catch (IllegalArgumentException exception) { // ignore } return null; }
java
private JvmAnnotationReference annotationClassRef(Class<? extends Annotation> type, List<? extends JvmTypeReference> values) { try { final JvmAnnotationReference annot = this._annotationTypesBuilder.annotationRef(type); final JvmTypeAnnotationValue annotationValue = this.services.getTypesFactory().createJvmTypeAnnotationValue(); for (final JvmTypeReference value : values) { annotationValue.getValues().add(this.typeBuilder.cloneWithProxies(value)); } annot.getExplicitValues().add(annotationValue); return annot; } catch (IllegalArgumentException exception) { // ignore } return null; }
[ "private", "JvmAnnotationReference", "annotationClassRef", "(", "Class", "<", "?", "extends", "Annotation", ">", "type", ",", "List", "<", "?", "extends", "JvmTypeReference", ">", "values", ")", "{", "try", "{", "final", "JvmAnnotationReference", "annot", "=", "...
Create an annotation with classes as values. @param type the type of the annotation. @param values the values. @return the reference to the JVM annotation.
[ "Create", "an", "annotation", "with", "classes", "as", "values", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L434-L448
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.initializeLocalTypes
protected void initializeLocalTypes(GenerationContext context, JvmFeature feature, XExpression expression) { if (expression != null) { int localTypeIndex = context.getLocalTypeIndex(); final TreeIterator<EObject> iterator = EcoreUtil2.getAllNonDerivedContents(expression, true); final String nameStub = "__" + feature.getDeclaringType().getSimpleName() + "_"; //$NON-NLS-1$ //$NON-NLS-2$ while (iterator.hasNext()) { final EObject next = iterator.next(); if (next.eClass() == XtendPackage.Literals.ANONYMOUS_CLASS) { inferLocalClass((AnonymousClass) next, nameStub + localTypeIndex, feature); iterator.prune(); ++localTypeIndex; } } context.setLocalTypeIndex(localTypeIndex); } }
java
protected void initializeLocalTypes(GenerationContext context, JvmFeature feature, XExpression expression) { if (expression != null) { int localTypeIndex = context.getLocalTypeIndex(); final TreeIterator<EObject> iterator = EcoreUtil2.getAllNonDerivedContents(expression, true); final String nameStub = "__" + feature.getDeclaringType().getSimpleName() + "_"; //$NON-NLS-1$ //$NON-NLS-2$ while (iterator.hasNext()) { final EObject next = iterator.next(); if (next.eClass() == XtendPackage.Literals.ANONYMOUS_CLASS) { inferLocalClass((AnonymousClass) next, nameStub + localTypeIndex, feature); iterator.prune(); ++localTypeIndex; } } context.setLocalTypeIndex(localTypeIndex); } }
[ "protected", "void", "initializeLocalTypes", "(", "GenerationContext", "context", ",", "JvmFeature", "feature", ",", "XExpression", "expression", ")", "{", "if", "(", "expression", "!=", "null", ")", "{", "int", "localTypeIndex", "=", "context", ".", "getLocalType...
Initialize the local class to the given expression. @param context the generation context. @param feature the feature which contains the expression. @param expression the expression which contains the local class.
[ "Initialize", "the", "local", "class", "to", "the", "given", "expression", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L456-L471
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.setBody
protected void setBody(JvmExecutable executable, Procedure1<ITreeAppendable> expression) { this.typeBuilder.setBody(executable, expression); }
java
protected void setBody(JvmExecutable executable, Procedure1<ITreeAppendable> expression) { this.typeBuilder.setBody(executable, expression); }
[ "protected", "void", "setBody", "(", "JvmExecutable", "executable", ",", "Procedure1", "<", "ITreeAppendable", ">", "expression", ")", "{", "this", ".", "typeBuilder", ".", "setBody", "(", "executable", ",", "expression", ")", ";", "}" ]
Set the body of the executable. @param executable the executable. @param expression the body definition.
[ "Set", "the", "body", "of", "the", "executable", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L510-L512
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.openContext
protected final synchronized GenerationContext openContext(EObject sarlObject, JvmDeclaredType type, final Iterable<Class<? extends XtendMember>> supportedMemberTypes) { assert type != null; assert supportedMemberTypes != null; this.sarlSignatureProvider.clear(type); final GenerationContext context = new GenerationContext(sarlObject, type) { @Override public boolean isSupportedMember(XtendMember member) { for (final Class<? extends XtendMember> supportedMemberType : supportedMemberTypes) { if (supportedMemberType.isInstance(member)) { return true; } } return false; } }; this.contextInjector.injectMembers(context); this.bufferedContexes.push(context); return context; }
java
protected final synchronized GenerationContext openContext(EObject sarlObject, JvmDeclaredType type, final Iterable<Class<? extends XtendMember>> supportedMemberTypes) { assert type != null; assert supportedMemberTypes != null; this.sarlSignatureProvider.clear(type); final GenerationContext context = new GenerationContext(sarlObject, type) { @Override public boolean isSupportedMember(XtendMember member) { for (final Class<? extends XtendMember> supportedMemberType : supportedMemberTypes) { if (supportedMemberType.isInstance(member)) { return true; } } return false; } }; this.contextInjector.injectMembers(context); this.bufferedContexes.push(context); return context; }
[ "protected", "final", "synchronized", "GenerationContext", "openContext", "(", "EObject", "sarlObject", ",", "JvmDeclaredType", "type", ",", "final", "Iterable", "<", "Class", "<", "?", "extends", "XtendMember", ">", ">", "supportedMemberTypes", ")", "{", "assert", ...
Open the context for the generation of a SARL-specific element. @param sarlObject the SARL object that is the cause of the generation. @param type the generated type. @param supportedMemberTypes the types of the supported members. @return the created context.
[ "Open", "the", "context", "for", "the", "generation", "of", "a", "SARL", "-", "specific", "element", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L521-L540
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.closeContext
protected final void closeContext(GenerationContext context) { boolean runPostElements = false; GenerationContext selectedContext = null; synchronized (this) { final Iterator<GenerationContext> iterator = this.bufferedContexes.iterator(); while (selectedContext == null && iterator.hasNext()) { final GenerationContext candidate = iterator.next(); if (Objects.equal(candidate.getTypeIdentifier(), context.getTypeIdentifier())) { runPostElements = candidate.getParentContext() == null; selectedContext = candidate; } } } if (selectedContext == null) { throw new IllegalStateException("Not same contexts when closing"); //$NON-NLS-1$ } if (runPostElements) { for (final Runnable handler : selectedContext.getPostFinalizationElements()) { handler.run(); } } synchronized (this) { final Iterator<GenerationContext> iterator = this.bufferedContexes.iterator(); while (iterator.hasNext()) { final GenerationContext candidate = iterator.next(); if (selectedContext == candidate) { candidate.setParentContext(null); iterator.remove(); return; } } } }
java
protected final void closeContext(GenerationContext context) { boolean runPostElements = false; GenerationContext selectedContext = null; synchronized (this) { final Iterator<GenerationContext> iterator = this.bufferedContexes.iterator(); while (selectedContext == null && iterator.hasNext()) { final GenerationContext candidate = iterator.next(); if (Objects.equal(candidate.getTypeIdentifier(), context.getTypeIdentifier())) { runPostElements = candidate.getParentContext() == null; selectedContext = candidate; } } } if (selectedContext == null) { throw new IllegalStateException("Not same contexts when closing"); //$NON-NLS-1$ } if (runPostElements) { for (final Runnable handler : selectedContext.getPostFinalizationElements()) { handler.run(); } } synchronized (this) { final Iterator<GenerationContext> iterator = this.bufferedContexes.iterator(); while (iterator.hasNext()) { final GenerationContext candidate = iterator.next(); if (selectedContext == candidate) { candidate.setParentContext(null); iterator.remove(); return; } } } }
[ "protected", "final", "void", "closeContext", "(", "GenerationContext", "context", ")", "{", "boolean", "runPostElements", "=", "false", ";", "GenerationContext", "selectedContext", "=", "null", ";", "synchronized", "(", "this", ")", "{", "final", "Iterator", "<",...
Close a generation context. @param context the context to be closed.
[ "Close", "a", "generation", "context", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L546-L578
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.getContext
protected final synchronized GenerationContext getContext(JvmIdentifiableElement type) { for (final GenerationContext candidate : this.bufferedContexes) { if (Objects.equal(candidate.getTypeIdentifier(), type.getIdentifier())) { return candidate; } } throw new GenerationContextNotFoundInternalError(type); }
java
protected final synchronized GenerationContext getContext(JvmIdentifiableElement type) { for (final GenerationContext candidate : this.bufferedContexes) { if (Objects.equal(candidate.getTypeIdentifier(), type.getIdentifier())) { return candidate; } } throw new GenerationContextNotFoundInternalError(type); }
[ "protected", "final", "synchronized", "GenerationContext", "getContext", "(", "JvmIdentifiableElement", "type", ")", "{", "for", "(", "final", "GenerationContext", "candidate", ":", "this", ".", "bufferedContexes", ")", "{", "if", "(", "Objects", ".", "equal", "("...
Replies the SARL-specific generation context. @param type the generated type. @return the SARL-specific generation context.
[ "Replies", "the", "SARL", "-", "specific", "generation", "context", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L585-L592
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.appendDefaultConstructors
protected void appendDefaultConstructors(XtendTypeDeclaration source, JvmGenericType target) { final GenerationContext context = getContext(target); if (!context.hasConstructor()) { // Special case: if a value was not set, we cannot create implicit constructors // in order to have the issue message "The blank final field may not have been initialized". final boolean notInitializedValueField = Iterables.any(source.getMembers(), it -> { if (it instanceof XtendField) { final XtendField op = (XtendField) it; if (op.isFinal() && op.getInitialValue() == null) { return true; } } return false; }); if (!notInitializedValueField) { // Add the default constructors for the agent, if not already added final JvmTypeReference reference = target.getExtendedClass(); if (reference != null) { final JvmType type = reference.getType(); if (type instanceof JvmGenericType) { copyVisibleJvmConstructors( (JvmGenericType) type, target, source, Sets.newTreeSet(), JvmVisibility.PUBLIC); } } } } }
java
protected void appendDefaultConstructors(XtendTypeDeclaration source, JvmGenericType target) { final GenerationContext context = getContext(target); if (!context.hasConstructor()) { // Special case: if a value was not set, we cannot create implicit constructors // in order to have the issue message "The blank final field may not have been initialized". final boolean notInitializedValueField = Iterables.any(source.getMembers(), it -> { if (it instanceof XtendField) { final XtendField op = (XtendField) it; if (op.isFinal() && op.getInitialValue() == null) { return true; } } return false; }); if (!notInitializedValueField) { // Add the default constructors for the agent, if not already added final JvmTypeReference reference = target.getExtendedClass(); if (reference != null) { final JvmType type = reference.getType(); if (type instanceof JvmGenericType) { copyVisibleJvmConstructors( (JvmGenericType) type, target, source, Sets.newTreeSet(), JvmVisibility.PUBLIC); } } } } }
[ "protected", "void", "appendDefaultConstructors", "(", "XtendTypeDeclaration", "source", ",", "JvmGenericType", "target", ")", "{", "final", "GenerationContext", "context", "=", "getContext", "(", "target", ")", ";", "if", "(", "!", "context", ".", "hasConstructor",...
Add the default constructors. <p>The default constructors have the same signature as the constructors of the super class. <p>This function adds the default constructors if no constructor was already added. This condition is determined with a call to {@link GenerationContext#hasConstructor()}. @param source the SARL element in which no constructor was specified. This SARL element should be associated to the {@code target} element. @param target the JVM type that is receiving the default constructor. @see GenerationContext#hasConstructor()
[ "Add", "the", "default", "constructors", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L755-L786
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.initialize
protected void initialize(SarlSkill source, JvmGenericType inferredJvmType) { // Issue #356: do not generate if the skill has no name. assert source != null; assert inferredJvmType != null; if (Strings.isNullOrEmpty(source.getName())) { return; } // Create the generation context that is used by the other transformation functions. final GenerationContext context = openContext(source, inferredJvmType, Arrays.asList( SarlField.class, SarlConstructor.class, SarlAction.class, SarlBehaviorUnit.class, SarlCapacityUses.class, SarlRequiredCapacity.class)); try { // Copy the documentation this.typeBuilder.copyDocumentationTo(source, inferredJvmType); // Change the modifiers on the generated type. setVisibility(inferredJvmType, source); inferredJvmType.setStatic(false); final boolean isAbstract = source.isAbstract() || Utils.hasAbstractMember(source); inferredJvmType.setAbstract(isAbstract); inferredJvmType.setStrictFloatingPoint(false); inferredJvmType.setFinal(!isAbstract && source.isFinal()); // Generate the annotations. translateAnnotationsTo(source.getAnnotations(), inferredJvmType); // Generate the extended types. appendConstrainedExtends(context, inferredJvmType, Skill.class, SarlSkill.class, source.getExtends()); appendConstrainedImplements(context, inferredJvmType, Capacity.class, SarlCapacity.class, source.getImplements()); // Issue #363: do not generate the skill if the SARL library is incompatible. if (Utils.isCompatibleSARLLibraryOnClasspath(this.typeReferences, source)) { // Generate the members of the generated type. appendAOPMembers( inferredJvmType, source, context); } // Add functions dedicated to comparisons (equals, hashCode, etc.) appendComparisonFunctions(context, source, inferredJvmType); // Add clone functions if the generated type is cloneable appendCloneFunctionIfCloneable(context, source, inferredJvmType); // Add the default constructors for the behavior, if not already added appendDefaultConstructors(source, inferredJvmType); // Add serialVersionUID field if the generated type is serializable appendSerialNumberIfSerializable(context, source, inferredJvmType); // Add the specification version of SARL appendSARLSpecificationVersion(context, source, inferredJvmType); // Add the type of SARL Element appendSARLElementType(source, inferredJvmType); // Resolving any name conflict with the generated JVM type this.nameClashResolver.resolveNameClashes(inferredJvmType); } finally { closeContext(context); } }
java
protected void initialize(SarlSkill source, JvmGenericType inferredJvmType) { // Issue #356: do not generate if the skill has no name. assert source != null; assert inferredJvmType != null; if (Strings.isNullOrEmpty(source.getName())) { return; } // Create the generation context that is used by the other transformation functions. final GenerationContext context = openContext(source, inferredJvmType, Arrays.asList( SarlField.class, SarlConstructor.class, SarlAction.class, SarlBehaviorUnit.class, SarlCapacityUses.class, SarlRequiredCapacity.class)); try { // Copy the documentation this.typeBuilder.copyDocumentationTo(source, inferredJvmType); // Change the modifiers on the generated type. setVisibility(inferredJvmType, source); inferredJvmType.setStatic(false); final boolean isAbstract = source.isAbstract() || Utils.hasAbstractMember(source); inferredJvmType.setAbstract(isAbstract); inferredJvmType.setStrictFloatingPoint(false); inferredJvmType.setFinal(!isAbstract && source.isFinal()); // Generate the annotations. translateAnnotationsTo(source.getAnnotations(), inferredJvmType); // Generate the extended types. appendConstrainedExtends(context, inferredJvmType, Skill.class, SarlSkill.class, source.getExtends()); appendConstrainedImplements(context, inferredJvmType, Capacity.class, SarlCapacity.class, source.getImplements()); // Issue #363: do not generate the skill if the SARL library is incompatible. if (Utils.isCompatibleSARLLibraryOnClasspath(this.typeReferences, source)) { // Generate the members of the generated type. appendAOPMembers( inferredJvmType, source, context); } // Add functions dedicated to comparisons (equals, hashCode, etc.) appendComparisonFunctions(context, source, inferredJvmType); // Add clone functions if the generated type is cloneable appendCloneFunctionIfCloneable(context, source, inferredJvmType); // Add the default constructors for the behavior, if not already added appendDefaultConstructors(source, inferredJvmType); // Add serialVersionUID field if the generated type is serializable appendSerialNumberIfSerializable(context, source, inferredJvmType); // Add the specification version of SARL appendSARLSpecificationVersion(context, source, inferredJvmType); // Add the type of SARL Element appendSARLElementType(source, inferredJvmType); // Resolving any name conflict with the generated JVM type this.nameClashResolver.resolveNameClashes(inferredJvmType); } finally { closeContext(context); } }
[ "protected", "void", "initialize", "(", "SarlSkill", "source", ",", "JvmGenericType", "inferredJvmType", ")", "{", "// Issue #356: do not generate if the skill has no name.", "assert", "source", "!=", "null", ";", "assert", "inferredJvmType", "!=", "null", ";", "if", "(...
Initialize the SARL skill type. @param source the source. @param inferredJvmType the JVM type.
[ "Initialize", "the", "SARL", "skill", "type", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L1259-L1321
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.initialize
protected void initialize(SarlCapacity source, JvmGenericType inferredJvmType) { // Issue #356: do not generate if the capacity has no name. assert source != null; assert inferredJvmType != null; if (Strings.isNullOrEmpty(source.getName())) { return; } // Create the generation context that is used by the other transformation functions. final GenerationContext context = openContext(source, inferredJvmType, Collections.singleton(SarlAction.class)); try { // Copy the documentation this.typeBuilder.copyDocumentationTo(source, inferredJvmType); // Change the modifiers on the generated type. inferredJvmType.setInterface(true); inferredJvmType.setAbstract(true); setVisibility(inferredJvmType, source); inferredJvmType.setStatic(false); inferredJvmType.setStrictFloatingPoint(false); inferredJvmType.setFinal(false); // Generate the annotations. translateAnnotationsTo(source.getAnnotations(), inferredJvmType); // Generate the extended types. appendConstrainedExtends(context, inferredJvmType, Capacity.class, SarlCapacity.class, source.getExtends()); // Issue #363: do not generate the capacity if the SARL library is incompatible. if (Utils.isCompatibleSARLLibraryOnClasspath(this.typeReferences, source)) { // Generate the members of the generated type. appendAOPMembers( inferredJvmType, source, context); } // Add the @FunctionalInterface appendFunctionalInterfaceAnnotation(inferredJvmType); // Add the specification version of SARL appendSARLSpecificationVersion(context, source, inferredJvmType); // Add the type of SARL Element appendSARLElementType(source, inferredJvmType); // Resolving any name conflict with the generated JVM type this.nameClashResolver.resolveNameClashes(inferredJvmType); } finally { closeContext(context); } // Generate the context aware wrapper appendCapacityContextAwareWrapper(source, inferredJvmType); }
java
protected void initialize(SarlCapacity source, JvmGenericType inferredJvmType) { // Issue #356: do not generate if the capacity has no name. assert source != null; assert inferredJvmType != null; if (Strings.isNullOrEmpty(source.getName())) { return; } // Create the generation context that is used by the other transformation functions. final GenerationContext context = openContext(source, inferredJvmType, Collections.singleton(SarlAction.class)); try { // Copy the documentation this.typeBuilder.copyDocumentationTo(source, inferredJvmType); // Change the modifiers on the generated type. inferredJvmType.setInterface(true); inferredJvmType.setAbstract(true); setVisibility(inferredJvmType, source); inferredJvmType.setStatic(false); inferredJvmType.setStrictFloatingPoint(false); inferredJvmType.setFinal(false); // Generate the annotations. translateAnnotationsTo(source.getAnnotations(), inferredJvmType); // Generate the extended types. appendConstrainedExtends(context, inferredJvmType, Capacity.class, SarlCapacity.class, source.getExtends()); // Issue #363: do not generate the capacity if the SARL library is incompatible. if (Utils.isCompatibleSARLLibraryOnClasspath(this.typeReferences, source)) { // Generate the members of the generated type. appendAOPMembers( inferredJvmType, source, context); } // Add the @FunctionalInterface appendFunctionalInterfaceAnnotation(inferredJvmType); // Add the specification version of SARL appendSARLSpecificationVersion(context, source, inferredJvmType); // Add the type of SARL Element appendSARLElementType(source, inferredJvmType); // Resolving any name conflict with the generated JVM type this.nameClashResolver.resolveNameClashes(inferredJvmType); } finally { closeContext(context); } // Generate the context aware wrapper appendCapacityContextAwareWrapper(source, inferredJvmType); }
[ "protected", "void", "initialize", "(", "SarlCapacity", "source", ",", "JvmGenericType", "inferredJvmType", ")", "{", "// Issue #356: do not generate if the capacity has no name.", "assert", "source", "!=", "null", ";", "assert", "inferredJvmType", "!=", "null", ";", "if"...
Initialize the SARL capacity type. @param source the source. @param inferredJvmType the JVM type.
[ "Initialize", "the", "SARL", "capacity", "type", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L1328-L1382
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.initialize
@SuppressWarnings("static-method") protected void initialize(SarlSpace source, JvmGenericType inferredJvmType) { // Issue #356: do not generate if the space has no name. assert source != null; assert inferredJvmType != null; if (Strings.isNullOrEmpty(source.getName())) { return; } }
java
@SuppressWarnings("static-method") protected void initialize(SarlSpace source, JvmGenericType inferredJvmType) { // Issue #356: do not generate if the space has no name. assert source != null; assert inferredJvmType != null; if (Strings.isNullOrEmpty(source.getName())) { return; } }
[ "@", "SuppressWarnings", "(", "\"static-method\"", ")", "protected", "void", "initialize", "(", "SarlSpace", "source", ",", "JvmGenericType", "inferredJvmType", ")", "{", "// Issue #356: do not generate if the space has no name.", "assert", "source", "!=", "null", ";", "a...
Initialize the SARL space type. @param source the source. @param inferredJvmType the JVM type.
[ "Initialize", "the", "SARL", "space", "type", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L1389-L1397
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.transform
@Override protected void transform(XtendField source, JvmGenericType container) { super.transform(source, container); // Override the visibility final JvmField field = (JvmField) this.sarlAssociations.getPrimaryJvmElement(source); setVisibility(field, source); final GenerationContext context = getContext(container); if (context != null) { final String name = source.getName(); if (!Strings.isNullOrEmpty(name)) { context.incrementSerial(name.hashCode()); } final JvmTypeReference type = source.getType(); if (type != null) { context.incrementSerial(type.getIdentifier().hashCode()); } } }
java
@Override protected void transform(XtendField source, JvmGenericType container) { super.transform(source, container); // Override the visibility final JvmField field = (JvmField) this.sarlAssociations.getPrimaryJvmElement(source); setVisibility(field, source); final GenerationContext context = getContext(container); if (context != null) { final String name = source.getName(); if (!Strings.isNullOrEmpty(name)) { context.incrementSerial(name.hashCode()); } final JvmTypeReference type = source.getType(); if (type != null) { context.incrementSerial(type.getIdentifier().hashCode()); } } }
[ "@", "Override", "protected", "void", "transform", "(", "XtendField", "source", ",", "JvmGenericType", "container", ")", "{", "super", ".", "transform", "(", "source", ",", "container", ")", ";", "// Override the visibility", "final", "JvmField", "field", "=", "...
Transform the field. @param source the feature to transform. @param container the target container of the transformation result.
[ "Transform", "the", "field", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L1555-L1573
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.appendAOPMembers
protected void appendAOPMembers( JvmGenericType featureContainerType, XtendTypeDeclaration container, GenerationContext context) { Utils.populateInheritanceContext( featureContainerType, context.getInheritedFinalOperations(), context.getInheritedOverridableOperations(), null, context.getInheritedOperationsToImplement(), null, this.sarlSignatureProvider); final List<XtendMember> delayedMembers = new LinkedList<>(); for (final XtendMember feature : container.getMembers()) { if (context.isSupportedMember(feature)) { if ((feature instanceof SarlCapacityUses) || (feature instanceof SarlRequiredCapacity)) { delayedMembers.add(feature); } else { transform(feature, featureContainerType, true); } } } for (final XtendMember feature : delayedMembers) { transform(feature, featureContainerType, false); } // Add event handlers appendEventGuardEvaluators(featureContainerType); // Add dispatch methods appendSyntheticDispatchMethods(container, featureContainerType); // Add SARL synthetic functions appendSyntheticDefaultValuedParameterMethods( container, featureContainerType, context); }
java
protected void appendAOPMembers( JvmGenericType featureContainerType, XtendTypeDeclaration container, GenerationContext context) { Utils.populateInheritanceContext( featureContainerType, context.getInheritedFinalOperations(), context.getInheritedOverridableOperations(), null, context.getInheritedOperationsToImplement(), null, this.sarlSignatureProvider); final List<XtendMember> delayedMembers = new LinkedList<>(); for (final XtendMember feature : container.getMembers()) { if (context.isSupportedMember(feature)) { if ((feature instanceof SarlCapacityUses) || (feature instanceof SarlRequiredCapacity)) { delayedMembers.add(feature); } else { transform(feature, featureContainerType, true); } } } for (final XtendMember feature : delayedMembers) { transform(feature, featureContainerType, false); } // Add event handlers appendEventGuardEvaluators(featureContainerType); // Add dispatch methods appendSyntheticDispatchMethods(container, featureContainerType); // Add SARL synthetic functions appendSyntheticDefaultValuedParameterMethods( container, featureContainerType, context); }
[ "protected", "void", "appendAOPMembers", "(", "JvmGenericType", "featureContainerType", ",", "XtendTypeDeclaration", "container", ",", "GenerationContext", "context", ")", "{", "Utils", ".", "populateInheritanceContext", "(", "featureContainerType", ",", "context", ".", "...
Generate the code for the given SARL members in a agent-oriented container. @param featureContainerType the feature container. @param container the SARL container. @param context description of the generation context in which the members must be considered.
[ "Generate", "the", "code", "for", "the", "given", "SARL", "members", "in", "a", "agent", "-", "oriented", "container", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L2185-L2227
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.toStringConcatenation
private static StringConcatenationClient toStringConcatenation(final String... javaCodeLines) { return new StringConcatenationClient() { @Override protected void appendTo(StringConcatenationClient.TargetStringConcatenation builder) { for (final String line : javaCodeLines) { builder.append(line); builder.newLineIfNotEmpty(); } } }; }
java
private static StringConcatenationClient toStringConcatenation(final String... javaCodeLines) { return new StringConcatenationClient() { @Override protected void appendTo(StringConcatenationClient.TargetStringConcatenation builder) { for (final String line : javaCodeLines) { builder.append(line); builder.newLineIfNotEmpty(); } } }; }
[ "private", "static", "StringConcatenationClient", "toStringConcatenation", "(", "final", "String", "...", "javaCodeLines", ")", "{", "return", "new", "StringConcatenationClient", "(", ")", "{", "@", "Override", "protected", "void", "appendTo", "(", "StringConcatenationC...
Create a string concatenation client from a set of Java code lines. @param javaCodeLines the Java code lines. @return the client.
[ "Create", "a", "string", "concatenation", "client", "from", "a", "set", "of", "Java", "code", "lines", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L2367-L2377
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.appendConstrainedImplements
protected void appendConstrainedImplements( GenerationContext context, JvmGenericType owner, Class<?> defaultJvmType, Class<? extends XtendTypeDeclaration> defaultSarlType, List<? extends JvmParameterizedTypeReference> implementedtypes) { boolean explicitType = false; for (final JvmParameterizedTypeReference superType : implementedtypes) { if (!Objects.equal(owner.getIdentifier(), superType.getIdentifier()) && superType.getType() instanceof JvmGenericType /*&& this.inheritanceHelper.isProxyOrSubTypeOf(superType, defaultJvmType, defaultSarlType, true)*/) { owner.getSuperTypes().add(this.typeBuilder.cloneWithProxies(superType)); context.incrementSerial(superType.getIdentifier().hashCode()); explicitType = true; } } if (!explicitType) { final JvmTypeReference type = this._typeReferenceBuilder.typeRef(defaultJvmType); owner.getSuperTypes().add(type); context.incrementSerial(type.getIdentifier().hashCode()); } }
java
protected void appendConstrainedImplements( GenerationContext context, JvmGenericType owner, Class<?> defaultJvmType, Class<? extends XtendTypeDeclaration> defaultSarlType, List<? extends JvmParameterizedTypeReference> implementedtypes) { boolean explicitType = false; for (final JvmParameterizedTypeReference superType : implementedtypes) { if (!Objects.equal(owner.getIdentifier(), superType.getIdentifier()) && superType.getType() instanceof JvmGenericType /*&& this.inheritanceHelper.isProxyOrSubTypeOf(superType, defaultJvmType, defaultSarlType, true)*/) { owner.getSuperTypes().add(this.typeBuilder.cloneWithProxies(superType)); context.incrementSerial(superType.getIdentifier().hashCode()); explicitType = true; } } if (!explicitType) { final JvmTypeReference type = this._typeReferenceBuilder.typeRef(defaultJvmType); owner.getSuperTypes().add(type); context.incrementSerial(type.getIdentifier().hashCode()); } }
[ "protected", "void", "appendConstrainedImplements", "(", "GenerationContext", "context", ",", "JvmGenericType", "owner", ",", "Class", "<", "?", ">", "defaultJvmType", ",", "Class", "<", "?", "extends", "XtendTypeDeclaration", ">", "defaultSarlType", ",", "List", "<...
Generate the implemented types for the given SARL statement. @param context the context of the generation. @param owner the JVM element to change. @param defaultJvmType the default JVM type. @param defaultSarlType the default SARL type. @param implementedtypes the implemented types.
[ "Generate", "the", "implemented", "types", "for", "the", "given", "SARL", "statement", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L2448-L2468
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.appendEventGuardEvaluators
protected void appendEventGuardEvaluators(JvmGenericType container) { final GenerationContext context = getContext(container); if (context != null) { final Collection<Pair<SarlBehaviorUnit, Collection<Procedure1<? super ITreeAppendable>>>> allEvaluators = context.getGuardEvaluationCodes(); if (allEvaluators == null || allEvaluators.isEmpty()) { return; } final JvmTypeReference voidType = this._typeReferenceBuilder.typeRef(Void.TYPE); final JvmTypeReference runnableType = this._typeReferenceBuilder.typeRef(Runnable.class); final JvmTypeReference collectionType = this._typeReferenceBuilder.typeRef(Collection.class, runnableType); for (final Pair<SarlBehaviorUnit, Collection<Procedure1<? super ITreeAppendable>>> evaluators : allEvaluators) { final SarlBehaviorUnit source = evaluators.getKey(); // Determine the name of the operation for the behavior output final String behName = Utils.createNameForHiddenGuardGeneralEvaluatorMethod(source.getName().getSimpleName()); // Create the main function final JvmOperation operation = this.typesFactory.createJvmOperation(); // Annotation for the event bus appendGeneratedAnnotation(operation, context); addAnnotationSafe(operation, PerceptGuardEvaluator.class); // Guard evaluator unit parameters // - Event occurrence JvmFormalParameter jvmParam = this.typesFactory.createJvmFormalParameter(); jvmParam.setName(this.grammarKeywordAccess.getOccurrenceKeyword()); jvmParam.setParameterType(this.typeBuilder.cloneWithProxies(source.getName())); this.associator.associate(source, jvmParam); operation.getParameters().add(jvmParam); // - List of runnables jvmParam = this.typesFactory.createJvmFormalParameter(); jvmParam.setName(RUNNABLE_COLLECTION); jvmParam.setParameterType(this.typeBuilder.cloneWithProxies(collectionType)); operation.getParameters().add(jvmParam); operation.setAbstract(false); operation.setNative(false); operation.setSynchronized(false); operation.setStrictFloatingPoint(false); operation.setFinal(false); operation.setVisibility(JvmVisibility.PRIVATE); operation.setStatic(false); operation.setSimpleName(behName); operation.setReturnType(this.typeBuilder.cloneWithProxies(voidType)); container.getMembers().add(operation); setBody(operation, it -> { it.append("assert "); //$NON-NLS-1$ it.append(this.grammarKeywordAccess.getOccurrenceKeyword()); it.append(" != null;"); //$NON-NLS-1$ it.newLine(); it.append("assert "); //$NON-NLS-1$ it.append(RUNNABLE_COLLECTION); it.append(" != null;"); //$NON-NLS-1$ for (final Procedure1<? super ITreeAppendable> code : evaluators.getValue()) { it.newLine(); code.apply(it); } }); this.associator.associatePrimary(source, operation); this.typeBuilder.copyDocumentationTo(source, operation); } } }
java
protected void appendEventGuardEvaluators(JvmGenericType container) { final GenerationContext context = getContext(container); if (context != null) { final Collection<Pair<SarlBehaviorUnit, Collection<Procedure1<? super ITreeAppendable>>>> allEvaluators = context.getGuardEvaluationCodes(); if (allEvaluators == null || allEvaluators.isEmpty()) { return; } final JvmTypeReference voidType = this._typeReferenceBuilder.typeRef(Void.TYPE); final JvmTypeReference runnableType = this._typeReferenceBuilder.typeRef(Runnable.class); final JvmTypeReference collectionType = this._typeReferenceBuilder.typeRef(Collection.class, runnableType); for (final Pair<SarlBehaviorUnit, Collection<Procedure1<? super ITreeAppendable>>> evaluators : allEvaluators) { final SarlBehaviorUnit source = evaluators.getKey(); // Determine the name of the operation for the behavior output final String behName = Utils.createNameForHiddenGuardGeneralEvaluatorMethod(source.getName().getSimpleName()); // Create the main function final JvmOperation operation = this.typesFactory.createJvmOperation(); // Annotation for the event bus appendGeneratedAnnotation(operation, context); addAnnotationSafe(operation, PerceptGuardEvaluator.class); // Guard evaluator unit parameters // - Event occurrence JvmFormalParameter jvmParam = this.typesFactory.createJvmFormalParameter(); jvmParam.setName(this.grammarKeywordAccess.getOccurrenceKeyword()); jvmParam.setParameterType(this.typeBuilder.cloneWithProxies(source.getName())); this.associator.associate(source, jvmParam); operation.getParameters().add(jvmParam); // - List of runnables jvmParam = this.typesFactory.createJvmFormalParameter(); jvmParam.setName(RUNNABLE_COLLECTION); jvmParam.setParameterType(this.typeBuilder.cloneWithProxies(collectionType)); operation.getParameters().add(jvmParam); operation.setAbstract(false); operation.setNative(false); operation.setSynchronized(false); operation.setStrictFloatingPoint(false); operation.setFinal(false); operation.setVisibility(JvmVisibility.PRIVATE); operation.setStatic(false); operation.setSimpleName(behName); operation.setReturnType(this.typeBuilder.cloneWithProxies(voidType)); container.getMembers().add(operation); setBody(operation, it -> { it.append("assert "); //$NON-NLS-1$ it.append(this.grammarKeywordAccess.getOccurrenceKeyword()); it.append(" != null;"); //$NON-NLS-1$ it.newLine(); it.append("assert "); //$NON-NLS-1$ it.append(RUNNABLE_COLLECTION); it.append(" != null;"); //$NON-NLS-1$ for (final Procedure1<? super ITreeAppendable> code : evaluators.getValue()) { it.newLine(); code.apply(it); } }); this.associator.associatePrimary(source, operation); this.typeBuilder.copyDocumentationTo(source, operation); } } }
[ "protected", "void", "appendEventGuardEvaluators", "(", "JvmGenericType", "container", ")", "{", "final", "GenerationContext", "context", "=", "getContext", "(", "container", ")", ";", "if", "(", "context", "!=", "null", ")", "{", "final", "Collection", "<", "Pa...
Append the guard evaluators. @param container the container type.
[ "Append", "the", "guard", "evaluators", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L2505-L2572
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.appendSerialNumber
protected void appendSerialNumber(GenerationContext context, XtendTypeDeclaration source, JvmGenericType target) { if (!isAppendSerialNumbersEnable(context)) { return; } for (final JvmField field : target.getDeclaredFields()) { if (SERIAL_FIELD_NAME.equals(field.getSimpleName())) { return; } } final JvmField field = this.typesFactory.createJvmField(); field.setSimpleName(SERIAL_FIELD_NAME); field.setVisibility(JvmVisibility.PRIVATE); field.setStatic(true); field.setTransient(false); field.setVolatile(false); field.setFinal(true); target.getMembers().add(field); field.setType(this.typeBuilder.cloneWithProxies(this._typeReferenceBuilder.typeRef(long.class))); final long serial = context.getSerial(); this.typeBuilder.setInitializer(field, toStringConcatenation(serial + "L")); //$NON-NLS-1$ appendGeneratedAnnotation(field, context); this.readAndWriteTracking.markInitialized(field, null); }
java
protected void appendSerialNumber(GenerationContext context, XtendTypeDeclaration source, JvmGenericType target) { if (!isAppendSerialNumbersEnable(context)) { return; } for (final JvmField field : target.getDeclaredFields()) { if (SERIAL_FIELD_NAME.equals(field.getSimpleName())) { return; } } final JvmField field = this.typesFactory.createJvmField(); field.setSimpleName(SERIAL_FIELD_NAME); field.setVisibility(JvmVisibility.PRIVATE); field.setStatic(true); field.setTransient(false); field.setVolatile(false); field.setFinal(true); target.getMembers().add(field); field.setType(this.typeBuilder.cloneWithProxies(this._typeReferenceBuilder.typeRef(long.class))); final long serial = context.getSerial(); this.typeBuilder.setInitializer(field, toStringConcatenation(serial + "L")); //$NON-NLS-1$ appendGeneratedAnnotation(field, context); this.readAndWriteTracking.markInitialized(field, null); }
[ "protected", "void", "appendSerialNumber", "(", "GenerationContext", "context", ",", "XtendTypeDeclaration", "source", ",", "JvmGenericType", "target", ")", "{", "if", "(", "!", "isAppendSerialNumbersEnable", "(", "context", ")", ")", "{", "return", ";", "}", "for...
Append the serial number field. <p>The serial number field is computed from the given context and from the generated fields. The field is added if no field with name "serialVersionUID" was defined. <p>This function does not test if the field container is serializable. @param context the current generation context. @param source the source object. @param target the inferred JVM object. @see #appendSerialNumberIfSerializable(GenerationContext, XtendTypeDeclaration, JvmGenericType)
[ "Append", "the", "serial", "number", "field", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L2767-L2790
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.appendSerialNumberIfSerializable
protected void appendSerialNumberIfSerializable(GenerationContext context, XtendTypeDeclaration source, JvmGenericType target) { if (!target.isInterface() && this.inheritanceHelper.isSubTypeOf(target, Serializable.class, null)) { appendSerialNumber(context, source, target); } }
java
protected void appendSerialNumberIfSerializable(GenerationContext context, XtendTypeDeclaration source, JvmGenericType target) { if (!target.isInterface() && this.inheritanceHelper.isSubTypeOf(target, Serializable.class, null)) { appendSerialNumber(context, source, target); } }
[ "protected", "void", "appendSerialNumberIfSerializable", "(", "GenerationContext", "context", ",", "XtendTypeDeclaration", "source", ",", "JvmGenericType", "target", ")", "{", "if", "(", "!", "target", ".", "isInterface", "(", ")", "&&", "this", ".", "inheritanceHel...
Append the serial number field if and only if the container type is serializable. <p>The serial number field is computed from the given context and from the generated fields. @param context the current generation context. @param source the source object. @param target the inferred JVM object. @see #appendSerialNumber(GenerationContext, XtendTypeDeclaration, JvmGenericType)
[ "Append", "the", "serial", "number", "field", "if", "and", "only", "if", "the", "container", "type", "is", "serializable", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L2801-L2805
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.appendCloneFunction
protected void appendCloneFunction(GenerationContext context, XtendTypeDeclaration source, JvmGenericType target) { if (!isAppendCloneFunctionsEnable(context)) { return; } for (final JvmOperation operation : target.getDeclaredOperations()) { if (CLONE_FUNCTION_NAME.equals(operation.getSimpleName())) { return; } } final ActionPrototype standardPrototype = new ActionPrototype(CLONE_FUNCTION_NAME, this.sarlSignatureProvider.createParameterTypesForVoid(), false); final Map<ActionPrototype, JvmOperation> finalOperations = new TreeMap<>(); Utils.populateInheritanceContext( target, finalOperations, null, null, null, null, this.sarlSignatureProvider); if (!finalOperations.containsKey(standardPrototype)) { final JvmTypeReference[] genericParameters = new JvmTypeReference[target.getTypeParameters().size()]; for (int i = 0; i < target.getTypeParameters().size(); ++i) { final JvmTypeParameter typeParameter = target.getTypeParameters().get(i); genericParameters[i] = this._typeReferenceBuilder.typeRef(typeParameter); } final JvmTypeReference myselfReference = this._typeReferenceBuilder.typeRef(target, genericParameters); final JvmOperation operation = this.typeBuilder.toMethod( source, CLONE_FUNCTION_NAME, myselfReference, null); target.getMembers().add(operation); operation.setVisibility(JvmVisibility.PUBLIC); addAnnotationSafe(operation, Override.class); if (context.getGeneratorConfig2().isGeneratePureAnnotation()) { addAnnotationSafe(operation, Pure.class); } final LightweightTypeReference myselfReference2 = Utils.toLightweightTypeReference( operation.getReturnType(), this.services); setBody(operation, it -> { it.append("try {"); //$NON-NLS-1$ it.increaseIndentation().newLine(); it.append("return (").append(myselfReference2).append(") super."); //$NON-NLS-1$//$NON-NLS-2$ it.append(CLONE_FUNCTION_NAME).append("();"); //$NON-NLS-1$ it.decreaseIndentation().newLine(); it.append("} catch (").append(Throwable.class).append(" exception) {"); //$NON-NLS-1$ //$NON-NLS-2$ it.increaseIndentation().newLine(); it.append("throw new ").append(Error.class).append("(exception);"); //$NON-NLS-1$ //$NON-NLS-2$ it.decreaseIndentation().newLine(); it.append("}"); //$NON-NLS-1$ }); appendGeneratedAnnotation(operation, context); } }
java
protected void appendCloneFunction(GenerationContext context, XtendTypeDeclaration source, JvmGenericType target) { if (!isAppendCloneFunctionsEnable(context)) { return; } for (final JvmOperation operation : target.getDeclaredOperations()) { if (CLONE_FUNCTION_NAME.equals(operation.getSimpleName())) { return; } } final ActionPrototype standardPrototype = new ActionPrototype(CLONE_FUNCTION_NAME, this.sarlSignatureProvider.createParameterTypesForVoid(), false); final Map<ActionPrototype, JvmOperation> finalOperations = new TreeMap<>(); Utils.populateInheritanceContext( target, finalOperations, null, null, null, null, this.sarlSignatureProvider); if (!finalOperations.containsKey(standardPrototype)) { final JvmTypeReference[] genericParameters = new JvmTypeReference[target.getTypeParameters().size()]; for (int i = 0; i < target.getTypeParameters().size(); ++i) { final JvmTypeParameter typeParameter = target.getTypeParameters().get(i); genericParameters[i] = this._typeReferenceBuilder.typeRef(typeParameter); } final JvmTypeReference myselfReference = this._typeReferenceBuilder.typeRef(target, genericParameters); final JvmOperation operation = this.typeBuilder.toMethod( source, CLONE_FUNCTION_NAME, myselfReference, null); target.getMembers().add(operation); operation.setVisibility(JvmVisibility.PUBLIC); addAnnotationSafe(operation, Override.class); if (context.getGeneratorConfig2().isGeneratePureAnnotation()) { addAnnotationSafe(operation, Pure.class); } final LightweightTypeReference myselfReference2 = Utils.toLightweightTypeReference( operation.getReturnType(), this.services); setBody(operation, it -> { it.append("try {"); //$NON-NLS-1$ it.increaseIndentation().newLine(); it.append("return (").append(myselfReference2).append(") super."); //$NON-NLS-1$//$NON-NLS-2$ it.append(CLONE_FUNCTION_NAME).append("();"); //$NON-NLS-1$ it.decreaseIndentation().newLine(); it.append("} catch (").append(Throwable.class).append(" exception) {"); //$NON-NLS-1$ //$NON-NLS-2$ it.increaseIndentation().newLine(); it.append("throw new ").append(Error.class).append("(exception);"); //$NON-NLS-1$ //$NON-NLS-2$ it.decreaseIndentation().newLine(); it.append("}"); //$NON-NLS-1$ }); appendGeneratedAnnotation(operation, context); } }
[ "protected", "void", "appendCloneFunction", "(", "GenerationContext", "context", ",", "XtendTypeDeclaration", "source", ",", "JvmGenericType", "target", ")", "{", "if", "(", "!", "isAppendCloneFunctionsEnable", "(", "context", ")", ")", "{", "return", ";", "}", "f...
Append the clone function. <p>The clone function replies a value of the current type, not {@code Object}. @param context the current generation context. @param source the source object. @param target the inferred JVM object. @since 0.6 @see #appendCloneFunctionIfCloneable(GenerationContext, XtendTypeDeclaration, JvmGenericType)
[ "Append", "the", "clone", "function", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L2817-L2865
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.appendSARLSpecificationVersion
protected void appendSARLSpecificationVersion(GenerationContext context, XtendTypeDeclaration source, JvmDeclaredType target) { addAnnotationSafe(target, SarlSpecification.class, SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING); }
java
protected void appendSARLSpecificationVersion(GenerationContext context, XtendTypeDeclaration source, JvmDeclaredType target) { addAnnotationSafe(target, SarlSpecification.class, SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING); }
[ "protected", "void", "appendSARLSpecificationVersion", "(", "GenerationContext", "context", ",", "XtendTypeDeclaration", "source", ",", "JvmDeclaredType", "target", ")", "{", "addAnnotationSafe", "(", "target", ",", "SarlSpecification", ".", "class", ",", "SARLVersion", ...
Append the SARL specification version as an annotation to the given container. <p>The added annotation may be used by any underground platform for determining what is the version of the SARL specification that was used for generating the container. @param context the current generation context. @param source the source object. @param target the inferred JVM object.
[ "Append", "the", "SARL", "specification", "version", "as", "an", "annotation", "to", "the", "given", "container", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L2892-L2895
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.appendSARLElementType
protected void appendSARLElementType(XtendTypeDeclaration source, JvmDeclaredType target) { addAnnotationSafe(target, SarlElementType.class, source.eClass().getClassifierID()); }
java
protected void appendSARLElementType(XtendTypeDeclaration source, JvmDeclaredType target) { addAnnotationSafe(target, SarlElementType.class, source.eClass().getClassifierID()); }
[ "protected", "void", "appendSARLElementType", "(", "XtendTypeDeclaration", "source", ",", "JvmDeclaredType", "target", ")", "{", "addAnnotationSafe", "(", "target", ",", "SarlElementType", ".", "class", ",", "source", ".", "eClass", "(", ")", ".", "getClassifierID",...
Append the SARL element type as an annotation to the given container. <p>The added annotation may be used by any underground platform for determining what is the type of the SARL element without invoking the costly "instanceof" operations. @param source the source object. @param target the inferred JVM object.
[ "Append", "the", "SARL", "element", "type", "as", "an", "annotation", "to", "the", "given", "container", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L2905-L2907
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.skipTypeParameters
protected JvmTypeReference skipTypeParameters(JvmTypeReference type, Notifier context) { final LightweightTypeReference ltr = Utils.toLightweightTypeReference(type, this.services); return ltr.getRawTypeReference().toJavaCompliantTypeReference(); }
java
protected JvmTypeReference skipTypeParameters(JvmTypeReference type, Notifier context) { final LightweightTypeReference ltr = Utils.toLightweightTypeReference(type, this.services); return ltr.getRawTypeReference().toJavaCompliantTypeReference(); }
[ "protected", "JvmTypeReference", "skipTypeParameters", "(", "JvmTypeReference", "type", ",", "Notifier", "context", ")", "{", "final", "LightweightTypeReference", "ltr", "=", "Utils", ".", "toLightweightTypeReference", "(", "type", ",", "this", ".", "services", ")", ...
Remove the type parameters from the given type. <p><table> <thead><tr><th>Referenced type</th><th>Input</th><th>Replied referenced type</th><th>Output</th></tr></thead> <tbody> <tr><td>Type with generic type parameter</td><td>{@code T<G>}</td><td>the type itself</td><td>{@code T}</td></tr> <tr><td>Type without generic type parameter</td><td>{@code T}</td><td>the type itself</td><td>{@code T}</td></tr> <tr><td>Type parameter without bound</td><td>{@code <S>}</td><td>{@code Object}</td><td>{@code Object}</td></tr> <tr><td>Type parameter with lower bound</td><td>{@code <S super B>}</td><td>{@code Object}</td><td>{@code Object}</td></tr> <tr><td>Type parameter with upper bound</td><td>{@code <S extends B>}</td><td>the bound type</td><td>{@code B}</td></tr> </tbody> </table> @param type the type. @param context the context in which the reference is located. @return the same type without the type parameters.
[ "Remove", "the", "type", "parameters", "from", "the", "given", "type", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L2926-L2929
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.translateAnnotationsTo
@SuppressWarnings("static-method") protected void translateAnnotationsTo(List<JvmAnnotationReference> annotations, JvmAnnotationTarget target, Class<?>... exceptions) { final Set<String> excepts = new HashSet<>(); for (final Class<?> type : exceptions) { excepts.add(type.getName()); } final List<JvmAnnotationReference> addition = new ArrayList<>(); for (final JvmAnnotationReference annotation : Iterables.filter(annotations, an -> { if (!ANNOTATION_TRANSLATION_FILTER.apply(an)) { return false; } return !excepts.contains(an.getAnnotation().getIdentifier()); })) { addition.add(annotation); } target.getAnnotations().addAll(addition); }
java
@SuppressWarnings("static-method") protected void translateAnnotationsTo(List<JvmAnnotationReference> annotations, JvmAnnotationTarget target, Class<?>... exceptions) { final Set<String> excepts = new HashSet<>(); for (final Class<?> type : exceptions) { excepts.add(type.getName()); } final List<JvmAnnotationReference> addition = new ArrayList<>(); for (final JvmAnnotationReference annotation : Iterables.filter(annotations, an -> { if (!ANNOTATION_TRANSLATION_FILTER.apply(an)) { return false; } return !excepts.contains(an.getAnnotation().getIdentifier()); })) { addition.add(annotation); } target.getAnnotations().addAll(addition); }
[ "@", "SuppressWarnings", "(", "\"static-method\"", ")", "protected", "void", "translateAnnotationsTo", "(", "List", "<", "JvmAnnotationReference", ">", "annotations", ",", "JvmAnnotationTarget", "target", ",", "Class", "<", "?", ">", "...", "exceptions", ")", "{", ...
Copy the annotations, except the ones given as parameters. @param annotations the annotations to copy. @param target the target. @param exceptions the annotations to skip.
[ "Copy", "the", "annotations", "except", "the", "ones", "given", "as", "parameters", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L3053-L3070
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.getTypeParametersFor
@SuppressWarnings("static-method") protected List<JvmTypeParameter> getTypeParametersFor(XtendTypeDeclaration type) { if (type instanceof XtendClass) { return ((XtendClass) type).getTypeParameters(); } if (type instanceof XtendInterface) { return ((XtendInterface) type).getTypeParameters(); } return Collections.emptyList(); }
java
@SuppressWarnings("static-method") protected List<JvmTypeParameter> getTypeParametersFor(XtendTypeDeclaration type) { if (type instanceof XtendClass) { return ((XtendClass) type).getTypeParameters(); } if (type instanceof XtendInterface) { return ((XtendInterface) type).getTypeParameters(); } return Collections.emptyList(); }
[ "@", "SuppressWarnings", "(", "\"static-method\"", ")", "protected", "List", "<", "JvmTypeParameter", ">", "getTypeParametersFor", "(", "XtendTypeDeclaration", "type", ")", "{", "if", "(", "type", "instanceof", "XtendClass", ")", "{", "return", "(", "(", "XtendCla...
Replies the type parameters for the given type. @param type the type. @return the type parameters for the given type.
[ "Replies", "the", "type", "parameters", "for", "the", "given", "type", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L3077-L3086
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.cloneWithTypeParametersAndProxies
protected JvmTypeReference cloneWithTypeParametersAndProxies(JvmTypeReference type, JvmExecutable forExecutable) { // Ensure that the executable is inside a container. Otherwise, the cloning function will fail. assert forExecutable.getDeclaringType() != null; // Get the type parameter mapping that is a consequence of the super type extension within the container. final Map<String, JvmTypeReference> superTypeParameterMapping = new HashMap<>(); Utils.getSuperTypeParameterMap(forExecutable.getDeclaringType(), superTypeParameterMapping); // Do the cloning return Utils.cloneWithTypeParametersAndProxies( type, forExecutable.getTypeParameters(), superTypeParameterMapping, this._typeReferenceBuilder, this.typeBuilder, this.typeReferences, this.typesFactory); }
java
protected JvmTypeReference cloneWithTypeParametersAndProxies(JvmTypeReference type, JvmExecutable forExecutable) { // Ensure that the executable is inside a container. Otherwise, the cloning function will fail. assert forExecutable.getDeclaringType() != null; // Get the type parameter mapping that is a consequence of the super type extension within the container. final Map<String, JvmTypeReference> superTypeParameterMapping = new HashMap<>(); Utils.getSuperTypeParameterMap(forExecutable.getDeclaringType(), superTypeParameterMapping); // Do the cloning return Utils.cloneWithTypeParametersAndProxies( type, forExecutable.getTypeParameters(), superTypeParameterMapping, this._typeReferenceBuilder, this.typeBuilder, this.typeReferences, this.typesFactory); }
[ "protected", "JvmTypeReference", "cloneWithTypeParametersAndProxies", "(", "JvmTypeReference", "type", ",", "JvmExecutable", "forExecutable", ")", "{", "// Ensure that the executable is inside a container. Otherwise, the cloning function will fail.", "assert", "forExecutable", ".", "ge...
Clone the given type reference that for being link to the given executable component. <p>The proxies are not resolved, and the type parameters are clone when they are related to the type parameter of the executable or the type container. @param type the source type. @param forExecutable the executable component that will contain the result type. @return the result type, i.e. a copy of the source type.
[ "Clone", "the", "given", "type", "reference", "that", "for", "being", "link", "to", "the", "given", "executable", "component", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L3296-L3309
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.cloneWithProxiesFromOtherResource
protected JvmTypeReference cloneWithProxiesFromOtherResource(JvmTypeReference type, JvmOperation target) { if (type == null) { return this._typeReferenceBuilder.typeRef(Void.TYPE); } // Do not clone inferred types because they are not yet resolved and it is located within the current resource. if (InferredTypeIndicator.isInferred(type)) { return type; } // Do not clone primitive types because the associated resource to the type reference will not be correct. final String id = type.getIdentifier(); if (Objects.equal(id, Void.TYPE.getName())) { return this._typeReferenceBuilder.typeRef(Void.TYPE); } if (this.services.getPrimitives().isPrimitive(type)) { return this._typeReferenceBuilder.typeRef(id); } // Clone the type if (target != null) { return cloneWithTypeParametersAndProxies(type, target); } return this.typeBuilder.cloneWithProxies(type); }
java
protected JvmTypeReference cloneWithProxiesFromOtherResource(JvmTypeReference type, JvmOperation target) { if (type == null) { return this._typeReferenceBuilder.typeRef(Void.TYPE); } // Do not clone inferred types because they are not yet resolved and it is located within the current resource. if (InferredTypeIndicator.isInferred(type)) { return type; } // Do not clone primitive types because the associated resource to the type reference will not be correct. final String id = type.getIdentifier(); if (Objects.equal(id, Void.TYPE.getName())) { return this._typeReferenceBuilder.typeRef(Void.TYPE); } if (this.services.getPrimitives().isPrimitive(type)) { return this._typeReferenceBuilder.typeRef(id); } // Clone the type if (target != null) { return cloneWithTypeParametersAndProxies(type, target); } return this.typeBuilder.cloneWithProxies(type); }
[ "protected", "JvmTypeReference", "cloneWithProxiesFromOtherResource", "(", "JvmTypeReference", "type", ",", "JvmOperation", "target", ")", "{", "if", "(", "type", "==", "null", ")", "{", "return", "this", ".", "_typeReferenceBuilder", ".", "typeRef", "(", "Void", ...
Clone the given type reference that is associated to another Xtext resource. <p>This function ensures that the resource of the reference clone is not pointing to the resource of the original reference. <p>This function calls {@link JvmTypesBuilder#cloneWithProxies(JvmTypeReference)} or {@link #cloneWithTypeParametersAndProxies(JvmTypeReference, JvmExecutable)} if the {@code target} is {@code null} for the first, and not {@code null} for the second. @param type the source type. @param target the operation for which the type is clone, or {@code null} if not relevant. @return the result type, i.e. a copy of the source type.
[ "Clone", "the", "given", "type", "reference", "that", "is", "associated", "to", "another", "Xtext", "resource", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L3324-L3345
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.copyNonStaticPublicJvmOperations
@SuppressWarnings("checkstyle:npathcomplexity") protected void copyNonStaticPublicJvmOperations(JvmGenericType source, JvmGenericType target, Set<ActionPrototype> createdActions, Procedure2<? super JvmOperation, ? super ITreeAppendable> bodyBuilder) { final Iterable<JvmOperation> operations = Iterables.transform(Iterables.filter(source.getMembers(), it -> { if (it instanceof JvmOperation) { final JvmOperation op = (JvmOperation) it; return !op.isStatic() && op.getVisibility() == JvmVisibility.PUBLIC; } return false; }), it -> (JvmOperation) it); for (final JvmOperation operation : operations) { final ActionParameterTypes types = this.sarlSignatureProvider.createParameterTypesFromJvmModel( operation.isVarArgs(), operation.getParameters()); final ActionPrototype actSigKey = this.sarlSignatureProvider.createActionPrototype( operation.getSimpleName(), types); if (createdActions.add(actSigKey)) { final JvmOperation newOp = this.typesFactory.createJvmOperation(); target.getMembers().add(newOp); newOp.setAbstract(false); newOp.setFinal(false); newOp.setNative(false); newOp.setStatic(false); newOp.setSynchronized(false); newOp.setVisibility(JvmVisibility.PUBLIC); newOp.setDefault(operation.isDefault()); newOp.setDeprecated(operation.isDeprecated()); newOp.setSimpleName(operation.getSimpleName()); newOp.setStrictFloatingPoint(operation.isStrictFloatingPoint()); copyTypeParametersFromJvmOperation(operation, newOp); for (final JvmTypeReference exception : operation.getExceptions()) { newOp.getExceptions().add(cloneWithTypeParametersAndProxies(exception, newOp)); } for (final JvmFormalParameter parameter : operation.getParameters()) { final JvmFormalParameter newParam = this.typesFactory.createJvmFormalParameter(); newOp.getParameters().add(newParam); newParam.setName(parameter.getSimpleName()); newParam.setParameterType(cloneWithTypeParametersAndProxies(parameter.getParameterType(), newOp)); } newOp.setVarArgs(operation.isVarArgs()); newOp.setReturnType(cloneWithTypeParametersAndProxies(operation.getReturnType(), newOp)); setBody(newOp, it -> bodyBuilder.apply(operation, it)); } } }
java
@SuppressWarnings("checkstyle:npathcomplexity") protected void copyNonStaticPublicJvmOperations(JvmGenericType source, JvmGenericType target, Set<ActionPrototype> createdActions, Procedure2<? super JvmOperation, ? super ITreeAppendable> bodyBuilder) { final Iterable<JvmOperation> operations = Iterables.transform(Iterables.filter(source.getMembers(), it -> { if (it instanceof JvmOperation) { final JvmOperation op = (JvmOperation) it; return !op.isStatic() && op.getVisibility() == JvmVisibility.PUBLIC; } return false; }), it -> (JvmOperation) it); for (final JvmOperation operation : operations) { final ActionParameterTypes types = this.sarlSignatureProvider.createParameterTypesFromJvmModel( operation.isVarArgs(), operation.getParameters()); final ActionPrototype actSigKey = this.sarlSignatureProvider.createActionPrototype( operation.getSimpleName(), types); if (createdActions.add(actSigKey)) { final JvmOperation newOp = this.typesFactory.createJvmOperation(); target.getMembers().add(newOp); newOp.setAbstract(false); newOp.setFinal(false); newOp.setNative(false); newOp.setStatic(false); newOp.setSynchronized(false); newOp.setVisibility(JvmVisibility.PUBLIC); newOp.setDefault(operation.isDefault()); newOp.setDeprecated(operation.isDeprecated()); newOp.setSimpleName(operation.getSimpleName()); newOp.setStrictFloatingPoint(operation.isStrictFloatingPoint()); copyTypeParametersFromJvmOperation(operation, newOp); for (final JvmTypeReference exception : operation.getExceptions()) { newOp.getExceptions().add(cloneWithTypeParametersAndProxies(exception, newOp)); } for (final JvmFormalParameter parameter : operation.getParameters()) { final JvmFormalParameter newParam = this.typesFactory.createJvmFormalParameter(); newOp.getParameters().add(newParam); newParam.setName(parameter.getSimpleName()); newParam.setParameterType(cloneWithTypeParametersAndProxies(parameter.getParameterType(), newOp)); } newOp.setVarArgs(operation.isVarArgs()); newOp.setReturnType(cloneWithTypeParametersAndProxies(operation.getReturnType(), newOp)); setBody(newOp, it -> bodyBuilder.apply(operation, it)); } } }
[ "@", "SuppressWarnings", "(", "\"checkstyle:npathcomplexity\"", ")", "protected", "void", "copyNonStaticPublicJvmOperations", "(", "JvmGenericType", "source", ",", "JvmGenericType", "target", ",", "Set", "<", "ActionPrototype", ">", "createdActions", ",", "Procedure2", "<...
Copy the JVM operations from the source to the destination. @param source the source. @param target the destination. @param createdActions the set of actions that are created before (input) or during (output) the invocation. @param bodyBuilder the builder of the target's operations. @since 0.5
[ "Copy", "the", "JVM", "operations", "from", "the", "source", "to", "the", "destination", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L3448-L3499
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.inferFunctionReturnType
protected JvmTypeReference inferFunctionReturnType(XExpression body) { XExpression expr = body; boolean stop = false; while (!stop && expr instanceof XBlockExpression) { final XBlockExpression block = (XBlockExpression) expr; switch (block.getExpressions().size()) { case 0: expr = null; break; case 1: expr = block.getExpressions().get(0); break; default: stop = true; } } if (expr == null || expr instanceof XAssignment || expr instanceof XVariableDeclaration || expr instanceof SarlBreakExpression || expr instanceof SarlContinueExpression || expr instanceof SarlAssertExpression) { return this._typeReferenceBuilder.typeRef(Void.TYPE); } return this.typeBuilder.inferredType(body); }
java
protected JvmTypeReference inferFunctionReturnType(XExpression body) { XExpression expr = body; boolean stop = false; while (!stop && expr instanceof XBlockExpression) { final XBlockExpression block = (XBlockExpression) expr; switch (block.getExpressions().size()) { case 0: expr = null; break; case 1: expr = block.getExpressions().get(0); break; default: stop = true; } } if (expr == null || expr instanceof XAssignment || expr instanceof XVariableDeclaration || expr instanceof SarlBreakExpression || expr instanceof SarlContinueExpression || expr instanceof SarlAssertExpression) { return this._typeReferenceBuilder.typeRef(Void.TYPE); } return this.typeBuilder.inferredType(body); }
[ "protected", "JvmTypeReference", "inferFunctionReturnType", "(", "XExpression", "body", ")", "{", "XExpression", "expr", "=", "body", ";", "boolean", "stop", "=", "false", ";", "while", "(", "!", "stop", "&&", "expr", "instanceof", "XBlockExpression", ")", "{", ...
Infer the function's return type. @param body the body of the function. @return the return type.
[ "Infer", "the", "function", "s", "return", "type", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L3611-L3633
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java
SARLJvmModelInferrer.inferFunctionReturnType
protected JvmTypeReference inferFunctionReturnType(XtendFunction source, JvmOperation target, JvmOperation overriddenOperation) { // The return type is explicitly given if (source.getReturnType() != null) { return ensureValidType(source.eResource(), source.getReturnType()); } // An super operation was detected => reuse its return type. if (overriddenOperation != null) { final JvmTypeReference type = overriddenOperation.getReturnType(); //return cloneWithProxiesFromOtherResource(type, target); return this.typeReferences.createDelegateTypeReference(type); } // Return type is inferred from the operation's expression. final XExpression expression = source.getExpression(); JvmTypeReference returnType = null; if (expression != null && ((!(expression instanceof XBlockExpression)) || (!((XBlockExpression) expression).getExpressions().isEmpty()))) { returnType = inferFunctionReturnType(expression); } return ensureValidType(source.eResource(), returnType); }
java
protected JvmTypeReference inferFunctionReturnType(XtendFunction source, JvmOperation target, JvmOperation overriddenOperation) { // The return type is explicitly given if (source.getReturnType() != null) { return ensureValidType(source.eResource(), source.getReturnType()); } // An super operation was detected => reuse its return type. if (overriddenOperation != null) { final JvmTypeReference type = overriddenOperation.getReturnType(); //return cloneWithProxiesFromOtherResource(type, target); return this.typeReferences.createDelegateTypeReference(type); } // Return type is inferred from the operation's expression. final XExpression expression = source.getExpression(); JvmTypeReference returnType = null; if (expression != null && ((!(expression instanceof XBlockExpression)) || (!((XBlockExpression) expression).getExpressions().isEmpty()))) { returnType = inferFunctionReturnType(expression); } return ensureValidType(source.eResource(), returnType); }
[ "protected", "JvmTypeReference", "inferFunctionReturnType", "(", "XtendFunction", "source", ",", "JvmOperation", "target", ",", "JvmOperation", "overriddenOperation", ")", "{", "// The return type is explicitly given", "if", "(", "source", ".", "getReturnType", "(", ")", ...
Infer the return type for the given source function. @param source the source function. @param target the target operation. @param overriddenOperation reference to the overridden operation. @return the inferred return type. @since 0.7
[ "Infer", "the", "return", "type", "for", "the", "given", "source", "function", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L3643-L3665
train
sarl/sarl
main/coreplugins/io.sarl.m2e/src/io/sarl/m2e/config/SARLConfiguration.java
SARLConfiguration.setFrom
@SuppressWarnings("checkstyle:npathcomplexity") public void setFrom(SARLConfiguration config) { if (this.input == null) { this.input = config.getInput(); } if (this.output == null) { this.output = config.getOutput(); } if (this.binOutput == null) { this.binOutput = config.getBinOutput(); } if (this.testInput == null) { this.testInput = config.getTestInput(); } if (this.testOutput == null) { this.testOutput = config.getTestOutput(); } if (this.testBinOutput == null) { this.testBinOutput = config.getTestBinOutput(); } if (this.inputCompliance == null) { this.inputCompliance = config.getInputCompliance(); } if (this.outputCompliance == null) { this.outputCompliance = config.getOutputCompliance(); } if (this.encoding == null) { this.encoding = config.getEncoding(); } }
java
@SuppressWarnings("checkstyle:npathcomplexity") public void setFrom(SARLConfiguration config) { if (this.input == null) { this.input = config.getInput(); } if (this.output == null) { this.output = config.getOutput(); } if (this.binOutput == null) { this.binOutput = config.getBinOutput(); } if (this.testInput == null) { this.testInput = config.getTestInput(); } if (this.testOutput == null) { this.testOutput = config.getTestOutput(); } if (this.testBinOutput == null) { this.testBinOutput = config.getTestBinOutput(); } if (this.inputCompliance == null) { this.inputCompliance = config.getInputCompliance(); } if (this.outputCompliance == null) { this.outputCompliance = config.getOutputCompliance(); } if (this.encoding == null) { this.encoding = config.getEncoding(); } }
[ "@", "SuppressWarnings", "(", "\"checkstyle:npathcomplexity\"", ")", "public", "void", "setFrom", "(", "SARLConfiguration", "config", ")", "{", "if", "(", "this", ".", "input", "==", "null", ")", "{", "this", ".", "input", "=", "config", ".", "getInput", "("...
Set the uninitialized field with given configuration. @param config the configured values.
[ "Set", "the", "uninitialized", "field", "with", "given", "configuration", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.m2e/src/io/sarl/m2e/config/SARLConfiguration.java#L57-L86
train
sarl/sarl
products/sarlc/src/main/java/io/sarl/lang/sarlc/modules/general/SarlBatchCompilerModule.java
SarlBatchCompilerModule.provideSarlBatchCompiler
@SuppressWarnings({"static-method", "checkstyle:npathcomplexity"}) @Provides @Singleton public SarlBatchCompiler provideSarlBatchCompiler( Injector injector, Provider<SarlConfig> config, Provider<SARLBootClasspathProvider> defaultBootClasspath, Provider<IssueMessageFormatter> issueMessageFormater, Provider<IJavaBatchCompiler> javaCompilerProvider) { final SarlConfig cfg = config.get(); final CompilerConfig compilerConfig = cfg.getCompiler(); final ValidatorConfig validatorConfig = cfg.getValidator(); final SarlBatchCompiler compiler = new SarlBatchCompiler(); injector.injectMembers(compiler); String fullClassPath = cfg.getBootClasspath(); if (Strings.isEmpty(fullClassPath)) { fullClassPath = defaultBootClasspath.get().getClasspath(); } final String userClassPath = cfg.getClasspath(); if (!Strings.isEmpty(userClassPath) && !Strings.isEmpty(fullClassPath)) { fullClassPath = fullClassPath + File.pathSeparator + userClassPath; } compiler.setClassPath(fullClassPath); if (!Strings.isEmpty(cfg.getJavaBootClasspath())) { compiler.setBootClassPath(cfg.getJavaBootClasspath()); } if (!Strings.isEmpty(compilerConfig.getFileEncoding())) { compiler.setFileEncoding(compilerConfig.getFileEncoding()); } if (!Strings.isEmpty(compilerConfig.getJavaVersion())) { compiler.setJavaSourceVersion(compilerConfig.getJavaVersion()); } final JavaCompiler jcompiler = compilerConfig.getJavaCompiler(); compiler.setJavaPostCompilationEnable(jcompiler != JavaCompiler.NONE); compiler.setJavaCompiler(javaCompilerProvider.get()); compiler.setOptimizationLevel(cfg.getCompiler().getOptimizationLevel()); compiler.setWriteTraceFiles(compilerConfig.getOutputTraceFiles()); compiler.setWriteStorageFiles(compilerConfig.getOutputTraceFiles()); compiler.setGenerateInlineAnnotation(compilerConfig.getGenerateInlines()); compiler.setUseExpressionInterpreterForInlineAnnotation(compilerConfig.getCompressInlineExpressions()); compiler.setGeneratePureAnnotation(compilerConfig.getGeneratePures()); compiler.setGenerateEqualityTestFunctions(compilerConfig.getGenerateEqualityTests()); compiler.setGenerateToStringFunctions(compilerConfig.getGenerateToString()); compiler.setGenerateCloneFunctions(compilerConfig.getGenerateClone()); compiler.setGenerateSerialNumberFields(compilerConfig.getGenerateSerialIds()); if (validatorConfig.getAllErrors()) { compiler.setAllWarningSeverities(Severity.ERROR); } else if (validatorConfig.getIgnoreWarnings()) { compiler.setAllWarningSeverities(Severity.IGNORE); } for (final Entry<String, Severity> entry : validatorConfig.getWarningLevels().entrySet()) { compiler.setWarningSeverity(entry.getKey(), entry.getValue()); } compiler.setIssueMessageFormatter(issueMessageFormater.get()); return compiler; }
java
@SuppressWarnings({"static-method", "checkstyle:npathcomplexity"}) @Provides @Singleton public SarlBatchCompiler provideSarlBatchCompiler( Injector injector, Provider<SarlConfig> config, Provider<SARLBootClasspathProvider> defaultBootClasspath, Provider<IssueMessageFormatter> issueMessageFormater, Provider<IJavaBatchCompiler> javaCompilerProvider) { final SarlConfig cfg = config.get(); final CompilerConfig compilerConfig = cfg.getCompiler(); final ValidatorConfig validatorConfig = cfg.getValidator(); final SarlBatchCompiler compiler = new SarlBatchCompiler(); injector.injectMembers(compiler); String fullClassPath = cfg.getBootClasspath(); if (Strings.isEmpty(fullClassPath)) { fullClassPath = defaultBootClasspath.get().getClasspath(); } final String userClassPath = cfg.getClasspath(); if (!Strings.isEmpty(userClassPath) && !Strings.isEmpty(fullClassPath)) { fullClassPath = fullClassPath + File.pathSeparator + userClassPath; } compiler.setClassPath(fullClassPath); if (!Strings.isEmpty(cfg.getJavaBootClasspath())) { compiler.setBootClassPath(cfg.getJavaBootClasspath()); } if (!Strings.isEmpty(compilerConfig.getFileEncoding())) { compiler.setFileEncoding(compilerConfig.getFileEncoding()); } if (!Strings.isEmpty(compilerConfig.getJavaVersion())) { compiler.setJavaSourceVersion(compilerConfig.getJavaVersion()); } final JavaCompiler jcompiler = compilerConfig.getJavaCompiler(); compiler.setJavaPostCompilationEnable(jcompiler != JavaCompiler.NONE); compiler.setJavaCompiler(javaCompilerProvider.get()); compiler.setOptimizationLevel(cfg.getCompiler().getOptimizationLevel()); compiler.setWriteTraceFiles(compilerConfig.getOutputTraceFiles()); compiler.setWriteStorageFiles(compilerConfig.getOutputTraceFiles()); compiler.setGenerateInlineAnnotation(compilerConfig.getGenerateInlines()); compiler.setUseExpressionInterpreterForInlineAnnotation(compilerConfig.getCompressInlineExpressions()); compiler.setGeneratePureAnnotation(compilerConfig.getGeneratePures()); compiler.setGenerateEqualityTestFunctions(compilerConfig.getGenerateEqualityTests()); compiler.setGenerateToStringFunctions(compilerConfig.getGenerateToString()); compiler.setGenerateCloneFunctions(compilerConfig.getGenerateClone()); compiler.setGenerateSerialNumberFields(compilerConfig.getGenerateSerialIds()); if (validatorConfig.getAllErrors()) { compiler.setAllWarningSeverities(Severity.ERROR); } else if (validatorConfig.getIgnoreWarnings()) { compiler.setAllWarningSeverities(Severity.IGNORE); } for (final Entry<String, Severity> entry : validatorConfig.getWarningLevels().entrySet()) { compiler.setWarningSeverity(entry.getKey(), entry.getValue()); } compiler.setIssueMessageFormatter(issueMessageFormater.get()); return compiler; }
[ "@", "SuppressWarnings", "(", "{", "\"static-method\"", ",", "\"checkstyle:npathcomplexity\"", "}", ")", "@", "Provides", "@", "Singleton", "public", "SarlBatchCompiler", "provideSarlBatchCompiler", "(", "Injector", "injector", ",", "Provider", "<", "SarlConfig", ">", ...
Replies the SARL batch compiler. @param injector the current injector. @param config the configuration for the paths. @param defaultBootClasspath the SARL boot class path that must be used by default. @param issueMessageFormater the formatter of the issue messages. @param javaCompilerProvider a provider of Java batch compiler. @return the SARL batch compiler
[ "Replies", "the", "SARL", "batch", "compiler", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/products/sarlc/src/main/java/io/sarl/lang/sarlc/modules/general/SarlBatchCompilerModule.java#L82-L147
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/macro/SarlAccessorsProcessor.java
SarlAccessorsProcessor.applyMinMaxVisibility
@SuppressWarnings("static-method") protected Visibility applyMinMaxVisibility(Visibility visibility, MutableFieldDeclaration it, TransformationContext context) { if (context.findTypeGlobally(Agent.class).isAssignableFrom(it.getDeclaringType())) { if (visibility.compareTo(Visibility.PROTECTED) > 0) { return Visibility.PROTECTED; } } return visibility; }
java
@SuppressWarnings("static-method") protected Visibility applyMinMaxVisibility(Visibility visibility, MutableFieldDeclaration it, TransformationContext context) { if (context.findTypeGlobally(Agent.class).isAssignableFrom(it.getDeclaringType())) { if (visibility.compareTo(Visibility.PROTECTED) > 0) { return Visibility.PROTECTED; } } return visibility; }
[ "@", "SuppressWarnings", "(", "\"static-method\"", ")", "protected", "Visibility", "applyMinMaxVisibility", "(", "Visibility", "visibility", ",", "MutableFieldDeclaration", "it", ",", "TransformationContext", "context", ")", "{", "if", "(", "context", ".", "findTypeGlob...
Apply the minimum and maximum visibilities to the given one. @param visibility the visibility. @param it the field associated to the accessors to generate. @param context the transformation context. @return the given {@code visibility}, or the min/max visibility if the given one is too high.
[ "Apply", "the", "minimum", "and", "maximum", "visibilities", "to", "the", "given", "one", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/macro/SarlAccessorsProcessor.java#L68-L76
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/ReflectMethod.java
ReflectMethod.of
public static <RT, T> ReflectMethod<RT, T> of(Class<RT> receiverType, Class<T> returnType, String methodName) { return new ReflectMethod<>(receiverType, returnType, methodName); }
java
public static <RT, T> ReflectMethod<RT, T> of(Class<RT> receiverType, Class<T> returnType, String methodName) { return new ReflectMethod<>(receiverType, returnType, methodName); }
[ "public", "static", "<", "RT", ",", "T", ">", "ReflectMethod", "<", "RT", ",", "T", ">", "of", "(", "Class", "<", "RT", ">", "receiverType", ",", "Class", "<", "T", ">", "returnType", ",", "String", "methodName", ")", "{", "return", "new", "ReflectMe...
Static constructor. @param <RT> the type of the receiver. @param <T> the type of the returned value. @param receiverType the type of the receiver. @param returnType the type of the returned values. @param methodName the name of the method. @return the instance.
[ "Static", "constructor", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/ReflectMethod.java#L68-L70
train
sarl/sarl
main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/ReflectMethod.java
ReflectMethod.invoke
public T invoke(RT receiver, Object... arguments) { assert receiver != null; final Method method; synchronized (this) { if (this.method == null) { this.method = getMethod(receiver, arguments); method = this.method; } else { method = this.method; } } try { return this.returnType.cast(method.invoke(receiver, arguments)); } catch (RuntimeException | Error exception) { throw exception; } catch (Throwable exception) { throw new RuntimeException(exception); } }
java
public T invoke(RT receiver, Object... arguments) { assert receiver != null; final Method method; synchronized (this) { if (this.method == null) { this.method = getMethod(receiver, arguments); method = this.method; } else { method = this.method; } } try { return this.returnType.cast(method.invoke(receiver, arguments)); } catch (RuntimeException | Error exception) { throw exception; } catch (Throwable exception) { throw new RuntimeException(exception); } }
[ "public", "T", "invoke", "(", "RT", "receiver", ",", "Object", "...", "arguments", ")", "{", "assert", "receiver", "!=", "null", ";", "final", "Method", "method", ";", "synchronized", "(", "this", ")", "{", "if", "(", "this", ".", "method", "==", "null...
Invoke the method. @param receiver the receiver, never {@code null}. @param arguments the arguments. @return the result of the invocation.
[ "Invoke", "the", "method", "." ]
ca00ff994598c730339972def4e19a60e0b8cace
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/ReflectMethod.java#L78-L96
train