I am trying to learn Eclipse editor annonations from this site:
http://www.ibm.com/developerworks/opensource/tutorials/os-eclipse-plugin-guide
It seems a preety good tutorial, but any code that I copied to my eclipse workspace, it shows always error "multiple marker in one line"
For example, when I copy the following code:
public static IMarker createMarker(IResource res)
throws CoreException {
IMarker marker = null;
//note: you use the id that is defined in your plugin.xml
marker = res.createMarker("com.ibm.mymarkers.mymarker");
marker.setAttribute("description," "this is one of my markers");
//note: you can also use attributes from your supertype
marker.setAttribute(IMarker.MESSAGE, "My Marker");
return marker;
}
I will get the error that multiple markers in one line. Can you please help me regards this? I am really frustrated with it and already spent 2 hours after it.
Multiple markers means that there is more than one thing wrong with the line specified.
I will be assuming the error is in this line:
marker.setAttribute("description," "this is one of my markers");
Note the misplaced comma (,) corrected version should be:
marker.setAttribute("description", "this is one of my markers");
Try it out and do a clean build. I am sure it will work this time.
Hover over the error marker on the left or open the "Problems View" to see the individual errors.
Related
I am having the following problem:
I have an Enum that was originally declared with 5 elements.
public enum GraphFormat {
DOT,
GML,
PUML,
JSON,
NEO4J,
TEXT {
#Override
public String getFileExtension() {
return ".txt";
}
};
Now I need to add an additional element to it (NEO4J). When I run my code or try to debug it I am getting an exception because the value can't be found in the enum.
I am using IntelliJ as my IDE, and have cleaned the cache, force a rebuild, etc.. and nothing happens. When I look at the .class file created on my target folder, it also has the new element.
Any ideas on what could be causing this issue ?
I found my problem and want to share here what was causing it. My code was actually for a Maven plug-in which I was pointing to another project of mine to run it as a goal. However the pom.xml of my target test project was pointing to the original version of the plug-in instead of the one I am working on, and that version of course is outdated and does not include the new value. Thank you.
I'm using jade as view engine in my node/express app, and it works just fine, even more too fine :) It does not throw error or warning if a comma is missing between tag attributes. For example:
div.main(data-ng-controller="ctrl" data-ng-form="form")
or
script(type="text/javascript" src="script.js" charset="utf-8")
compiles without errors, however the jade syntax docs says to use commas or new lines to separate tag attributes, so these should be the correct lines:
div.main(data-ng-controller="ctrl", data-ng-form="form")
script(type="text/javascript", src="script.js", charset="utf-8")
And the problem is that I use the same jade templates also in a java project, and the java-jade compiler throws bad syntax exception because the missing attribute separators.
In my opinion the node-jade compiler has a bug or something, and the java-jade compiler works in the righ way: as it should. The inconvenience is if I miss a comma during developing my pages in node environment, I won't notice the error until building my java project.
Is it possible to set up the node-jade compiler to throw errors or warnings for missing commas, or am I using it wrong?
The express setup is like this:
app.set('views', 'path/to/views');
app.set('view engine', 'jade');
Thanks guys!
PlatformLogUtil.logAsError(Activator.getDefault(), new Status(IStatus.ERROR, "com.sample.example",enter code here "ERROR"));
I am using above code for Logging in eclipse problems log.
But it is not visible in problems log but able to see in console.
Can any one suggest is it right what i am performing in above code or do i need to do some thing else to view in Problem Log in eclipse.
If you take a look at the PlatformLogUtil implementation, you will see, that it does not create any problems, it just logs the error, which is shown in the "Error Log" view.
In order to show a problem in the problem view, you need to create a marker for your problem. Please read "Mark My Words" article to get more information on how to do it.
void reportError(IResource resource, int line, String msg) {
IMarker m = resource.createMarker(IMarker.PROBLEM);
m.setAttribute(IMarker.LINE_NUMBER, line);
m.setAttribute(IMarker.MESSAGE, msg);
m.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_HIGH);
m.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
}
This will log the error in the .log file in the workspace .metadata directory. The Error Log view should also show the error.
If the plugin you pass to PlatformLogUtil is null (from Activator.getDefault()) then the error is sent to the console.
I have a weird problem debugging an android application.
To be accurate, I copy here the exact code I'm running on:
// Get the puzzles from cache
List<PuzzleDetails> newPuzzles = m_cachedPuzzles.getPuzzles(count);
if(newPuzzles.size() > 0){
// Remove from cache
m_cachedPuzzles.removePuzzles(newPuzzles); // LINE (A)
// Add the new puzzles from cache immediately
m_ownedPuzzles.addPuzzles(newPuzzles);
Log.d("requests", "" + newPuzzles.size() + " moved from cache to user");
}
int left = count - newPuzzles.size();
String deviceId = ResourcesPublisher.getInstance().getDeviceId();
// Don't let anyone else use these points for now
ChallengePointsManagerImpl.getInstance().usePoints(left);
Log.d("requests", "aquirePuzzles(" + left + ")");
// Get a list of requests for 'left' number of puzzles
RequestList reqList = getRequestList(left);
// TODO this is a bug, now
if(reqList.size() > 1){
reqList = getRequestList(left); // LINE (B)
}
When I run on this code, after stepping over the line (A)
m_cachedPuzzles.removePuzzles(newPuzzles);
The debugger "jumps" to the last line (B)
reqList = getRequestList(left);
A simple check shows it really skipped all code between these code lines.
For example the Log.d(...) was never called nor written.
Can anyone give me a clue why does it happen???
Thanks!
Try to do a right click > refresh on the project as it appears on the Project Explorer after you compile the code and before you start debugging.
Perhaps an exception was thrown from line A, and the next step corresponds to it closing off this stack frame?
mIsReaded = (mIsReaded)?false:true;
//mIsReaded = !mIsReaded;
saveReadFlag();
refreshUI();
Toast.makeText(getSherlockActivity(),...
In my case commented codeline cause the similar problem (two lines are skipped). For to solve it I just changed this line by codeline posted above (I mean mIsReaded = (mIsReaded)?false:true;) So different cases haves different solutions. It is result of code optimization by compiler, so please refactor something in (inside)
m_cachedPuzzles.removePuzzles(newPuzzles);
I had the same problem. The thing is, you are probably debugging the code that is in your IDE and not the on on the server. You have to deploy the code from the IDE (Eclypse, Netbeans etc.) on the server. It worked for me! Good luck!
Not directly related to Eclipse but I experienced a similar problem using the Xamarin Extension for Visual Studio and my realization may be of some help. I was developing an App with a Class library. when i made changes to the library then began emulating my App, the DLL wouldn't always rebuild so the debugger would step through the PDB as it was before my latest changes. After rebuilding the DLL, it would step through fine.
In short, rebuild dependencies if there are any changes made.
Hope you solve your issue. Have a good one
comment TODO using multi-line comment
/*// TODO this is a bug, now*/
and try again.
I have an Java class with a static final method getAll:
public static final Vector<Category> getAll(Context context, ContentValues where) {
ArrayList<Integer> IDs = null;
if(where != null && where.containsKey(DatabaseAdapter.KEY_PRODUCT)) {
IDs = OvertureItem.getAll(context, DatabaseAdapter.TABLE_PRODUCT_CATEGORY, new String[] { DatabaseAdapter.KEY_CATEGORY }, where);
} else {
IDs = OvertureItem.getAll(context, DatabaseAdapter.TABLE_CATEGORIES, where);
}
Vector<Category> categories = new Vector<Category>();
for(Integer id: IDs) {
categories.add(Category.get(context, id));
}
return categories;
}
Now I want to hand in null as a value for the where statemant so that it will just be ignored later on in the code. Anyway in the testcase for this method I have:
Vector<Category> categories = Category.getAll(context, null);
Which then in turn gives me a NoSuchMethodError. I don't know exactly why it does that. The only thing I could imagine is that the null I hand in would not match the signature of the above method. But how can I overcome this? I already thought of overloading. But this would just end in rewriting most of the code. At least when I do it, how I think.
Any suggestions on that?
Phil
P.S. This is the stack trace I get:
java.lang.NoSuchMethodError: com.sap.catalogue.model.Category.getAll
at com.sap.overture.test.model.CategoryTest.testGetAll(CategoryTest.java:59)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:430)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
If the method did not exist at compile-time, then the code would not compile.
If you get NoSuchMethodError at run-time, then this suggests that the version of the Category class you are running against is different than the version of the Category class you are compiling against.
What is your setup like - is this class in the same project? Are you copying in JARs from another project?
The real answer
So I now finally figured it out and it wasn't as obvious as I expected. I started wondering, when every new test case for any new method I wrote would give me the NoSuchMethodError. So I digged a little bit deeper and then, suddenly it came to my mind: "I changed the package name of the android application". I thought this would not make any difference to the test project as long as I kept the properties right in the AndroidManifest.xml but I was wrong!
In fact when your application package is named com.foo.bar.app, the package for your tests has to be named com.foo.bar.app.test! What happened was, that with my old configuration somehow the classes that sat in the bin/ folder were used. I thought, that they should have been deleted when I cleaned the project but they weren't. This way all of the older test cases would still pass and only the new ones would give me the NoSuchMethodError. After I deleted the bin/ folder manually I got a whole bunch of errors. I then renamed the package holding the test cases and did a full clean/ rebuild on the project et voilá everything is back to normal again.
Thanks for all the tips! I really appreciate your help that just kept me digging to the bottom of the problem. Hope this here will help anybody with the same problem in the future.
Phil