Xtext: quickfix give an ConcurrentModificationException Exception - xtext

Writing a quickfix routing using the semantic model to fix and error, a ConcurrentModificationException is created:
org.eclipse.emf.common.util.WrappedException: java.util.ConcurrentModificationException
at org.eclipse.xtext.ui.editor.quickfix.IssueResolution.apply(IssueResolution.java:78)
at org.eclipse.xtext.ui.editor.quickfix.QuickAssistCompletionProposal.apply(QuickAssistCompletionProposal.java:36)
...
The method implemented:
#Fix(DslValidator.INVALID_NORMALISED_FLOW)
def fixNormalised_ParameterDeclarations(Issue issue, IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, 'Normalize the parameters', 'Capitalize the name.', 'upcase.png') [ element, context |
var param = element as ParameterDeclarations
//var index_s = issue.data // index provided from the validator
var index = 1 // dummy index
for (name : param.declare.get(index).identifier) {
param.declare.get(index - 1).identifier.add(name)
}
param.declare.drop(index)
]
}
The input syntax look like a:int, b:int and must be converted to a, b:int where
ParameterDeclarations:
(
declare+=VariableDeclare
(',' declare+=VariableDeclare)*
) | (
connection=ConnectionName
) | (
not_connected?='void'?
);
VariableDeclare:
identifier+=VariableName (',' identifier+=VariableName)* ':' type=Type;
In the syntax a and b are instances of VariableName and int of Type.
How do I resolve the exception?
Updates:
Stack trace:
eclipse.buildId=4.7.3.M20180301-0715
java.version=1.8.0_161
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_ZA
Framework arguments: -product org.eclipse.platform.ide
Command-line arguments: -product org.eclipse.platform.ide -data /home/johan/workspace/sofl_dsl_2018_April/../runtime-EclipseXtext -dev file:/home/johan/workspace/sofl_dsl_2018_April/.metadata/.plugins /org.eclipse.pde.core/Launch Runtime Eclipse/dev.properties -os linux -ws gtk -arch x86_64
org.eclipse.ui
Error
Sun Apr 08 18:29:26 SAST 2018
Unhandled event loop exception
org.eclipse.emf.common.util.WrappedException: java.util.ConcurrentModificationException
at org.eclipse.xtext.ui.editor.quickfix.IssueResolution.apply(IssueResolution.java:78)
at org.eclipse.xtext.ui.editor.quickfix.QuickAssistCompletionProposal.apply(QuickAssistCompletionProposal.java:36)
at org.eclipse.xtext.ui.editor.hover.AnnotationWithQuickFixesHover$AnnotationInformationControl.apply(AnnotationWithQuickFixesHover.java:536)
at org.eclipse.xtext.ui.editor.hover.AnnotationWithQuickFixesHover$AnnotationInformationControl.access$2(AnnotationWithQuickFixesHover.java:513)
at org.eclipse.xtext.ui.editor.hover.AnnotationWithQuickFixesHover$AnnotationInformationControl$5.widgetSelected(AnnotationWithQuickFixesHover.java:507)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:249)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:86)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5348)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1348)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1374)
at org.eclipse.swt.widgets.Widget.sendSelectionEvent(Widget.java:1488)
at org.eclipse.swt.widgets.Link.gtk_button_release_event(Link.java:384)
at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1957)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:6193)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5608)
at org.eclipse.swt.internal.gtk.OS._gtk_main_do_event(Native Method)
at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(OS.java:9282)
at org.eclipse.swt.widgets.Display.eventProc(Display.java:1328)
at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:2116)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4181)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1150)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1039)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:680)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:594)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:151)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
at org.eclipse.equinox.launcher.Main.run(Main.java:1499)
at org.eclipse.equinox.launcher.Main.main(Main.java:1472)
Caused by: java.util.ConcurrentModificationException
at org.eclipse.emf.common.util.AbstractEList$EIterator.checkModCount(AbstractEList.java:760)
at org.eclipse.emf.common.util.AbstractEList$EIterator.doNext(AbstractEList.java:714)
at org.eclipse.emf.common.util.AbstractEList$EIterator.next(AbstractEList.java:694)
at tuks.sofl.ui.quickfix.DslQuickfixProvider.lambda$0(DslQuickfixProvider.java:41)
at org.eclipse.xtext.ui.editor.model.edit.SemanticModificationWrapper$1.process(SemanticModificationWrapper.java:36)
at org.eclipse.xtext.ui.editor.model.edit.SemanticModificationWrapper$1.process(SemanticModificationWrapper.java:1)
at org.eclipse.xtext.util.concurrent.IUnitOfWork$Void.exec(IUnitOfWork.java:37)
at org.eclipse.xtext.ui.editor.model.edit.ReconcilingUnitOfWork.exec(ReconcilingUnitOfWork.java:56)
at org.eclipse.xtext.ui.editor.model.edit.ReconcilingUnitOfWork.exec(ReconcilingUnitOfWork.java:1)
at org.eclipse.xtext.resource.OutdatedStateManager.exec(OutdatedStateManager.java:91)
at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.modify(XtextDocument.java:428)
at org.eclipse.xtext.ui.editor.model.XtextDocument.internalModify(XtextDocument.java:162)
at org.eclipse.xtext.ui.editor.model.XtextDocument.modify(XtextDocument.java:155)
at org.eclipse.xtext.ui.editor.model.edit.SemanticModificationWrapper.apply(SemanticModificationWrapper.java:32)
at org.eclipse.xtext.ui.editor.quickfix.IssueResolution.apply(IssueResolution.java:76)
... 42 more

Making a copy of the list (the correct way) and use the right method to remove an element in a list:
#Fix(DslValidator.INVALID_NORMALISED_FLOW)
def fixNormalised_ParameterDeclarations(Issue issue, IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, 'Normalize the parameters', 'Capitalize the name.', 'upcase.png') [ element, context |
var param = element as ParameterDeclarations
var index = 1 // dummy index
val copier = new EcoreUtil.Copier();
var names_to_add = copier.copyAll(param.declare.get(index).identifier)
//for (name : param.declare.get(index).identifier) {
for (name : names_to_add) {
param.declare.get(index - 1).identifier.add(name)
}
param.declare.remove(index) // Also fix here use remove and not drop
]
}

Related

? operator to avoid NoSuchMethodError in dart

I saw a video of someone try to avoid NoSuchMethodError by using ? operator . here's the code:
/*1*/ void main () {
/*2*/ var v = vu() ;
/*3*/ var f = v.casting() ;
/*4*/ f.tbu ;
/*5*/}
show error on line 4
Unhandled exception: NoSuchMethodError: The
getter 'tbu' was called on null. Receiver: null Tried calling: tbu
but he used the ? operator :
/*1*/ void main () {
/*2*/ var v = vu() ;
/*3*/ var f = v.casting() ;
/*4*/ f?.tbu ;
/*5*/}
run without problem .
My question is what is the ? operator ??
The question mark placed before the dot allows conditional property access, which guards against trying to access a property or method of an object that might be null:
myObject?.someProperty
is equivalent to the following:
(myObject != null) ? myObject.someProperty : null
This is similar to optional chaining in JavaScript.

`url_serde` asking for unrelated trait bounds

Using the serde and url_serde crates, I get errors suggesting I need to fulfill unrelated trait bounds:
Compiling ser v0.1.0 (/data/scratch/ser)
error[E0277]: the trait bound `for<'a> url_serde::Ser<'a, url::Url>: a::_::_serde::Serialize` is not satisfied
--> src/b.rs:4:10
|
4 | #[derive(Serialize, Deserialize)]
| ^^^^^^^^^ the trait `for<'a> a::_::_serde::Serialize` is not implemented for `url_serde::Ser<'a, url::Url>`
|
::: /home/danj/.cargo/registry/src/github.com-1ecc6299db9ec823/url_serde-0.2.0/src/lib.rs:77:46
|
77 | where S: Serializer, for<'a> Ser<'a, T>: Serialize
| --------- required by this bound in `url_serde::serialize`
|
= help: the following implementations were found:
<url_serde::Ser<'a, std::option::Option<url::Url>> as a::_::_serde::Serialize>
<url_serde::Ser<'a, url::Url> as a::_::_serde::Serialize>
<url_serde::Ser<'a, url::host::Host<String>> as a::_::_serde::Serialize>
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `url_serde::De<url::Url>: a::_::_serde::Deserialize<'_>` is not satisfied
--> src/b.rs:4:21
|
4 | #[derive(Serialize, Deserialize)]
| ^^^^^^^^^^^ the trait `a::_::_serde::Deserialize<'_>` is not implemented for `url_serde::De<url::Url>`
|
::: /home/danj/.cargo/registry/src/github.com-1ecc6299db9ec823/url_serde-0.2.0/src/lib.rs:158:40
|
158 | where D: Deserializer<'de>, De<T>: Deserialize<'de>
| ---------------- required by this bound in `url_serde::deserialize`
|
= help: the following implementations were found:
<url_serde::De<std::option::Option<url::Url>> as a::_::_serde::Deserialize<'de>>
<url_serde::De<url::Url> as a::_::_serde::Deserialize<'de>>
<url_serde::De<url::host::Host> as a::_::_serde::Deserialize<'de>>
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.
error: could not compile `ser`.
To learn more, run the command again with --verbose.
Cargo.toml
[package]
name = "ser"
version = "0.1.0"
authors = ["..."]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde = { version = "1.0.115", features = ["derive"] }
url = "2.1.1"
url_serde = "0.2.0"
src/lib.rs:
pub mod a;
pub mod b;
src/a.rs:
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct A {
pub name: String,
}
src/b.rs:
use serde::{Deserialize, Serialize};
use url::Url;
#[derive(Serialize, Deserialize)]
pub struct B {
#[serde(with = "url_serde")]
uri: Url,
}
Found this through crates.io linking to an upgrade: https://github.com/servo/rust-url/blob/b03895bd479d72c75600dc09c8c7906f5ee203ea/UPGRADING.md
tl;dr
url = { version = "2.0", features = ["serde"] }
and remove all references to url_serde

MyBatis foreach update can't see all item parameters from collection

I'm trying to use foreach loop in #Update with my mapper and unexpectedly mybatis has a problem with resolving all parameters from collection. Some details below:
#Update("<script>"
+ "<foreach collection='objects' item='item' separator=';'>"
+ "UPDATE some_table "
+ "SET field_x=#{item.x}, "
+ "field_y=#{item.y} "
+ "WHERE field_z=#{item.z} AND field_a=#{item.a}"
+ "</foreach>"
+ "</script>")
void update(#Param("objects") List<SomeObject> objects);
and:
public class SomeObject {
private String z;
private SomeEnum a;
private BigDecimal x;
private Integer y;
}
method call returned:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='__frch_item_1.dailyAmount', mode=IN, javaType=class java.math.BigDecimal, jdbcType=null, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #5 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: org.h2.jdbc.JdbcSQLException: Invalid value "5" for parameter "parameterIndex" [90008-196]
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
at com.sun.proxy.$Proxy33.update(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:294)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:62)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
at com.sun.proxy.$Proxy43.updateLimits(Unknown Source)
at pl.raiffeisen.ekd.blik.core.persistence.DataProvider.updateLimits(DataProvider.java:76)
at pl.raiffeisen.ekd.blik.api.rest.settings.SettingsController.updateLimits(SettingsController.java:136)
at pl.raiffeisen.ekd.blik.test.rest.SettingsControllerTest.testUpdateLimitsSuccessPath(SettingsControllerTest.java:532)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='__frch_item_1.dailyAmount', mode=IN, javaType=class java.math.BigDecimal, jdbcType=null, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #5 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: org.h2.jdbc.JdbcSQLException: Invalid value "5" for parameter "parameterIndex" [90008-196]
at org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:89)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:93)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:64)
at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:86)
at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:49)
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:198)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
... 38 more
Caused by: org.apache.ibatis.type.TypeException: Error setting non null for parameter #5 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: org.h2.jdbc.JdbcSQLException: Invalid value "5" for parameter "parameterIndex" [90008-196]
at org.apache.ibatis.type.BaseTypeHandler.setParameter(BaseTypeHandler.java:55)
at org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:87)
... 50 more
Caused by: org.h2.jdbc.JdbcSQLException: Invalid value "5" for parameter "parameterIndex" [90008-196]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException.getInvalidValueException(DbException.java:228)
at org.h2.jdbc.JdbcPreparedStatement.setParameter(JdbcPreparedStatement.java:1444)
at org.h2.jdbc.JdbcPreparedStatement.setBigDecimal(JdbcPreparedStatement.java:384)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:67)
at com.sun.proxy.$Proxy58.setBigDecimal(Unknown Source)
at org.apache.ibatis.type.BigDecimalTypeHandler.setNonNullParameter(BigDecimalTypeHandler.java:32)
at org.apache.ibatis.type.BigDecimalTypeHandler.setNonNullParameter(BigDecimalTypeHandler.java:27)
at org.apache.ibatis.type.BaseTypeHandler.setParameter(BaseTypeHandler.java:53)
... 51 more
after debugging I saw this: (at: org.h2.jdbc.JdbcPreparedStatement:1002)
this = prep19: UPDATE some_table SET field_x=?, field_y=? WHERE field_z=? AND field_a=? ;
UPDATE transaction_limit SET field_x=?, field_y=? WHERE field_z=? AND field_a=? ;
UPDATE transaction_limit SET field_x=?, field_y=? WHERE field_z=? AND type=? ;
{1: 250.00, 2: 1, 3: 'qwerty123', 4: 'VALUE1'}
It should be something like this: (example values)
{1: 250.00, 2: 1, 3: 'qwerty123', 4: 'VALUE1',
5: 750.00, 6: 4, 7: 'qwerty123', 8: 'VALUE2',
9: 500.00, 10: 3, 11: 'qwerty123', 12: 'VALUE3'}
Could anyone tell me why there is only one object mapped from list instead of all three (passed 3 element list to method)?
I have resolved this issue. Database H2 obviously doesn't support foreach script. With PostgreSQL everything is ok.

groovy.lang.MissingMethodException: No signature of method: com.x.License.add() is applicable for argument types: (com.x.License) values

I'm using a scheduled job to retrieve the licenses every so often. When I retrieve the licenses for each license I want to add that license to a hashmap per account. In the hashmap I have an Account and a list of Licenses. For each license I try to check if there already is a list of Licenses in the hashmap, if there isn't I make a new list and that works fine. But if there is a list I try to add it to that list and that where it throws an error for some reason
licenses.each{license->
List<License> licensesPerAccount = accountLicenseMap.get(license.account)
log.info("initial licenseperaccount " + licensesPerAccount)
if(licensesPerAccount == null) {
accountLicenseMap.put(license.account, license as List<License>)
} else{
log.info("licenseperaccount in else is " + licensesPerAccount)
licensesPerAccount.push(license)
log.info("licenseperaccount now is " + licensesPerAccount)
accountLicenseMap.put(license.account, licensesPerAccount)
}
}
This is the error it throws:
ERROR 2017-12-27 10:12:59,045 grails.plugins.quartz.listeners.ExceptionPrinterJobListener - Exception occurred in job: Grails Job
org.quartz.JobExecutionException: groovy.lang.MissingMethodException: No signature of method: com.x.License.add() is applicable for argument types: (com.x.License) values: [com.x.License : 10]
Possible solutions: any(), find(com.x.License), any(groovy.lang.Closure), wait(), last(), save()
at grails.plugins.quartz.GrailsJobFactory$GrailsJob.execute(GrailsJobFactory.java:111)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: groovy.lang.MissingMethodException: No signature of method: com.x.License.add() is applicable for argument types: (com.x.License) values: [com.x.License : 10]
Possible solutions: any(), find(com.x.License), any(groovy.lang.Closure), wait(), last(), save()
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoMetaMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:253)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:71)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at com.x.NewLicenseJob$_execute_closure1$$EQezpeTI.doCall(NewLicenseJob.groovy:32)
at sun.reflect.GeneratedMethodAccessor629.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springsource.loaded.ri.ReloadedTypeInvoker$2.invoke(ReloadedTypeInvoker.java:133)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1461)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1021)
at groovy.lang.Closure.call(Closure.java:426)
at com.x.NewLicenseJob$_execute_closure1.call(NewLicenseJob.groovy)
at groovy.lang.Closure.call(Closure.java:442)
at com.x.NewLicenseJob$_execute_closure1.call(NewLicenseJob.groovy)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2030)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2015)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2056)
at org.codehaus.groovy.runtime.dgm$162.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at com.x.NewLicenseJob$$EQezpeT2.execute(NewLicenseJob.groovy:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springsource.loaded.ri.ReloadedTypeInvoker$2.invoke(ReloadedTypeInvoker.java:133)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1461)
at grails.plugins.quartz.GrailsJobFactory$GrailsJob.execute(GrailsJobFactory.java:104)
... 2 common frames omitted
And this is what it logs:
INFO 2017-12-27 10:12:59,029 grails.app.jobs.com.x.NewLicenseJob - initial licenseperaccount null
Hibernate: select account0_.id as id1_4_0_, account0_.approve_hours_by_manager as approve_2_4_0_, account0_.brand_id as brand_id3_4_0_, account0_.check_tags as check_ta4_4_0_, account0_.checkin_at_work_module as checkin_5_4_0_, account0_.cj1_export as cj6_4_0_, account0_.company_id as company_7_4_0_, account0_.csv_import as csv_impo8_4_0_, account0_.default_date_pattern as default_9_4_0_, account0_.default_date_time_pattern as default10_4_0_, account0_.default_time_pattern as default11_4_0_, account0_.default_time_zone as default12_4_0_, account0_.default_view as default13_4_0_, account0_.deleted as deleted14_4_0_, account0_.display_as_decimal as display15_4_0_, account0_.instant_feedback as instant16_4_0_, account0_.language as languag17_4_0_, account0_.match_registration_hours as match_r18_4_0_, account0_.payroll_hours as payroll19_4_0_, account0_.project_tags as project20_4_0_, account0_.separate_date as separat21_4_0_, account0_.show_charts as show_ch22_4_0_, account0_.templa_link as templa_23_4_0_, account0_.vip_export as vip_exp24_4_0_ from account account0_ where account0_.id=?
Hibernate: select company0_.id as id1_14_0_, company0_.account_id as account_2_14_0_, company0_.address as address3_14_0_, company0_.city as city4_14_0_, company0_.cocnumber as cocnumbe5_14_0_, company0_.country as country6_14_0_, company0_.deleted as deleted7_14_0_, company0_.emailaddress as emailadd8_14_0_, company0_.logo_url as logo_url9_14_0_, company0_.name as name10_14_0_, company0_.phonenumber as phonenu11_14_0_, company0_.province as provinc12_14_0_, company0_.vatnumber as vatnumb13_14_0_, company0_.website as website14_14_0_, company0_.zipcode as zipcode15_14_0_ from company company0_ where company0_.id=?
INFO 2017-12-27 10:12:59,045 grails.app.jobs.com.x.NewLicenseJob - initial licenseperaccount null
INFO 2017-12-27 10:12:59,045 grails.app.jobs.com.x.NewLicenseJob - initial licenseperaccount [com.x.License : 9]
INFO 2017-12-27 10:12:59,045 grails.app.jobs.com.x.NewLicenseJob - licenseperaccount in else is [com.x.License : 9]
I fixed it by creating the list as follows:
List<License> licenseList = []
licenseList << license
accountLicenseMap.put(license.account, licenseList)
Instead of doing accountLicenseMap.put(license.account, license as List<License>)

XText can not insert line before current quickfix point (XText version 2.9)

In my Xtext project I want to use quickfix to insert a new line before the current line for the missing cross-reference.But it gives following exception.
!ENTRY org.eclipse.core.jobs 4 2 2015-06-02 17:22:05.616
!MESSAGE An internal error occurred during: "Select and reveal referenced object".
!STACK 0
java.lang.IllegalArgumentException: The feature 'content' is not a valid feature
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eStructuralFeature(BasicEObjectImpl.java:733)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eObjectForURIFragmentSegment(BasicEObjectImpl.java:551)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.getEObject(ResourceImpl.java:766)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.getEObject(ResourceImpl.java:742)
at org.eclipse.xtext.resource.XtextResource.access$1(XtextResource.java:1)
at org.eclipse.xtext.resource.XtextResource$1.getEObject(XtextResource.java:115)
at org.eclipse.xtext.resource.DefaultFragmentProvider.getEObject(DefaultFragmentProvider.java:28)
at org.eclipse.xtext.resource.XtextResource.basicGetEObject(XtextResource.java:346)
at org.eclipse.xtext.resource.XtextResource.getEObject(XtextResource.java:332)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:235)
at org.eclipse.xtext.ui.editor.LanguageSpecificURIEditorOpener.findEObjectByURI(LanguageSpecificURIEditorOpener.java:159)
at org.eclipse.xtext.ui.editor.LanguageSpecificURIEditorOpener$2.process(LanguageSpecificURIEditorOpener.java:125)
at org.eclipse.xtext.ui.editor.LanguageSpecificURIEditorOpener$2.process(LanguageSpecificURIEditorOpener.java:1)
at org.eclipse.xtext.util.concurrent.IUnitOfWork$Void.exec(IUnitOfWork.java:37)
at org.eclipse.xtext.resource.OutdatedStateManager.exec(OutdatedStateManager.java:121)
at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.internalReadOnly(XtextDocument.java:520)
at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.readOnly(XtextDocument.java:492)
at org.eclipse.xtext.ui.editor.model.XtextDocument.readOnly(XtextDocument.java:133)
at org.eclipse.xtext.ui.editor.LanguageSpecificURIEditorOpener.selectAndReveal(LanguageSpecificURIEditorOpener.java:121)
at org.eclipse.xtext.ui.editor.LanguageSpecificURIEditorOpener$1.run(LanguageSpecificURIEditorOpener.java:88)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
My Code is very simple liking this:
acceptor.accept(issue, "Create label", "Create a new jump label", null) [ element, context |
if (element instanceof ContinueCommand) {
var lineNum = issue.lineNumber
var doc = context.xtextDocument
// If use doc.getLineOffset(lineNum). It works and inserts newline after current line.
var offset = doc.getLineOffset(lineNum-1)
var id = doc.get(issue.offset, issue.length)
var toInsert = "!" + id + " : comment\n"
doc.replace(offset, 0, toInsert)
}
]
I tried it in other quickfix methods (not for cross-references). It works good. I use xtext version 2.9.
Has anybody the same problem?

Resources