Dart static type errors (instead of just warnings) in Eclipse - eclipse

I am using the Dart plugin for Eclipse (not the standalone Dart Editor).
How do I configure the project/build so that static type warnings appear as errors in the Eclipse "Problems" tab? For example, this line of code actually compiles, which seems ludicrous:
int newtodo = new LIElement();
Running dartanalyzer at the command line gives an error, as desired:
dartanalyzer foo.dart
But instead of having to run dartanalyzer at the command line (or discovering them at runtime), I would like to have these errors reported on-the-fly in Eclipse.

If this doesn't produce a warning this is a bug according to this discussion new user question. type warnings as errors in Eclipse
(Also initiated from #Justin M. Keyes)

Related

Pydev debugger error - NameError: name 'psort' is not defined

I am getting an error message from Pydev in the Eclipse Console window when debugging Python code. The same error message repeats every time the debugger pauses:
ValueError: invalid literal for int() with base 10: "NameError: name 'psort' is not defined"
Traceback (most recent call last):
File "C:\Users\Bill\.p2\pool\plugins\org.python.pydev.core_9.2.0.202110311311\pysrc\_pydevd_bundle\pydevd_process_net_command.py", line 63, in process_net_command
cmd = on_command(py_db, cmd_id, seq, text)
File "C:\Users\Bill\.p2\pool\plugins\org.python.pydev.core_9.2.0.202110311311\pysrc\_pydevd_bundle\pydevd_process_net_command.py", line 367, in _cmd_exec_or_evaluate_expression
trim_if_too_big = int(trim) == 1
ValueError: invalid literal for int() with base 10: "NameError: name 'psort' is not defined"
This is not a bug in my own code, and I don't know how to fix it. I can't tell if is my configuration or a Pydev bug, or what? The debugger still works, but the console window gets filled up with those repeated messages.
I have been tolerating it for some months, thinking I just had to update Pydev, but I finally updated Pydev today(11/2021) and I still get the error messages.
I am using:
Windows 10 64bit
Eclipse IDE for C/C++, Version: 2020-12 (4.18.0), Build id: 20201210-1552
The Pydev version I updated to today:
Pydev version 9.2.0.20211031131
I may have solved this, or at least a very similar looking problem. I think it was caused by some references in the Eclipse 'Expressions' view. I had let many expressions accumulate in the Expressions View. Some referenced deleted variables, out of scope variables, or variables whose definitions had changed - so expressions using them may have been buggy.
I stopped the errors by removing all of the expressions in the 'Expressions' view. I was then able to add expressions again without causing the error.
Sorry to say, I didn't identify the problem expression(s), so I didn't get to find out how they caused the problem.

Groovy:General error during semantic analysis: java.lang.NoSuchMethodError:

Imported the gradle project from the "complete" folder and received the following error:
Groovy:General error during semantic analysis:
java.lang.NoSuchMethodError: 'org.codehaus.groovy.ast.expr.Expression org.codehaus.groovy.ast.tools.GeneralUtils.propX(org.codehaus.groovy.ast.expr.Expression, java.lang.String)'
I am using the latest version of Eclipse, 2020-12, with groovy tools installed.
From grails guide
https://guides.grails.org/gorm-without-grails/guide/index.html
Downloaded code sample from github
https://github.com/grails-guides/gorm-without-grails.git
It seems likely to be a version mismatch, but I cannot determine how to correct this problem.
I have tried to delete the offending file, src/main/groovy/demo/domain/Manufacturer.groovy, and the error appears on the file in this package on line 1.
The error does not appear in any other package. I have done the usual internet searches for resolutions that apply, but have thus far been unable to find a suitable solution. I am hopeful for a suggestion?
I think this error comes from an AST transform that references the older signature of GeneralUtils#propX. This method used to return Expression and was changed to return PropertyExpression.
The bridge method for binary compatibility was missing in groovy-eclipse. https://github.com/groovy/groovy-eclipse/commit/f6f448675d95f858b4ec65b6fc8e55f27ccaaa94

Threads in Eclipse AND c++11

My goal has been to create multi-threading programs, and I can not even get a simple thread
to execute ON ECLIPSE CDT. my Tools:
ECLIPSE 3.8.1 CDT
Ubuntu 13.10
I have noticed very similar issues regarding mine. I have tried those other solutions but I could not get them to work for me.
When I type the code in Eclipse CDT, Eclipse does not 'resolve' the symbols 'thread', however, It can find the header file 'thread'. 'Mutex' also does not resolve. Furthermore, after building, I run the program, eclipse returns :
"terminate called after throwing an instance of 'std::system_error'
what(): Enable multithreading to use std::thread: Operation not permitted"
Some additional notes:
I can compile and execute the code in the terminal using:
'clang++ c.cpp -pthread -std=c++11'
but...
'g++ c.cpp -pthread -std=c++11' compiles and
produces the same error as quoted above. So it looks like it's a compiler issue. I did
start to write the code in a new project within Eclipse CDT with the clang++ compiler and now that gives the same non-resolved 'thread' and produces the error as quoted above. So now I think I have some wrong settings, paths or flags set in Eclipse.
include <iostream>
include <thread>
using namespace std;
void p1(){
cout<<"process 1 is processing"<<endl;
}
int main() {
thread t1(&p1);
cout<<"Hello from main()"<<endl;
t1.join();
return 0;
}
I have been struggling with the very same issue and I finally resolved it. Here is what I did:
1) Add -std=c++11 for c++ build. To do that right-click your project, select properties and then: C/C++ Build -> Settings -> GCC C++ Compiler -> Miscellaneous(last option)
In other flags append -std=c++11. My Other flags now looks like: -c -fmessage-length=0 -std=c++11 but yours may be a bit different.
2) Add some linker options. In the same view(C/C++ Build -> Settings) as above select the GCC C++ Linker option and from there go to Miscellaneous(second to last option). Add the following Linker flags(the field was empty for me): -Wl,--no-as-needed -pthread. Hit apply.
3) Add a macro. Again from the project properties menu(project->right click->properties). Navigate to C/C++ General -> Paths and symbols -> Symbols. Select GNU C++. Add a symbol with the name __GXX_EXPERIMENTAL_CXX0X__ and no value. Again hit apply.
4) Navigate to C/C++ General -> Preprocessor Include paths.. Select the providers tab. In this tab leave only the following two options checked: CDT GCC Built-in Compiler Settings and CDT Managed Build Setting Entries. Select CDT GCC Built-in Compiler Settings uncheck the checkbox Share setting entries between projects(global provider) and now the text box labeled Command to get compiler specs should be enabled. In this text box append the good old -std=c++11. The text now looks like this for me ${COMMAND} -E -P -v -dD ${INPUTS} -std=c++11. Hit apply one last time.
5) Rebuild the index for the project. To do that right click the project->Index->Rebuild
Following these steps I was able to compile a c++11 multithreaded program, execute it and also Eclipse CDT did not report any errors and was helpful with the autocompletion. Unfortunately this setting has to be done separately for Release and Debug(or at least I have not found a way to share it). Hope this helps.

Eclipse giving me Invalid arguments ' Candidates are: void * memset(void *, int, ?) ' though I know the args are good

I am getting an invalid arguments error in eclipse, though I am confident my arguments are good. The suggested arguments contains a '?' which I think may indicate the problem, though I do not know how to fix it.
I have done my best to copy the example I saw here:
http://www.cplusplus.com/reference/clibrary/cstring/memset/
In order to be certain that I am getting the args right.
#include <stdio.h>
#include <string.h>
void foo()
{
char str[] = "why oh why does my IDE give me errors when I know my args are good?";
memset(str, '-', 4);
puts(str);
}
Eclipse gives me the following error on the memset line:
Invalid arguments ' Candidates are: void * memset(void *, int, ?) '
What could be causing this? And what is up with that '?' as the 3rd arg?
Thanks in advance!
PS: Just noticed I am getting similar errors when I try to use operations like malloc, calloc, etc.
In Eclipse:
right click the project
click properties
Expand "C/C++ general" the item in the left hand tree view by clicking the arrow, (just clicking the item itself does not expand the suboptions)
From the suboptions select "Preprocessor Include Paths, Macros etc."
Click the "Providers" tab
Check the box next to "CDT GCC Built-in Compiler Settings [ Shared ]".
Edit:
The reason this works is that there are a bunch of default includes and defines that the compiler silently adds behind the scene when you compile. These instructions get eclipse to grab these otherwise silent preprocessor directives so that it's own indexer is using the same settings
The following method resolves the same problem that I was having. (on eclipse 4.2)
Clean your project (Project -> Clean)
Reindex files (Project -> C/C++ Index -> Rebuild)
Rebuild your project (Project -> Build All)
I think it is something to do with your Eclipse setup, somehow.
Taken standalone, that fragment compiles under GCC (G++) 4.7.1 on Mac OS X 10.7.5 with the command line:
g++ -O3 -g -Wall -Wextra -c ms.cpp
The only surprising thing about the third argument to memset() is that it is of type size_t, but the headers are supposed to declare that, so it should not be an issue.
If you're using malloc() et al, you will be including <stdlib.h>, of course. There is also room to argue that you should be using <cstdio>, <cstring> and <cstdlib>, but that shouldn't stop the code you presented from compiling without error.
If you're working with Visual Studio, size_t is defined as
typedef unsigned __int64 size_t;
In previous versions of the Eclipse CDT, __int64 was not defined. You can fix that issue by adding into C/C++ General -> Paths and Symbols -> Symbols
Symbol: __int64
Value: long long
Or you can upgrade your Eclipse CDT version
I've been using a 3rd party C++ library for BeagleBone development and I tried every possible way to include it (as preprocessor includes, source folder, assember includes, library includes, C++ compiler includes, C compiler includes etc). Refreshen, reindex, clean and built for every change I attempted. I even deleted the project and copied only the .cpp and .h files over to a new project.
I finally found the problem in my setup and rectified it as follows.
Right-click the project > Properties > C/C++ Build > Tool-chain editor > Current Builder:> Select CDT Internal Builder
I'm using g++, for your information.
I had a similar issue with the Eclipse CDT. But in my case the thing was that I had put the using namespace std; statement in a several headers. And in some combination of conditions, when I included all of this headers the Eclipse had such the behavior.
I had a similar issue when compiling someone's code, and the problem was the code style. They defined some methods in this way:
// ... Inside a class
static void
sleep( u32 ms );
I guess this is GNU style. Just changing the declaration to
static void sleep( u32 ms );
removed the issue.

Scala project won't compile in Eclipse; "Could not find the main class."

I have installed Eclipse 3.5.2 and today's Scala plugin from /update-current (that's Scala 2.8 final.) I can compile and run Scala projects consisting of a single singleton object that implements main().
But, if a project contains more classes, I receive the "Could not find the main class" error.
I have tried searching for the solution and I discovered:
Eclipse is correctly looking for the Main$ class, not the Main class
* under Debug Configurations, my main class is correctly identified as mypackage.Main
* my plugin is up to date and recommended for my version of Eclipse
* cleaning, restarting etc. doesn't help.
The same project will compile with scalac.
Thanks for any ideas on how to solve this.
EDIT: MatthieuF suggested I should post the code.
This snippet produces an error. It's not the most idiomatic code, but I wrote it that way to test my environment. I tried it as a single file and as separate files. It DOES work with scalac.
import swing._
class HelloFrame extends Frame {
title = "First program"
contents = new Label("Hello, world!")
}
object Hello {
val frame = new HelloFrame
def main(args : Array[String]) : Unit = {
frame.visible = true
}
}
BUT, if I nest the definition of HelloFrame within Hello, it works. This snippet runs perfectly:
import swing._
object Hello {
class HelloFrame extends Frame {
title = "First program"
contents = new Label("Hello, world!")
}
val frame = new HelloFrame
def main(args : Array[String]) : Unit = {
frame.visible = true
}
}
For me, the problem was that there was a build error (see Problems tab) which was preventing compilation; oops! The reason you see the error is that the run macro proceeds despite the failed compilation step, and attempts to run class files it expects to be there; they don't exist because there was a build error preventing compilation, so it says it can't find Main (not compiled).
Problem goes away when build can complete successfully, i.e. errors are fixed.
I guess, theoretically, there may be more complicated reasons your build is not completing successfully that are not listed in Problems.
One possibility is that you are trying to launch using ctrl-F11, but from a different class.
The Scala Eclipse plugin does not obey the defaults for Java launching. In Preferences->Run/Debug->Launching, there are some options Launch Operation->Always Launch the previously selected application, etc. This currently does not work in the Scala eclipse plugin. To launch a specified main, you need to launch it from the editor for the class.
There has been a bug raised for this. http://scala-ide.assembla.com/spaces/scala-ide/tickets/1000023-scala-launch--does-not-follow-jdt-behaviour
EDIT: This is now (mostly) fixed.
For me it was Eclipse specific problem. I noticed that .class file wasn't built at all. So bin directory doesn't have compiled classes.
When I manually compiled *.scala file using *.sbt and copied it to bin directory it was working as expected.
I tried different tips and tricks and it wasn't worked until I reinstalled Scala plugin in Eclipse .
I'd solve similar problem by executig "Project->Clean.." with next automatically building.
I had the same error message with a Java application made by myself.
The problem was that I deleted (though inside Eclipse) a jar that belonged to the Java build path, without deleting it from the Java build path (project's Properties window). When I did it the class could compile and run again.
Make sure that the .class files exist, usually below the bin directory.
In particular, if you have errors in unrelated files in the same project then the compilation may fail, and no .class files will be produced.
There can be the case of projects, containing errors, added to the build path of the application which prevents the completion of successful compilation. Make sure you remove any such project from the build path before running the application.
Removing these projects solved the problem for me.
Do you have a proper build tool setup? Like sbt have you installed it?
You can check its version by $sbt --version
If it is not setup you can download from here http://www.scala-sbt.org/download.html
You might have to restart your eclipse after installation.
Just copy your XXX.scala file code. Remove the package and create a new Scala Class. Paste your XXX.scala code. (If you are using maven, do a maven clean and build.) Run configuration again. This works for me.
I have faced this issue. I have just deleted the package name, created scala class, Written the same code, Set Build to "Build Automatically". Finally, It works perfectly fine.
Check scala-ide.log
For me the issue was that there were errors on:
AppData\Local\Temp\sbt_10d322fb\xsbt\ClassName.scala:16: error: not found: value enteringPhase
enteringPhase(currentRun.flattenPhase.next) { s fullName separator }
If you are using Intellij, mark directory as source root