in our project we have a custom annotation #DeprecationReason which should be used to document why a member/method/class is deprecated (and thus annotated with #Deprecated)
So to have an IntelliJ warning when #Deprecated is used but #DeprecationReason is missing, I want to check if #Deprecated is present but not #DeprecatedReason.
In general, I find it difficult to find documentation about structural search, but I haven't found anything about analysing "sibling annotations".
Could anyone give me a hint about this?
You could try a template like this:
<searchConfiguration name="Not annotated methods" text="#Deprecated #$Annotation$
$MethodType$ $Method$($ParameterType$ $Parameter$);" recursive="true" type="JAVA" pattern_context="member" search_injected="false">
<constraint name="__context__" within="" contains="" />
<constraint name="Annotation" regexp="DeprecatedReason" minCount="0" maxCount="0" within="" contains="" />
<constraint name="MethodType" within="" contains="" />
<constraint name="Method" within="" contains="" />
<constraint name="ParameterType" within="" contains="" />
<constraint name="Parameter" minCount="0" maxCount="2147483647" within="" contains="" />
</searchConfiguration>
Which I based on the built-in/existing template "Not annotated methods". You can import this in the Structural Search dialog using the "Import Template from Clipboard" action under the tool button in the upper right.
Fields and classes will need a separate template.
Related
I'm using VS Code for Java development and working with other developers who use IntelliJ. I'd like to use the Organize Imports command (Shift+Alt+O) to clean up my imports, but I don't want to fight over import order with every commit. So I'd like to configure VS Code to organize the imports in the same order as IntelliJ's default. Does anybody have a configuration that would do this?
If this is not possible, is there a workspace configuration I can apply to both VS Code and IntelliJ so that the two IDEs will agree, even if they aren't agreeing on IntelliJ's default?
We were able to get it the almost identical with the following config tweaks.
VS Code:
{
"java.completion.importOrder": [
"",
"javax",
"java",
"#"
]
}
IntelliJ
The only difference from the IntelliJ default is a new line between import javax... and import java....
It's possible to get VS Code and IntelliJ to agree on a standard format, as long as that standard format:
Puts static imports at the top*
Separates all specific sections with empty lines
Puts everything not in its own specific section in a catch-all section at the end*
Never uses wildcard imports
Not actually true; static imports can be positioned in VS Code with '#', and everything else can be position in VS Code with ''.
IntelliJ's default settings don't work for this, but it is flexible enough to be reconfigured. Here are the files to add to a project to make just that project set up consistent rules for both IDEs (make sure they are not excluded in .gitignore).
Rule: The following groups separated by empty lines: Static imports, java.*, javax.*, everything else.
.vscode/settings.json:
{
"java.completion.importOrder": ["java", "javax"],
}
.idea/codeStyles/codeStyleConfig.xml:
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>
.idea/codeStyles/Project.xml
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<JavaCodeStyleSettings>
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="IMPORT_LAYOUT_TABLE">
<value>
<package name="" withSubpackages="true" static="true" />
<emptyLine />
<package name="java" withSubpackages="true" static="false" />
<emptyLine />
<package name="javax" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="false" />
</value>
</option>
</JavaCodeStyleSettings>
</code_scheme>
</component>
My VoiceXML provider, Nexmo, seems not to handle the xml:lang="es-ES" attribute in the root vxml (This is generated by Rivr with a context.setLanguage("es-ES") in my Dialog)
I want Nexmo to use a spanish TTS engine but as I am using Rivr, I can't see where I can specify that I want the "prompt" to include, for example, xml:lang="es-es-female", so it generates VoiceXML:
<prompt xml:lang="es-es-female">
Hola.
</prompt>
interaction().addPrompt() only accepts the SpeechSynthesis object which does not allow (as far as I see) language options.
I've also tried include SSML in the SpeechSynthesis object (using a DocumentFragment as I see in Rivr Javadoc) but that won't work. Probably Nexmo does not support SSML.
Any workarounds? (A part from changing to a better VoiceXML provider)
Thanks a lot!!!
If you only want to play a message without getting input from the user, use can use the Message class:
//Play a synthesis message in another language
Message message = new Message("synthesis-french-message",
new SpeechSynthesis("Ceci est un message."));
message.setLanguage("fr-CA");
DialogueUtils.doTurn(message, context);
If you need to specify the language for a prompt in an Interaction, this can be done with the InteractionBuilder. The setLanguage() method can be used before the addPrompt() method. Multiple languages can be used within the same interaction:
Interaction interaction = OutputTurns.interaction("multilingual-interaction")
.setLanguage("es-ES")
.addPrompt(new SpeechSynthesis("Holá."))
.setLanguage("fr-CA")
.addPrompt(new SpeechSynthesis("Bonjour."))
.build(new SpeechRecognition(new GrammarReference("grammar.grxml")),
Duration.seconds(2));
DialogueUtils.doTurn(interaction, context);
If you don't want to use the builder, you can do it by hand but it's much longer:
List<Interaction.Prompt> prompts = new ArrayList<Interaction.Prompt>();
Interaction.Prompt spanishPrompt = new Interaction.Prompt(new SpeechSynthesis("Holá."));
spanishPrompt.setLanguage("es-ES");
prompts.add(spanishPrompt);
Interaction.Prompt frenchPrompt = new Interaction.Prompt(new SpeechSynthesis("Bonjour."));
frenchPrompt.setLanguage("fr-CA");
prompts.add(frenchPrompt);
SpeechRecognition speechRecognition = new SpeechRecognition(new GrammarReference("grammar.grxml"));
FinalRecognitionWindow finalRecognitionWindow = new FinalRecognitionWindow(speechRecognition,
Duration.seconds(2));
Interaction interaction2 = new Interaction("multilingual-interaction2",
prompts,
finalRecognitionWindow);
DialogueUtils.doTurn(interaction2, context);
The output VoiceXML is:
<?xml version="1.0" encoding="UTF-8"?>
<vxml application="/rivr-cookbook-message-language/dialogue/root/efe10575-1766-48fb-9e13-572a771bc5f4" version="2.1"
xmlns="http://www.w3.org/2001/vxml">
<script>application.rivr.localErrorHandling = false; application.rivr.inputTurn = {};</script>
<form id="form">
<block name="prompt0">
<prompt bargein="false" xml:lang="es-ES">Holá.</prompt>
</block>
<block name="prompt1">
<prompt bargein="false" xml:lang="fr-CA">Bonjour.</prompt>
</block>
<field name="recognition">
<grammar mode="voice" src="grammar.grxml" />
<property name="timeout" value="2000ms" />
</field>
<filled mode="any">
<script>application.rivr.addRecognitionResult()</script>
<goto next="#submitForm" />
</filled>
</form>
<catch>
<if cond="_event.substring(0, 5) == "error"">
<if cond="application.rivr.localErrorHandling">
<goto next="#fatalErrorForm" />
<else />
<script>application.rivr.localErrorHandling=true</script>
</if>
</if>
<script>application.rivr.addEventResult(_event, _message)</script>
<goto next="#submitForm" />
</catch>
<form id="fatalErrorForm">
<block>
<exit />
</block>
</form>
<form id="submitForm">
<block>
<var expr="application.rivr.toJson(application.rivr.inputTurn)" name="inputTurn" />
<if cond="application.rivr.hasRecording(application.rivr.inputTurn)">
<var expr="application.rivr.inputTurn.recordingMetaData.data" name="recording" />
<assign expr="undefined" name="application.rivr.inputTurn.recordingMetaData.data" />
<submit enctype="multipart/form-data" method="post" namelist="inputTurn recording"
next="/rivr-cookbook-message-language/dialogue/efe10575-1766-48fb-9e13-572a771bc5f4/0/multilingual-interaction2" />
<else />
<submit method="post" namelist="inputTurn"
next="/rivr-cookbook-message-language/dialogue/efe10575-1766-48fb-9e13-572a771bc5f4/0/multilingual-interaction2" />
</if>
</block>
</form>
</vxml>
I have added the following in the findbugs exclude.xml file
<Match>
<Class name="com.ebay.kernel.service.invocation.SvcInvocationConfig" />
<Method name="getConnectionConfig" />
<Bug pattern="IS2_INCONSISTENT_SYNC" />
</Match>
The code that needs to be ignored
public ConnectionConfig getConnectionConfig() {
return m_connectionConfig;
}
because Findbugs reports that
m_connectionConfig suffers from (inconsistent synchronization) BUG - IS2_INCONSISTENT_SYNC
But for some reason my findbugs are not getting ignored.
and when I do following -
<Match>
<Class name="com.ebay.kernel.service.invocation.SvcInvocationConfig" />
<Bug pattern="IS2_INCONSISTENT_SYNC" />
</Match>
The findbugs is getting ignored for the entire class but as soon as I introduce
<Method name="getConnectionConfig">
tag in between, findbugs stops getting ignored for that method.
Can someone help me figure out why?
The IS2_INCONSISTENT_SYNC warning is issued on a data member (field), according to its usages by various methods, constructors, static blocks, etc. and not on the method itself, so you can't ignore it with a <Method> element.
Instead, you could use a <Field> element:
<Match>
<Class name="com.ebay.kernel.service.invocation.SvcInvocationConfig" />
<Field name="m_connectionConfig" />
<Bug pattern="IS2_INCONSISTENT_SYNC" />
</Match>
For some additional/custom attributes, like tab indices or tool tip texts, it would be nice to annotate the FXML with custom annotations. I have three proposals for it:
XML-Comment:
<!-- #TabIndex(index=1) -->
<Button fx:id="test_audio" text="Test" />
fx attribute:
<Button fx:id="test_audio" fx:tab_index="1" text="Test" />
Custom XML namespace attribute :
<Button fx:id="test_audio" custom:tab_index="1" text="Test" />
Is there a way to do this and get the attribute values on runtime?
I am trying to follow the code for Spring Webflow from 'Spring in Action'. However, when I tried to run the application, I got the following error:
org.springframework.webflow.engine.FlowInputMappingException: Errors occurred during input mapping on startup of the 'pizza' flow; errors = [[RequiredError#13cb4078 mapping = order -> flowScope.order, code = 'required', error = true, errorCause = [null], originalValue = [null], mappedValue = [null]]]
I believe the line that instantiates the order object in the following flow xml is responsible for the exception:
<var name="order" class="com.mycompany.pizza.domain.Order" />
<subflow-state id="customer" subflow="customer-flow">
<input name="order" value="order"/>
<transition on="customerReady" to="buildOrder" />
</subflow-state>
My subflow xml looks like this:
<view-state id="welcome">
<transition on="phoneEntered" to="lookupCustomer" />
</view-state>
<action-state id="lookupCustomer">
<evaluate result="order.customer"
expression="pizzaFlowActions.lookupCustomer(requestParameters.phoneNumber)" />
<transition to="registrationForm"
on-exception="com.mycompany.pizza.service.CustomerNotFoundException" />
<transition to="customerReady" />
</action-state>
Hope there's someone who could point me at the right direction. Thanks!
The error is saying you are REQUIRED to pass a NOT NULL input param/obj "order" to your subflow and you are passing a null value in the order input. So if it is not provided it will throw the exception you see. At the top of your subflow should look something like this:
<input name="order" required="true" type="com.mycompany.pizza.domain.Order"/>
That being said, generally I think when passing pojos between flows/subflows it is good practice to be very explicit and fill out the 'type' attribute in both input tags on the caller of the subflow and the subflow itself and to fill out the scope prefix for the value attribute (e.g flowScope.order)
Moreover, I think your problem is that the <var> tag is NOT initializing your Order pojo that is why it is null it is the equiv of:
Order order = null;
You should explicitly set flowScope.order via a new operator or a factory-method call using the 'set' tag inside an 'on-start' tag in beginning of your parent flow. Something like this:
<on-start>
<set name="flowScope.order" value="new com.mycompany.pizza.domain.Order()"/>
<!-- for development purposes... assuming you are using log4j grab the logger and check that order is in fact NOT null -->
<evaluate expression="T(org.apache.log4j.Logger).getLogger('someLogger').info(flowScope.order)"/>
</on-start>
and then (still inside your parent flow) change your subflow call to look like this:
<subflow-state id="customer" subflow="customer-flow">
<input name="order" value="flowScope.order" type="com.mycompany.pizza.domain.Order"/>
<transition on="customerReady" to="buildOrder" />
</subflow-state>
and... Make sure you also fill out the type attribute inside the input tag of your subflow.xml for order like so:
<input name="order" required="true" type="com.mycompany.pizza.domain.Order"/>