Why does the RASCAL IDE extension for Eclipse not work? - eclipse

I've tried to use this example of the RASCAL documentation:
http://tutor.rascal-mpl.org/Rascal/Libraries/util/IDE/Menus/Menus.html#/Rascal/Libraries/util/IDE/IDE.html
After registering the language and annotator nothing happens.
My goal is to build out this example to register some menu items for java files which could startup a RASCAL visualization or report.
Any help is appreciated.
Steps to reproduce:
Start Rascal console in Eclipse
type import util::IDE;
type import ParseTree;
type m1 = popup(menu("MyMenu", [action("Example item", void (Tree t, loc s) { println("<t> # <s>");})]));
type registerContributions("abc",{m1});
I expect a new menu item 'MyMenu' in the Eclipse IDE when I open a *.abc file. I don't know where it should popup, the documentation doesn't tell where the menuitem should show up.
rascal>import util::IDE;
ok
rascal>import ParseTree;
ok
rascal>m1 = popup(menu("MyMenu", [action("Example item", void (Tree t, loc s) { println("<t> # <s>");})]));
Contribution: popup(menu(
"MyMenu",
[action("Example item",function(|prompt:///|(50,45,<1,50>,<1,95>)))]))
rascal>registerContributions("abc",{m1});
ok
rascal>registerContributions("rsc",{m1});

To add a menu item to an editor which is not generated by Rascal itself but already exist in eclipse, for example a Java editor, you can use registerNonRascalContributions. See http://tutor.rascal-mpl.org/Rascal/Libraries/util/IDE/IDE.html#/Rascal/Libraries/util/IDE/registerNonRascalContributions/registerNonRascalContributions.html
You need the "editor id" for the default Java editor plugin which is org.eclipse.ui.JavaEditor I believe.

Related

Eclipse and PHPUnit: "The import PHPUnit\Framework\TestCase cannot be resolved"

I'm starting with PHPUnit, and it works fine so far. I just got one problem:
Eclipse (Oxygen.3) is telling me in this line:
use PHPUnit\Framework\TestCase;
"The import PHPUnit\Framework\TestCase cannot be resolved"
I went to Window -> Preferences -> PHP -> Tools -> PHPUnit and added the path to my phpunit.phar. But this didn't help.
I went to Window -> Preferences -> PHP -> Source Paths -> Libraries and tried to import my phpunit.phar. But this results in an error "The selected file is not a valid user library data file".
Any other ideas how to get rid of this error?
I was having the same problem and this solution worked for me:
Going into Project > Properties
Under PHP > Include Path, pick the "Libraries" tab.
On "Add External PHARs..." select the PHPUnit framework file on your system (phpunit.phar).

Eclipse/Java9: how to access internal javafx packages?

My context:
Eclipse IDE for Java Developers, Version: Oxygen.1a Release (4.7.1a), Build id: 20171005-1200oxygen
jdk9.0.1
win10
Something simple like:
import com.sun.javafx.scene.control.LambdaMultiplePropertyChangeListenerHandler;
import javafx.application.Application;
import javafx.stage.Stage;
public class ImportCom extends Application {
#Override
public void start(Stage arg0) throws Exception {
new LambdaMultiplePropertyChangeListenerHandler();
}
}
won't compile due to
The type com.sun.javafx.scene.control.LambdaMultiplePropertyChangeListenerHandler is not accessible
What to do?
looks similar but now for internal classes ;) Had been compiling until patch 530 of the beta9 support but not after - so keeping that oldish oxygen as a gold treasure ...
Note: cross-posted to eclipse forum
Edit:
Just checked that the behavior of javac on the commandline:
C:\Users\kleopatra\ox-1a-64\dummy\src>\java\jdk\190-64\bin\javac first\ImportCom.java
first\ImportCom.java:3: error: package com.sun.javafx.scene.control is not visible
import com.sun.javafx.scene.control.LambdaMultiplePropertyChangeListenerHandler;
^
(package com.sun.javafx.scene.control is declared in module javafx.controls, which does not export it to the unnamed module)
1 error
The error is similar to the one in Eclipse. Works fine with --add-exports:
C:\Users\kleopatra\ox-1a-64\dummy\src>\java\jdk\190-64\bin\javac --add-exports=javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED first\ImportCom.java
So the question boils down to: where/how to configure Eclipse such that it compiles access to internal classes just the same way as javac?
In Project > Properties: Java Build Path, Libraries tab, select the node Modulepath/JRE System Library[JavaSE-9]/Is modular and click Edit...
In the Module Properties dialog, in the Details tab, in the Added exports section click Add... and enter the following:
Source module: javafx.controls
Package: com.sun.javafx.scene.control
Click OK twice to close the Add-exports configuration and the Module Properties dialogs and Apply and Close to close the Properties dialog
Well, it's a bit hidden:
open Java Build Path dialog of the project
select Libraries tab
select isModular entry
use the Edit... button to open the module properties dialog
select Details tab
create all required entries with the Add.. button
If you have installed the Beta plugin for Java 9 support - uninstall. Make sure the latest Java 9 support plugin is installed.
In order to solve this issue you have to add the compiler argument
--add-exports=javafx.controls/com.sun.javafx.scene.control=A‌​LL-UNNAMED.
This can be done in Eclipse too but I have to admit at a very hidden place.
Go to the properties of your project and then to the Java Build Path.
Select Modulepath and then the JRE System library (should be java 9).
Inside that you find an item "is modular". Select that. Then open "Edit"
on the right and a menu will open. At the top select "Details". There you will see a table where you can add your exports. Believe it or not but it works :-) I had to clean and re-build the project though in order to really get this compiled.

Get classic user interface on eclipse mars

When I installed Eclipse Mars on my Arch Linux x64 I was shocked how the user interface changed compared to Luna and previous.
If you're wondering what I'm talking about see yourself:
Mars:
Luna (and previous):
Does anyone know how I can get the classic user interface back on Eclipse Mars?
Thanks in advance!
This appears to be Eclipse bug 453128 which is currently not resolved.
I've been using the following workaround to get a usable interface. You need to create two files in eclipse folder: gtkrc-2.0 and eclipse.sh. The first contains settings for GTK, the second lunches eclipse with these settings.
Contents below:
gtkrc-2.0
style "gtkcompact" {
font_name="Sans 9"
GtkButton::default_border={0,0,0,0}
GtkButton::default_outside_border={0,0,0,0}
GtkButtonBox::child_min_width=0
GtkButtonBox::child_min_heigth=0
GtkButtonBox::child_internal_pad_x=0
GtkButtonBox::child_internal_pad_y=0
GtkMenu::vertical-padding=1
GtkMenuBar::internal_padding=0
GtkMenuItem::horizontal_padding=4
GtkToolbar::internal-padding=0
GtkToolbar::space-size=0
GtkOptionMenu::indicator_size=0
GtkOptionMenu::indicator_spacing=0
GtkPaned::handle_size=4
GtkRange::trough_border=0
GtkRange::stepper_spacing=0
GtkScale::value_spacing=0
GtkScrolledWindow::scrollbar_spacing=0
GtkExpander::expander_size=10
GtkExpander::expander_spacing=0
GtkTreeView::vertical-separator=0
GtkTreeView::horizontal-separator=0
GtkTreeView::expander-size=8
GtkTreeView::fixed-height-mode=TRUE
GtkWidget::focus_padding=0
}
style "gtkcompactextra" {
xthickness=0
ythickness=0
}
class "GtkWidget" style "gtkcompact"
#class "GtkButton" style "gtkcompactextra"
class "GtkToolbar" style "gtkcompactextra"
class "GtkPaned" style "gtkcompactextra"
eclipse.sh
#!/bin/sh
PWD="$(cd "$(dirname "$0")" && pwd)"
SWT_GTK3=0 GTK2_RC_FILES=${PWD}/gtkrc-2.0 ${PWD}/eclipse & 2>1

Cannot run scala files from command prompt

I could not run a Scala project from command prompt. It was able to get it to work when I wrote the program in Scala Worksheet, but I want to get it to run from Eclipse using CMD. I did:
C:\WINDOWS\System32>scalac Hello_WORLD.scala
error: source file 'Hello_WORLD.scala' could not be found
one error found
Then, I tried to skip the compiling and go straight to the execution:
C:\WINDOWS\system32>scala Hello_WORLD
No such file or class on classpath: Hello_WORLD
Here is my code that I wrote in Eclipse. I created a Scala Project and a Scala class within the src folder.
class Hello_WORLD {
def main(args: Array[String]){
println("HELLO!")
}
}
Can you please help me? Please try not to leave rude comments. This is my first time trying out Scala. I would greatly appreciate your help. I tried looking at the Scala documentation and other posts on StackOverflow, but none of them helped my situation. I made sure that the environment variables were configured correctly. If you need any more information, please let me know in the comments.
Regards,
Ani
There's an option in Eclipse:
From the Package Explorer tab -> Select the project src directory -> Right click -> New -> Scala Application
From File -> New -> Scala Application
Choosing one of those for the default package, lets me create this:
object HelloWorld extends App {
println( "Hello World")
}
Notice that the "main" comes from extending App. It's an object instead of a class and you can run it inside of Eclipse via:
Choosing it in the Package Explorer -> right click -> Run As -> Scala Application
Run -> Run Configurations -> Scala Applications -> New -> Hello World -> Run
If you want to run that from the command line, you can Export your code to a jar file using:
Package Explorer tab -> right click -> Java -> Jar file -> browse to choose the name/location of the Jar file.
Here is all steps you have to take:
1- Install Scala and make sure the path is included in the windows path variable.( to check it, type scala in terminal, it should go to scala console
2- cd to directory with HellWorld.scala
3- the code should be this:
object HelloWorld extends App{
println("Hello World!")
}
4- scalac Helloworld.scala
it should work.
A scala programm needs a main class to work like java but if u dont want to define a "main" then you can go for "object" with extending "App". This will work fine. In this case you will not asked to have a "main" class.
object FirstProg extends App {
println("My first prog...!")
}

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script7.groovy: 1: unable to resolve class

I am currently receiving this error when trying to run a soapui file:
org.codehaus.groovy.control.MultipleCompilationErrorsException:
startup failed: Script7.groovy: 1: unable to resolve class com.company.ui.test.SoapUI_T11001_StockConsSecurityCurBusiDate # line 1, column 1.
import com.company.ui.test.SoapUI_T11001_StockConsSecurityCurBusiDate
^
org.codehaus.groovy.syntax.SyntaxException: unable to resolve class com.company.ui.test.SoapUI_T11001_StockConsSecurityCurBusiDate # line 1, column 1.
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError(ClassCodeVisitorSupport.java:148)
at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1206)
at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:148)
at org.codehaus.groovy.control.CompilationUnit$6.call(CompilationUnit.java:585)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:832)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:519)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:495)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:472)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:292)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:727)
at groovy.lang.GroovyShell.parse(GroovyShell.java:739)
at groovy.lang.GroovyShell.parse(GroovyShell.java:766)
at groovy.lang.GroovyShell.parse(GroovyShell.java:757)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:141)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:90)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:148)
at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:274)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
1 error
soapUI code:
import com.company.ui.test.SoapUI_T11001_StockConsSecurityCurBusiDate
def env = testRunner.testCase.testSuite.project.getPropertyValue("env")
def baseUrl = testRunner.testCase.testSuite.project.getPropertyValue("baseUrl")
log.info("The baseurl is "+baseUrl)
log.info("The env under test is "+env)
SoapUI_T11001_StockConsSecurityCurBusiDate testStep = new SoapUI_T11001_StockConsSecurityCurBusiDate();
testStep.init(baseUrl);
testStep.execute(null);
eclipse code:
package com.company.ui.test;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import com.eviware.soapui.model.support.AbstractSubmitContext;
import com.eviware.soapui.model.testsuite.TestRunner;
public class SoapUI_T11001_StockConsSecurityCurBusiDate extends BaseSelenium{
public static void main(final String[] args){
final SoapUI_T11001_StockConsSecurityCurBusiDate ico = new SoapUI_T11001_StockConsSecurityCurBusiDate();
try{
ico.init("https://avncedevn1.nam.nsroot.net:17620/", false);
}catch(Exception e){
// TODO Auto-generated catch block
e.printStackTrace();
}
ico.execute(null);
}
//...code....
}
how do I solve this error ? I'm not sure what is causing the error.
This work for me:
Press Ctr+Alt+Shift+s
or:
From File menu -> Project Structure -> SDK Location -> JDK location Drop down menu choose:
Embeded JDK c:....\jre
Then ok.
If you using android studio and got this error then I solved it changing the Gradle version of the project to the newest version 6.2.1 on the project structure options.
One of the possible reasons is that the jdk version is too high. For example, using jdk 16 to build the source code of Apache Kafka throws this error. Using jdk 11 is fine.
bild.gradel file in change clashpath
dependencies {
classpath "com.android.tools.build:gradle:7.0.1"
}
gradel-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
I'm Using Android Studio - Arctic Fox and this worked for me
Go To File menu -> Project Structure -> SDK Location -> Gradle Setting
Then check the "Download external annotations for dependencies" button and select JDK location from the drop down menu and choose: Android Default Jdk Vesion.
Click on Ok.
If you wanted to make a new project on Android Studio after first install, probably you write your application name including (') sign as called apostrophe.
For Example, I tried to set a name as: "Henry's Game" but apostrophe caused Android Studio to not load because of this mistake:
Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
So, just change your application's name, and simply use Latin alphabet languages such as English.
To fix: Go to your Android Project Tree and find Gradle Scripts > settings.gradle > change the name:
rootProject.name='Henry Game'
include ':app'
With Eclipse Juno (Kepler Release) Build id: 20121114-2344, I found similar problem:
org.codehaus.groovy.control.multiplecompilationerrorsexception startup failed unable to resolve class Chart
The class Chart is my container class for some utilities for charting.
I tried outside of Eclipse, with Groovy 2.0 Console the same code segment works fine. After scratching my head for about 3 hours, I resolved it by adding the following
import excel.Chart
in the invoking class with main() that has "new Chart()" thus getting the complaints, once added, the error is gone. Even more weird, after passing the error, I remove that import, there is still no more complaints! (All my scripts/classes are under the same package excel, I suppose such import statement is not needed.)
One of the symptom of the complaints is that there was not Chart.class generated in the output bin folder. Once the complaints gone, Chart.class appeared there.
I guess that it might be a bug of Eclipse/Groovy plugin (I use Groovy Plugin for Juno).
Hope my understanding is correct, and it helps.
The solution for me was change the gradle version and the Gradle JDK:
File > Project Structure > Project
enter image description here
File > Project Structure > SDK Location
enter image description here
Go to Files and click Invalidate caches/ Restart . Android studio will clear the cached and it will be restarted without any error.
Hope this answer helps you :)
For this problem, you might also encounter package naming from gsp as I did. In the build/gsptmp folder, Grails 4.x.x creates temporary gsp files to link the classes that they refer to. Due to the change of a package name it was failing to do so in my case. Try with command grails war --stacktrace during war build!
Previously, it was <%# page import="bv.BankReconciliationController" %>
but the folder bv was renamed to factoring.
So, the solve was to change the import to
<%# page import="factoring.BankReconciliationController" %> and it worked :)
I have also faced the same and tried all of the solution here and other places as well, at last i deleted my .gradle and gradle both folder and caches of android studio and open the studio again and rebuild the project, it's works after that fine and used the latest gradle version and previously it was picking up the older version and causing issues.
for me , solution is to upgrade the gradle to latest version , and remove the .idea file , and invalidate caches and restart android studio.
When starting a project make sure to select SDK version 11 or later. It will default to a minimum SDK but you have to scroll down to a later version for it to work. Then the project should load and build.
For me, I just delete the .grade file under program files(C:\Users\username\ .gradle) in windows and it will work.
This work for me:
From File menu -> Project Structure -> SDK Location -> klik Gradle Setting for show hide menu, Gradle JDK choose:
Embeded JDK c:....\jre
Then ok.
Do you have the grail and groovy plugin installed? If so try uninstalling this plugin. I had the same error message and uninstalling the plugin, restart IDE worked for me.