getReference() on PsiElement always returns null value - intellij-idea

I get the PsiElement using a PsiRecursiveElementVisitor. The I call getReference() function on it but it always returns null. In my use case, I cannot use Caret for getting the reference. I am assuming the references we get from both are the same. Any help would be great!

Maybe that PsiElement simply doesn't have any references? Try with its parents.

Related

Webdriver.io browser.elementIdDisplayed(ID) is not returning boolean

I'm trying to use webdriver.io function browser.elementIdDisplayed(element.ELEMENT), but it doesn't return a boolean as the docs says. Instead it returns some kind of object.
I'm confused, how can I get a value from this if the element is displayed or not?
Please help.
I have tried also with browser.elementIdDisplayed(element.ELEMENT).value but it is always true?
It was ok to use
browser.elementIdDisplayed(element.ELEMENT).value,
but my other logic of verifying that element was displayed was wrong.

passing null as aparameter to listOf

can you please tell me what does the second parameter passed to the method listOf means? why do we need to pass null? why is the purpose of it?
code:
val listWithNulls: List<String?> = listOf("Kotlin", null)
listOf accepts a vararg of elements. Your second null is just one of many elements you passed to the list. Your list then consists of "Kotlin" and null.
So to answer your other questions:
why do we need to pass null? you don't need to...
what is the purpose of it? the person who wrote that code wanted to add a null element to the list... if it isn't clear from the context, why it is there, you should better ask the one who wrote that code. If it just consists of the line you showed, it's probably to demonstrate how lists with a nullable type can be constructed/used.

Velocity template function from string literal

Is it possible to call a function that was created from string literal? For example
${object}.staticPartOfFunctionName${dynamicPartOfFunctionName}()
doesn't return correct value, but instead just prints the object and the function name.
$object.staticFunctionName()
prints correctly, and
$object.staticPartOfFunctionName${dynamicPartOfFunctionName}()
gives warning "Encountered ")"
You don't have to use introspection:
#evaluate("\$object.staticPartOfFunctionName${dynamicPartOfFunctionName}()")
Well, I found one solution myself from Java side:
$object.getClass().getMethod("staticPartOfFunctionName$dynamicPartOfFunctionName").invoke($object))
I don't know if it's any good, so if someone knows how to do it velocity way, lemme know.

Core Data - Fetch object with optional attribute

I have an EntityA which has an optional attribute int32 result. When I create EntityA I do not set the result attribute. Then later on when I fetch it I expect it to have nil value but for some reason it's set to 3 even though I have not set this attribute.
What's going on here?
1st possible issue:
You have set a default value in the model editor. Select the attribute and check the inspector.
2nd possible issue:
You are retrieving or showing the wrong value. Show the code you are using to find out that result is '3'.
3rd possible issue:
You are setting the value later inadvertently, perhaps in a loop or something similar. Do a text search for the attribute to find a possible occurrence in your code.
Your int32 will be stored wrapped into a NSNumber object. If you don't provide a value, no NSNumber object will be created - sql will treat it as NULL.
The iOS Core Data Programming Guide says:
You can specify that an attribute is optional—that is, it is not
required to have a value. In general, however, you are discouraged
from doing so—especially for numeric values (typically you can get
better results using a mandatory attribute with a default value—in the
model—of 0). The reason for this is that SQL has special comparison
behavior for NULL that is unlike Objective-C's nil. NULL in a database
is not the same as 0, and searches for 0 will not match columns with
NULL.
So, it may be better to either make the attribute mandatory and set it to a distinct value, or to pass in NSNumber from the start.

MSAccess use of special character

I have got a very strange problem.
In the earlier version of programm i have found the following statement inside a query.
table1!field1 > table2!Field2
I ma not able to understand the meaning of the ! sign here.
Can any one able to help me in this regard
thank you in advance
! means default property with String parameter type in VB/VBA. Apparently Table object has default property Field("fieldname") and Field object has default property Value, thereby instead of table1.Field("field1").Value you can use shortcut notation table1!field1.