| Summary: | problems view refresh problem when generating java source file | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | jf <jf.aubert> | ||||
| Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> | ||||
| Status: | CLOSED WONTFIX | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | jf.aubert, Olivier_Thomann | ||||
| Version: | 3.1 | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | stalebug | ||||||
| Attachments: |
|
||||||
Is this still a problem? Could you please try with 3.2.1 or integration builds? Closing as REMIND. Please reopen if you get it again. Thanks for the reply Tried using 3.2.1 (testcase reproduced) Still the same Bug reopen Sorry this got lost. Could you please try again with 3.5? Please attach your project to this bug report if you get it again. I leave the bug open. Created attachment 140182 [details]
plugin directory archive
Steps to reproduce using the supplied plugin project: -create a java project (folders not separated) -enable the test plugin on the test property page for this project -add a file named test.test (this will create test.java) -fill-it with some text (no valid java code as the text is inserted in test.java) - ^S to save the file, no problem appears in the list - F5 show the problem Thanks for your help PS: I finally found a way using IProblemRequestor,ICompilationUnit & reconcile. However, the purpose of the test builder is to generate a java source file for which another builder is implemented in eclipse and is supposed to do its job, not to re-code the java builer itself. This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |
my plugin generates java source files. When compilation errors occurs, the 'problems view' doest not get correctly refreshed. Scenario: - generate bad java code . source file created . class file compiled . editor on source file shows the errors . no problem in the problems view - regenerate correct java code . source file updated . class file re-compiled . editor ok . previous compilation errors appears in the problems view Pressing the F5 key corrects the problems view, but programmatically no action can correct the view (file or java-file or project refreshLocal, add/remove marker on the file or java-file. I include here after the test-sources *** plugin.xml *** <?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.0"?> <plugin id="test" name="Test_builder Plug-in" version="1.0.0" provider-name="" class="test.TestPlugin"> <runtime> <library name="test.jar"/> </runtime> <requires> <import plugin="org.eclipse.ui"/> <import plugin="org.eclipse.core.runtime"/> <import plugin="org.eclipse.core.resources"/> </requires> <extension id="builder" name="Test Builder" point="org.eclipse.core.resources.builders"> <builder hasNature="false"> <run class="test.TestBuilder"/> </builder> </extension> <extension id="project.property.pages" point="org.eclipse.ui.propertyPages"> <page adaptable="true" objectClass="org.eclipse.core.resources.IProject" class="test.TestProjectPropertyPage" name="Test Property Page" id="project.property.page"> </page> </extension> </plugin> *** property page (to assign builder on project) *** package test; import org.eclipse.core.resources.*; import org.eclipse.ui.dialogs.*; import org.eclipse.swt.*; import org.eclipse.swt.widgets.*; import org.eclipse.swt.layout.*; public class TestProjectPropertyPage extends PropertyPage { Button activated; protected Control createContents(Composite parent) { Composite composite=new Composite(parent,SWT.NONE); GridLayout layout=new GridLayout(); composite.setLayout(layout); activated=new Button(composite,SWT.CHECK); activated.setText("enable test builder for this project"); return(composite); } public void performApply() { try { if(activated.getSelection()) { IProject project=(IProject)getElement(); IProjectDescription pd=project.getDescription (); ICommand[] commands=pd.getBuildSpec(); ICommand command=pd.newCommand(); command.setBuilderName("test.builder"); ICommand[] newCommands=new ICommand [commands.length+1]; System.arraycopy (commands,0,newCommands,0,commands.length); newCommands[commands.length]=command; pd.setBuildSpec(newCommands); project.setDescription(pd,null); } } catch(Exception e) { e.printStackTrace(); } } } *** test builder *** package test; import org.eclipse.core.runtime.*; import org.eclipse.core.resources.*; import java.io.*; public class TestBuilder extends IncrementalProjectBuilder { protected IProject[] build(int kind,java.util.Map args,IProgressMonitor monitor) { if(kind==IncrementalProjectBuilder.FULL_BUILD) { fullBuild(monitor); } else { IResourceDelta delta=getDelta(getProject()); if(delta==null) { fullBuild(monitor); } else { incrementalBuild(delta,monitor); } } return(null); } private void fullBuild(IProgressMonitor monitor) { } private void incrementalBuild(IResourceDelta delta,IProgressMonitor monitor) { try { delta.accept(new IResourceDeltaVisitor() { public boolean visit(IResourceDelta delta) { if(delta!=null && delta.getResource ().getFullPath().getFileExtension()!=null) { if(delta.getResource ().getFullPath().getFileExtension().equalsIgnoreCase("test")) { String pn=delta.getResource().getFullPath().removeFirstSegments(1).removeFileExtension ().removeLastSegments(1).toString().replaceAll("/","."); if(pn.startsWith(".")) pn=pn.substring(1); if(pn.endsWith(".")) pn=pn.substring(0,pn.length()-1); String cn=delta.getResource().getFullPath().removeFirstSegments(1).removeFileExtension ().toString().substring(pn.length()); if(cn.startsWith("/")) cn=cn.substring(1); IFile ifile=delta.getResource().getProject().getFile(delta.getResource ().getProjectRelativePath()); if(!ifile.exists()) return(true); String it=new String(); try { InputStream is=ifile.getContents(); int b; while ((b=is.read())!=-1) { it=it+ (char)b; } } catch(Exception e) { e.printStackTrace(); } IFile ofile=delta.getResource().getProject().getFile("/"+delta.getResource ().getFullPath().removeFirstSegments(1).removeFileExtension().addFileExtension ("java")); ByteArrayInputStream bais=new java.io.ByteArrayInputStream(process(pn,cn,it).toString().getBytes()); try { if(ofile.exists ()) { ofile.setContents(bais,IFile.FORCE,null); } else { ensurePathExists(ofile); ofile.create(bais,true,null); } } catch(Exception e) { e.printStackTrace(); } } } return(true); } }); } catch (CoreException e) { e.printStackTrace(); } } void ensurePathExists(IFile file) { IProject project=file.getProject(); IPath path=file.getProjectRelativePath(); String[] segments=path.segments(); IFolder folder=project.getFolder(segments[0]); for(int i=0;i<segments.length-1;i++) { try { if(!folder.exists()) folder.create (true,false,null); } catch(Exception e) { e.printStackTrace(); } folder=folder.getFolder(segments[i+1]); } } public static StringBuffer process(String packageName,String className,String text) { StringBuffer sb=new StringBuffer(); if(packageName!=null && !packageName.equals("")) { sb.append("package "+packageName.replace('/','.') +";\n"); } sb.append("\n"); sb.append("public class "+className+"\n"); sb.append("{\n"); sb.append(text); sb.append("}\n"); return(sb); } } *** To reproduct the case, simply create a test plugin with these two classes and, when running the plugin, create a project, assign it the builder using the project property page and create a file named test.test, its content will be included the <default package>/test.java source file.