How to make Eclipse "Open Type" window to show project classes first in list, third-party classes last? - eclipse

When you work with a project you more often open classes from your project and less often third party classes, so it would be good to have project classes displayed first in "Open Type" window. Is there a way to do this ?

Eclipse doesn't provide any configuration for Open Type dialog. You can only filter an unwanted packages so they will not be shown (Settings->Java->Appearance->Type Filters).
It's very simple with patterns to search for a classes within a given package. Assume I want to go to the Node class in the pl.toro package. If I just type node it will return more than 20 classes with my class at the end of the list. But with a pattern p.Node the class will be first and only. p stands for the first letter of the package (pl).
More from Eclipse's help:
Wildcards: "*" for any string and "?" for any character
terminating "<" or " " (space) to prevent the automatic prefix
matching, e.g.
"java.*Access<" to match java.util.RandomAccess but not
java.security.AccessControlContext
Camel case:
"TZ" for types containing "T" and "Z" as upper-case letters in
camel-case notation, e.g.
java.util.TimeZone
"NuPoEx" or "NuPo" for types containing "Nu", "Po", (and "Ex") as
parts in camel-case notation, e.g.
java.lang.NullPointerException
terminating "<" or " " (space) to fix the number of camel-case parts,
e.g.
"HMap<" and "HaMap<" match "HashMap" and "HatMapper", but not
"HashMapEntry" nor "Hashmap".
Both pattern kinds also support package prefixes, e.g. "j.util.*Map<".

Related

Why Kotlin does not allow slash in identifiers

The Unicode is allowed in identifiers in backticks
val `💾id` = "1"
But slash is not allowed
val `application/json` = "application/json"
In Scala we can have such names.
This is a JVM limitation. From the specification section 4.2.2:
Names of methods, fields, local variables, and formal parameters are stored as unqualified names. An unqualified name must contain at least one Unicode code point and must not contain any of the ASCII characters . ; [ / (that is, period or semicolon or left square bracket or forward slash).
In Scala names are mangled to avoid this limitation, in Kotlin they are not.
Kotlin's identifiers are used as-is, without any mangling, in the names of JVM classes and methods generated from the Kotlin code. The slash has a special meaning in JVM names (it separates packages and class names). Therefore, Kotlin doesn't allow using it in an identifier.

Rules / Regexp in Watson Knowledge Studio

I need to formulate a set of rules and regular expressions in WKS to identify song title and artist in sentences like "Play Locomotive Breath" or "Play the song Locomotive Breath by Jethro Tull" (I actually do this for German, so I can't use builtin entities in NLU).
My problem is that the "by " part is optional. I have set up regular expressions for the German equivalents of "Play [the song]" (mapping to a class PLAY) and "by" (mapping to a class BY) and tried to add two rules, one matching
PLAY (any tokens) BY (any tokens)
and PLAY (any tokens).
The problem is that the second rule also matches when the first one does, so that in the sentence "Play Locomotive Breath by Jethro Tull" the title is recognized as "Locomotive Breath by Jethro Tull".
I tried to define a regular expression with negative lookahead, i.e. (\w* (?!(by)))* to match the text up the "by", but this does not seem to work in WKS.
Any ideas how I can extract song titles and artists using WKS rules?
Regular expressions with negative lookahead should work fine in WKS.
I am not sure if your regular expression (\w* (?!(by)))* expresses what you intended. Is it working as you expected outside of WKS?
Maybe you meant something like ((?!(by))\w)* ?

How can I use keys to navigate between words separated by underscores?

In programming for Drupal, much of what I do is pass function names within strings.
I would like to use Ctrl+Right arrow and Ctrl+Left arrow to navigate through the string, but NetBeans does not recognize the underscores as separating words inside strings. Because of this, the Ctrl+arrow movements only take me to the beginning or ending of the string.
NetBeans supports navigation based on Camel notation. Is there any way to make it give similar support for underscores?

Include slashes and parentheses in tokens

Background
I have search indexes containing Greek characters. Many people don't know how to type Greek so they enter something called "beta-code". Beta-code can be converted into Greek. For example, beta-code "NO/MOU" would be converted to "νόμου". Characters such as a slash or parenthesis is used to indicate an accent.
Desired Behavior
I want users to be able to search using either beta-code or text in the Greek script. I figured out that the Whoosh Variations class provides the mechanism I need and it almost solves my problem.
Problem
The Variation class works well except for when a slash or a parenthesis are used to indicate an accent in a users' query. The problem is the query are parsed such that the the special characters used to denote the accent result in the words being split up. For example, a search for "NO/MOU" results in the Variations class being asked to find variations of "no" and "mou" instead of "NO/MOU".
Question
Is there a way to influence how the query is parsed such that slashes and parentheses are included in the search words (i.e. that a search for "NO/MOU" results in a search for a token of ""NO/MOU" instead of "no" and "mou")?
The search parser uses a Tokenizer class for breaking up the search string into individual terms. Whoosh will use the class that is associated with the schema. For example, the case below, the SimpleAnalyzer() will be used when searching the "content" field.
Schema( verse_id = NUMERIC(unique=True, stored=True),
content = TEXT(analyzer=SimpleAnalyzer()) )
By default, the SimpleAnalyzer() uses the following regular expression to tokenize search terms: "\w+(.?\w+)*"
To use a different regular expression, assign the first argument to the SimpleAnalyzer to another regular expression. For example, to include beta-code characters (slashes, parentheses, etc.) in tokens, use the following SimpleAnalyzer:
SimpleAnalyzer( rcompile(r"[\w/*()=\+|&']+(\.?[\w/*()=\+|&']+)*") )
Searches will now allow terms to include the special beta-code characters and the Variations class will be able to convert the term to the unicode version.

How to search in resource files in Eclipse? (escaped chars)

How do you search in resource files (*.properties) in Eclipse for string containing non-ASCII characters?
EDIT: Currently I use * in place of those special chars, but I'd prefer Eclipse to handle this for me: so it would either search for '\u00E1' in raw files when I enter 'á', or it might translate the files first and then just search for 'á'.
My apologize for not being specific enough when asking.
In Eclipse, you can use Search -> File Search . In the Search dialog, check the Regular expression option. Then enter this pattern in the Containing text: field to find non-ASCII characters:
[\u007f-\uffff]
(the square brackets are part of the pattern). Enter the File name patterns
*.properties
and then select which resources to search (selected resource, workspace, working set, etc.) and click OK
See also the Pattern javadoc for how to express such regular expressions.
Personally, I search them from the command line using grep, but you can search them in Eclipse by using a question mark in a non-regular-expression search, which should match any character. You can also use a period in a regular expression search.
The search dialog allows you to search for strings in *.resources files in the workspace.
Go to Search -> File. Enable the Regular Expressions checkbox - this also content assist to choose the regular expression according to your needs. In the file name patterns, give *.properties and then, Go :)