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 | docs/io.sarl.docs.doclet/src/main/java/io/sarl/docs/doclet/proxy/ProgrammaticWrappingProxyInstaller.java | ProgrammaticWrappingProxyInstaller.wrap | public ConstructorDoc wrap(ConstructorDoc source) {
if (source == null || source instanceof Proxy<?> || !(source instanceof ConstructorDocImpl)) {
return source;
}
return new ConstructorDocWrapper((ConstructorDocImpl) source);
} | java | public ConstructorDoc wrap(ConstructorDoc source) {
if (source == null || source instanceof Proxy<?> || !(source instanceof ConstructorDocImpl)) {
return source;
}
return new ConstructorDocWrapper((ConstructorDocImpl) source);
} | [
"public",
"ConstructorDoc",
"wrap",
"(",
"ConstructorDoc",
"source",
")",
"{",
"if",
"(",
"source",
"==",
"null",
"||",
"source",
"instanceof",
"Proxy",
"<",
"?",
">",
"||",
"!",
"(",
"source",
"instanceof",
"ConstructorDocImpl",
")",
")",
"{",
"return",
"... | Wrap a constructor doc.
@param source the source
@return the wrapper. | [
"Wrap",
"a",
"constructor",
"doc",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/docs/io.sarl.docs.doclet/src/main/java/io/sarl/docs/doclet/proxy/ProgrammaticWrappingProxyInstaller.java#L260-L265 | train |
sarl/sarl | docs/io.sarl.docs.doclet/src/main/java/io/sarl/docs/doclet/proxy/ProgrammaticWrappingProxyInstaller.java | ProgrammaticWrappingProxyInstaller.wrap | public MethodDoc wrap(MethodDoc source) {
if (source == null || source instanceof Proxy<?> || !(source instanceof MethodDocImpl)) {
return source;
}
return new MethodDocWrapper((MethodDocImpl) source);
} | java | public MethodDoc wrap(MethodDoc source) {
if (source == null || source instanceof Proxy<?> || !(source instanceof MethodDocImpl)) {
return source;
}
return new MethodDocWrapper((MethodDocImpl) source);
} | [
"public",
"MethodDoc",
"wrap",
"(",
"MethodDoc",
"source",
")",
"{",
"if",
"(",
"source",
"==",
"null",
"||",
"source",
"instanceof",
"Proxy",
"<",
"?",
">",
"||",
"!",
"(",
"source",
"instanceof",
"MethodDocImpl",
")",
")",
"{",
"return",
"source",
";",... | Wrap a method doc.
@param source the source
@return the wrapper. | [
"Wrap",
"a",
"method",
"doc",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/docs/io.sarl.docs.doclet/src/main/java/io/sarl/docs/doclet/proxy/ProgrammaticWrappingProxyInstaller.java#L290-L295 | train |
sarl/sarl | docs/io.sarl.docs.doclet/src/main/java/io/sarl/docs/doclet/proxy/ProgrammaticWrappingProxyInstaller.java | ProgrammaticWrappingProxyInstaller.wrap | public AnnotationTypeElementDoc wrap(AnnotationTypeElementDoc source) {
if (source == null || source instanceof Proxy<?> || !(source instanceof AnnotationTypeElementDocImpl)) {
return source;
}
return new AnnotationTypeElementDocWrapper((AnnotationTypeElementDocImpl) source);
} | java | public AnnotationTypeElementDoc wrap(AnnotationTypeElementDoc source) {
if (source == null || source instanceof Proxy<?> || !(source instanceof AnnotationTypeElementDocImpl)) {
return source;
}
return new AnnotationTypeElementDocWrapper((AnnotationTypeElementDocImpl) source);
} | [
"public",
"AnnotationTypeElementDoc",
"wrap",
"(",
"AnnotationTypeElementDoc",
"source",
")",
"{",
"if",
"(",
"source",
"==",
"null",
"||",
"source",
"instanceof",
"Proxy",
"<",
"?",
">",
"||",
"!",
"(",
"source",
"instanceof",
"AnnotationTypeElementDocImpl",
")",... | Wrap a annotation type element doc.
@param source the source
@return the wrapper. | [
"Wrap",
"a",
"annotation",
"type",
"element",
"doc",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/docs/io.sarl.docs.doclet/src/main/java/io/sarl/docs/doclet/proxy/ProgrammaticWrappingProxyInstaller.java#L332-L337 | train |
sarl/sarl | main/coreplugins/io.sarl.lang.core/src/io/sarl/lang/scoping/extensions/time/TimeExtensions.java | TimeExtensions.seconds | @Pure
@Inline(value = "(long) (($1).doubleValue() * $2.MILLIS_IN_SECOND)", imported = {TimeExtensions.class})
public static long seconds(Number secs) {
return (long) (secs.doubleValue() * MILLIS_IN_SECOND);
} | java | @Pure
@Inline(value = "(long) (($1).doubleValue() * $2.MILLIS_IN_SECOND)", imported = {TimeExtensions.class})
public static long seconds(Number secs) {
return (long) (secs.doubleValue() * MILLIS_IN_SECOND);
} | [
"@",
"Pure",
"@",
"Inline",
"(",
"value",
"=",
"\"(long) (($1).doubleValue() * $2.MILLIS_IN_SECOND)\"",
",",
"imported",
"=",
"{",
"TimeExtensions",
".",
"class",
"}",
")",
"public",
"static",
"long",
"seconds",
"(",
"Number",
"secs",
")",
"{",
"return",
"(",
... | Convert seconds to milliseconds.
@param secs number of seconds to convert.
@return the number of milliseconds in seconds. | [
"Convert",
"seconds",
"to",
"milliseconds",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.core/src/io/sarl/lang/scoping/extensions/time/TimeExtensions.java#L156-L160 | train |
sarl/sarl | main/coreplugins/io.sarl.lang.core/src/io/sarl/lang/scoping/extensions/time/TimeExtensions.java | TimeExtensions.minutes | @Pure
@Inline(value = "(long) (($1).doubleValue() * $2.MILLIS_IN_MINUTE)", imported = {TimeExtensions.class})
public static long minutes(Number mins) {
return (long) (mins.doubleValue() * MILLIS_IN_MINUTE);
} | java | @Pure
@Inline(value = "(long) (($1).doubleValue() * $2.MILLIS_IN_MINUTE)", imported = {TimeExtensions.class})
public static long minutes(Number mins) {
return (long) (mins.doubleValue() * MILLIS_IN_MINUTE);
} | [
"@",
"Pure",
"@",
"Inline",
"(",
"value",
"=",
"\"(long) (($1).doubleValue() * $2.MILLIS_IN_MINUTE)\"",
",",
"imported",
"=",
"{",
"TimeExtensions",
".",
"class",
"}",
")",
"public",
"static",
"long",
"minutes",
"(",
"Number",
"mins",
")",
"{",
"return",
"(",
... | Convert minutes to milliseconds.
@param mins number of minutes to convert.
@return the number of milliseconds in <code>mins</code> | [
"Convert",
"minutes",
"to",
"milliseconds",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.core/src/io/sarl/lang/scoping/extensions/time/TimeExtensions.java#L233-L237 | train |
sarl/sarl | main/coreplugins/io.sarl.lang.core/src/io/sarl/lang/scoping/extensions/time/TimeExtensions.java | TimeExtensions.hours | @Pure
@Inline(value = "(long) (($1).doubleValue() * $2.MILLIS_IN_HOUR)", imported = {TimeExtensions.class})
public static long hours(Number hours) {
return (long) (hours.doubleValue() * MILLIS_IN_HOUR);
} | java | @Pure
@Inline(value = "(long) (($1).doubleValue() * $2.MILLIS_IN_HOUR)", imported = {TimeExtensions.class})
public static long hours(Number hours) {
return (long) (hours.doubleValue() * MILLIS_IN_HOUR);
} | [
"@",
"Pure",
"@",
"Inline",
"(",
"value",
"=",
"\"(long) (($1).doubleValue() * $2.MILLIS_IN_HOUR)\"",
",",
"imported",
"=",
"{",
"TimeExtensions",
".",
"class",
"}",
")",
"public",
"static",
"long",
"hours",
"(",
"Number",
"hours",
")",
"{",
"return",
"(",
"lo... | Convert hours to milliseconds.
@param hours number of hours to convert.
@return the number of milliseconds in <code>hours</code> | [
"Convert",
"hours",
"to",
"milliseconds",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.core/src/io/sarl/lang/scoping/extensions/time/TimeExtensions.java#L310-L314 | train |
sarl/sarl | main/coreplugins/io.sarl.lang.core/src/io/sarl/lang/scoping/extensions/time/TimeExtensions.java | TimeExtensions.days | @Pure
@Inline(value = "(long) (($1).doubleValue() * $2.MILLIS_IN_DAY)", imported = {TimeExtensions.class})
public static long days(Number days) {
return (long) (days.doubleValue() * MILLIS_IN_DAY);
} | java | @Pure
@Inline(value = "(long) (($1).doubleValue() * $2.MILLIS_IN_DAY)", imported = {TimeExtensions.class})
public static long days(Number days) {
return (long) (days.doubleValue() * MILLIS_IN_DAY);
} | [
"@",
"Pure",
"@",
"Inline",
"(",
"value",
"=",
"\"(long) (($1).doubleValue() * $2.MILLIS_IN_DAY)\"",
",",
"imported",
"=",
"{",
"TimeExtensions",
".",
"class",
"}",
")",
"public",
"static",
"long",
"days",
"(",
"Number",
"days",
")",
"{",
"return",
"(",
"long"... | Convert days to milliseconds.
@param days number of days to convert.
@return the number of days in <code>days</code> | [
"Convert",
"days",
"to",
"milliseconds",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.core/src/io/sarl/lang/scoping/extensions/time/TimeExtensions.java#L387-L391 | train |
sarl/sarl | main/coreplugins/io.sarl.lang.core/src/io/sarl/lang/scoping/extensions/time/TimeExtensions.java | TimeExtensions.weeks | @Pure
@Inline(value = "(long) (($1).doubleValue() * $2.MILLIS_IN_WEEK)", imported = {TimeExtensions.class})
public static long weeks(Number weeks) {
return (long) (weeks.doubleValue() * MILLIS_IN_WEEK);
} | java | @Pure
@Inline(value = "(long) (($1).doubleValue() * $2.MILLIS_IN_WEEK)", imported = {TimeExtensions.class})
public static long weeks(Number weeks) {
return (long) (weeks.doubleValue() * MILLIS_IN_WEEK);
} | [
"@",
"Pure",
"@",
"Inline",
"(",
"value",
"=",
"\"(long) (($1).doubleValue() * $2.MILLIS_IN_WEEK)\"",
",",
"imported",
"=",
"{",
"TimeExtensions",
".",
"class",
"}",
")",
"public",
"static",
"long",
"weeks",
"(",
"Number",
"weeks",
")",
"{",
"return",
"(",
"lo... | Convert weeks to milliseconds.
@param weeks number of weeks to convert.
@return the number of milliseconds in <code>weeks</code> | [
"Convert",
"weeks",
"to",
"milliseconds",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.core/src/io/sarl/lang/scoping/extensions/time/TimeExtensions.java#L464-L468 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/SARLStandaloneSetup.java | SARLStandaloneSetup.createInjectorAndDoEMFRegistration | public Injector createInjectorAndDoEMFRegistration(Module... modules) {
doPreSetup();
final Injector injector = createInjector(modules);
register(injector);
return injector;
} | java | public Injector createInjectorAndDoEMFRegistration(Module... modules) {
doPreSetup();
final Injector injector = createInjector(modules);
register(injector);
return injector;
} | [
"public",
"Injector",
"createInjectorAndDoEMFRegistration",
"(",
"Module",
"...",
"modules",
")",
"{",
"doPreSetup",
"(",
")",
";",
"final",
"Injector",
"injector",
"=",
"createInjector",
"(",
"modules",
")",
";",
"register",
"(",
"injector",
")",
";",
"return",... | Create the injector based on the given set of modules and prepare the EMF infrastructure.
@param modules the injection modules that are overriding the standard SARL module.
@return the injector.
@since 0.8
@see SARLRuntimeModule | [
"Create",
"the",
"injector",
"based",
"on",
"the",
"given",
"set",
"of",
"modules",
"and",
"prepare",
"the",
"EMF",
"infrastructure",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/SARLStandaloneSetup.java#L97-L102 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/SARLStandaloneSetup.java | SARLStandaloneSetup.createInjector | @SuppressWarnings("static-method")
public Injector createInjector(Module... modules) {
return Guice.createInjector(Modules.override(new SARLRuntimeModule()).with(modules));
} | java | @SuppressWarnings("static-method")
public Injector createInjector(Module... modules) {
return Guice.createInjector(Modules.override(new SARLRuntimeModule()).with(modules));
} | [
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"public",
"Injector",
"createInjector",
"(",
"Module",
"...",
"modules",
")",
"{",
"return",
"Guice",
".",
"createInjector",
"(",
"Modules",
".",
"override",
"(",
"new",
"SARLRuntimeModule",
"(",
")",
")",
... | Create the injectors based on the given set of modules.
@param modules the injection modules that are overriding the standard SARL module.
@return the injector.
@since 0.8
@see SARLRuntimeModule | [
"Create",
"the",
"injectors",
"based",
"on",
"the",
"given",
"set",
"of",
"modules",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/SARLStandaloneSetup.java#L111-L114 | train |
sarl/sarl | sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/bic/BuiltinSkill.java | BuiltinSkill.installationOrder | protected static int installationOrder(Skill skill) {
final int len = StandardBuiltinCapacitiesProvider.SKILL_INSTALLATION_ORDER.length;
if (skill instanceof BuiltinSkill) {
for (int i = 0; i < len; ++i) {
final Class<? extends Skill> type = StandardBuiltinCapacitiesProvider.SKILL_INSTALLATION_ORDER[i];
if (type.isInstance(skill)) {
return i;
}
}
}
return len;
} | java | protected static int installationOrder(Skill skill) {
final int len = StandardBuiltinCapacitiesProvider.SKILL_INSTALLATION_ORDER.length;
if (skill instanceof BuiltinSkill) {
for (int i = 0; i < len; ++i) {
final Class<? extends Skill> type = StandardBuiltinCapacitiesProvider.SKILL_INSTALLATION_ORDER[i];
if (type.isInstance(skill)) {
return i;
}
}
}
return len;
} | [
"protected",
"static",
"int",
"installationOrder",
"(",
"Skill",
"skill",
")",
"{",
"final",
"int",
"len",
"=",
"StandardBuiltinCapacitiesProvider",
".",
"SKILL_INSTALLATION_ORDER",
".",
"length",
";",
"if",
"(",
"skill",
"instanceof",
"BuiltinSkill",
")",
"{",
"f... | Replies the installation order of the given skill.
@param skill the skill.
@return the installation order. | [
"Replies",
"the",
"installation",
"order",
"of",
"the",
"given",
"skill",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/bic/BuiltinSkill.java#L56-L67 | train |
sarl/sarl | main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/wizards/sreinstall/SREInstallWizard.java | SREInstallWizard.getPage | public AbstractSREInstallPage getPage(ISREInstall sre) {
final IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(
SARLEclipsePlugin.PLUGIN_ID,
SARLEclipseConfig.EXTENSION_POINT_SRE_INSTALL_PAGES);
if (sre != null && extensionPoint != null) {
IConfigurationElement firstTypeMatching = null;
for (final IConfigurationElement info : extensionPoint.getConfigurationElements()) {
final String id = info.getAttribute("sreInstallId"); //$NON-NLS-1$
if (sre.getId().equals(Strings.nullToEmpty(id))) {
try {
final AbstractSREInstallPage page = (AbstractSREInstallPage)
info.createExecutableExtension("class"); //$NON-NLS-1$
page.setExistingNames(this.names);
return page;
} catch (CoreException e) {
SARLEclipsePlugin.getDefault().log(e);
}
} else if (firstTypeMatching == null
&& isInstance(info.getAttribute("sreInstallType"), sre)) { //$NON-NLS-1$
firstTypeMatching = info;
}
}
if (firstTypeMatching != null) {
try {
final AbstractSREInstallPage page = (AbstractSREInstallPage)
firstTypeMatching.createExecutableExtension("class"); //$NON-NLS-1$
page.setExistingNames(this.names);
return page;
} catch (CoreException e) {
SARLEclipsePlugin.getDefault().log(e);
}
}
}
if (sre == null || sre instanceof StandardSREInstall) {
final StandardSREPage standardVMPage = new StandardSREPage();
standardVMPage.setExistingNames(this.names);
return standardVMPage;
}
throw new SREException(MessageFormat.format(
Messages.SREInstallWizard_5, sre.getName()));
} | java | public AbstractSREInstallPage getPage(ISREInstall sre) {
final IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(
SARLEclipsePlugin.PLUGIN_ID,
SARLEclipseConfig.EXTENSION_POINT_SRE_INSTALL_PAGES);
if (sre != null && extensionPoint != null) {
IConfigurationElement firstTypeMatching = null;
for (final IConfigurationElement info : extensionPoint.getConfigurationElements()) {
final String id = info.getAttribute("sreInstallId"); //$NON-NLS-1$
if (sre.getId().equals(Strings.nullToEmpty(id))) {
try {
final AbstractSREInstallPage page = (AbstractSREInstallPage)
info.createExecutableExtension("class"); //$NON-NLS-1$
page.setExistingNames(this.names);
return page;
} catch (CoreException e) {
SARLEclipsePlugin.getDefault().log(e);
}
} else if (firstTypeMatching == null
&& isInstance(info.getAttribute("sreInstallType"), sre)) { //$NON-NLS-1$
firstTypeMatching = info;
}
}
if (firstTypeMatching != null) {
try {
final AbstractSREInstallPage page = (AbstractSREInstallPage)
firstTypeMatching.createExecutableExtension("class"); //$NON-NLS-1$
page.setExistingNames(this.names);
return page;
} catch (CoreException e) {
SARLEclipsePlugin.getDefault().log(e);
}
}
}
if (sre == null || sre instanceof StandardSREInstall) {
final StandardSREPage standardVMPage = new StandardSREPage();
standardVMPage.setExistingNames(this.names);
return standardVMPage;
}
throw new SREException(MessageFormat.format(
Messages.SREInstallWizard_5, sre.getName()));
} | [
"public",
"AbstractSREInstallPage",
"getPage",
"(",
"ISREInstall",
"sre",
")",
"{",
"final",
"IExtensionPoint",
"extensionPoint",
"=",
"Platform",
".",
"getExtensionRegistry",
"(",
")",
".",
"getExtensionPoint",
"(",
"SARLEclipsePlugin",
".",
"PLUGIN_ID",
",",
"SARLEc... | Returns a page to use for editing a SRE install type.
@param sre the edited SRE.
@return the wizard page. | [
"Returns",
"a",
"page",
"to",
"use",
"for",
"editing",
"a",
"SRE",
"install",
"type",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/wizards/sreinstall/SREInstallWizard.java#L96-L139 | train |
sarl/sarl | main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/editor/SARLEditorErrorTickUpdater.java | SARLEditorErrorTickUpdater.getXtextResource | protected Resource getXtextResource() {
//FIXME: for helping to resolve #661
final XtextEditor editor = getEditor();
if (editor != null) {
final IResource resource = editor.getResource();
if (resource instanceof IStorage) {
final IProject project = resource.getProject();
if (project != null) {
final ResourceSet resourceSet = this.resourceSetProvider.get(project);
assert resourceSet != null;
final URI uri = this.uriMapper.getUri((IStorage) resource);
return resourceSet.getResource(uri, true);
}
}
}
return null;
} | java | protected Resource getXtextResource() {
//FIXME: for helping to resolve #661
final XtextEditor editor = getEditor();
if (editor != null) {
final IResource resource = editor.getResource();
if (resource instanceof IStorage) {
final IProject project = resource.getProject();
if (project != null) {
final ResourceSet resourceSet = this.resourceSetProvider.get(project);
assert resourceSet != null;
final URI uri = this.uriMapper.getUri((IStorage) resource);
return resourceSet.getResource(uri, true);
}
}
}
return null;
} | [
"protected",
"Resource",
"getXtextResource",
"(",
")",
"{",
"//FIXME: for helping to resolve #661",
"final",
"XtextEditor",
"editor",
"=",
"getEditor",
"(",
")",
";",
"if",
"(",
"editor",
"!=",
"null",
")",
"{",
"final",
"IResource",
"resource",
"=",
"editor",
"... | Replies the current Xtext document that is supported by the linked editor.
@return the Xtext document, or {@code null} if neither an editor nor a
Xtext document was linked. | [
"Replies",
"the",
"current",
"Xtext",
"document",
"that",
"is",
"supported",
"by",
"the",
"linked",
"editor",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/editor/SARLEditorErrorTickUpdater.java#L94-L110 | train |
sarl/sarl | main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/codebuilder/fragments/ExpressionBuilderFragment.java | ExpressionBuilderFragment.generateExpressionAppender | protected void generateExpressionAppender() {
final TypeReference builderInterface = getExpressionBuilderInterface();
final TypeReference appender = getCodeElementExtractor().getElementAppenderImpl("Expression"); //$NON-NLS-1$
final StringConcatenationClient content = new StringConcatenationClient() {
@Override
protected void appendTo(TargetStringConcatenation it) {
it.append("/** Builder of a " + getLanguageName() //$NON-NLS-1$
+ " XExpression."); //$NON-NLS-1$
it.newLine();
it.append(" */"); //$NON-NLS-1$
it.newLine();
it.append("@SuppressWarnings(\"all\")"); //$NON-NLS-1$
it.newLine();
it.append("public class "); //$NON-NLS-1$
it.append(appender.getSimpleName());
it.append(" extends "); //$NON-NLS-1$
it.append(getCodeElementExtractor().getAbstractAppenderImpl());
it.append(" implements "); //$NON-NLS-1$
it.append(builderInterface);
it.append(" {"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append(generateAppenderMembers(appender.getSimpleName(),
builderInterface, "getXExpression()")); //$NON-NLS-1$
it.append(generateMembers(false, true));
it.append("}"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
}
};
final JavaFileAccess javaFile = getFileAccessFactory().createJavaFile(appender, content);
javaFile.writeTo(getSrcGen());
} | java | protected void generateExpressionAppender() {
final TypeReference builderInterface = getExpressionBuilderInterface();
final TypeReference appender = getCodeElementExtractor().getElementAppenderImpl("Expression"); //$NON-NLS-1$
final StringConcatenationClient content = new StringConcatenationClient() {
@Override
protected void appendTo(TargetStringConcatenation it) {
it.append("/** Builder of a " + getLanguageName() //$NON-NLS-1$
+ " XExpression."); //$NON-NLS-1$
it.newLine();
it.append(" */"); //$NON-NLS-1$
it.newLine();
it.append("@SuppressWarnings(\"all\")"); //$NON-NLS-1$
it.newLine();
it.append("public class "); //$NON-NLS-1$
it.append(appender.getSimpleName());
it.append(" extends "); //$NON-NLS-1$
it.append(getCodeElementExtractor().getAbstractAppenderImpl());
it.append(" implements "); //$NON-NLS-1$
it.append(builderInterface);
it.append(" {"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append(generateAppenderMembers(appender.getSimpleName(),
builderInterface, "getXExpression()")); //$NON-NLS-1$
it.append(generateMembers(false, true));
it.append("}"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
}
};
final JavaFileAccess javaFile = getFileAccessFactory().createJavaFile(appender, content);
javaFile.writeTo(getSrcGen());
} | [
"protected",
"void",
"generateExpressionAppender",
"(",
")",
"{",
"final",
"TypeReference",
"builderInterface",
"=",
"getExpressionBuilderInterface",
"(",
")",
";",
"final",
"TypeReference",
"appender",
"=",
"getCodeElementExtractor",
"(",
")",
".",
"getElementAppenderImp... | Generate the expression appender. | [
"Generate",
"the",
"expression",
"appender",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/codebuilder/fragments/ExpressionBuilderFragment.java#L171-L203 | train |
sarl/sarl | main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/codebuilder/fragments/ExpressionBuilderFragment.java | ExpressionBuilderFragment.ensureContainerKeyword | protected String ensureContainerKeyword(EObject grammarContainer) {
final Iterator<Keyword> iterator = Iterators.filter(grammarContainer.eContents().iterator(), Keyword.class);
if (iterator.hasNext()) {
return iterator.next().getValue();
}
return getExpressionConfig().getFieldContainerDeclarationKeyword();
} | java | protected String ensureContainerKeyword(EObject grammarContainer) {
final Iterator<Keyword> iterator = Iterators.filter(grammarContainer.eContents().iterator(), Keyword.class);
if (iterator.hasNext()) {
return iterator.next().getValue();
}
return getExpressionConfig().getFieldContainerDeclarationKeyword();
} | [
"protected",
"String",
"ensureContainerKeyword",
"(",
"EObject",
"grammarContainer",
")",
"{",
"final",
"Iterator",
"<",
"Keyword",
">",
"iterator",
"=",
"Iterators",
".",
"filter",
"(",
"grammarContainer",
".",
"eContents",
"(",
")",
".",
"iterator",
"(",
")",
... | Replies a keyword for declaring a container.
@param grammarContainer the container description.
@return the keyword, never <code>null</code> nor an empty string. | [
"Replies",
"a",
"keyword",
"for",
"declaring",
"a",
"container",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/codebuilder/fragments/ExpressionBuilderFragment.java#L1158-L1164 | train |
sarl/sarl | main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/codebuilder/fragments/ExpressionBuilderFragment.java | ExpressionBuilderFragment.ensureFieldDeclarationKeyword | protected String ensureFieldDeclarationKeyword(CodeElementExtractor.ElementDescription memberDescription) {
final List<String> modifiers = getCodeBuilderConfig().getModifiers().get(memberDescription.getName());
if (modifiers != null && !modifiers.isEmpty()) {
return modifiers.get(0);
}
return getExpressionConfig().getFieldDeclarationKeyword();
} | java | protected String ensureFieldDeclarationKeyword(CodeElementExtractor.ElementDescription memberDescription) {
final List<String> modifiers = getCodeBuilderConfig().getModifiers().get(memberDescription.getName());
if (modifiers != null && !modifiers.isEmpty()) {
return modifiers.get(0);
}
return getExpressionConfig().getFieldDeclarationKeyword();
} | [
"protected",
"String",
"ensureFieldDeclarationKeyword",
"(",
"CodeElementExtractor",
".",
"ElementDescription",
"memberDescription",
")",
"{",
"final",
"List",
"<",
"String",
">",
"modifiers",
"=",
"getCodeBuilderConfig",
"(",
")",
".",
"getModifiers",
"(",
")",
".",
... | Replies a keyword for declaring a field.
@param memberDescription the member description.
@return the keyword, never <code>null</code> nor an empty string. | [
"Replies",
"a",
"keyword",
"for",
"declaring",
"a",
"field",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/codebuilder/fragments/ExpressionBuilderFragment.java#L1171-L1177 | train |
sarl/sarl | main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/codebuilder/fragments/ExpressionBuilderFragment.java | ExpressionBuilderFragment.getExpressionContextDescription | protected ExpressionContextDescription getExpressionContextDescription() {
for (final CodeElementExtractor.ElementDescription containerDescription : getCodeElementExtractor().getTopElements(
getGrammar(), getCodeBuilderConfig())) {
final AbstractRule rule = getMemberRule(containerDescription);
if (rule != null) {
final Pattern fieldTypePattern = Pattern.compile(getExpressionConfig().getExpressionFieldTypenamePattern());
final ExpressionContextDescription description = getCodeElementExtractor().visitMemberElements(
containerDescription, rule, null,
(it, grammarContainer, memberContainer, classifier) -> {
if (fieldTypePattern.matcher(classifier.getName()).find()) {
final Assignment expressionAssignment = findAssignmentFromTerminalPattern(
memberContainer,
getExpressionConfig().getExpressionGrammarPattern());
final CodeElementExtractor.ElementDescription memberDescription =
it.newElementDescription(classifier.getName(), memberContainer,
classifier, XExpression.class);
return new ExpressionContextDescription(
containerDescription,
memberDescription,
ensureContainerKeyword(containerDescription.getGrammarComponent()),
ensureFieldDeclarationKeyword(memberDescription),
expressionAssignment);
}
return null;
},
null);
if (description != null) {
return description;
}
}
}
return null;
} | java | protected ExpressionContextDescription getExpressionContextDescription() {
for (final CodeElementExtractor.ElementDescription containerDescription : getCodeElementExtractor().getTopElements(
getGrammar(), getCodeBuilderConfig())) {
final AbstractRule rule = getMemberRule(containerDescription);
if (rule != null) {
final Pattern fieldTypePattern = Pattern.compile(getExpressionConfig().getExpressionFieldTypenamePattern());
final ExpressionContextDescription description = getCodeElementExtractor().visitMemberElements(
containerDescription, rule, null,
(it, grammarContainer, memberContainer, classifier) -> {
if (fieldTypePattern.matcher(classifier.getName()).find()) {
final Assignment expressionAssignment = findAssignmentFromTerminalPattern(
memberContainer,
getExpressionConfig().getExpressionGrammarPattern());
final CodeElementExtractor.ElementDescription memberDescription =
it.newElementDescription(classifier.getName(), memberContainer,
classifier, XExpression.class);
return new ExpressionContextDescription(
containerDescription,
memberDescription,
ensureContainerKeyword(containerDescription.getGrammarComponent()),
ensureFieldDeclarationKeyword(memberDescription),
expressionAssignment);
}
return null;
},
null);
if (description != null) {
return description;
}
}
}
return null;
} | [
"protected",
"ExpressionContextDescription",
"getExpressionContextDescription",
"(",
")",
"{",
"for",
"(",
"final",
"CodeElementExtractor",
".",
"ElementDescription",
"containerDescription",
":",
"getCodeElementExtractor",
"(",
")",
".",
"getTopElements",
"(",
"getGrammar",
... | Replies the description of the expression context.
@return the description. | [
"Replies",
"the",
"description",
"of",
"the",
"expression",
"context",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/codebuilder/fragments/ExpressionBuilderFragment.java#L1183-L1215 | train |
sarl/sarl | sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/jdk/contextspace/Context.java | Context.postConstruction | public EventSpace postConstruction() {
this.spaceRepository.postConstruction();
this.defaultSpace = createSpace(OpenEventSpaceSpecification.class, this.defaultSpaceID);
if (this.defaultSpace == null) {
// The default space could have been created before thanks to Hazelcast,
// thus createSpace returns null because the space already exist,
// in this case we return the already existing default space stored in the SpaceRepository
this.defaultSpace = (OpenEventSpace) this.spaceRepository
.getSpace(new SpaceID(this.id, this.defaultSpaceID, OpenEventSpaceSpecification.class));
}
return this.defaultSpace;
} | java | public EventSpace postConstruction() {
this.spaceRepository.postConstruction();
this.defaultSpace = createSpace(OpenEventSpaceSpecification.class, this.defaultSpaceID);
if (this.defaultSpace == null) {
// The default space could have been created before thanks to Hazelcast,
// thus createSpace returns null because the space already exist,
// in this case we return the already existing default space stored in the SpaceRepository
this.defaultSpace = (OpenEventSpace) this.spaceRepository
.getSpace(new SpaceID(this.id, this.defaultSpaceID, OpenEventSpaceSpecification.class));
}
return this.defaultSpace;
} | [
"public",
"EventSpace",
"postConstruction",
"(",
")",
"{",
"this",
".",
"spaceRepository",
".",
"postConstruction",
"(",
")",
";",
"this",
".",
"defaultSpace",
"=",
"createSpace",
"(",
"OpenEventSpaceSpecification",
".",
"class",
",",
"this",
".",
"defaultSpaceID"... | Create the default space in this context.
@return the created space. | [
"Create",
"the",
"default",
"space",
"in",
"this",
"context",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/jdk/contextspace/Context.java#L100-L111 | train |
sarl/sarl | main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/highlighting/SARLHighlightingConfiguration.java | SARLHighlightingConfiguration.capacityMethodInvocation | @SuppressWarnings("checkstyle:magicnumber")
public TextStyle capacityMethodInvocation() {
final TextStyle textStyle = extensionMethodInvocation().copy();
//textStyle.setColor(new RGB(128, 36, 0));
textStyle.setStyle(SWT.ITALIC);
return textStyle;
} | java | @SuppressWarnings("checkstyle:magicnumber")
public TextStyle capacityMethodInvocation() {
final TextStyle textStyle = extensionMethodInvocation().copy();
//textStyle.setColor(new RGB(128, 36, 0));
textStyle.setStyle(SWT.ITALIC);
return textStyle;
} | [
"@",
"SuppressWarnings",
"(",
"\"checkstyle:magicnumber\"",
")",
"public",
"TextStyle",
"capacityMethodInvocation",
"(",
")",
"{",
"final",
"TextStyle",
"textStyle",
"=",
"extensionMethodInvocation",
"(",
")",
".",
"copy",
"(",
")",
";",
"//textStyle.setColor(new RGB(12... | Style for the capacity method extension.
@return the style. | [
"Style",
"for",
"the",
"capacity",
"method",
"extension",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/highlighting/SARLHighlightingConfiguration.java#L55-L61 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java | AbstractExtraLanguageValidator.validate | public void validate(StateAccess validationState, ValidationMessageAcceptor messageAcceptor) {
if (isResponsible(validationState.getState().context, validationState.getState().currentObject)) {
try {
for (final MethodWrapper method : getMethods(validationState.getState().currentObject)) {
final Context ctx = new Context(validationState, this, method, messageAcceptor);
this.currentContext.set(ctx);
initializeContext(ctx);
method.invoke(ctx);
}
} finally {
this.currentContext.set(null);
}
}
} | java | public void validate(StateAccess validationState, ValidationMessageAcceptor messageAcceptor) {
if (isResponsible(validationState.getState().context, validationState.getState().currentObject)) {
try {
for (final MethodWrapper method : getMethods(validationState.getState().currentObject)) {
final Context ctx = new Context(validationState, this, method, messageAcceptor);
this.currentContext.set(ctx);
initializeContext(ctx);
method.invoke(ctx);
}
} finally {
this.currentContext.set(null);
}
}
} | [
"public",
"void",
"validate",
"(",
"StateAccess",
"validationState",
",",
"ValidationMessageAcceptor",
"messageAcceptor",
")",
"{",
"if",
"(",
"isResponsible",
"(",
"validationState",
".",
"getState",
"(",
")",
".",
"context",
",",
"validationState",
".",
"getState"... | Validate the given resource.
@param validationState the current validation state.
@param messageAcceptor the message acceptor. | [
"Validate",
"the",
"given",
"resource",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java#L160-L173 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java | AbstractExtraLanguageValidator.collectMethods | protected void collectMethods(Class<? extends AbstractExtraLanguageValidator> clazz,
Collection<Class<?>> visitedClasses,
Collection<MethodWrapper> result) {
if (!visitedClasses.add(clazz)) {
return;
}
for (final Method method : clazz.getDeclaredMethods()) {
if (method.getAnnotation(Check.class) != null && method.getParameterTypes().length == 1) {
result.add(createMethodWrapper(method));
}
}
final Class<? extends AbstractExtraLanguageValidator> superClass = getSuperClass(clazz);
if (superClass != null) {
collectMethods(superClass, visitedClasses, result);
}
} | java | protected void collectMethods(Class<? extends AbstractExtraLanguageValidator> clazz,
Collection<Class<?>> visitedClasses,
Collection<MethodWrapper> result) {
if (!visitedClasses.add(clazz)) {
return;
}
for (final Method method : clazz.getDeclaredMethods()) {
if (method.getAnnotation(Check.class) != null && method.getParameterTypes().length == 1) {
result.add(createMethodWrapper(method));
}
}
final Class<? extends AbstractExtraLanguageValidator> superClass = getSuperClass(clazz);
if (superClass != null) {
collectMethods(superClass, visitedClasses, result);
}
} | [
"protected",
"void",
"collectMethods",
"(",
"Class",
"<",
"?",
"extends",
"AbstractExtraLanguageValidator",
">",
"clazz",
",",
"Collection",
"<",
"Class",
"<",
"?",
">",
">",
"visitedClasses",
",",
"Collection",
"<",
"MethodWrapper",
">",
"result",
")",
"{",
"... | Collect the check methods.
@param clazz the type to explore.
@param visitedClasses the visited classes.
@param result the collected methods. | [
"Collect",
"the",
"check",
"methods",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java#L181-L196 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java | AbstractExtraLanguageValidator.isResponsible | @SuppressWarnings("static-method")
protected boolean isResponsible(Map<Object, Object> context, EObject eObject) {
// Skip the validation of an feature call if one of its container was validated previously
if (eObject instanceof XMemberFeatureCall || eObject instanceof XFeatureCall) {
final XAbstractFeatureCall rootFeatureCall = Utils.getRootFeatureCall((XAbstractFeatureCall) eObject);
return !isCheckedFeatureCall(context, rootFeatureCall);
}
return true;
} | java | @SuppressWarnings("static-method")
protected boolean isResponsible(Map<Object, Object> context, EObject eObject) {
// Skip the validation of an feature call if one of its container was validated previously
if (eObject instanceof XMemberFeatureCall || eObject instanceof XFeatureCall) {
final XAbstractFeatureCall rootFeatureCall = Utils.getRootFeatureCall((XAbstractFeatureCall) eObject);
return !isCheckedFeatureCall(context, rootFeatureCall);
}
return true;
} | [
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"protected",
"boolean",
"isResponsible",
"(",
"Map",
"<",
"Object",
",",
"Object",
">",
"context",
",",
"EObject",
"eObject",
")",
"{",
"// Skip the validation of an feature call if one of its container was validated p... | Replies if the validator is responsible to validate the given object.
@param context the context.
@param eObject the validated object.
@return {@code true} if the validator could be run. | [
"Replies",
"if",
"the",
"validator",
"is",
"responsible",
"to",
"validate",
"the",
"given",
"object",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java#L245-L253 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java | AbstractExtraLanguageValidator.error | protected void error(String message, EObject source, EStructuralFeature feature) {
getContext().getMessageAcceptor().acceptError(
MessageFormat.format(getErrorMessageFormat(), message),
source,
feature,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
IssueCodes.INVALID_EXTRA_LANGUAGE_GENERATION);
} | java | protected void error(String message, EObject source, EStructuralFeature feature) {
getContext().getMessageAcceptor().acceptError(
MessageFormat.format(getErrorMessageFormat(), message),
source,
feature,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
IssueCodes.INVALID_EXTRA_LANGUAGE_GENERATION);
} | [
"protected",
"void",
"error",
"(",
"String",
"message",
",",
"EObject",
"source",
",",
"EStructuralFeature",
"feature",
")",
"{",
"getContext",
"(",
")",
".",
"getMessageAcceptor",
"(",
")",
".",
"acceptError",
"(",
"MessageFormat",
".",
"format",
"(",
"getErr... | Generate an error for the extra-language.
<p>This function generates an error, a warning, or an information depending on the extra-language generation's
configuration.
@param message the error message.
@param source the source of the error.
@param feature the structural feature. | [
"Generate",
"an",
"error",
"for",
"the",
"extra",
"-",
"language",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java#L264-L271 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java | AbstractExtraLanguageValidator.warning | protected void warning(String message, EObject source, EStructuralFeature feature) {
getContext().getMessageAcceptor().acceptWarning(
MessageFormat.format(getErrorMessageFormat(), message),
source,
feature,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
IssueCodes.INVALID_EXTRA_LANGUAGE_GENERATION);
} | java | protected void warning(String message, EObject source, EStructuralFeature feature) {
getContext().getMessageAcceptor().acceptWarning(
MessageFormat.format(getErrorMessageFormat(), message),
source,
feature,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
IssueCodes.INVALID_EXTRA_LANGUAGE_GENERATION);
} | [
"protected",
"void",
"warning",
"(",
"String",
"message",
",",
"EObject",
"source",
",",
"EStructuralFeature",
"feature",
")",
"{",
"getContext",
"(",
")",
".",
"getMessageAcceptor",
"(",
")",
".",
"acceptWarning",
"(",
"MessageFormat",
".",
"format",
"(",
"ge... | Generate a warning for the extra-language.
<p>This function generates an error, a warning, or an information depending on the extra-language generation's
configuration.
@param message the warning message.
@param source the source of the error.
@param feature the structural feature. | [
"Generate",
"a",
"warning",
"for",
"the",
"extra",
"-",
"language",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java#L282-L289 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java | AbstractExtraLanguageValidator.info | protected void info(String message, EObject source, EStructuralFeature feature) {
getContext().getMessageAcceptor().acceptInfo(
MessageFormat.format(getErrorMessageFormat(), message),
source,
feature,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
IssueCodes.INVALID_EXTRA_LANGUAGE_GENERATION);
} | java | protected void info(String message, EObject source, EStructuralFeature feature) {
getContext().getMessageAcceptor().acceptInfo(
MessageFormat.format(getErrorMessageFormat(), message),
source,
feature,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
IssueCodes.INVALID_EXTRA_LANGUAGE_GENERATION);
} | [
"protected",
"void",
"info",
"(",
"String",
"message",
",",
"EObject",
"source",
",",
"EStructuralFeature",
"feature",
")",
"{",
"getContext",
"(",
")",
".",
"getMessageAcceptor",
"(",
")",
".",
"acceptInfo",
"(",
"MessageFormat",
".",
"format",
"(",
"getError... | Generate an information message for the extra-language.
<p>This function generates an error, a warning, or an information depending on the extra-language generation's
configuration.
@param message the info message.
@param source the source of the error.
@param feature the structural feature. | [
"Generate",
"an",
"information",
"message",
"for",
"the",
"extra",
"-",
"language",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java#L300-L307 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java | AbstractExtraLanguageValidator.getTypeConverter | public ExtraLanguageTypeConverter getTypeConverter() {
ExtraLanguageTypeConverter converter = this.typeConverter;
if (converter == null) {
converter = createTypeConverterInstance(getTypeConverterInitializer(), null);
this.injector.injectMembers(converter);
this.typeConverter = converter;
}
return converter;
} | java | public ExtraLanguageTypeConverter getTypeConverter() {
ExtraLanguageTypeConverter converter = this.typeConverter;
if (converter == null) {
converter = createTypeConverterInstance(getTypeConverterInitializer(), null);
this.injector.injectMembers(converter);
this.typeConverter = converter;
}
return converter;
} | [
"public",
"ExtraLanguageTypeConverter",
"getTypeConverter",
"(",
")",
"{",
"ExtraLanguageTypeConverter",
"converter",
"=",
"this",
".",
"typeConverter",
";",
"if",
"(",
"converter",
"==",
"null",
")",
"{",
"converter",
"=",
"createTypeConverterInstance",
"(",
"getType... | Replies the type converter.
@return the type converter. | [
"Replies",
"the",
"type",
"converter",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java#L334-L342 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java | AbstractExtraLanguageValidator.createTypeConverterInstance | @SuppressWarnings("static-method")
protected ExtraLanguageTypeConverter createTypeConverterInstance(
IExtraLanguageConversionInitializer initializer,
IExtraLanguageGeneratorContext context) {
return new ExtraLanguageTypeConverter(initializer, context);
} | java | @SuppressWarnings("static-method")
protected ExtraLanguageTypeConverter createTypeConverterInstance(
IExtraLanguageConversionInitializer initializer,
IExtraLanguageGeneratorContext context) {
return new ExtraLanguageTypeConverter(initializer, context);
} | [
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"protected",
"ExtraLanguageTypeConverter",
"createTypeConverterInstance",
"(",
"IExtraLanguageConversionInitializer",
"initializer",
",",
"IExtraLanguageGeneratorContext",
"context",
")",
"{",
"return",
"new",
"ExtraLanguage... | Create the instance of the type converter.
@param initializer the converter initializer.
@param context the generation context.
@return the type converter. | [
"Create",
"the",
"instance",
"of",
"the",
"type",
"converter",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java#L350-L355 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java | AbstractExtraLanguageValidator.getFeatureNameConverter | public ExtraLanguageFeatureNameConverter getFeatureNameConverter() {
ExtraLanguageFeatureNameConverter converter = this.featureConverter;
if (converter == null) {
converter = createFeatureNameConverterInstance(getFeatureConverterInitializer(), null);
this.injector.injectMembers(converter);
this.featureConverter = converter;
}
return converter;
} | java | public ExtraLanguageFeatureNameConverter getFeatureNameConverter() {
ExtraLanguageFeatureNameConverter converter = this.featureConverter;
if (converter == null) {
converter = createFeatureNameConverterInstance(getFeatureConverterInitializer(), null);
this.injector.injectMembers(converter);
this.featureConverter = converter;
}
return converter;
} | [
"public",
"ExtraLanguageFeatureNameConverter",
"getFeatureNameConverter",
"(",
")",
"{",
"ExtraLanguageFeatureNameConverter",
"converter",
"=",
"this",
".",
"featureConverter",
";",
"if",
"(",
"converter",
"==",
"null",
")",
"{",
"converter",
"=",
"createFeatureNameConver... | Replies the feature name converter.
@return the feature name converter. | [
"Replies",
"the",
"feature",
"name",
"converter",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java#L361-L369 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java | AbstractExtraLanguageValidator.createFeatureNameConverterInstance | protected ExtraLanguageFeatureNameConverter createFeatureNameConverterInstance(
IExtraLanguageConversionInitializer initializer,
IExtraLanguageGeneratorContext context) {
return new ExtraLanguageFeatureNameConverter(initializer, context, getExtraLanguageKeywordProvider());
} | java | protected ExtraLanguageFeatureNameConverter createFeatureNameConverterInstance(
IExtraLanguageConversionInitializer initializer,
IExtraLanguageGeneratorContext context) {
return new ExtraLanguageFeatureNameConverter(initializer, context, getExtraLanguageKeywordProvider());
} | [
"protected",
"ExtraLanguageFeatureNameConverter",
"createFeatureNameConverterInstance",
"(",
"IExtraLanguageConversionInitializer",
"initializer",
",",
"IExtraLanguageGeneratorContext",
"context",
")",
"{",
"return",
"new",
"ExtraLanguageFeatureNameConverter",
"(",
"initializer",
","... | Create the instance of the feature name converter.
@param initializer the converter initializer.
@param context the generation context.
@return the feature name converter. | [
"Create",
"the",
"instance",
"of",
"the",
"feature",
"name",
"converter",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java#L377-L381 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java | AbstractExtraLanguageValidator.doTypeMappingCheck | protected boolean doTypeMappingCheck(EObject source, JvmType type, Procedure3<? super EObject, ? super JvmType, ? super String> errorHandler) {
if (source != null && type != null) {
final ExtraLanguageTypeConverter converter = getTypeConverter();
final String qn = type.getQualifiedName();
if (converter != null && !converter.hasConversion(qn)) {
if (errorHandler != null) {
errorHandler.apply(source, type, qn);
}
return false;
}
}
return true;
} | java | protected boolean doTypeMappingCheck(EObject source, JvmType type, Procedure3<? super EObject, ? super JvmType, ? super String> errorHandler) {
if (source != null && type != null) {
final ExtraLanguageTypeConverter converter = getTypeConverter();
final String qn = type.getQualifiedName();
if (converter != null && !converter.hasConversion(qn)) {
if (errorHandler != null) {
errorHandler.apply(source, type, qn);
}
return false;
}
}
return true;
} | [
"protected",
"boolean",
"doTypeMappingCheck",
"(",
"EObject",
"source",
",",
"JvmType",
"type",
",",
"Procedure3",
"<",
"?",
"super",
"EObject",
",",
"?",
"super",
"JvmType",
",",
"?",
"super",
"String",
">",
"errorHandler",
")",
"{",
"if",
"(",
"source",
... | Do a type mapping check.
@param source the source of the type.
@param type the type to check.
@param errorHandler the error handler.
@return {@code true} if a type mapping is defined. | [
"Do",
"a",
"type",
"mapping",
"check",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java#L390-L402 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java | AbstractExtraLanguageValidator.doCheckMemberFeatureCallMapping | protected void doCheckMemberFeatureCallMapping(XAbstractFeatureCall featureCall,
Procedure3<? super EObject, ? super JvmType, ? super String> typeErrorHandler,
Function2<? super EObject, ? super JvmIdentifiableElement, ? extends Boolean> featureErrorHandler) {
final XAbstractFeatureCall rootFeatureCall = Utils.getRootFeatureCall(featureCall);
final Map<Object, Object> context = getContext().getContext();
if (isCheckedFeatureCall(context, rootFeatureCall)) {
// One of the containing expressions was already checked.
return;
}
// Mark the root container as validated.
setCheckedFeatureCall(context, rootFeatureCall);
// Validate the current call.
internalCheckMemberFeaturCallMapping(rootFeatureCall, typeErrorHandler, featureErrorHandler);
} | java | protected void doCheckMemberFeatureCallMapping(XAbstractFeatureCall featureCall,
Procedure3<? super EObject, ? super JvmType, ? super String> typeErrorHandler,
Function2<? super EObject, ? super JvmIdentifiableElement, ? extends Boolean> featureErrorHandler) {
final XAbstractFeatureCall rootFeatureCall = Utils.getRootFeatureCall(featureCall);
final Map<Object, Object> context = getContext().getContext();
if (isCheckedFeatureCall(context, rootFeatureCall)) {
// One of the containing expressions was already checked.
return;
}
// Mark the root container as validated.
setCheckedFeatureCall(context, rootFeatureCall);
// Validate the current call.
internalCheckMemberFeaturCallMapping(rootFeatureCall, typeErrorHandler, featureErrorHandler);
} | [
"protected",
"void",
"doCheckMemberFeatureCallMapping",
"(",
"XAbstractFeatureCall",
"featureCall",
",",
"Procedure3",
"<",
"?",
"super",
"EObject",
",",
"?",
"super",
"JvmType",
",",
"?",
"super",
"String",
">",
"typeErrorHandler",
",",
"Function2",
"<",
"?",
"su... | Check if the feature call could be translated to the extra-language.
@param featureCall the feature call.
@param typeErrorHandler the error handler for the type conversion.
@param featureErrorHandler the error handler for the feature call conversion. | [
"Check",
"if",
"the",
"feature",
"call",
"could",
"be",
"translated",
"to",
"the",
"extra",
"-",
"language",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java#L432-L445 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java | AbstractExtraLanguageValidator.handleInvocationTargetException | @SuppressWarnings("static-method")
protected void handleInvocationTargetException(Throwable targetException, Context context) {
// ignore NullPointerException, as not having to check for NPEs all the time is a convenience feature
if (!(targetException instanceof NullPointerException)) {
Exceptions.throwUncheckedException(targetException);
}
} | java | @SuppressWarnings("static-method")
protected void handleInvocationTargetException(Throwable targetException, Context context) {
// ignore NullPointerException, as not having to check for NPEs all the time is a convenience feature
if (!(targetException instanceof NullPointerException)) {
Exceptions.throwUncheckedException(targetException);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"protected",
"void",
"handleInvocationTargetException",
"(",
"Throwable",
"targetException",
",",
"Context",
"context",
")",
"{",
"// ignore NullPointerException, as not having to check for NPEs all the time is a convenience fea... | Handle an exception.
@param targetException the exception.
@param context the context. | [
"Handle",
"an",
"exception",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/validator/AbstractExtraLanguageValidator.java#L488-L494 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/compiler/SARLJvmGenerator.java | SARLJvmGenerator.generateStaticConstructor | protected ITreeAppendable generateStaticConstructor(JvmOperation it, ITreeAppendable appendable, GeneratorConfig config) {
appendable.newLine();
appendable.openScope();
generateJavaDoc(it, appendable, config);
final ITreeAppendable tracedAppendable = appendable.trace(it);
tracedAppendable.append("static "); //$NON-NLS-1$
generateExecutableBody(it, tracedAppendable, config);
return appendable;
} | java | protected ITreeAppendable generateStaticConstructor(JvmOperation it, ITreeAppendable appendable, GeneratorConfig config) {
appendable.newLine();
appendable.openScope();
generateJavaDoc(it, appendable, config);
final ITreeAppendable tracedAppendable = appendable.trace(it);
tracedAppendable.append("static "); //$NON-NLS-1$
generateExecutableBody(it, tracedAppendable, config);
return appendable;
} | [
"protected",
"ITreeAppendable",
"generateStaticConstructor",
"(",
"JvmOperation",
"it",
",",
"ITreeAppendable",
"appendable",
",",
"GeneratorConfig",
"config",
")",
"{",
"appendable",
".",
"newLine",
"(",
")",
";",
"appendable",
".",
"openScope",
"(",
")",
";",
"g... | Generate a static constructor from the given Jvm constructor.
@param it the container of the code.
@param appendable the output.
@param config the generation configuration.
@return the appendable. | [
"Generate",
"a",
"static",
"constructor",
"from",
"the",
"given",
"Jvm",
"constructor",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/compiler/SARLJvmGenerator.java#L129-L137 | train |
sarl/sarl | main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/log/SubmitEclipseLogWizard.java | SubmitEclipseLogWizard.open | public static int open(Shell parentShell) {
final SubmitEclipseLogWizard wizard = new SubmitEclipseLogWizard();
final WizardDialog dialog = new WizardDialog(parentShell, wizard);
wizard.setWizardDialog(dialog);
return dialog.open();
} | java | public static int open(Shell parentShell) {
final SubmitEclipseLogWizard wizard = new SubmitEclipseLogWizard();
final WizardDialog dialog = new WizardDialog(parentShell, wizard);
wizard.setWizardDialog(dialog);
return dialog.open();
} | [
"public",
"static",
"int",
"open",
"(",
"Shell",
"parentShell",
")",
"{",
"final",
"SubmitEclipseLogWizard",
"wizard",
"=",
"new",
"SubmitEclipseLogWizard",
"(",
")",
";",
"final",
"WizardDialog",
"dialog",
"=",
"new",
"WizardDialog",
"(",
"parentShell",
",",
"w... | Open the wizard.
<p>This method waits until the window is closed by the end user, and then it returns the window's return code;
otherwise, this method returns immediately. A window's return codes are
window-specific, although two standard return codes are predefined:
<code>OK</code> and <code>CANCEL</code>.
</p>
@param parentShell the parent shell.
@return the return code. | [
"Open",
"the",
"wizard",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/log/SubmitEclipseLogWizard.java#L103-L108 | train |
sarl/sarl | main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/log/SubmitEclipseLogWizard.java | SubmitEclipseLogWizard.getWizardDialog | WizardDialog getWizardDialog() {
final WeakReference<WizardDialog> ref = this.wizardDialog;
return (ref == null) ? null : ref.get();
} | java | WizardDialog getWizardDialog() {
final WeakReference<WizardDialog> ref = this.wizardDialog;
return (ref == null) ? null : ref.get();
} | [
"WizardDialog",
"getWizardDialog",
"(",
")",
"{",
"final",
"WeakReference",
"<",
"WizardDialog",
">",
"ref",
"=",
"this",
".",
"wizardDialog",
";",
"return",
"(",
"ref",
"==",
"null",
")",
"?",
"null",
":",
"ref",
".",
"get",
"(",
")",
";",
"}"
] | Replies the associated wieard dialog.
@return the dialog. | [
"Replies",
"the",
"associated",
"wieard",
"dialog",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/log/SubmitEclipseLogWizard.java#L123-L126 | train |
sarl/sarl | main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/log/SubmitEclipseLogWizard.java | SubmitEclipseLogWizard.buildContent | @SuppressWarnings("static-method")
protected String buildContent(String description, Charset charset) throws IOException {
final StringBuilder fullContent = new StringBuilder();
// User message
if (!Strings.isEmpty(description)) {
fullContent.append(description);
fullContent.append(Messages.SubmitEclipseLogWizard_8);
}
// Log
final SARLEclipsePlugin plugin = SARLEclipsePlugin.getDefault();
plugin.getLog().log(plugin.createStatus(IStatus.INFO, Messages.SubmitEclipseLogWizard_12));
fullContent.append(Messages.SubmitEclipseLogWizard_9);
final String filename = Platform.getLogFileLocation().toOSString();
final File log = new File(filename);
if (!log.exists()) {
throw new IOException("Unable to find the log file"); //$NON-NLS-1$
}
final List<String> logLines = Files.readLines(log, charset);
int logStartIndex = -1;
for (int i = logLines.size() - 1; logStartIndex == -1 && i >= 0; --i) {
final String line = logLines.get(i);
if (line.startsWith("!SESSION")) { //$NON-NLS-1$
logStartIndex = i;
}
}
for (int i = logStartIndex; i < logLines.size(); ++i) {
fullContent.append(logLines.get(i));
fullContent.append(Messages.SubmitEclipseLogWizard_8);
}
// Properties
fullContent.append(Messages.SubmitEclipseLogWizard_10);
for (final Entry<Object, Object> entry : System.getProperties().entrySet()) {
fullContent.append(Objects.toString(entry.getKey()));
fullContent.append(Messages.SubmitEclipseLogWizard_11);
fullContent.append(Objects.toString(entry.getValue()));
fullContent.append(Messages.SubmitEclipseLogWizard_8);
}
fullContent.append(Messages.SubmitEclipseLogWizard_13);
return fullContent.toString();
} | java | @SuppressWarnings("static-method")
protected String buildContent(String description, Charset charset) throws IOException {
final StringBuilder fullContent = new StringBuilder();
// User message
if (!Strings.isEmpty(description)) {
fullContent.append(description);
fullContent.append(Messages.SubmitEclipseLogWizard_8);
}
// Log
final SARLEclipsePlugin plugin = SARLEclipsePlugin.getDefault();
plugin.getLog().log(plugin.createStatus(IStatus.INFO, Messages.SubmitEclipseLogWizard_12));
fullContent.append(Messages.SubmitEclipseLogWizard_9);
final String filename = Platform.getLogFileLocation().toOSString();
final File log = new File(filename);
if (!log.exists()) {
throw new IOException("Unable to find the log file"); //$NON-NLS-1$
}
final List<String> logLines = Files.readLines(log, charset);
int logStartIndex = -1;
for (int i = logLines.size() - 1; logStartIndex == -1 && i >= 0; --i) {
final String line = logLines.get(i);
if (line.startsWith("!SESSION")) { //$NON-NLS-1$
logStartIndex = i;
}
}
for (int i = logStartIndex; i < logLines.size(); ++i) {
fullContent.append(logLines.get(i));
fullContent.append(Messages.SubmitEclipseLogWizard_8);
}
// Properties
fullContent.append(Messages.SubmitEclipseLogWizard_10);
for (final Entry<Object, Object> entry : System.getProperties().entrySet()) {
fullContent.append(Objects.toString(entry.getKey()));
fullContent.append(Messages.SubmitEclipseLogWizard_11);
fullContent.append(Objects.toString(entry.getValue()));
fullContent.append(Messages.SubmitEclipseLogWizard_8);
}
fullContent.append(Messages.SubmitEclipseLogWizard_13);
return fullContent.toString();
} | [
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"protected",
"String",
"buildContent",
"(",
"String",
"description",
",",
"Charset",
"charset",
")",
"throws",
"IOException",
"{",
"final",
"StringBuilder",
"fullContent",
"=",
"new",
"StringBuilder",
"(",
")",... | Build the issue content.
@param description the description of the issue.
@param charset the charset to use.
@return the content.
@throws IOException if the content cannot be built. | [
"Build",
"the",
"issue",
"content",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/log/SubmitEclipseLogWizard.java#L309-L353 | train |
sarl/sarl | sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/zeromq/ZeroMQNetworkService.java | ZeroMQNetworkService.setSpaceService | @Inject
public void setSpaceService(ContextSpaceService service) {
if (this.spaceService != null) {
this.spaceService.removeSpaceRepositoryListener(this.serviceListener);
}
this.spaceService = service;
if (this.spaceService != null) {
this.spaceService.addSpaceRepositoryListener(this.serviceListener);
}
} | java | @Inject
public void setSpaceService(ContextSpaceService service) {
if (this.spaceService != null) {
this.spaceService.removeSpaceRepositoryListener(this.serviceListener);
}
this.spaceService = service;
if (this.spaceService != null) {
this.spaceService.addSpaceRepositoryListener(this.serviceListener);
}
} | [
"@",
"Inject",
"public",
"void",
"setSpaceService",
"(",
"ContextSpaceService",
"service",
")",
"{",
"if",
"(",
"this",
".",
"spaceService",
"!=",
"null",
")",
"{",
"this",
".",
"spaceService",
".",
"removeSpaceRepositoryListener",
"(",
"this",
".",
"serviceList... | Set the reference to the space service.
@param service the service. | [
"Set",
"the",
"reference",
"to",
"the",
"space",
"service",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/zeromq/ZeroMQNetworkService.java#L135-L144 | train |
sarl/sarl | sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/zeromq/ZeroMQNetworkService.java | ZeroMQNetworkService.firePeerConnected | protected void firePeerConnected(URI peerURI, SpaceID space) {
final NetworkServiceListener[] ilisteners;
synchronized (this.listeners) {
ilisteners = new NetworkServiceListener[this.listeners.size()];
this.listeners.toArray(ilisteners);
}
for (final NetworkServiceListener listener : ilisteners) {
listener.peerConnected(peerURI, space);
}
} | java | protected void firePeerConnected(URI peerURI, SpaceID space) {
final NetworkServiceListener[] ilisteners;
synchronized (this.listeners) {
ilisteners = new NetworkServiceListener[this.listeners.size()];
this.listeners.toArray(ilisteners);
}
for (final NetworkServiceListener listener : ilisteners) {
listener.peerConnected(peerURI, space);
}
} | [
"protected",
"void",
"firePeerConnected",
"(",
"URI",
"peerURI",
",",
"SpaceID",
"space",
")",
"{",
"final",
"NetworkServiceListener",
"[",
"]",
"ilisteners",
";",
"synchronized",
"(",
"this",
".",
"listeners",
")",
"{",
"ilisteners",
"=",
"new",
"NetworkService... | Notifies that a peer space was connected.
@param peerURI
- the URI of the peer that was connected to.
@param space
- the identifier of the connected space. | [
"Notifies",
"that",
"a",
"peer",
"space",
"was",
"connected",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/zeromq/ZeroMQNetworkService.java#L185-L194 | train |
sarl/sarl | sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/zeromq/ZeroMQNetworkService.java | ZeroMQNetworkService.firePeerDisconnected | protected void firePeerDisconnected(URI peerURI, SpaceID space) {
final NetworkServiceListener[] ilisteners;
synchronized (this.listeners) {
ilisteners = new NetworkServiceListener[this.listeners.size()];
this.listeners.toArray(ilisteners);
}
for (final NetworkServiceListener listener : ilisteners) {
listener.peerDisconnected(peerURI, space);
}
} | java | protected void firePeerDisconnected(URI peerURI, SpaceID space) {
final NetworkServiceListener[] ilisteners;
synchronized (this.listeners) {
ilisteners = new NetworkServiceListener[this.listeners.size()];
this.listeners.toArray(ilisteners);
}
for (final NetworkServiceListener listener : ilisteners) {
listener.peerDisconnected(peerURI, space);
}
} | [
"protected",
"void",
"firePeerDisconnected",
"(",
"URI",
"peerURI",
",",
"SpaceID",
"space",
")",
"{",
"final",
"NetworkServiceListener",
"[",
"]",
"ilisteners",
";",
"synchronized",
"(",
"this",
".",
"listeners",
")",
"{",
"ilisteners",
"=",
"new",
"NetworkServ... | Notifies that a peer space was disconnected.
@param peerURI
- the URI of the peer that was disconnected to.
@param space
- the identifier of the disconnected space. | [
"Notifies",
"that",
"a",
"peer",
"space",
"was",
"disconnected",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/zeromq/ZeroMQNetworkService.java#L204-L213 | train |
sarl/sarl | sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/zeromq/ZeroMQNetworkService.java | ZeroMQNetworkService.firePeerDiscovered | protected void firePeerDiscovered(URI peerURI) {
final NetworkServiceListener[] ilisteners;
synchronized (this.listeners) {
ilisteners = new NetworkServiceListener[this.listeners.size()];
this.listeners.toArray(ilisteners);
}
for (final NetworkServiceListener listener : ilisteners) {
listener.peerDiscovered(peerURI);
}
} | java | protected void firePeerDiscovered(URI peerURI) {
final NetworkServiceListener[] ilisteners;
synchronized (this.listeners) {
ilisteners = new NetworkServiceListener[this.listeners.size()];
this.listeners.toArray(ilisteners);
}
for (final NetworkServiceListener listener : ilisteners) {
listener.peerDiscovered(peerURI);
}
} | [
"protected",
"void",
"firePeerDiscovered",
"(",
"URI",
"peerURI",
")",
"{",
"final",
"NetworkServiceListener",
"[",
"]",
"ilisteners",
";",
"synchronized",
"(",
"this",
".",
"listeners",
")",
"{",
"ilisteners",
"=",
"new",
"NetworkServiceListener",
"[",
"this",
... | Notifies that a peer was discovered.
@param peerURI
- the URI of the remote kernel that was disconnected to. | [
"Notifies",
"that",
"a",
"peer",
"was",
"discovered",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/zeromq/ZeroMQNetworkService.java#L238-L247 | train |
sarl/sarl | sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/zeromq/ZeroMQNetworkService.java | ZeroMQNetworkService.extractEnvelope | private static EventEnvelope extractEnvelope(Socket socket) throws IOException {
// To-Do: Read the ZeroMQ socket via a NIO wrapper to support large data:
// indeed the arrays has a maximal size bounded by a native int value, and
// the real data could be larger than this limit.
byte[] data = socket.recv(ZMQ.DONTWAIT);
byte[] cdata;
int oldSize = 0;
while (socket.hasReceiveMore()) {
cdata = socket.recv(ZMQ.DONTWAIT);
oldSize = data.length;
data = Arrays.copyOf(data, data.length + cdata.length);
System.arraycopy(cdata, 0, data, oldSize, cdata.length);
}
final ByteBuffer buffer = ByteBuffer.wrap(data);
final byte[] contextId = readBlock(buffer);
assert contextId != null && contextId.length > 0;
final byte[] spaceId = readBlock(buffer);
assert spaceId != null && spaceId.length > 0;
final byte[] scope = readBlock(buffer);
assert scope != null && scope.length > 0;
final byte[] headers = readBlock(buffer);
assert headers != null && headers.length > 0;
final byte[] body = readBlock(buffer);
assert body != null && body.length > 0;
return new EventEnvelope(contextId, spaceId, scope, headers, body);
} | java | private static EventEnvelope extractEnvelope(Socket socket) throws IOException {
// To-Do: Read the ZeroMQ socket via a NIO wrapper to support large data:
// indeed the arrays has a maximal size bounded by a native int value, and
// the real data could be larger than this limit.
byte[] data = socket.recv(ZMQ.DONTWAIT);
byte[] cdata;
int oldSize = 0;
while (socket.hasReceiveMore()) {
cdata = socket.recv(ZMQ.DONTWAIT);
oldSize = data.length;
data = Arrays.copyOf(data, data.length + cdata.length);
System.arraycopy(cdata, 0, data, oldSize, cdata.length);
}
final ByteBuffer buffer = ByteBuffer.wrap(data);
final byte[] contextId = readBlock(buffer);
assert contextId != null && contextId.length > 0;
final byte[] spaceId = readBlock(buffer);
assert spaceId != null && spaceId.length > 0;
final byte[] scope = readBlock(buffer);
assert scope != null && scope.length > 0;
final byte[] headers = readBlock(buffer);
assert headers != null && headers.length > 0;
final byte[] body = readBlock(buffer);
assert body != null && body.length > 0;
return new EventEnvelope(contextId, spaceId, scope, headers, body);
} | [
"private",
"static",
"EventEnvelope",
"extractEnvelope",
"(",
"Socket",
"socket",
")",
"throws",
"IOException",
"{",
"// To-Do: Read the ZeroMQ socket via a NIO wrapper to support large data:",
"// indeed the arrays has a maximal size bounded by a native int value, and",
"// the real data ... | Receive data from the network.
@param socket
- network reader.
@return the envelope received over the network.
@throws IOException
if the envelope cannot be read from the network. | [
"Receive",
"data",
"from",
"the",
"network",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/zeromq/ZeroMQNetworkService.java#L319-L352 | train |
sarl/sarl | sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/zeromq/ZeroMQNetworkService.java | ZeroMQNetworkService.receive | protected synchronized void receive(EventEnvelope env) throws Exception {
this.logger.getKernelLogger().fine(MessageFormat.format(Messages.ZeroMQNetworkService_8, this.validatedURI, env));
final EventDispatch dispatch = this.serializer.deserialize(env);
this.logger.getKernelLogger().fine(MessageFormat.format(Messages.ZeroMQNetworkService_9, dispatch));
final SpaceID spaceID = dispatch.getSpaceID();
final NetworkEventReceivingListener space = this.messageRecvListeners.get(spaceID);
if (space != null) {
this.executorService.submit(new AsyncRunner(space, spaceID, dispatch.getScope(), dispatch.getEvent()));
} else {
this.logger.getKernelLogger().fine(MessageFormat.format(Messages.ZeroMQNetworkService_10, spaceID, dispatch.getEvent()));
}
} | java | protected synchronized void receive(EventEnvelope env) throws Exception {
this.logger.getKernelLogger().fine(MessageFormat.format(Messages.ZeroMQNetworkService_8, this.validatedURI, env));
final EventDispatch dispatch = this.serializer.deserialize(env);
this.logger.getKernelLogger().fine(MessageFormat.format(Messages.ZeroMQNetworkService_9, dispatch));
final SpaceID spaceID = dispatch.getSpaceID();
final NetworkEventReceivingListener space = this.messageRecvListeners.get(spaceID);
if (space != null) {
this.executorService.submit(new AsyncRunner(space, spaceID, dispatch.getScope(), dispatch.getEvent()));
} else {
this.logger.getKernelLogger().fine(MessageFormat.format(Messages.ZeroMQNetworkService_10, spaceID, dispatch.getEvent()));
}
} | [
"protected",
"synchronized",
"void",
"receive",
"(",
"EventEnvelope",
"env",
")",
"throws",
"Exception",
"{",
"this",
".",
"logger",
".",
"getKernelLogger",
"(",
")",
".",
"fine",
"(",
"MessageFormat",
".",
"format",
"(",
"Messages",
".",
"ZeroMQNetworkService_8... | Extract data from a received envelope, and forwad it to the rest of the platform.
@param env
- the evenlope received over the network, and that must be deserialize.
@throws Exception
- if cannot deserialize the envelope. | [
"Extract",
"data",
"from",
"a",
"received",
"envelope",
"and",
"forwad",
"it",
"to",
"the",
"rest",
"of",
"the",
"platform",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/zeromq/ZeroMQNetworkService.java#L415-L427 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/GenerationContext.java | GenerationContext.getGeneratorConfig | public GeneratorConfig getGeneratorConfig() {
if (this.generatorConfig == null) {
this.generatorConfig = this.generatorConfigProvider.get(
EcoreUtil.getRootContainer(this.contextObject));
}
return this.generatorConfig;
} | java | public GeneratorConfig getGeneratorConfig() {
if (this.generatorConfig == null) {
this.generatorConfig = this.generatorConfigProvider.get(
EcoreUtil.getRootContainer(this.contextObject));
}
return this.generatorConfig;
} | [
"public",
"GeneratorConfig",
"getGeneratorConfig",
"(",
")",
"{",
"if",
"(",
"this",
".",
"generatorConfig",
"==",
"null",
")",
"{",
"this",
".",
"generatorConfig",
"=",
"this",
".",
"generatorConfigProvider",
".",
"get",
"(",
"EcoreUtil",
".",
"getRootContainer... | Replies the generator configuration.
@return the configuration. | [
"Replies",
"the",
"generator",
"configuration",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/GenerationContext.java#L192-L198 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/GenerationContext.java | GenerationContext.getGeneratorConfig2 | public GeneratorConfig2 getGeneratorConfig2() {
if (this.generatorConfig2 == null) {
this.generatorConfig2 = this.generatorConfigProvider2.get(
EcoreUtil.getRootContainer(this.contextObject));
}
return this.generatorConfig2;
} | java | public GeneratorConfig2 getGeneratorConfig2() {
if (this.generatorConfig2 == null) {
this.generatorConfig2 = this.generatorConfigProvider2.get(
EcoreUtil.getRootContainer(this.contextObject));
}
return this.generatorConfig2;
} | [
"public",
"GeneratorConfig2",
"getGeneratorConfig2",
"(",
")",
"{",
"if",
"(",
"this",
".",
"generatorConfig2",
"==",
"null",
")",
"{",
"this",
".",
"generatorConfig2",
"=",
"this",
".",
"generatorConfigProvider2",
".",
"get",
"(",
"EcoreUtil",
".",
"getRootCont... | Replies the generator configuration v2.
@return the configuration. | [
"Replies",
"the",
"generator",
"configuration",
"v2",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/GenerationContext.java#L204-L210 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/GenerationContext.java | GenerationContext.getGuardEvalationCodeFor | public Collection<Procedure1<? super ITreeAppendable>> getGuardEvalationCodeFor(SarlBehaviorUnit source) {
assert source != null;
final String id = source.getName().getIdentifier();
final Collection<Procedure1<? super ITreeAppendable>> evaluators;
final Pair<SarlBehaviorUnit, Collection<Procedure1<? super ITreeAppendable>>> pair = this.guardEvaluators.get(id);
if (pair == null) {
evaluators = new ArrayList<>();
this.guardEvaluators.put(id, new Pair<>(source, evaluators));
} else {
evaluators = pair.getValue();
assert evaluators != null;
}
return evaluators;
} | java | public Collection<Procedure1<? super ITreeAppendable>> getGuardEvalationCodeFor(SarlBehaviorUnit source) {
assert source != null;
final String id = source.getName().getIdentifier();
final Collection<Procedure1<? super ITreeAppendable>> evaluators;
final Pair<SarlBehaviorUnit, Collection<Procedure1<? super ITreeAppendable>>> pair = this.guardEvaluators.get(id);
if (pair == null) {
evaluators = new ArrayList<>();
this.guardEvaluators.put(id, new Pair<>(source, evaluators));
} else {
evaluators = pair.getValue();
assert evaluators != null;
}
return evaluators;
} | [
"public",
"Collection",
"<",
"Procedure1",
"<",
"?",
"super",
"ITreeAppendable",
">",
">",
"getGuardEvalationCodeFor",
"(",
"SarlBehaviorUnit",
"source",
")",
"{",
"assert",
"source",
"!=",
"null",
";",
"final",
"String",
"id",
"=",
"source",
".",
"getName",
"... | Replies the guard evaluation code for the given event.
@param source the source of the guard evaluation.
@return the guard evaluators. | [
"Replies",
"the",
"guard",
"evaluation",
"code",
"for",
"the",
"given",
"event",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/GenerationContext.java#L226-L239 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/GenerationContext.java | GenerationContext.getPostFinalizationElements | public List<Runnable> getPostFinalizationElements() {
final GenerationContext prt = getParentContext();
if (prt != null) {
return prt.getPostFinalizationElements();
}
return this.postFinalization;
} | java | public List<Runnable> getPostFinalizationElements() {
final GenerationContext prt = getParentContext();
if (prt != null) {
return prt.getPostFinalizationElements();
}
return this.postFinalization;
} | [
"public",
"List",
"<",
"Runnable",
">",
"getPostFinalizationElements",
"(",
")",
"{",
"final",
"GenerationContext",
"prt",
"=",
"getParentContext",
"(",
")",
";",
"if",
"(",
"prt",
"!=",
"null",
")",
"{",
"return",
"prt",
".",
"getPostFinalizationElements",
"(... | Replies the collection of the elements that must be generated after
the generation process of the current SARL element.
<p>The differed generation element are the element's components that could be
generated after the complete JVM type is generated. They are extended the
JVM type definition with additionnal elements (annotations...)
@return the original collection of elements.
@since 0.5 | [
"Replies",
"the",
"collection",
"of",
"the",
"elements",
"that",
"must",
"be",
"generated",
"after",
"the",
"generation",
"process",
"of",
"the",
"current",
"SARL",
"element",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/GenerationContext.java#L346-L352 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/compiler/GeneratorConfigProvider2.java | GeneratorConfigProvider2.install | public GeneratorConfig2 install(final ResourceSet resourceSet, GeneratorConfig2 config) {
GeneratorConfigAdapter adapter = GeneratorConfigAdapter.findInEmfObject(resourceSet);
if (adapter == null) {
adapter = new GeneratorConfigAdapter();
}
adapter.attachToEmfObject(resourceSet);
return adapter.getLanguage2GeneratorConfig().put(this.languageId, config);
} | java | public GeneratorConfig2 install(final ResourceSet resourceSet, GeneratorConfig2 config) {
GeneratorConfigAdapter adapter = GeneratorConfigAdapter.findInEmfObject(resourceSet);
if (adapter == null) {
adapter = new GeneratorConfigAdapter();
}
adapter.attachToEmfObject(resourceSet);
return adapter.getLanguage2GeneratorConfig().put(this.languageId, config);
} | [
"public",
"GeneratorConfig2",
"install",
"(",
"final",
"ResourceSet",
"resourceSet",
",",
"GeneratorConfig2",
"config",
")",
"{",
"GeneratorConfigAdapter",
"adapter",
"=",
"GeneratorConfigAdapter",
".",
"findInEmfObject",
"(",
"resourceSet",
")",
";",
"if",
"(",
"adap... | Install the given configuration in the resource set.
@param resourceSet the resource set.
@param config the ne configuration.
@return the configuration. | [
"Install",
"the",
"given",
"configuration",
"in",
"the",
"resource",
"set",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/compiler/GeneratorConfigProvider2.java#L86-L93 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/compiler/AbstractExpressionGenerator.java | AbstractExpressionGenerator.getOperatorSymbol | protected String getOperatorSymbol(XAbstractFeatureCall call) {
if (call != null) {
final Resource res = call.eResource();
if (res instanceof StorageAwareResource) {
final boolean isLoadedFromStorage = ((StorageAwareResource) res).isLoadedFromStorage();
if (isLoadedFromStorage) {
final QualifiedName operator = getOperatorMapping().getOperator(
QualifiedName.create(call.getFeature().getSimpleName()));
return Objects.toString(operator);
}
}
return call.getConcreteSyntaxFeatureName();
}
return null;
} | java | protected String getOperatorSymbol(XAbstractFeatureCall call) {
if (call != null) {
final Resource res = call.eResource();
if (res instanceof StorageAwareResource) {
final boolean isLoadedFromStorage = ((StorageAwareResource) res).isLoadedFromStorage();
if (isLoadedFromStorage) {
final QualifiedName operator = getOperatorMapping().getOperator(
QualifiedName.create(call.getFeature().getSimpleName()));
return Objects.toString(operator);
}
}
return call.getConcreteSyntaxFeatureName();
}
return null;
} | [
"protected",
"String",
"getOperatorSymbol",
"(",
"XAbstractFeatureCall",
"call",
")",
"{",
"if",
"(",
"call",
"!=",
"null",
")",
"{",
"final",
"Resource",
"res",
"=",
"call",
".",
"eResource",
"(",
")",
";",
"if",
"(",
"res",
"instanceof",
"StorageAwareResou... | Get the string representation of an operator.
@param call the call to the operator feature.
@return the string representation of the operator or {@code null} if not a valid operator. | [
"Get",
"the",
"string",
"representation",
"of",
"an",
"operator",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/compiler/AbstractExpressionGenerator.java#L363-L377 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/compiler/AbstractExpressionGenerator.java | AbstractExpressionGenerator.getCallSimpleName | public static String getCallSimpleName(XAbstractFeatureCall featureCall,
ILogicalContainerProvider logicalContainerProvider,
IdentifiableSimpleNameProvider featureNameProvider,
Function0<? extends String> nullKeyword,
Function0<? extends String> thisKeyword,
Function0<? extends String> superKeyword,
Function1<? super JvmIdentifiableElement, ? extends String> referenceNameLambda) {
String name = null;
final JvmIdentifiableElement calledFeature = featureCall.getFeature();
if (calledFeature instanceof JvmConstructor) {
final JvmDeclaredType constructorContainer = ((JvmConstructor) calledFeature).getDeclaringType();
final JvmIdentifiableElement logicalContainer = logicalContainerProvider.getNearestLogicalContainer(featureCall);
final JvmDeclaredType contextType = ((JvmMember) logicalContainer).getDeclaringType();
if (contextType == constructorContainer) {
name = thisKeyword.apply();
} else {
name = superKeyword.apply();
}
} else if (calledFeature != null) {
final String referenceName = referenceNameLambda.apply(calledFeature);
if (referenceName != null) {
name = referenceName;
} else if (calledFeature instanceof JvmOperation) {
name = featureNameProvider.getSimpleName(calledFeature);
} else {
name = featureCall.getConcreteSyntaxFeatureName();
}
}
if (name == null) {
return nullKeyword.apply();
}
return name;
} | java | public static String getCallSimpleName(XAbstractFeatureCall featureCall,
ILogicalContainerProvider logicalContainerProvider,
IdentifiableSimpleNameProvider featureNameProvider,
Function0<? extends String> nullKeyword,
Function0<? extends String> thisKeyword,
Function0<? extends String> superKeyword,
Function1<? super JvmIdentifiableElement, ? extends String> referenceNameLambda) {
String name = null;
final JvmIdentifiableElement calledFeature = featureCall.getFeature();
if (calledFeature instanceof JvmConstructor) {
final JvmDeclaredType constructorContainer = ((JvmConstructor) calledFeature).getDeclaringType();
final JvmIdentifiableElement logicalContainer = logicalContainerProvider.getNearestLogicalContainer(featureCall);
final JvmDeclaredType contextType = ((JvmMember) logicalContainer).getDeclaringType();
if (contextType == constructorContainer) {
name = thisKeyword.apply();
} else {
name = superKeyword.apply();
}
} else if (calledFeature != null) {
final String referenceName = referenceNameLambda.apply(calledFeature);
if (referenceName != null) {
name = referenceName;
} else if (calledFeature instanceof JvmOperation) {
name = featureNameProvider.getSimpleName(calledFeature);
} else {
name = featureCall.getConcreteSyntaxFeatureName();
}
}
if (name == null) {
return nullKeyword.apply();
}
return name;
} | [
"public",
"static",
"String",
"getCallSimpleName",
"(",
"XAbstractFeatureCall",
"featureCall",
",",
"ILogicalContainerProvider",
"logicalContainerProvider",
",",
"IdentifiableSimpleNameProvider",
"featureNameProvider",
",",
"Function0",
"<",
"?",
"extends",
"String",
">",
"nu... | Compute the simple name for the called feature.
@param featureCall the feature call.
@param logicalContainerProvider the provider of logicial container.
@param featureNameProvider the provider of feature name.
@param nullKeyword the null-equivalent keyword.
@param thisKeyword the this-equivalent keyword.
@param superKeyword the super-equivalent keyword.
@param referenceNameLambda replies the reference name or {@code null} if none.
@return the simple name. | [
"Compute",
"the",
"simple",
"name",
"for",
"the",
"called",
"feature",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/compiler/AbstractExpressionGenerator.java#L390-L422 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/compiler/AbstractExpressionGenerator.java | AbstractExpressionGenerator.buildCallReceiver | public static boolean buildCallReceiver(XAbstractFeatureCall call, Function0<? extends String> thisKeyword,
Function1<? super XExpression, ? extends String> referenceNameDefinition, List<Object> output) {
if (call.isStatic()) {
if (call instanceof XMemberFeatureCall) {
final XMemberFeatureCall memberFeatureCall = (XMemberFeatureCall) call;
if (memberFeatureCall.isStaticWithDeclaringType()) {
final XAbstractFeatureCall target = (XAbstractFeatureCall) memberFeatureCall.getMemberCallTarget();
final JvmType declaringType = (JvmType) target.getFeature();
output.add(declaringType);
return true;
}
}
output.add(((JvmFeature) call.getFeature()).getDeclaringType());
return true;
}
final XExpression receiver = call.getActualReceiver();
if (receiver == null) {
return false;
}
final XExpression implicit = call.getImplicitReceiver();
if (receiver == implicit) {
output.add(thisKeyword.apply());
} else {
output.add(receiver);
if (receiver instanceof XAbstractFeatureCall) {
// some local types have a reference name bound to the empty string
// which is the reason why we have to check for an empty string as a valid
// reference name here
// see AnonymousClassCompilerTest.testCapturedLocalVar_04
// if it turns out that we have to deal with generics there too, we may
// have to create a field in the synthesized local class with a unique
// name that points to 'this'
if (((XAbstractFeatureCall) receiver).getFeature() instanceof JvmType) {
final String referenceName = referenceNameDefinition.apply(receiver);
if (referenceName != null && referenceName.length() == 0) {
return false;
}
}
}
}
return true;
} | java | public static boolean buildCallReceiver(XAbstractFeatureCall call, Function0<? extends String> thisKeyword,
Function1<? super XExpression, ? extends String> referenceNameDefinition, List<Object> output) {
if (call.isStatic()) {
if (call instanceof XMemberFeatureCall) {
final XMemberFeatureCall memberFeatureCall = (XMemberFeatureCall) call;
if (memberFeatureCall.isStaticWithDeclaringType()) {
final XAbstractFeatureCall target = (XAbstractFeatureCall) memberFeatureCall.getMemberCallTarget();
final JvmType declaringType = (JvmType) target.getFeature();
output.add(declaringType);
return true;
}
}
output.add(((JvmFeature) call.getFeature()).getDeclaringType());
return true;
}
final XExpression receiver = call.getActualReceiver();
if (receiver == null) {
return false;
}
final XExpression implicit = call.getImplicitReceiver();
if (receiver == implicit) {
output.add(thisKeyword.apply());
} else {
output.add(receiver);
if (receiver instanceof XAbstractFeatureCall) {
// some local types have a reference name bound to the empty string
// which is the reason why we have to check for an empty string as a valid
// reference name here
// see AnonymousClassCompilerTest.testCapturedLocalVar_04
// if it turns out that we have to deal with generics there too, we may
// have to create a field in the synthesized local class with a unique
// name that points to 'this'
if (((XAbstractFeatureCall) receiver).getFeature() instanceof JvmType) {
final String referenceName = referenceNameDefinition.apply(receiver);
if (referenceName != null && referenceName.length() == 0) {
return false;
}
}
}
}
return true;
} | [
"public",
"static",
"boolean",
"buildCallReceiver",
"(",
"XAbstractFeatureCall",
"call",
",",
"Function0",
"<",
"?",
"extends",
"String",
">",
"thisKeyword",
",",
"Function1",
"<",
"?",
"super",
"XExpression",
",",
"?",
"extends",
"String",
">",
"referenceNameDefi... | Compute the list of object that serve as the receiver for the given call.
@param call the feature call to analyze.
@param output the objects that constitute the call's receiver.
@param thisKeyword the "this" keyword.
@param referenceNameDefinition replies the name of the expression, if defined.
@return {@code true} if a receiver was found; otherwise {@code false}. | [
"Compute",
"the",
"list",
"of",
"object",
"that",
"serve",
"as",
"the",
"receiver",
"for",
"the",
"given",
"call",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/extralanguage/compiler/AbstractExpressionGenerator.java#L432-L473 | train |
sarl/sarl | sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/modules/BootModule.java | BootModule.getContextID | @Provides
@Named(JanusConfig.DEFAULT_CONTEXT_ID_NAME)
public static UUID getContextID() {
String str = JanusConfig.getSystemProperty(JanusConfig.DEFAULT_CONTEXT_ID_NAME);
if (Strings.isNullOrEmpty(str)) {
Boolean v;
// From boot agent type
str = JanusConfig.getSystemProperty(JanusConfig.BOOT_DEFAULT_CONTEXT_ID_NAME);
if (Strings.isNullOrEmpty(str)) {
v = JanusConfig.BOOT_DEFAULT_CONTEXT_ID_VALUE;
} else {
v = Boolean.valueOf(Boolean.parseBoolean(str));
}
if (v.booleanValue()) {
final String bootClassname = JanusConfig.getSystemProperty(JanusConfig.BOOT_AGENT);
str = UUID.nameUUIDFromBytes(bootClassname.getBytes()).toString();
} else {
// Random
str = JanusConfig.getSystemProperty(JanusConfig.RANDOM_DEFAULT_CONTEXT_ID_NAME);
if (Strings.isNullOrEmpty(str)) {
v = JanusConfig.RANDOM_DEFAULT_CONTEXT_ID_VALUE;
} else {
v = Boolean.valueOf(Boolean.parseBoolean(str));
}
if (v.booleanValue()) {
str = UUID.randomUUID().toString();
} else {
str = JanusConfig.DEFAULT_CONTEXT_ID_VALUE;
}
}
// Force the global value of the property to prevent to re-generate the UUID at the next call.
System.setProperty(JanusConfig.DEFAULT_CONTEXT_ID_NAME, str);
}
assert !Strings.isNullOrEmpty(str);
return UUID.fromString(str);
} | java | @Provides
@Named(JanusConfig.DEFAULT_CONTEXT_ID_NAME)
public static UUID getContextID() {
String str = JanusConfig.getSystemProperty(JanusConfig.DEFAULT_CONTEXT_ID_NAME);
if (Strings.isNullOrEmpty(str)) {
Boolean v;
// From boot agent type
str = JanusConfig.getSystemProperty(JanusConfig.BOOT_DEFAULT_CONTEXT_ID_NAME);
if (Strings.isNullOrEmpty(str)) {
v = JanusConfig.BOOT_DEFAULT_CONTEXT_ID_VALUE;
} else {
v = Boolean.valueOf(Boolean.parseBoolean(str));
}
if (v.booleanValue()) {
final String bootClassname = JanusConfig.getSystemProperty(JanusConfig.BOOT_AGENT);
str = UUID.nameUUIDFromBytes(bootClassname.getBytes()).toString();
} else {
// Random
str = JanusConfig.getSystemProperty(JanusConfig.RANDOM_DEFAULT_CONTEXT_ID_NAME);
if (Strings.isNullOrEmpty(str)) {
v = JanusConfig.RANDOM_DEFAULT_CONTEXT_ID_VALUE;
} else {
v = Boolean.valueOf(Boolean.parseBoolean(str));
}
if (v.booleanValue()) {
str = UUID.randomUUID().toString();
} else {
str = JanusConfig.DEFAULT_CONTEXT_ID_VALUE;
}
}
// Force the global value of the property to prevent to re-generate the UUID at the next call.
System.setProperty(JanusConfig.DEFAULT_CONTEXT_ID_NAME, str);
}
assert !Strings.isNullOrEmpty(str);
return UUID.fromString(str);
} | [
"@",
"Provides",
"@",
"Named",
"(",
"JanusConfig",
".",
"DEFAULT_CONTEXT_ID_NAME",
")",
"public",
"static",
"UUID",
"getContextID",
"(",
")",
"{",
"String",
"str",
"=",
"JanusConfig",
".",
"getSystemProperty",
"(",
"JanusConfig",
".",
"DEFAULT_CONTEXT_ID_NAME",
")... | Create a context identifier.
@return the contextID | [
"Create",
"a",
"context",
"identifier",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/modules/BootModule.java#L78-L116 | train |
sarl/sarl | sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/modules/BootModule.java | BootModule.getSpaceID | @Provides
@Named(JanusConfig.DEFAULT_SPACE_ID_NAME)
public static UUID getSpaceID() {
final String v = JanusConfig.getSystemProperty(JanusConfig.DEFAULT_SPACE_ID_NAME, JanusConfig.DEFAULT_SPACE_ID_VALUE);
return UUID.fromString(v);
} | java | @Provides
@Named(JanusConfig.DEFAULT_SPACE_ID_NAME)
public static UUID getSpaceID() {
final String v = JanusConfig.getSystemProperty(JanusConfig.DEFAULT_SPACE_ID_NAME, JanusConfig.DEFAULT_SPACE_ID_VALUE);
return UUID.fromString(v);
} | [
"@",
"Provides",
"@",
"Named",
"(",
"JanusConfig",
".",
"DEFAULT_SPACE_ID_NAME",
")",
"public",
"static",
"UUID",
"getSpaceID",
"(",
")",
"{",
"final",
"String",
"v",
"=",
"JanusConfig",
".",
"getSystemProperty",
"(",
"JanusConfig",
".",
"DEFAULT_SPACE_ID_NAME",
... | Construct a space identifier.
@return the spaceID | [
"Construct",
"a",
"space",
"identifier",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/modules/BootModule.java#L123-L128 | train |
sarl/sarl | sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/modules/BootModule.java | BootModule.getPUBURIAsString | private static String getPUBURIAsString() {
String pubUri = JanusConfig.getSystemProperty(JanusConfig.PUB_URI);
if (pubUri == null || pubUri.isEmpty()) {
InetAddress a = NetworkUtil.getPrimaryAddress();
if (a == null) {
a = NetworkUtil.getLoopbackAddress();
}
if (a != null) {
pubUri = NetworkUtil.toURI(a, -1).toString();
System.setProperty(JanusConfig.PUB_URI, pubUri);
}
}
return pubUri;
} | java | private static String getPUBURIAsString() {
String pubUri = JanusConfig.getSystemProperty(JanusConfig.PUB_URI);
if (pubUri == null || pubUri.isEmpty()) {
InetAddress a = NetworkUtil.getPrimaryAddress();
if (a == null) {
a = NetworkUtil.getLoopbackAddress();
}
if (a != null) {
pubUri = NetworkUtil.toURI(a, -1).toString();
System.setProperty(JanusConfig.PUB_URI, pubUri);
}
}
return pubUri;
} | [
"private",
"static",
"String",
"getPUBURIAsString",
"(",
")",
"{",
"String",
"pubUri",
"=",
"JanusConfig",
".",
"getSystemProperty",
"(",
"JanusConfig",
".",
"PUB_URI",
")",
";",
"if",
"(",
"pubUri",
"==",
"null",
"||",
"pubUri",
".",
"isEmpty",
"(",
")",
... | Extract the current value of the PUB_URI from the system's property or form the platform default value.
@return the current PUB_URI | [
"Extract",
"the",
"current",
"value",
"of",
"the",
"PUB_URI",
"from",
"the",
"system",
"s",
"property",
"or",
"form",
"the",
"platform",
"default",
"value",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/modules/BootModule.java#L151-L164 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.populateInterfaceElements | public static void populateInterfaceElements(
JvmDeclaredType jvmElement,
Map<ActionPrototype, JvmOperation> operations,
Map<String, JvmField> fields,
IActionPrototypeProvider sarlSignatureProvider) {
for (final JvmFeature feature : jvmElement.getAllFeatures()) {
if (!"java.lang.Object".equals(feature.getDeclaringType().getQualifiedName())) { //$NON-NLS-1$
if (operations != null && feature instanceof JvmOperation) {
final JvmOperation operation = (JvmOperation) feature;
final ActionParameterTypes sig = sarlSignatureProvider.createParameterTypesFromJvmModel(
operation.isVarArgs(), operation.getParameters());
final ActionPrototype actionKey = sarlSignatureProvider.createActionPrototype(
operation.getSimpleName(), sig);
operations.put(actionKey, operation);
} else if (fields != null && feature instanceof JvmField) {
fields.put(feature.getSimpleName(), (JvmField) feature);
}
}
}
} | java | public static void populateInterfaceElements(
JvmDeclaredType jvmElement,
Map<ActionPrototype, JvmOperation> operations,
Map<String, JvmField> fields,
IActionPrototypeProvider sarlSignatureProvider) {
for (final JvmFeature feature : jvmElement.getAllFeatures()) {
if (!"java.lang.Object".equals(feature.getDeclaringType().getQualifiedName())) { //$NON-NLS-1$
if (operations != null && feature instanceof JvmOperation) {
final JvmOperation operation = (JvmOperation) feature;
final ActionParameterTypes sig = sarlSignatureProvider.createParameterTypesFromJvmModel(
operation.isVarArgs(), operation.getParameters());
final ActionPrototype actionKey = sarlSignatureProvider.createActionPrototype(
operation.getSimpleName(), sig);
operations.put(actionKey, operation);
} else if (fields != null && feature instanceof JvmField) {
fields.put(feature.getSimpleName(), (JvmField) feature);
}
}
}
} | [
"public",
"static",
"void",
"populateInterfaceElements",
"(",
"JvmDeclaredType",
"jvmElement",
",",
"Map",
"<",
"ActionPrototype",
",",
"JvmOperation",
">",
"operations",
",",
"Map",
"<",
"String",
",",
"JvmField",
">",
"fields",
",",
"IActionPrototypeProvider",
"sa... | Analyzing the type hierarchy of the given interface and
extract hierarchy information.
@param jvmElement - the element to analyze
@param operations - filled with the operations inside and inherited by the element.
@param fields - filled with the fields inside and inherited by the element.
@param sarlSignatureProvider - provider of tools related to action signatures.
@see OverrideHelper | [
"Analyzing",
"the",
"type",
"hierarchy",
"of",
"the",
"given",
"interface",
"and",
"extract",
"hierarchy",
"information",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L184-L203 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.isVarArg | public static boolean isVarArg(List<? extends XtendParameter> params) {
assert params != null;
if (params.size() > 0) {
final XtendParameter param = params.get(params.size() - 1);
assert param != null;
return param.isVarArg();
}
return false;
} | java | public static boolean isVarArg(List<? extends XtendParameter> params) {
assert params != null;
if (params.size() > 0) {
final XtendParameter param = params.get(params.size() - 1);
assert param != null;
return param.isVarArg();
}
return false;
} | [
"public",
"static",
"boolean",
"isVarArg",
"(",
"List",
"<",
"?",
"extends",
"XtendParameter",
">",
"params",
")",
"{",
"assert",
"params",
"!=",
"null",
";",
"if",
"(",
"params",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"final",
"XtendParameter",
"p... | Replies if the last parameter is a variadic parameter.
@param params - parameters.
@return <code>true</code> if the late parameter is variadic. | [
"Replies",
"if",
"the",
"last",
"parameter",
"is",
"a",
"variadic",
"parameter",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L363-L371 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.createNameForHiddenCapacityImplementationAttribute | public static String createNameForHiddenCapacityImplementationAttribute(String id) {
return PREFIX_CAPACITY_IMPLEMENTATION + fixHiddenMember(id.toUpperCase()).replace(".", //$NON-NLS-1$
HIDDEN_MEMBER_REPLACEMENT_CHARACTER);
} | java | public static String createNameForHiddenCapacityImplementationAttribute(String id) {
return PREFIX_CAPACITY_IMPLEMENTATION + fixHiddenMember(id.toUpperCase()).replace(".", //$NON-NLS-1$
HIDDEN_MEMBER_REPLACEMENT_CHARACTER);
} | [
"public",
"static",
"String",
"createNameForHiddenCapacityImplementationAttribute",
"(",
"String",
"id",
")",
"{",
"return",
"PREFIX_CAPACITY_IMPLEMENTATION",
"+",
"fixHiddenMember",
"(",
"id",
".",
"toUpperCase",
"(",
")",
")",
".",
"replace",
"(",
"\".\"",
",",
"/... | Create the name of the hidden field that is containing a capacity implementation.
@param id the id of the capacity.
@return the field name. | [
"Create",
"the",
"name",
"of",
"the",
"hidden",
"field",
"that",
"is",
"containing",
"a",
"capacity",
"implementation",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L414-L417 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.isNameForHiddenCapacityImplementationCallingMethod | public static boolean isNameForHiddenCapacityImplementationCallingMethod(String simpleName) {
return simpleName != null && simpleName.startsWith(PREFIX_CAPACITY_IMPLEMENTATION)
&& simpleName.endsWith(POSTFIX_CAPACITY_IMPLEMENTATION_CALLER);
} | java | public static boolean isNameForHiddenCapacityImplementationCallingMethod(String simpleName) {
return simpleName != null && simpleName.startsWith(PREFIX_CAPACITY_IMPLEMENTATION)
&& simpleName.endsWith(POSTFIX_CAPACITY_IMPLEMENTATION_CALLER);
} | [
"public",
"static",
"boolean",
"isNameForHiddenCapacityImplementationCallingMethod",
"(",
"String",
"simpleName",
")",
"{",
"return",
"simpleName",
"!=",
"null",
"&&",
"simpleName",
".",
"startsWith",
"(",
"PREFIX_CAPACITY_IMPLEMENTATION",
")",
"&&",
"simpleName",
".",
... | Replies if the given simple name is the name of the hidden method that is calling a capacity implementation.
@param simpleName the simple name.
@return <code>true</code> if the given simple name if for the hidden method for capacuty uses. | [
"Replies",
"if",
"the",
"given",
"simple",
"name",
"is",
"the",
"name",
"of",
"the",
"hidden",
"method",
"that",
"is",
"calling",
"a",
"capacity",
"implementation",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L434-L437 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.createNameForHiddenGuardEvaluatorMethod | public static String createNameForHiddenGuardEvaluatorMethod(String eventId, int handlerIndex) {
return PREFIX_GUARD + fixHiddenMember(eventId)
+ HIDDEN_MEMBER_CHARACTER + handlerIndex;
} | java | public static String createNameForHiddenGuardEvaluatorMethod(String eventId, int handlerIndex) {
return PREFIX_GUARD + fixHiddenMember(eventId)
+ HIDDEN_MEMBER_CHARACTER + handlerIndex;
} | [
"public",
"static",
"String",
"createNameForHiddenGuardEvaluatorMethod",
"(",
"String",
"eventId",
",",
"int",
"handlerIndex",
")",
"{",
"return",
"PREFIX_GUARD",
"+",
"fixHiddenMember",
"(",
"eventId",
")",
"+",
"HIDDEN_MEMBER_CHARACTER",
"+",
"handlerIndex",
";",
"}... | Create the name of the hidden method that is containing the event guard evaluation.
@param eventId the id of the event.
@param handlerIndex the index of the handler in the container type.
@return the method name. | [
"Create",
"the",
"name",
"of",
"the",
"hidden",
"method",
"that",
"is",
"containing",
"the",
"event",
"guard",
"evaluation",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L463-L466 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.createNameForHiddenEventHandlerMethod | public static String createNameForHiddenEventHandlerMethod(String eventId, int handlerIndex) {
return PREFIX_EVENT_HANDLER + fixHiddenMember(eventId) + HIDDEN_MEMBER_CHARACTER + handlerIndex;
} | java | public static String createNameForHiddenEventHandlerMethod(String eventId, int handlerIndex) {
return PREFIX_EVENT_HANDLER + fixHiddenMember(eventId) + HIDDEN_MEMBER_CHARACTER + handlerIndex;
} | [
"public",
"static",
"String",
"createNameForHiddenEventHandlerMethod",
"(",
"String",
"eventId",
",",
"int",
"handlerIndex",
")",
"{",
"return",
"PREFIX_EVENT_HANDLER",
"+",
"fixHiddenMember",
"(",
"eventId",
")",
"+",
"HIDDEN_MEMBER_CHARACTER",
"+",
"handlerIndex",
";"... | Create the name of the hidden method that is containing the event handler code.
@param eventId the id of the event.
@param handlerIndex the index of the handler in the container type.
@return the attribute name. | [
"Create",
"the",
"name",
"of",
"the",
"hidden",
"method",
"that",
"is",
"containing",
"the",
"event",
"handler",
"code",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L474-L476 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.isClass | public static boolean isClass(LightweightTypeReference typeRef) {
final JvmType t = typeRef.getType();
if (t instanceof JvmGenericType) {
return !((JvmGenericType) t).isInterface();
}
return false;
} | java | public static boolean isClass(LightweightTypeReference typeRef) {
final JvmType t = typeRef.getType();
if (t instanceof JvmGenericType) {
return !((JvmGenericType) t).isInterface();
}
return false;
} | [
"public",
"static",
"boolean",
"isClass",
"(",
"LightweightTypeReference",
"typeRef",
")",
"{",
"final",
"JvmType",
"t",
"=",
"typeRef",
".",
"getType",
"(",
")",
";",
"if",
"(",
"t",
"instanceof",
"JvmGenericType",
")",
"{",
"return",
"!",
"(",
"(",
"JvmG... | Replies if the given reference is pointing to a class type.
@param typeRef - the type reference to test.
@return <code>true</code> if the pointed element is a class type. | [
"Replies",
"if",
"the",
"given",
"reference",
"is",
"pointing",
"to",
"a",
"class",
"type",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L483-L489 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.isFinal | public static boolean isFinal(LightweightTypeReference expressionTypeRef) {
if (expressionTypeRef.isArray()) {
return isFinal(expressionTypeRef.getComponentType());
}
if (expressionTypeRef.isPrimitive()) {
return true;
}
return expressionTypeRef.getType() instanceof JvmDeclaredType
&& ((JvmDeclaredType) expressionTypeRef.getType()).isFinal();
} | java | public static boolean isFinal(LightweightTypeReference expressionTypeRef) {
if (expressionTypeRef.isArray()) {
return isFinal(expressionTypeRef.getComponentType());
}
if (expressionTypeRef.isPrimitive()) {
return true;
}
return expressionTypeRef.getType() instanceof JvmDeclaredType
&& ((JvmDeclaredType) expressionTypeRef.getType()).isFinal();
} | [
"public",
"static",
"boolean",
"isFinal",
"(",
"LightweightTypeReference",
"expressionTypeRef",
")",
"{",
"if",
"(",
"expressionTypeRef",
".",
"isArray",
"(",
")",
")",
"{",
"return",
"isFinal",
"(",
"expressionTypeRef",
".",
"getComponentType",
"(",
")",
")",
"... | Replies if the given reference is referencing a final type.
@param expressionTypeRef - the type reference to test.
@return <code>true</code> if the given type is final. | [
"Replies",
"if",
"the",
"given",
"reference",
"is",
"referencing",
"a",
"final",
"type",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L505-L514 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.isFinal | public static boolean isFinal(Class<?> expressionType) {
if (expressionType.isArray()) {
return isFinal(expressionType.getComponentType());
}
if (expressionType.isPrimitive()) {
return true;
}
return expressionType.isEnum()
|| Modifier.isFinal(expressionType.getModifiers());
} | java | public static boolean isFinal(Class<?> expressionType) {
if (expressionType.isArray()) {
return isFinal(expressionType.getComponentType());
}
if (expressionType.isPrimitive()) {
return true;
}
return expressionType.isEnum()
|| Modifier.isFinal(expressionType.getModifiers());
} | [
"public",
"static",
"boolean",
"isFinal",
"(",
"Class",
"<",
"?",
">",
"expressionType",
")",
"{",
"if",
"(",
"expressionType",
".",
"isArray",
"(",
")",
")",
"{",
"return",
"isFinal",
"(",
"expressionType",
".",
"getComponentType",
"(",
")",
")",
";",
"... | Replies if the given type is a final type.
@param expressionType - the type to test.
@return <code>true</code> if the given type is final. | [
"Replies",
"if",
"the",
"given",
"type",
"is",
"a",
"final",
"type",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L521-L530 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.isInterface | public static boolean isInterface(LightweightTypeReference type) {
return type.getType() instanceof JvmGenericType
&& ((JvmGenericType) type.getType()).isInterface();
} | java | public static boolean isInterface(LightweightTypeReference type) {
return type.getType() instanceof JvmGenericType
&& ((JvmGenericType) type.getType()).isInterface();
} | [
"public",
"static",
"boolean",
"isInterface",
"(",
"LightweightTypeReference",
"type",
")",
"{",
"return",
"type",
".",
"getType",
"(",
")",
"instanceof",
"JvmGenericType",
"&&",
"(",
"(",
"JvmGenericType",
")",
"type",
".",
"getType",
"(",
")",
")",
".",
"i... | Replies if the given type is an interface.
@param type - the type to test.
@return <code>true</code> if the given type is an interface. | [
"Replies",
"if",
"the",
"given",
"type",
"is",
"an",
"interface",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L537-L540 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.canCast | @SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:booleanexpressioncomplexity"})
public static boolean canCast(
LightweightTypeReference fromType, LightweightTypeReference toType,
boolean enablePrimitiveWidening, boolean enableVoidMatchingNull,
boolean allowSynonyms) {
if (enableVoidMatchingNull) {
final boolean fromVoid = fromType == null || fromType.isPrimitiveVoid();
final boolean toVoid = toType == null || toType.isPrimitiveVoid();
if (fromVoid) {
return toVoid;
}
if (toVoid) {
return fromVoid;
}
assert fromType != null;
assert toType != null;
} else if ((fromType == null || toType == null)
|| (fromType.isPrimitiveVoid() != toType.isPrimitiveVoid())) {
return false;
}
final TypeConformanceComputationArgument conform = new TypeConformanceComputationArgument(
false, false, true, enablePrimitiveWidening, false, allowSynonyms);
if (((fromType.getType() instanceof JvmDeclaredType || fromType.isPrimitive())
// if one of the types is an interface and the other is a non final class
// (or interface) there always can be a subtype
&& (!isInterface(fromType) || isFinal(toType))
&& (!isInterface(toType) || isFinal(fromType))
&& (!toType.isAssignableFrom(fromType, conform))
&& (isFinal(fromType) || isFinal(toType)
|| isClass(fromType) && isClass(toType))
// no upcast
&& (!fromType.isAssignableFrom(toType, conform)))
|| (toType.isPrimitive() && !(fromType.isPrimitive() || fromType.isWrapper()))) {
return false;
}
return true;
} | java | @SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:booleanexpressioncomplexity"})
public static boolean canCast(
LightweightTypeReference fromType, LightweightTypeReference toType,
boolean enablePrimitiveWidening, boolean enableVoidMatchingNull,
boolean allowSynonyms) {
if (enableVoidMatchingNull) {
final boolean fromVoid = fromType == null || fromType.isPrimitiveVoid();
final boolean toVoid = toType == null || toType.isPrimitiveVoid();
if (fromVoid) {
return toVoid;
}
if (toVoid) {
return fromVoid;
}
assert fromType != null;
assert toType != null;
} else if ((fromType == null || toType == null)
|| (fromType.isPrimitiveVoid() != toType.isPrimitiveVoid())) {
return false;
}
final TypeConformanceComputationArgument conform = new TypeConformanceComputationArgument(
false, false, true, enablePrimitiveWidening, false, allowSynonyms);
if (((fromType.getType() instanceof JvmDeclaredType || fromType.isPrimitive())
// if one of the types is an interface and the other is a non final class
// (or interface) there always can be a subtype
&& (!isInterface(fromType) || isFinal(toType))
&& (!isInterface(toType) || isFinal(fromType))
&& (!toType.isAssignableFrom(fromType, conform))
&& (isFinal(fromType) || isFinal(toType)
|| isClass(fromType) && isClass(toType))
// no upcast
&& (!fromType.isAssignableFrom(toType, conform)))
|| (toType.isPrimitive() && !(fromType.isPrimitive() || fromType.isWrapper()))) {
return false;
}
return true;
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"checkstyle:cyclomaticcomplexity\"",
",",
"\"checkstyle:booleanexpressioncomplexity\"",
"}",
")",
"public",
"static",
"boolean",
"canCast",
"(",
"LightweightTypeReference",
"fromType",
",",
"LightweightTypeReference",
"toType",
",",
"boole... | Replies if it is allowed to cast between the given types.
@param fromType - source type
@param toType - target type
@param enablePrimitiveWidening - indicates if the widening of the primitive types is allowed.
@param enableVoidMatchingNull - indicates if the <code>null</code> is matching <code>void</code>.
@param allowSynonyms - indicates if the synonyms are allowed.
@return the state of the cast. | [
"Replies",
"if",
"it",
"is",
"allowed",
"to",
"cast",
"between",
"the",
"given",
"types",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L551-L587 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.toLightweightTypeReference | public static LightweightTypeReference toLightweightTypeReference(
JvmType type, CommonTypeComputationServices services,
boolean keepUnboundWildcardInformation) {
if (type == null) {
return null;
}
final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(services, type);
final LightweightTypeReferenceFactory factory = new LightweightTypeReferenceFactory(owner,
keepUnboundWildcardInformation);
final LightweightTypeReference reference = factory.toLightweightReference(type);
return reference;
} | java | public static LightweightTypeReference toLightweightTypeReference(
JvmType type, CommonTypeComputationServices services,
boolean keepUnboundWildcardInformation) {
if (type == null) {
return null;
}
final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(services, type);
final LightweightTypeReferenceFactory factory = new LightweightTypeReferenceFactory(owner,
keepUnboundWildcardInformation);
final LightweightTypeReference reference = factory.toLightweightReference(type);
return reference;
} | [
"public",
"static",
"LightweightTypeReference",
"toLightweightTypeReference",
"(",
"JvmType",
"type",
",",
"CommonTypeComputationServices",
"services",
",",
"boolean",
"keepUnboundWildcardInformation",
")",
"{",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"return",
"null... | Convert a type to a lightweight type reference.
@param type - type to convert.
@param services - services used for the conversion
@param keepUnboundWildcardInformation - indicates if the unbound wild card
information must be keeped in the lightweight reference.
@return the lightweight type reference. | [
"Convert",
"a",
"type",
"to",
"a",
"lightweight",
"type",
"reference",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L641-L652 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.compareVersions | public static int compareVersions(String v1, String v2) {
// Remove the SNAPSHOT version.
//final String fixedv1 = v1.replaceFirst("-SNAPSHOT$", ""); //$NON-NLS-1$ //$NON-NLS-2$
//final String fixedv2 = v2.replaceFirst("-SNAPSHOT$", ""); //$NON-NLS-1$ //$NON-NLS-2$
//final Version vobject1 = Version.parseVersion(fixedv1);
//final Version vobject2 = Version.parseVersion(fixedv2);
final Version vobject1 = Version.parseVersion(v1);
final Version vobject2 = Version.parseVersion(v2);
return vobject1.compareTo(vobject2);
} | java | public static int compareVersions(String v1, String v2) {
// Remove the SNAPSHOT version.
//final String fixedv1 = v1.replaceFirst("-SNAPSHOT$", ""); //$NON-NLS-1$ //$NON-NLS-2$
//final String fixedv2 = v2.replaceFirst("-SNAPSHOT$", ""); //$NON-NLS-1$ //$NON-NLS-2$
//final Version vobject1 = Version.parseVersion(fixedv1);
//final Version vobject2 = Version.parseVersion(fixedv2);
final Version vobject1 = Version.parseVersion(v1);
final Version vobject2 = Version.parseVersion(v2);
return vobject1.compareTo(vobject2);
} | [
"public",
"static",
"int",
"compareVersions",
"(",
"String",
"v1",
",",
"String",
"v2",
")",
"{",
"// Remove the SNAPSHOT version.",
"//final String fixedv1 = v1.replaceFirst(\"-SNAPSHOT$\", \"\"); //$NON-NLS-1$ //$NON-NLS-2$",
"//final String fixedv2 = v2.replaceFirst(\"-SNAPSHOT$\", \"... | Compare the two strings as they are version numbers.
@param v1 - first version to compare.
@param v2 - second version to compare.
@return Negative integer of <code>v1</code> is lower than <code>v2</code>;
positive integer of <code>v1</code> is greater than <code>v2</code>;
{@code 0} if they are strictly equal. | [
"Compare",
"the",
"two",
"strings",
"as",
"they",
"are",
"version",
"numbers",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L662-L671 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.getSarlCodeFor | public static String getSarlCodeFor(EObject object) {
final ICompositeNode node = NodeModelUtils.getNode(object);
if (node != null) {
String text = node.getText();
if (text != null) {
text = text.trim();
text = text.replaceAll("[\n\r\f]+", " "); //$NON-NLS-1$//$NON-NLS-2$
}
return Strings.emptyToNull(text);
}
return null;
} | java | public static String getSarlCodeFor(EObject object) {
final ICompositeNode node = NodeModelUtils.getNode(object);
if (node != null) {
String text = node.getText();
if (text != null) {
text = text.trim();
text = text.replaceAll("[\n\r\f]+", " "); //$NON-NLS-1$//$NON-NLS-2$
}
return Strings.emptyToNull(text);
}
return null;
} | [
"public",
"static",
"String",
"getSarlCodeFor",
"(",
"EObject",
"object",
")",
"{",
"final",
"ICompositeNode",
"node",
"=",
"NodeModelUtils",
".",
"getNode",
"(",
"object",
")",
";",
"if",
"(",
"node",
"!=",
"null",
")",
"{",
"String",
"text",
"=",
"node",... | Replies the original code for the given Ecore object.
<p>The replied code is the SARL code within the source file. It's format depends on
how the developer has input it.
<p>This function does:<ul>
<li>replace any sequence of "new line" characters by a space character, and</li>
<li>trim the whitespaces.</li>
</ul>
@param object the object to search the code for.
@return the SARL code for the given object, or {@code null} if no code was found.
@since 0.7 | [
"Replies",
"the",
"original",
"code",
"for",
"the",
"given",
"Ecore",
"object",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L712-L723 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.hasAbstractMember | public static boolean hasAbstractMember(XtendTypeDeclaration declaration) {
if (declaration != null) {
for (final XtendMember member : declaration.getMembers()) {
if (member instanceof XtendFunction) {
if (((XtendFunction) member).isAbstract()) {
return true;
}
}
}
}
return false;
} | java | public static boolean hasAbstractMember(XtendTypeDeclaration declaration) {
if (declaration != null) {
for (final XtendMember member : declaration.getMembers()) {
if (member instanceof XtendFunction) {
if (((XtendFunction) member).isAbstract()) {
return true;
}
}
}
}
return false;
} | [
"public",
"static",
"boolean",
"hasAbstractMember",
"(",
"XtendTypeDeclaration",
"declaration",
")",
"{",
"if",
"(",
"declaration",
"!=",
"null",
")",
"{",
"for",
"(",
"final",
"XtendMember",
"member",
":",
"declaration",
".",
"getMembers",
"(",
")",
")",
"{",... | Replies if the given declaration has an abstract member.
@param declaration - the declaration.
@return <code>true</code> if the given type has an abstract function. | [
"Replies",
"if",
"the",
"given",
"declaration",
"has",
"an",
"abstract",
"member",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L1027-L1038 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.isCompatibleSARLLibraryOnClasspath | public static boolean isCompatibleSARLLibraryOnClasspath(TypeReferences typeReferences, Notifier context) {
final OutParameter<String> version = new OutParameter<>();
final SarlLibraryErrorCode code = getSARLLibraryVersionOnClasspath(typeReferences, context, version);
if (code == SarlLibraryErrorCode.SARL_FOUND) {
return isCompatibleSARLLibraryVersion(version.get());
}
return false;
} | java | public static boolean isCompatibleSARLLibraryOnClasspath(TypeReferences typeReferences, Notifier context) {
final OutParameter<String> version = new OutParameter<>();
final SarlLibraryErrorCode code = getSARLLibraryVersionOnClasspath(typeReferences, context, version);
if (code == SarlLibraryErrorCode.SARL_FOUND) {
return isCompatibleSARLLibraryVersion(version.get());
}
return false;
} | [
"public",
"static",
"boolean",
"isCompatibleSARLLibraryOnClasspath",
"(",
"TypeReferences",
"typeReferences",
",",
"Notifier",
"context",
")",
"{",
"final",
"OutParameter",
"<",
"String",
">",
"version",
"=",
"new",
"OutParameter",
"<>",
"(",
")",
";",
"final",
"S... | Check if a compatible SARL library is available on the classpath.
@param typeReferences - the accessor to the types.
@param context - the context that is providing the access to the classpath.
@return <code>true</code> if a compatible SARL library was found.
Otherwise <code>false</code>. | [
"Check",
"if",
"a",
"compatible",
"SARL",
"library",
"is",
"available",
"on",
"the",
"classpath",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L1047-L1054 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.isCompatibleSARLLibraryVersion | public static boolean isCompatibleSARLLibraryVersion(String version) {
if (version != null) {
final Version currentVersion = Version.parseVersion(SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING);
final Version paramVersion = Version.parseVersion(version);
return currentVersion.getMajor() == paramVersion.getMajor()
&& currentVersion.getMinor() == paramVersion.getMinor();
}
return false;
} | java | public static boolean isCompatibleSARLLibraryVersion(String version) {
if (version != null) {
final Version currentVersion = Version.parseVersion(SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING);
final Version paramVersion = Version.parseVersion(version);
return currentVersion.getMajor() == paramVersion.getMajor()
&& currentVersion.getMinor() == paramVersion.getMinor();
}
return false;
} | [
"public",
"static",
"boolean",
"isCompatibleSARLLibraryVersion",
"(",
"String",
"version",
")",
"{",
"if",
"(",
"version",
"!=",
"null",
")",
"{",
"final",
"Version",
"currentVersion",
"=",
"Version",
".",
"parseVersion",
"(",
"SARLVersion",
".",
"SPECIFICATION_RE... | Check if a version is compatible with the expected SARL library.
@param version - the version to test.
@return <code>true</code> if a compatible SARL library was found.
Otherwise <code>false</code>. | [
"Check",
"if",
"a",
"version",
"is",
"compatible",
"with",
"the",
"expected",
"SARL",
"library",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L1062-L1070 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.isCompatibleJREVersion | public static boolean isCompatibleJREVersion(String version) {
if (version != null && !version.isEmpty()) {
final Version current = Version.parseVersion(version);
if (current != null) {
final Version minJdk = Version.parseVersion(SARLVersion.MINIMAL_JDK_VERSION);
assert minJdk != null;
if (current.compareTo(minJdk) >= 0) {
final Version maxJdk = Version.parseVersion(SARLVersion.MAXIMAL_JDK_VERSION);
assert maxJdk != null;
return current.compareTo(maxJdk) <= 0;
}
}
}
return false;
} | java | public static boolean isCompatibleJREVersion(String version) {
if (version != null && !version.isEmpty()) {
final Version current = Version.parseVersion(version);
if (current != null) {
final Version minJdk = Version.parseVersion(SARLVersion.MINIMAL_JDK_VERSION);
assert minJdk != null;
if (current.compareTo(minJdk) >= 0) {
final Version maxJdk = Version.parseVersion(SARLVersion.MAXIMAL_JDK_VERSION);
assert maxJdk != null;
return current.compareTo(maxJdk) <= 0;
}
}
}
return false;
} | [
"public",
"static",
"boolean",
"isCompatibleJREVersion",
"(",
"String",
"version",
")",
"{",
"if",
"(",
"version",
"!=",
"null",
"&&",
"!",
"version",
".",
"isEmpty",
"(",
")",
")",
"{",
"final",
"Version",
"current",
"=",
"Version",
".",
"parseVersion",
"... | Check if a version of the JRE is compatible with the SARL library.
@param version - the version to test.
@return <code>true</code> if this version is for a compatible JRE.
Otherwise <code>false</code>. | [
"Check",
"if",
"a",
"version",
"of",
"the",
"JRE",
"is",
"compatible",
"with",
"the",
"SARL",
"library",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L1078-L1092 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.isCompatibleXtextVersion | public static boolean isCompatibleXtextVersion(String version) {
return version != null && !version.isEmpty()
&& compareVersions(version, SARLVersion.MINIMAL_XTEXT_VERSION) >= 0;
} | java | public static boolean isCompatibleXtextVersion(String version) {
return version != null && !version.isEmpty()
&& compareVersions(version, SARLVersion.MINIMAL_XTEXT_VERSION) >= 0;
} | [
"public",
"static",
"boolean",
"isCompatibleXtextVersion",
"(",
"String",
"version",
")",
"{",
"return",
"version",
"!=",
"null",
"&&",
"!",
"version",
".",
"isEmpty",
"(",
")",
"&&",
"compareVersions",
"(",
"version",
",",
"SARLVersion",
".",
"MINIMAL_XTEXT_VER... | Check if a version of Xtext is compatible with the SARL library.
@param version - the version to test.
@return <code>true</code> if this version is for a compatible Xtext.
Otherwise <code>false</code>. | [
"Check",
"if",
"a",
"version",
"of",
"Xtext",
"is",
"compatible",
"with",
"the",
"SARL",
"library",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L1109-L1112 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.isCompatibleXtextVersion | public static boolean isCompatibleXtextVersion() {
final XtextVersion xtextVersion = XtextVersion.getCurrent();
if (xtextVersion != null && !Strings.isNullOrEmpty(xtextVersion.getVersion())) {
return isCompatibleXtextVersion(xtextVersion.getVersion());
}
return false;
} | java | public static boolean isCompatibleXtextVersion() {
final XtextVersion xtextVersion = XtextVersion.getCurrent();
if (xtextVersion != null && !Strings.isNullOrEmpty(xtextVersion.getVersion())) {
return isCompatibleXtextVersion(xtextVersion.getVersion());
}
return false;
} | [
"public",
"static",
"boolean",
"isCompatibleXtextVersion",
"(",
")",
"{",
"final",
"XtextVersion",
"xtextVersion",
"=",
"XtextVersion",
".",
"getCurrent",
"(",
")",
";",
"if",
"(",
"xtextVersion",
"!=",
"null",
"&&",
"!",
"Strings",
".",
"isNullOrEmpty",
"(",
... | Check if a version of the current Xtext is compatible with the SARL library.
@return <code>true</code> if this version is for a compatible Xtext.
Otherwise <code>false</code>. | [
"Check",
"if",
"a",
"version",
"of",
"the",
"current",
"Xtext",
"is",
"compatible",
"with",
"the",
"SARL",
"library",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L1119-L1125 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.isSARLAnnotation | public static boolean isSARLAnnotation(Class<?> type) {
return (type != null && Annotation.class.isAssignableFrom(type))
&& isSARLAnnotation(type.getPackage().getName());
} | java | public static boolean isSARLAnnotation(Class<?> type) {
return (type != null && Annotation.class.isAssignableFrom(type))
&& isSARLAnnotation(type.getPackage().getName());
} | [
"public",
"static",
"boolean",
"isSARLAnnotation",
"(",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"return",
"(",
"type",
"!=",
"null",
"&&",
"Annotation",
".",
"class",
".",
"isAssignableFrom",
"(",
"type",
")",
")",
"&&",
"isSARLAnnotation",
"(",
"type",
... | Replies if the given annotation is an annotation from the SARL core library.
@param type the type of the annotation
@return <code>true</code> if the given type is a SARL annotation. | [
"Replies",
"if",
"the",
"given",
"annotation",
"is",
"an",
"annotation",
"from",
"the",
"SARL",
"core",
"library",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L1206-L1209 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.isFunctionalInterface | public static boolean isFunctionalInterface(JvmGenericType type, IActionPrototypeProvider sarlSignatureProvider) {
if (type != null && type.isInterface()) {
final Map<ActionPrototype, JvmOperation> operations = new HashMap<>();
populateInterfaceElements(type, operations, null, sarlSignatureProvider);
if (operations.size() == 1) {
final JvmOperation op = operations.values().iterator().next();
return !op.isStatic() && !op.isDefault();
}
}
return false;
} | java | public static boolean isFunctionalInterface(JvmGenericType type, IActionPrototypeProvider sarlSignatureProvider) {
if (type != null && type.isInterface()) {
final Map<ActionPrototype, JvmOperation> operations = new HashMap<>();
populateInterfaceElements(type, operations, null, sarlSignatureProvider);
if (operations.size() == 1) {
final JvmOperation op = operations.values().iterator().next();
return !op.isStatic() && !op.isDefault();
}
}
return false;
} | [
"public",
"static",
"boolean",
"isFunctionalInterface",
"(",
"JvmGenericType",
"type",
",",
"IActionPrototypeProvider",
"sarlSignatureProvider",
")",
"{",
"if",
"(",
"type",
"!=",
"null",
"&&",
"type",
".",
"isInterface",
"(",
")",
")",
"{",
"final",
"Map",
"<",... | Replies if the given type is a functional interface.
<p>This function does not test if the {@code @FunctionalInterface} is attached to the type.
The function counts the number of operations.
@param type the type to test.
@param sarlSignatureProvider the provider of SARL operation signatures.
@return <code>true</code> if the given type is final. | [
"Replies",
"if",
"the",
"given",
"type",
"is",
"a",
"functional",
"interface",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L1229-L1239 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.dump | @SuppressWarnings("checkstyle:npathcomplexity")
public static String dump(Object object, boolean includeStaticField) {
if (object == null) {
return new String();
}
final StringBuilder buffer = new StringBuilder();
final LinkedList<Class<?>> types = new LinkedList<>();
types.add(object.getClass());
while (!types.isEmpty()) {
final Class<?> type = types.removeFirst();
final Class<?> supertype = type.getSuperclass();
if (supertype != null && !supertype.equals(Object.class)) {
types.add(supertype);
}
if (buffer.length() > 0) {
buffer.append("\n"); //$NON-NLS-1$
}
final Field[] fields = type.getDeclaredFields();
buffer.append(type.getSimpleName()).append(" {\n"); //$NON-NLS-1$
boolean firstRound = true;
for (final Field field : fields) {
if (!includeStaticField && Flags.isStatic(field.getModifiers())) {
continue;
}
if (!firstRound) {
buffer.append(",\n"); //$NON-NLS-1$
}
firstRound = false;
field.setAccessible(true);
try {
final Object fieldObj = field.get(object);
final String value;
if (null == fieldObj) {
value = "null"; //$NON-NLS-1$
} else {
value = fieldObj.toString();
}
buffer.append('\t').append(field.getName()).append('=').append('"');
buffer.append(org.eclipse.xtext.util.Strings.convertToJavaString(value));
buffer.append("\"\n"); //$NON-NLS-1$
} catch (IllegalAccessException ignore) {
//this should never happen
}
}
buffer.append('}');
}
return buffer.toString();
} | java | @SuppressWarnings("checkstyle:npathcomplexity")
public static String dump(Object object, boolean includeStaticField) {
if (object == null) {
return new String();
}
final StringBuilder buffer = new StringBuilder();
final LinkedList<Class<?>> types = new LinkedList<>();
types.add(object.getClass());
while (!types.isEmpty()) {
final Class<?> type = types.removeFirst();
final Class<?> supertype = type.getSuperclass();
if (supertype != null && !supertype.equals(Object.class)) {
types.add(supertype);
}
if (buffer.length() > 0) {
buffer.append("\n"); //$NON-NLS-1$
}
final Field[] fields = type.getDeclaredFields();
buffer.append(type.getSimpleName()).append(" {\n"); //$NON-NLS-1$
boolean firstRound = true;
for (final Field field : fields) {
if (!includeStaticField && Flags.isStatic(field.getModifiers())) {
continue;
}
if (!firstRound) {
buffer.append(",\n"); //$NON-NLS-1$
}
firstRound = false;
field.setAccessible(true);
try {
final Object fieldObj = field.get(object);
final String value;
if (null == fieldObj) {
value = "null"; //$NON-NLS-1$
} else {
value = fieldObj.toString();
}
buffer.append('\t').append(field.getName()).append('=').append('"');
buffer.append(org.eclipse.xtext.util.Strings.convertToJavaString(value));
buffer.append("\"\n"); //$NON-NLS-1$
} catch (IllegalAccessException ignore) {
//this should never happen
}
}
buffer.append('}');
}
return buffer.toString();
} | [
"@",
"SuppressWarnings",
"(",
"\"checkstyle:npathcomplexity\"",
")",
"public",
"static",
"String",
"dump",
"(",
"Object",
"object",
",",
"boolean",
"includeStaticField",
")",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"{",
"return",
"new",
"String",
"(",
")"... | Dump the object.
@param object the object.
@param includeStaticField indicates if the static fields should be included.
@return the string representation of the object.
@since 0.6 | [
"Dump",
"the",
"object",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L1385-L1438 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.cloneWithTypeParametersAndProxies | public static JvmTypeReference cloneWithTypeParametersAndProxies(
JvmTypeReference type,
Iterable<JvmTypeParameter> executableTypeParameters,
Map<String, JvmTypeReference> superTypeParameterMapping,
JvmTypeReferenceBuilder typeParameterBuilder, JvmTypesBuilder typeBuilder,
TypeReferences typeReferences, TypesFactory jvmTypesFactory) {
if (type == null) {
return typeParameterBuilder.typeRef(Object.class);
}
boolean cloneType = true;
JvmTypeReference typeCandidate = type;
// Use also cloneType as a flag that indicates if the type was already found in type parameters.
if ((executableTypeParameters.iterator().hasNext() || !superTypeParameterMapping.isEmpty()) && cloneType) {
final Map<String, JvmTypeParameter> typeParameterIdentifiers = new TreeMap<>();
for (final JvmTypeParameter typeParameter : executableTypeParameters) {
typeParameterIdentifiers.put(typeParameter.getIdentifier(), typeParameter);
}
if (type instanceof JvmParameterizedTypeReference) {
// Try to clone the type parameters.
cloneType = false;
typeCandidate = cloneAndAssociate(type, typeParameterIdentifiers, superTypeParameterMapping,
typeParameterBuilder, typeReferences, jvmTypesFactory);
} else if (type instanceof XFunctionTypeRef) {
// Try to clone the function reference.
final XFunctionTypeRef functionRef = (XFunctionTypeRef) type;
cloneType = false;
final XFunctionTypeRef cloneReference = XtypeFactory.eINSTANCE.createXFunctionTypeRef();
for (final JvmTypeReference paramType : functionRef.getParamTypes()) {
cloneReference.getParamTypes().add(cloneAndAssociate(
paramType, typeParameterIdentifiers, superTypeParameterMapping,
typeParameterBuilder, typeReferences, jvmTypesFactory));
}
cloneReference.setReturnType(cloneAndAssociate(
functionRef.getReturnType(), typeParameterIdentifiers, superTypeParameterMapping,
typeParameterBuilder, typeReferences, jvmTypesFactory));
cloneReference.setInstanceContext(functionRef.isInstanceContext());
typeCandidate = cloneReference;
}
}
// Do the clone according to the type of the entity.
assert typeCandidate != null;
final JvmTypeReference returnType;
if (!cloneType) {
returnType = typeCandidate;
} else {
returnType = typeBuilder.cloneWithProxies(typeCandidate);
}
return returnType;
} | java | public static JvmTypeReference cloneWithTypeParametersAndProxies(
JvmTypeReference type,
Iterable<JvmTypeParameter> executableTypeParameters,
Map<String, JvmTypeReference> superTypeParameterMapping,
JvmTypeReferenceBuilder typeParameterBuilder, JvmTypesBuilder typeBuilder,
TypeReferences typeReferences, TypesFactory jvmTypesFactory) {
if (type == null) {
return typeParameterBuilder.typeRef(Object.class);
}
boolean cloneType = true;
JvmTypeReference typeCandidate = type;
// Use also cloneType as a flag that indicates if the type was already found in type parameters.
if ((executableTypeParameters.iterator().hasNext() || !superTypeParameterMapping.isEmpty()) && cloneType) {
final Map<String, JvmTypeParameter> typeParameterIdentifiers = new TreeMap<>();
for (final JvmTypeParameter typeParameter : executableTypeParameters) {
typeParameterIdentifiers.put(typeParameter.getIdentifier(), typeParameter);
}
if (type instanceof JvmParameterizedTypeReference) {
// Try to clone the type parameters.
cloneType = false;
typeCandidate = cloneAndAssociate(type, typeParameterIdentifiers, superTypeParameterMapping,
typeParameterBuilder, typeReferences, jvmTypesFactory);
} else if (type instanceof XFunctionTypeRef) {
// Try to clone the function reference.
final XFunctionTypeRef functionRef = (XFunctionTypeRef) type;
cloneType = false;
final XFunctionTypeRef cloneReference = XtypeFactory.eINSTANCE.createXFunctionTypeRef();
for (final JvmTypeReference paramType : functionRef.getParamTypes()) {
cloneReference.getParamTypes().add(cloneAndAssociate(
paramType, typeParameterIdentifiers, superTypeParameterMapping,
typeParameterBuilder, typeReferences, jvmTypesFactory));
}
cloneReference.setReturnType(cloneAndAssociate(
functionRef.getReturnType(), typeParameterIdentifiers, superTypeParameterMapping,
typeParameterBuilder, typeReferences, jvmTypesFactory));
cloneReference.setInstanceContext(functionRef.isInstanceContext());
typeCandidate = cloneReference;
}
}
// Do the clone according to the type of the entity.
assert typeCandidate != null;
final JvmTypeReference returnType;
if (!cloneType) {
returnType = typeCandidate;
} else {
returnType = typeBuilder.cloneWithProxies(typeCandidate);
}
return returnType;
} | [
"public",
"static",
"JvmTypeReference",
"cloneWithTypeParametersAndProxies",
"(",
"JvmTypeReference",
"type",
",",
"Iterable",
"<",
"JvmTypeParameter",
">",
"executableTypeParameters",
",",
"Map",
"<",
"String",
",",
"JvmTypeReference",
">",
"superTypeParameterMapping",
","... | Clone the given type reference that for being link to the given operation.
<p>The proxies are not resolved, and the type parameters are clone when they are
related to the type parameter of the type container.
@param type the source type.
@param executableTypeParameters the type parameters of the executable component that will contain the result type.
@param superTypeParameterMapping the mapping from the type parameters inherited from the super types.
@param typeParameterBuilder the builder if type parameter.
@param typeBuilder the builder of type.
@param typeReferences the builder of type references.
@param jvmTypesFactory the factory of Jvm types.
@return the result type, i.e. a copy of the source type.
@since 0.6 | [
"Clone",
"the",
"given",
"type",
"reference",
"that",
"for",
"being",
"link",
"to",
"the",
"given",
"operation",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L1455-L1507 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.getSuperTypeParameterMap | public static void getSuperTypeParameterMap(JvmDeclaredType type, Map<String, JvmTypeReference> mapping) {
for (final JvmTypeReference superTypeReference : type.getSuperTypes()) {
if (superTypeReference instanceof JvmParameterizedTypeReference) {
final JvmParameterizedTypeReference parameterizedTypeReference = (JvmParameterizedTypeReference) superTypeReference;
final JvmType st = superTypeReference.getType();
if (st instanceof JvmTypeParameterDeclarator) {
final JvmTypeParameterDeclarator superType = (JvmTypeParameterDeclarator) st;
int i = 0;
for (final JvmTypeParameter typeParameter : superType.getTypeParameters()) {
mapping.put(typeParameter.getIdentifier(), parameterizedTypeReference.getArguments().get(i));
++i;
}
}
}
}
} | java | public static void getSuperTypeParameterMap(JvmDeclaredType type, Map<String, JvmTypeReference> mapping) {
for (final JvmTypeReference superTypeReference : type.getSuperTypes()) {
if (superTypeReference instanceof JvmParameterizedTypeReference) {
final JvmParameterizedTypeReference parameterizedTypeReference = (JvmParameterizedTypeReference) superTypeReference;
final JvmType st = superTypeReference.getType();
if (st instanceof JvmTypeParameterDeclarator) {
final JvmTypeParameterDeclarator superType = (JvmTypeParameterDeclarator) st;
int i = 0;
for (final JvmTypeParameter typeParameter : superType.getTypeParameters()) {
mapping.put(typeParameter.getIdentifier(), parameterizedTypeReference.getArguments().get(i));
++i;
}
}
}
}
} | [
"public",
"static",
"void",
"getSuperTypeParameterMap",
"(",
"JvmDeclaredType",
"type",
",",
"Map",
"<",
"String",
",",
"JvmTypeReference",
">",
"mapping",
")",
"{",
"for",
"(",
"final",
"JvmTypeReference",
"superTypeReference",
":",
"type",
".",
"getSuperTypes",
... | Extract the mapping between the type parameters declared within the super types and the
type parameters arguments that are declared within the given type.
<p>For example, consider the following code:
<pre><code>
interface X<T> {
def a(p1 : T, p2 : U) with U
}
interface Y<T> {
}
class Z<TT> implements X<TT>, Y<TT> {
def a(p1 : TT, p2 : W) with W { }
}
</code></pre>
The mapping is:
<pre><code>
X.T => TT
Y.T => TT
</code></pre>
@param type the type to analyze.
@param mapping the map to fill with the mapping.
@since 0.7 | [
"Extract",
"the",
"mapping",
"between",
"the",
"type",
"parameters",
"declared",
"within",
"the",
"super",
"types",
"and",
"the",
"type",
"parameters",
"arguments",
"that",
"are",
"declared",
"within",
"the",
"given",
"type",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L1590-L1605 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.setStructuralFeature | public static void setStructuralFeature(EObject object, EStructuralFeature property, Object value) {
assert object != null;
assert property != null;
if (value == null) {
object.eUnset(property);
} else {
object.eSet(property, value);
}
} | java | public static void setStructuralFeature(EObject object, EStructuralFeature property, Object value) {
assert object != null;
assert property != null;
if (value == null) {
object.eUnset(property);
} else {
object.eSet(property, value);
}
} | [
"public",
"static",
"void",
"setStructuralFeature",
"(",
"EObject",
"object",
",",
"EStructuralFeature",
"property",
",",
"Object",
"value",
")",
"{",
"assert",
"object",
"!=",
"null",
";",
"assert",
"property",
"!=",
"null",
";",
"if",
"(",
"value",
"==",
"... | Set the given structure feature with the given value.
@param object the object that contains the feature.
@param property the feature to change.
@param value the value of the feature. | [
"Set",
"the",
"given",
"structure",
"feature",
"with",
"the",
"given",
"value",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L1696-L1704 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.getRootFeatureCall | public static XAbstractFeatureCall getRootFeatureCall(XAbstractFeatureCall featureCall) {
final EObject container = featureCall.eContainer();
final XAbstractFeatureCall rootFeatureCall;
if (container instanceof XMemberFeatureCall || container instanceof XFeatureCall) {
rootFeatureCall = (XAbstractFeatureCall) getFirstContainerForPredicate(featureCall,
it -> it.eContainer() != null && !(it.eContainer() instanceof XMemberFeatureCall || it.eContainer() instanceof XFeatureCall));
} else {
rootFeatureCall = featureCall;
}
return rootFeatureCall;
} | java | public static XAbstractFeatureCall getRootFeatureCall(XAbstractFeatureCall featureCall) {
final EObject container = featureCall.eContainer();
final XAbstractFeatureCall rootFeatureCall;
if (container instanceof XMemberFeatureCall || container instanceof XFeatureCall) {
rootFeatureCall = (XAbstractFeatureCall) getFirstContainerForPredicate(featureCall,
it -> it.eContainer() != null && !(it.eContainer() instanceof XMemberFeatureCall || it.eContainer() instanceof XFeatureCall));
} else {
rootFeatureCall = featureCall;
}
return rootFeatureCall;
} | [
"public",
"static",
"XAbstractFeatureCall",
"getRootFeatureCall",
"(",
"XAbstractFeatureCall",
"featureCall",
")",
"{",
"final",
"EObject",
"container",
"=",
"featureCall",
".",
"eContainer",
"(",
")",
";",
"final",
"XAbstractFeatureCall",
"rootFeatureCall",
";",
"if",
... | Replies the root feature call into a sequence of feature calls.
@param featureCall the leaf feature call.
@return the root feature call.
@since 0.8.6
@see #getRootFeatureCall(XAbstractFeatureCall, XExpression, List) | [
"Replies",
"the",
"root",
"feature",
"call",
"into",
"a",
"sequence",
"of",
"feature",
"calls",
"."
] | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L1713-L1723 | train |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.getRootFeatureCall | public static XAbstractFeatureCall getRootFeatureCall(XAbstractFeatureCall featureCall,
XExpression container, List<JvmFormalParameter> containerParameters) {
if (hasLocalParameters(featureCall, container, containerParameters)
|| !(featureCall instanceof XMemberFeatureCall || featureCall instanceof XFeatureCall)) {
return null;
}
XAbstractFeatureCall current = featureCall;
EObject currentContainer = current.eContainer();
while (currentContainer != null) {
if (currentContainer instanceof XMemberFeatureCall || currentContainer instanceof XFeatureCall) {
final XAbstractFeatureCall c = (XAbstractFeatureCall) currentContainer;
if (hasLocalParameters(c, container, containerParameters)) {
return current;
}
current = c;
currentContainer = current.eContainer();
} else {
return current;
}
}
return current;
} | java | public static XAbstractFeatureCall getRootFeatureCall(XAbstractFeatureCall featureCall,
XExpression container, List<JvmFormalParameter> containerParameters) {
if (hasLocalParameters(featureCall, container, containerParameters)
|| !(featureCall instanceof XMemberFeatureCall || featureCall instanceof XFeatureCall)) {
return null;
}
XAbstractFeatureCall current = featureCall;
EObject currentContainer = current.eContainer();
while (currentContainer != null) {
if (currentContainer instanceof XMemberFeatureCall || currentContainer instanceof XFeatureCall) {
final XAbstractFeatureCall c = (XAbstractFeatureCall) currentContainer;
if (hasLocalParameters(c, container, containerParameters)) {
return current;
}
current = c;
currentContainer = current.eContainer();
} else {
return current;
}
}
return current;
} | [
"public",
"static",
"XAbstractFeatureCall",
"getRootFeatureCall",
"(",
"XAbstractFeatureCall",
"featureCall",
",",
"XExpression",
"container",
",",
"List",
"<",
"JvmFormalParameter",
">",
"containerParameters",
")",
"{",
"if",
"(",
"hasLocalParameters",
"(",
"featureCall"... | Replies the root feature call into a sequence of feature calls that has
not reference to elements declared within the container, and that are
not one of the container's parameters.
@param featureCall the leaf feature call.
@param container the container of the feature call.
@param containerParameters the parameters of the container.
@return the root feature call, or {@code null} if there is no root feature call.
@since 0.8.6
@see #getRootFeatureCall(XAbstractFeatureCall) | [
"Replies",
"the",
"root",
"feature",
"call",
"into",
"a",
"sequence",
"of",
"feature",
"calls",
"that",
"has",
"not",
"reference",
"to",
"elements",
"declared",
"within",
"the",
"container",
"and",
"that",
"are",
"not",
"one",
"of",
"the",
"container",
"s",
... | ca00ff994598c730339972def4e19a60e0b8cace | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L1736-L1757 | train |
amzn/ion-java | src/com/amazon/ion/impl/IonWriterSystem.java | IonWriterSystem.isFieldNameSet | @Override
public final boolean isFieldNameSet()
{
if (_field_name_type != null) {
switch (_field_name_type) {
case STRING:
return _field_name != null;
case INT:
return _field_name_sid >= 0;
default:
break;
}
}
return false;
} | java | @Override
public final boolean isFieldNameSet()
{
if (_field_name_type != null) {
switch (_field_name_type) {
case STRING:
return _field_name != null;
case INT:
return _field_name_sid >= 0;
default:
break;
}
}
return false;
} | [
"@",
"Override",
"public",
"final",
"boolean",
"isFieldNameSet",
"(",
")",
"{",
"if",
"(",
"_field_name_type",
"!=",
"null",
")",
"{",
"switch",
"(",
"_field_name_type",
")",
"{",
"case",
"STRING",
":",
"return",
"_field_name",
"!=",
"null",
";",
"case",
"... | not supported. | [
"not",
"supported",
"."
] | 4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270 | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/impl/IonWriterSystem.java#L341-L355 | train |
amzn/ion-java | src/com/amazon/ion/impl/LocalSymbolTable.java | LocalSymbolTable.putSymbol | int putSymbol(String symbolName)
{
if (isReadOnly)
{
throw new ReadOnlyValueException(SymbolTable.class);
}
if (mySymbolsCount == mySymbolNames.length)
{
int newlen = mySymbolsCount * 2;
if (newlen < DEFAULT_CAPACITY)
{
newlen = DEFAULT_CAPACITY;
}
String[] temp = new String[newlen];
System.arraycopy(mySymbolNames, 0, temp, 0, mySymbolsCount);
mySymbolNames = temp;
}
int sid = -1;
if (symbolName != null)
{
sid = mySymbolsCount + myFirstLocalSid;
assert sid == getMaxId() + 1;
putToMapIfNotThere(mySymbolsMap, symbolName, sid);
}
mySymbolNames[mySymbolsCount] = symbolName;
mySymbolsCount++;
return sid;
} | java | int putSymbol(String symbolName)
{
if (isReadOnly)
{
throw new ReadOnlyValueException(SymbolTable.class);
}
if (mySymbolsCount == mySymbolNames.length)
{
int newlen = mySymbolsCount * 2;
if (newlen < DEFAULT_CAPACITY)
{
newlen = DEFAULT_CAPACITY;
}
String[] temp = new String[newlen];
System.arraycopy(mySymbolNames, 0, temp, 0, mySymbolsCount);
mySymbolNames = temp;
}
int sid = -1;
if (symbolName != null)
{
sid = mySymbolsCount + myFirstLocalSid;
assert sid == getMaxId() + 1;
putToMapIfNotThere(mySymbolsMap, symbolName, sid);
}
mySymbolNames[mySymbolsCount] = symbolName;
mySymbolsCount++;
return sid;
} | [
"int",
"putSymbol",
"(",
"String",
"symbolName",
")",
"{",
"if",
"(",
"isReadOnly",
")",
"{",
"throw",
"new",
"ReadOnlyValueException",
"(",
"SymbolTable",
".",
"class",
")",
";",
"}",
"if",
"(",
"mySymbolsCount",
"==",
"mySymbolNames",
".",
"length",
")",
... | NOT SYNCHRONIZED! Call within constructor or from synch'd method. | [
"NOT",
"SYNCHRONIZED!",
"Call",
"within",
"constructor",
"or",
"from",
"synch",
"d",
"method",
"."
] | 4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270 | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/impl/LocalSymbolTable.java#L534-L566 | train |
amzn/ion-java | src/com/amazon/ion/impl/LocalSymbolTable.java | LocalSymbolTable.symtabExtends | boolean symtabExtends(SymbolTable other)
{
// Throws ClassCastException if other isn't a local symtab
LocalSymbolTable subset = (LocalSymbolTable) other;
// Gather snapshots of each LST's data, so we don't
// Superset must have same/more known symbols than subset.
if (getMaxId() < subset.getMaxId()) return false;
// TODO amzn/ion-java/issues/18 Currently, we check imports by their refs. which
// might be overly strict; imports which are not the same ref.
// but have the same semantic states fails the extension check.
if (! myImportsList.equalImports(subset.myImportsList))
return false;
int subLocalSymbolCount = subset.mySymbolsCount;
// Superset extends subset if subset doesn't have any declared symbols.
if (subLocalSymbolCount == 0) return true;
// Superset must have same/more declared (local) symbols than subset.
if (mySymbolsCount < subLocalSymbolCount) return false;
String[] subsetSymbols = subset.mySymbolNames;
// Before we go through the expensive iteration from the front,
// check the last (largest) declared symbol in subset beforehand
if (! safeEquals(mySymbolNames[subLocalSymbolCount- 1],
subsetSymbols[subLocalSymbolCount- 1]))
{
return false;
}
// Now, we iterate from the first declared symbol, note that the
// iteration below is O(n)!
for (int i = 0; i < subLocalSymbolCount - 1; i++)
{
if (! safeEquals(mySymbolNames[i], subsetSymbols[i]))
return false;
}
return true;
} | java | boolean symtabExtends(SymbolTable other)
{
// Throws ClassCastException if other isn't a local symtab
LocalSymbolTable subset = (LocalSymbolTable) other;
// Gather snapshots of each LST's data, so we don't
// Superset must have same/more known symbols than subset.
if (getMaxId() < subset.getMaxId()) return false;
// TODO amzn/ion-java/issues/18 Currently, we check imports by their refs. which
// might be overly strict; imports which are not the same ref.
// but have the same semantic states fails the extension check.
if (! myImportsList.equalImports(subset.myImportsList))
return false;
int subLocalSymbolCount = subset.mySymbolsCount;
// Superset extends subset if subset doesn't have any declared symbols.
if (subLocalSymbolCount == 0) return true;
// Superset must have same/more declared (local) symbols than subset.
if (mySymbolsCount < subLocalSymbolCount) return false;
String[] subsetSymbols = subset.mySymbolNames;
// Before we go through the expensive iteration from the front,
// check the last (largest) declared symbol in subset beforehand
if (! safeEquals(mySymbolNames[subLocalSymbolCount- 1],
subsetSymbols[subLocalSymbolCount- 1]))
{
return false;
}
// Now, we iterate from the first declared symbol, note that the
// iteration below is O(n)!
for (int i = 0; i < subLocalSymbolCount - 1; i++)
{
if (! safeEquals(mySymbolNames[i], subsetSymbols[i]))
return false;
}
return true;
} | [
"boolean",
"symtabExtends",
"(",
"SymbolTable",
"other",
")",
"{",
"// Throws ClassCastException if other isn't a local symtab",
"LocalSymbolTable",
"subset",
"=",
"(",
"LocalSymbolTable",
")",
"other",
";",
"// Gather snapshots of each LST's data, so we don't",
"// Superset must h... | This method, and the context from which it is called, assumes that the
symtabs are not being mutated by another thread.
Therefore it doesn't use synchronization. | [
"This",
"method",
"and",
"the",
"context",
"from",
"which",
"it",
"is",
"called",
"assumes",
"that",
"the",
"symtabs",
"are",
"not",
"being",
"mutated",
"by",
"another",
"thread",
".",
"Therefore",
"it",
"doesn",
"t",
"use",
"synchronization",
"."
] | 4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270 | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/impl/LocalSymbolTable.java#L819-L862 | train |
amzn/ion-java | src/com/amazon/ion/impl/_Private_Utils.java | _Private_Utils.newSymbolToken | public static SymbolToken newSymbolToken(SymbolTable symtab,
String text)
{
// TODO amzn/ion-java/issues/21 symtab should not be null
text.getClass(); // quick null check
SymbolToken tok = (symtab == null ? null : symtab.find(text));
if (tok == null)
{
tok = new SymbolTokenImpl(text, UNKNOWN_SYMBOL_ID);
}
return tok;
} | java | public static SymbolToken newSymbolToken(SymbolTable symtab,
String text)
{
// TODO amzn/ion-java/issues/21 symtab should not be null
text.getClass(); // quick null check
SymbolToken tok = (symtab == null ? null : symtab.find(text));
if (tok == null)
{
tok = new SymbolTokenImpl(text, UNKNOWN_SYMBOL_ID);
}
return tok;
} | [
"public",
"static",
"SymbolToken",
"newSymbolToken",
"(",
"SymbolTable",
"symtab",
",",
"String",
"text",
")",
"{",
"// TODO amzn/ion-java/issues/21 symtab should not be null",
"text",
".",
"getClass",
"(",
")",
";",
"// quick null check",
"SymbolToken",
"tok",
"=",
"("... | Checks symbol content.
@return not null | [
"Checks",
"symbol",
"content",
"."
] | 4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270 | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/impl/_Private_Utils.java#L208-L220 | train |
amzn/ion-java | src/com/amazon/ion/impl/_Private_Utils.java | _Private_Utils.newSymbolTokens | public static SymbolToken[] newSymbolTokens(SymbolTable symtab,
String... text)
{
if (text != null)
{
int count = text.length;
if (count != 0)
{
SymbolToken[] result = new SymbolToken[count];
for (int i = 0; i < count; i++)
{
String s = text[i];
result[i] = newSymbolToken(symtab, s);
}
return result;
}
}
return SymbolToken.EMPTY_ARRAY;
} | java | public static SymbolToken[] newSymbolTokens(SymbolTable symtab,
String... text)
{
if (text != null)
{
int count = text.length;
if (count != 0)
{
SymbolToken[] result = new SymbolToken[count];
for (int i = 0; i < count; i++)
{
String s = text[i];
result[i] = newSymbolToken(symtab, s);
}
return result;
}
}
return SymbolToken.EMPTY_ARRAY;
} | [
"public",
"static",
"SymbolToken",
"[",
"]",
"newSymbolTokens",
"(",
"SymbolTable",
"symtab",
",",
"String",
"...",
"text",
")",
"{",
"if",
"(",
"text",
"!=",
"null",
")",
"{",
"int",
"count",
"=",
"text",
".",
"length",
";",
"if",
"(",
"count",
"!=",
... | Validates each text element.
@param text may be null or empty.
@return not null. | [
"Validates",
"each",
"text",
"element",
"."
] | 4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270 | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/impl/_Private_Utils.java#L240-L258 | train |
amzn/ion-java | src/com/amazon/ion/impl/_Private_Utils.java | _Private_Utils.toStrings | public static String[] toStrings(SymbolToken[] symbols, int count)
{
if (count == 0) return _Private_Utils.EMPTY_STRING_ARRAY;
String[] annotations = new String[count];
for (int i = 0; i < count; i++)
{
SymbolToken tok = symbols[i];
String text = tok.getText();
if (text == null)
{
throw new UnknownSymbolException(tok.getSid());
}
annotations[i] = text;
}
return annotations;
} | java | public static String[] toStrings(SymbolToken[] symbols, int count)
{
if (count == 0) return _Private_Utils.EMPTY_STRING_ARRAY;
String[] annotations = new String[count];
for (int i = 0; i < count; i++)
{
SymbolToken tok = symbols[i];
String text = tok.getText();
if (text == null)
{
throw new UnknownSymbolException(tok.getSid());
}
annotations[i] = text;
}
return annotations;
} | [
"public",
"static",
"String",
"[",
"]",
"toStrings",
"(",
"SymbolToken",
"[",
"]",
"symbols",
",",
"int",
"count",
")",
"{",
"if",
"(",
"count",
"==",
"0",
")",
"return",
"_Private_Utils",
".",
"EMPTY_STRING_ARRAY",
";",
"String",
"[",
"]",
"annotations",
... | Extracts the non-null text from a list of symbol tokens.
@return not null.
@throws UnknownSymbolException if any token is missing text. | [
"Extracts",
"the",
"non",
"-",
"null",
"text",
"from",
"a",
"list",
"of",
"symbol",
"tokens",
"."
] | 4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270 | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/impl/_Private_Utils.java#L358-L374 | train |
amzn/ion-java | src/com/amazon/ion/impl/_Private_Utils.java | _Private_Utils.iterate | public static Iterator<IonValue> iterate(ValueFactory valueFactory,
IonReader input)
{
return new IonIteratorImpl(valueFactory, input);
} | java | public static Iterator<IonValue> iterate(ValueFactory valueFactory,
IonReader input)
{
return new IonIteratorImpl(valueFactory, input);
} | [
"public",
"static",
"Iterator",
"<",
"IonValue",
">",
"iterate",
"(",
"ValueFactory",
"valueFactory",
",",
"IonReader",
"input",
")",
"{",
"return",
"new",
"IonIteratorImpl",
"(",
"valueFactory",
",",
"input",
")",
";",
"}"
] | Create a value iterator from a reader.
Primarily a trampoline for access permission. | [
"Create",
"a",
"value",
"iterator",
"from",
"a",
"reader",
".",
"Primarily",
"a",
"trampoline",
"for",
"access",
"permission",
"."
] | 4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270 | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/impl/_Private_Utils.java#L661-L665 | train |
amzn/ion-java | src/com/amazon/ion/impl/_Private_Utils.java | _Private_Utils.isTrivialTable | public static boolean isTrivialTable(SymbolTable table)
{
if (table == null) return true;
if (table.isSystemTable()) return true;
if (table.isLocalTable()) {
// this is only true when there are no local
// symbols defined
// and there are no imports with any symbols
if (table.getMaxId() == table.getSystemSymbolTable().getMaxId()) {
return true;
}
}
return false;
} | java | public static boolean isTrivialTable(SymbolTable table)
{
if (table == null) return true;
if (table.isSystemTable()) return true;
if (table.isLocalTable()) {
// this is only true when there are no local
// symbols defined
// and there are no imports with any symbols
if (table.getMaxId() == table.getSystemSymbolTable().getMaxId()) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"isTrivialTable",
"(",
"SymbolTable",
"table",
")",
"{",
"if",
"(",
"table",
"==",
"null",
")",
"return",
"true",
";",
"if",
"(",
"table",
".",
"isSystemTable",
"(",
")",
")",
"return",
"true",
";",
"if",
"(",
"table",
".... | Is the table null, system, or local without imported symbols? | [
"Is",
"the",
"table",
"null",
"system",
"or",
"local",
"without",
"imported",
"symbols?"
] | 4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270 | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/impl/_Private_Utils.java#L716-L729 | train |
amzn/ion-java | src/com/amazon/ion/impl/_Private_Utils.java | _Private_Utils.copyLocalSymbolTable | public static SymbolTable copyLocalSymbolTable(SymbolTable symtab)
throws SubstituteSymbolTableException
{
if (! symtab.isLocalTable())
{
String message = "symtab should be a local symtab";
throw new IllegalArgumentException(message);
}
SymbolTable[] imports =
((LocalSymbolTable) symtab).getImportedTablesNoCopy();
// Iterate over each import, we assume that the list of imports
// rarely exceeds 5.
for (int i = 0; i < imports.length; i++)
{
if (imports[i].isSubstitute())
{
String message =
"local symtabs with substituted symtabs for imports " +
"(indicating no exact match within the catalog) cannot " +
"be copied";
throw new SubstituteSymbolTableException(message);
}
}
return ((LocalSymbolTable) symtab).makeCopy();
} | java | public static SymbolTable copyLocalSymbolTable(SymbolTable symtab)
throws SubstituteSymbolTableException
{
if (! symtab.isLocalTable())
{
String message = "symtab should be a local symtab";
throw new IllegalArgumentException(message);
}
SymbolTable[] imports =
((LocalSymbolTable) symtab).getImportedTablesNoCopy();
// Iterate over each import, we assume that the list of imports
// rarely exceeds 5.
for (int i = 0; i < imports.length; i++)
{
if (imports[i].isSubstitute())
{
String message =
"local symtabs with substituted symtabs for imports " +
"(indicating no exact match within the catalog) cannot " +
"be copied";
throw new SubstituteSymbolTableException(message);
}
}
return ((LocalSymbolTable) symtab).makeCopy();
} | [
"public",
"static",
"SymbolTable",
"copyLocalSymbolTable",
"(",
"SymbolTable",
"symtab",
")",
"throws",
"SubstituteSymbolTableException",
"{",
"if",
"(",
"!",
"symtab",
".",
"isLocalTable",
"(",
")",
")",
"{",
"String",
"message",
"=",
"\"symtab should be a local symt... | local symtab has substituted symtabs for imports. | [
"local",
"symtab",
"has",
"substituted",
"symtabs",
"for",
"imports",
"."
] | 4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270 | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/impl/_Private_Utils.java#L793-L820 | train |
amzn/ion-java | src/com/amazon/ion/impl/_Private_Utils.java | _Private_Utils.initialSymtab | public static SymbolTable initialSymtab(_Private_LocalSymbolTableFactory lstFactory,
SymbolTable defaultSystemSymtab,
SymbolTable... imports)
{
if (imports == null || imports.length == 0)
{
return defaultSystemSymtab;
}
if (imports.length == 1 && imports[0].isSystemTable())
{
return imports[0];
}
return lstFactory.newLocalSymtab(defaultSystemSymtab, imports);
} | java | public static SymbolTable initialSymtab(_Private_LocalSymbolTableFactory lstFactory,
SymbolTable defaultSystemSymtab,
SymbolTable... imports)
{
if (imports == null || imports.length == 0)
{
return defaultSystemSymtab;
}
if (imports.length == 1 && imports[0].isSystemTable())
{
return imports[0];
}
return lstFactory.newLocalSymtab(defaultSystemSymtab, imports);
} | [
"public",
"static",
"SymbolTable",
"initialSymtab",
"(",
"_Private_LocalSymbolTableFactory",
"lstFactory",
",",
"SymbolTable",
"defaultSystemSymtab",
",",
"SymbolTable",
"...",
"imports",
")",
"{",
"if",
"(",
"imports",
"==",
"null",
"||",
"imports",
".",
"length",
... | Returns a minimal symtab that, either system or local depending on the
given values, that supports representation as an IonStruct. If the
imports are empty, the default system symtab is returned.
@param lstFactory
the factory to use to build the local symbol table, never null
@param defaultSystemSymtab
the default system symtab, which will be used if the first
import in {@code imports} isn't a system symtab, never null
@param imports
the set of shared symbol tables to import; may be null or empty.
The first (and only the first) may be a system table, in which case the
{@code defaultSystemSymtab} is ignored. | [
"Returns",
"a",
"minimal",
"symtab",
"that",
"either",
"system",
"or",
"local",
"depending",
"on",
"the",
"given",
"values",
"that",
"supports",
"representation",
"as",
"an",
"IonStruct",
".",
"If",
"the",
"imports",
"are",
"empty",
"the",
"default",
"system",... | 4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270 | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/impl/_Private_Utils.java#L851-L866 | train |
amzn/ion-java | src/com/amazon/ion/impl/_Private_Utils.java | _Private_Utils.isNonSymbolScalar | public static boolean isNonSymbolScalar(IonType type)
{
return ! IonType.isContainer(type) && ! type.equals(IonType.SYMBOL);
} | java | public static boolean isNonSymbolScalar(IonType type)
{
return ! IonType.isContainer(type) && ! type.equals(IonType.SYMBOL);
} | [
"public",
"static",
"boolean",
"isNonSymbolScalar",
"(",
"IonType",
"type",
")",
"{",
"return",
"!",
"IonType",
".",
"isContainer",
"(",
"type",
")",
"&&",
"!",
"type",
".",
"equals",
"(",
"IonType",
".",
"SYMBOL",
")",
";",
"}"
] | Determines whether the passed-in data type is a scalar and not a symbol. | [
"Determines",
"whether",
"the",
"passed",
"-",
"in",
"data",
"type",
"is",
"a",
"scalar",
"and",
"not",
"a",
"symbol",
"."
] | 4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270 | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/impl/_Private_Utils.java#L991-L994 | train |
amzn/ion-java | src/com/amazon/ion/impl/_Private_Utils.java | _Private_Utils.getSidForSymbolTableField | public static final int getSidForSymbolTableField(String text)
{
final int shortestFieldNameLength = 4; // 'name'
if (text != null && text.length() >= shortestFieldNameLength)
{
int c = text.charAt(0);
switch (c)
{
case 'v':
if (VERSION.equals(text))
{
return VERSION_SID;
}
break;
case 'n':
if (NAME.equals(text))
{
return NAME_SID;
}
break;
case 's':
if (SYMBOLS.equals(text))
{
return SYMBOLS_SID;
}
break;
case 'i':
if (IMPORTS.equals(text))
{
return IMPORTS_SID;
}
break;
case 'm':
if (MAX_ID.equals(text))
{
return MAX_ID_SID;
}
break;
default:
break;
}
}
return UNKNOWN_SYMBOL_ID;
} | java | public static final int getSidForSymbolTableField(String text)
{
final int shortestFieldNameLength = 4; // 'name'
if (text != null && text.length() >= shortestFieldNameLength)
{
int c = text.charAt(0);
switch (c)
{
case 'v':
if (VERSION.equals(text))
{
return VERSION_SID;
}
break;
case 'n':
if (NAME.equals(text))
{
return NAME_SID;
}
break;
case 's':
if (SYMBOLS.equals(text))
{
return SYMBOLS_SID;
}
break;
case 'i':
if (IMPORTS.equals(text))
{
return IMPORTS_SID;
}
break;
case 'm':
if (MAX_ID.equals(text))
{
return MAX_ID_SID;
}
break;
default:
break;
}
}
return UNKNOWN_SYMBOL_ID;
} | [
"public",
"static",
"final",
"int",
"getSidForSymbolTableField",
"(",
"String",
"text",
")",
"{",
"final",
"int",
"shortestFieldNameLength",
"=",
"4",
";",
"// 'name'",
"if",
"(",
"text",
"!=",
"null",
"&&",
"text",
".",
"length",
"(",
")",
">=",
"shortestFi... | Returns the symbol ID matching a system symbol text of a
local or shared symtab field. | [
"Returns",
"the",
"symbol",
"ID",
"matching",
"a",
"system",
"symbol",
"text",
"of",
"a",
"local",
"or",
"shared",
"symtab",
"field",
"."
] | 4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270 | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/impl/_Private_Utils.java#L1001-L1046 | train |
amzn/ion-java | src/com/amazon/ion/Timestamp.java | Timestamp.make_localtime | private Timestamp make_localtime()
{
int offset = _offset != null
? _offset.intValue()
: 0;
// We use a Copy-Constructor that expects the time parameters to be in
// UTC, as that's what we're supposed to have.
// As this Copy-Constructor doesn't apply local offset to the time
// field values (it assumes that the local offset is already applied to
// them), we explicitly apply the local offset to the time field values
// after we obtain the new Timestamp instance.
Timestamp localtime = new Timestamp(_precision,
_year,
_month,
_day,
_hour,
_minute,
_second,
_fraction,
_offset,
APPLY_OFFSET_NO);
// explicitly apply the local offset to the time field values
localtime.apply_offset(-offset);
assert localtime._offset == _offset;
return localtime;
} | java | private Timestamp make_localtime()
{
int offset = _offset != null
? _offset.intValue()
: 0;
// We use a Copy-Constructor that expects the time parameters to be in
// UTC, as that's what we're supposed to have.
// As this Copy-Constructor doesn't apply local offset to the time
// field values (it assumes that the local offset is already applied to
// them), we explicitly apply the local offset to the time field values
// after we obtain the new Timestamp instance.
Timestamp localtime = new Timestamp(_precision,
_year,
_month,
_day,
_hour,
_minute,
_second,
_fraction,
_offset,
APPLY_OFFSET_NO);
// explicitly apply the local offset to the time field values
localtime.apply_offset(-offset);
assert localtime._offset == _offset;
return localtime;
} | [
"private",
"Timestamp",
"make_localtime",
"(",
")",
"{",
"int",
"offset",
"=",
"_offset",
"!=",
"null",
"?",
"_offset",
".",
"intValue",
"(",
")",
":",
"0",
";",
"// We use a Copy-Constructor that expects the time parameters to be in",
"// UTC, as that's what we're suppos... | Applies the local offset from UTC to each of the applicable time field
values and returns the new Timestamp. In short, this makes the Timestamp
represent local time.
@return a new Timestamp in its local time | [
"Applies",
"the",
"local",
"offset",
"from",
"UTC",
"to",
"each",
"of",
"the",
"applicable",
"time",
"field",
"values",
"and",
"returns",
"the",
"new",
"Timestamp",
".",
"In",
"short",
"this",
"makes",
"the",
"Timestamp",
"represent",
"local",
"time",
"."
] | 4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270 | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/Timestamp.java#L1192-L1220 | train |
amzn/ion-java | src/com/amazon/ion/Timestamp.java | Timestamp.getYear | public int getYear()
{
Timestamp adjusted = this;
if (this._offset != null) {
if (this._offset.intValue() != 0) {
adjusted = make_localtime();
}
}
return adjusted._year;
} | java | public int getYear()
{
Timestamp adjusted = this;
if (this._offset != null) {
if (this._offset.intValue() != 0) {
adjusted = make_localtime();
}
}
return adjusted._year;
} | [
"public",
"int",
"getYear",
"(",
")",
"{",
"Timestamp",
"adjusted",
"=",
"this",
";",
"if",
"(",
"this",
".",
"_offset",
"!=",
"null",
")",
"{",
"if",
"(",
"this",
".",
"_offset",
".",
"intValue",
"(",
")",
"!=",
"0",
")",
"{",
"adjusted",
"=",
"... | Returns the year of this Timestamp, in its local time.
@return
a number within the range [1, 9999], in its local time | [
"Returns",
"the",
"year",
"of",
"this",
"Timestamp",
"in",
"its",
"local",
"time",
"."
] | 4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270 | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/Timestamp.java#L1649-L1659 | train |
amzn/ion-java | src/com/amazon/ion/Timestamp.java | Timestamp.getMonth | public int getMonth()
{
Timestamp adjusted = this;
if (this._offset != null) {
if (this._offset.intValue() != 0) {
adjusted = make_localtime();
}
}
return adjusted._month;
} | java | public int getMonth()
{
Timestamp adjusted = this;
if (this._offset != null) {
if (this._offset.intValue() != 0) {
adjusted = make_localtime();
}
}
return adjusted._month;
} | [
"public",
"int",
"getMonth",
"(",
")",
"{",
"Timestamp",
"adjusted",
"=",
"this",
";",
"if",
"(",
"this",
".",
"_offset",
"!=",
"null",
")",
"{",
"if",
"(",
"this",
".",
"_offset",
".",
"intValue",
"(",
")",
"!=",
"0",
")",
"{",
"adjusted",
"=",
... | Returns the month of this Timestamp, in its local time.
@return
a number within the range [1, 12], whereby 1 refers to January
and 12 refers to December, in its local time;
1 is returned if the Timestamp isn't precise to
the month | [
"Returns",
"the",
"month",
"of",
"this",
"Timestamp",
"in",
"its",
"local",
"time",
"."
] | 4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270 | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/Timestamp.java#L1671-L1681 | train |
amzn/ion-java | src/com/amazon/ion/Timestamp.java | Timestamp.getHour | public int getHour()
{
Timestamp adjusted = this;
if (this._offset != null) {
if (this._offset.intValue() != 0) {
adjusted = make_localtime();
}
}
return adjusted._hour;
} | java | public int getHour()
{
Timestamp adjusted = this;
if (this._offset != null) {
if (this._offset.intValue() != 0) {
adjusted = make_localtime();
}
}
return adjusted._hour;
} | [
"public",
"int",
"getHour",
"(",
")",
"{",
"Timestamp",
"adjusted",
"=",
"this",
";",
"if",
"(",
"this",
".",
"_offset",
"!=",
"null",
")",
"{",
"if",
"(",
"this",
".",
"_offset",
".",
"intValue",
"(",
")",
"!=",
"0",
")",
"{",
"adjusted",
"=",
"... | Returns the hour of this Timestamp, in its local time.
@return
a number within the range [0, 23], in its local time;
0 is returned if the Timestamp isn't
precise to the hour | [
"Returns",
"the",
"hour",
"of",
"this",
"Timestamp",
"in",
"its",
"local",
"time",
"."
] | 4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270 | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/Timestamp.java#L1712-L1721 | train |
amzn/ion-java | src/com/amazon/ion/Timestamp.java | Timestamp.getMinute | public int getMinute()
{
Timestamp adjusted = this;
if (this._offset != null) {
if (this._offset.intValue() != 0) {
adjusted = make_localtime();
}
}
return adjusted._minute;
} | java | public int getMinute()
{
Timestamp adjusted = this;
if (this._offset != null) {
if (this._offset.intValue() != 0) {
adjusted = make_localtime();
}
}
return adjusted._minute;
} | [
"public",
"int",
"getMinute",
"(",
")",
"{",
"Timestamp",
"adjusted",
"=",
"this",
";",
"if",
"(",
"this",
".",
"_offset",
"!=",
"null",
")",
"{",
"if",
"(",
"this",
".",
"_offset",
".",
"intValue",
"(",
")",
"!=",
"0",
")",
"{",
"adjusted",
"=",
... | Returns the minute of this Timestamp, in its local time.
@return
a number within the range [0, 59], in its local time;
0 is returned if the Timestamp isn't
precise to the minute | [
"Returns",
"the",
"minute",
"of",
"this",
"Timestamp",
"in",
"its",
"local",
"time",
"."
] | 4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270 | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/Timestamp.java#L1732-L1741 | train |
amzn/ion-java | src/com/amazon/ion/Timestamp.java | Timestamp.withLocalOffset | public Timestamp withLocalOffset(Integer offset)
{
Precision precision = getPrecision();
if (precision.alwaysUnknownOffset() ||
safeEquals(offset, getLocalOffset()))
{
return this;
}
Timestamp ts = createFromUtcFields(precision,
getZYear(),
getZMonth(),
getZDay(),
getZHour(),
getZMinute(),
getZSecond(),
getZFractionalSecond(),
offset);
return ts;
} | java | public Timestamp withLocalOffset(Integer offset)
{
Precision precision = getPrecision();
if (precision.alwaysUnknownOffset() ||
safeEquals(offset, getLocalOffset()))
{
return this;
}
Timestamp ts = createFromUtcFields(precision,
getZYear(),
getZMonth(),
getZDay(),
getZHour(),
getZMinute(),
getZSecond(),
getZFractionalSecond(),
offset);
return ts;
} | [
"public",
"Timestamp",
"withLocalOffset",
"(",
"Integer",
"offset",
")",
"{",
"Precision",
"precision",
"=",
"getPrecision",
"(",
")",
";",
"if",
"(",
"precision",
".",
"alwaysUnknownOffset",
"(",
")",
"||",
"safeEquals",
"(",
"offset",
",",
"getLocalOffset",
... | Returns a timestamp at the same point in time, but with the given local
offset. If this timestamp has precision coarser than minutes, then it
is returned unchanged since such timestamps always have an unknown
offset. | [
"Returns",
"a",
"timestamp",
"at",
"the",
"same",
"point",
"in",
"time",
"but",
"with",
"the",
"given",
"local",
"offset",
".",
"If",
"this",
"timestamp",
"has",
"precision",
"coarser",
"than",
"minutes",
"then",
"it",
"is",
"returned",
"unchanged",
"since",... | 4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270 | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/Timestamp.java#L1948-L1967 | train |
amzn/ion-java | src/com/amazon/ion/Timestamp.java | Timestamp.clearUnusedPrecision | private void clearUnusedPrecision() {
switch (_precision) {
case YEAR:
_month = 1;
case MONTH:
_day = 1;
case DAY:
_hour = 0;
_minute = 0;
case MINUTE:
_second = 0;
_fraction = null;
case SECOND:
}
} | java | private void clearUnusedPrecision() {
switch (_precision) {
case YEAR:
_month = 1;
case MONTH:
_day = 1;
case DAY:
_hour = 0;
_minute = 0;
case MINUTE:
_second = 0;
_fraction = null;
case SECOND:
}
} | [
"private",
"void",
"clearUnusedPrecision",
"(",
")",
"{",
"switch",
"(",
"_precision",
")",
"{",
"case",
"YEAR",
":",
"_month",
"=",
"1",
";",
"case",
"MONTH",
":",
"_day",
"=",
"1",
";",
"case",
"DAY",
":",
"_hour",
"=",
"0",
";",
"_minute",
"=",
... | Clears any fields more precise than this Timestamp's precision supports. | [
"Clears",
"any",
"fields",
"more",
"precise",
"than",
"this",
"Timestamp",
"s",
"precision",
"supports",
"."
] | 4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270 | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/Timestamp.java#L2303-L2317 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.