Eclipse - view packages as heirarchical, but not if only package contains more than one item - eclipse

I'm trying to get Eclipse to show packages in the package explorer this way I've seen elsewhere, but its two options (flat/hierarchical) aren't getting me there.
Flat looks like this:
com.mything.example
com.mything.example.subpackage1
com.mything.example.subpackage2
com.mything.example.subpackage2.eggplant
Hierarchical looks like this:
com
mything
example
subpackage1
subpackage2
eggplant
I want this:
com.mything.example
subpackage1
subpackage2.eggplant
Any help?
Edit:
Moreover, sometimes it works inconsistently:

Related

Printing to console in VDM++?

How do I print text or values to the console to validate that my model is working correctly?
I would like to do something like this:
class Main
operations
public Run: () ==> ()
Run() ==
print "Text"
print mon.Func()
end Main
It seems to be possible, but I just cant figure out how to do it.
You need to use the VDM IO library. There are a couple of operations that do what you want - println (for printing fixed values) and printf, which has parameter substitution. So you would call IO`println("hello"), for example.
In the latest release of Overture and VDMJ, you can also use a VDM annotation to print values without adding anything to the "content" of the specification itself. Annotations are rather added as comments. See #Printf.
Nick Battle answered my question but for other beginners to VDM, there is missing a detail to his answer, how to include libraries.
Before one can use the IO library, you first have to include it.
I am using Overture and to include libraries into your project, you have to right-click on the project in the side menu and press New > Add VDM Library.
You can then choose which libraries you want to include in a menu that pops up.
Here you choose IO.
After this you should be able to print out values using the IO`println(val) function.

initRelector is defined in multiple libraries

I'm trying to export my various component templates from a templates.dart file. For example export './src/foo/foo_component.template.dart';
export './src/bar/bar_component.template.dart';
The VSCode analyzer is complaining "The name 'initReflector' is defined in the libraries
package:my_app/src/foo/foo_component.template.dart and package:my_app/src/bar/bar_component.template.dart"
I'd suggest only showing what you need from those libraries instead of exporting everything that is public:
export './src/bar/bar_component.template.dart' show BarComponentNgFactory;
If that seems too much of a hassle you could go the other way and just hide initReflector.

go to file in eclipse by using location datatype

When clicking on a location type in the output window of eclipse, you can go to that file (location).
I would like to be able to trigger this with a method in rascal.
So to be clear, I have the location of a java method, I would like to trigger eclipse to focus on this file through rascal.
Take a look at the util::Editors module. It contains an edit function that opens any file you pass it, with the relevant editor, with optional highlights.
Note, that if you have a logical location like java+method://... you will have to lookup the actual physical location of the method in the m3 model using IO:resolveLocation, and use that. For example:
rascal>import IO;
ok
rascal>resolveLocation(|java+method:///io/usethesource/impulse/language/LanguageRegistry/IMPFileEditorMapping/setTheDefaultEditor(org.eclipse.ui.IEditorDescriptor)|)
loc: |project://impulse/src/io/usethesource/impulse/language/LanguageRegistry.java|(15638,134,<433,8>,<436,9>)
rascal>openEditor(resolveLocation(|java+method:///io/usethesource/impulse/language/LanguageRegistry/IMPFileEditorMapping/setTheDefaultEditor(org.eclipse.ui.IEditorDescriptor)|))
You are looking for openEditor in util::ValueUI.
First import util::ValueUI;, then try
openEditor(|project://rascal/src/org/rascalmpl/library/Map.rsc|);
and an editor for the Map module will open.

Eclipse Plugin Development: Adding items to a working set with the path of the item?

Hello,
I'm an eclipse plugin development newbie looking for pointers to get me started on a particular project.
I am trying to build an eclipse plugin that will automatically construct a working set from a text file that simply consists of a list of file path names. The files/items need not share any parent directories. The rough idea is represented in the following diagram:
I am not asking for the solution to this task. That's the over-arching goal. To achieve that goal, I want to conquer some smaller goals first.
With that in mind, here's the smaller goal I'm currently trying to tackle:
In Eclipse, how can I prompt the user for a single file's path, and then add that file to an existing working set?
I'm not sure where to start. Should I work directly off of the existing org.eclipse.ui.workingSets extension point? Or should I use a collection of other extension points? How do I convert strings into something that can be added to a working set? Do I write code that directly modifies the workingsets.xml file?
Even with a much simpler goal, I still feel quite overwhelmed with the vastness of eclipse extension options. There are probably many ways to go about implementing something like this, but I just need one to get started.
Thanks a bunch!
To manipulate working sets you use the working set manager interface IWorkingSetManager. Get this with:
IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager();
From this you can get a particular working by name with:
IWorkingSet workingSet = manager.getWorkingSet("name");
The contents of a working set is an array of IAdaptable objects:
IAdaptable [] contents = workingSet.getElements();
You add to the contents by adding to this array and setting the contents:
IAdaptable [] newContents
.... get new array with old contents + new contents
workingSet.setElements(newContents);
A lot of Eclipse objects implement IAdaptable, for a file in the workspace you would use IFile. You can use dialogs such as ResourceSelectionDialog to select resources from the workspace.

Use the tree-view in Atom editor init script

I'm trying to write a init script for the Atom editor to add a custom command to be able to reveal the currently opened editor file in the tree-view with one key combination, instead of two.
Here is an example code (which makes something different) to make clear how it generally has to look like.
atom.commands.add 'atom-editor', 'custom:cut-line', ->
editor = atom.workspace.getActiveEditor()
editor.selectLine()
editor.cutSelectedText()
The two commands I need should not be sent to the editor, but to the tree-view. Here are the two commands:
tree-view:toggle-focus
tree-view:reveal-active-file
I assume I have to do something similar as above, like getActiveTreeView or something like that. I tried to google it but it doesn't seem to be obvious. Does someone know how to do this?
It could look something like this:
atom.commands.add 'atom-editor', 'custom:show-active-file', ->
tree-view.toggle-focus()
tree-view.reveal-active-file()
You can use the atom.commands.dispatch() method to send a command when getting a hold of the object to send the commands to is hard. In your case, you can use:
atom.commands.add 'atom-editor', 'custom:show-active-file', ->
atom.commands.dispatch(atom.workspaceView.element, 'tree-view:toggle-focus')
atom.commands.dispatch(atom.workspaceView.element, 'tree-view:reveal-active-file')
Sadly, Lee's answer is not correct anymore. Within changes in the API the changed the naming of atom.workspaceView to atom.workspace.
So, if anyone gets here (sure questions and answer is a "bit" old), here's the current working script.
atom.commands.add 'atom-editor', 'custom:show-active-file', ->
atom.commands.dispatch(atom.workspace.element, 'tree-view:toggle-focus')
atom.commands.dispatch(atom.workspace.element, 'tree-view:reveal-active-file')
#Source
https://discuss.atom.io/t/workspaceview-events/14595/4