quan-xie / goclipse

Automatically exported from code.google.com/p/goclipse
0 stars 0 forks source link

Incremental builds fail on Windows #116

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Under Windows 7 and Eclipse Juno, create a new project
2. Create hello.go as described in GettingStarted wiki page
3. Build hello.go
4. Make minor change to what hello.go prints.
5. Do an incremental build

What is the expected output? What do you see instead?
Incremental build should replace old binary with new binary and output should 
be visible. Instead the error log has

java.util.regex.PatternSyntaxException: Unexpected internal error near index 11
F/game/src\
           ^
    at java.util.regex.Pattern.error(Unknown Source)
    at java.util.regex.Pattern.compile(Unknown Source)
    at java.util.regex.Pattern.<init>(Unknown Source)
    at java.util.regex.Pattern.compile(Unknown Source)
    at java.lang.String.replaceFirst(Unknown Source)
    at com.googlecode.goclipse.dependency.DependencyGraph.reprocessResources(Unknown Source)
    at com.googlecode.goclipse.builder.GoBuilder.incrementalBuild(Unknown Source)
    at com.googlecode.goclipse.builder.GoBuilder.build(Unknown Source)
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:728)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374)
    at org.eclipse.core.internal.resources.Workspace.buildInternal(Workspace.java:513)
    at org.eclipse.core.internal.resources.Workspace.build(Workspace.java:422)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:827)
    at com.googlecode.goclipse.debug.launch.ui.GoLaunchShortcut.launch(Unknown Source)
    at com.googlecode.goclipse.debug.launch.ui.GoLaunchShortcut.launch(Unknown Source)
    at org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension.launch(LaunchShortcutExtension.java:434)
    at org.eclipse.debug.internal.ui.actions.LaunchShortcutAction.run(LaunchShortcutAction.java:73)
    at org.eclipse.debug.internal.ui.actions.LaunchShortcutAction.runWithEvent(LaunchShortcutAction.java:121)
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
    at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
    at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
    at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:774)
    at org.eclipse.jface.action.ActionContributionItem$9.handleEvent(ActionContributionItem.java:1284)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4169)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3758)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1022)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:916)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:585)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:540)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1438)

What version of the product are you using? On what operating system?
Windows 7, Eclipse Juno, Goeclipse 0.7.2

Please provide any additional information below.
I believe the bug is in reprocessResources() in
http://code.google.com/p/goclipse/source/browse/trunk/goclipse-n/src/com/googlec
ode/goclipse/dependency/DependencyGraph.java

In the second call to replaceFirst, the first argument is the regex 
srcfolder.toString()+File.separator. Under Windows, File.separator is the 
backslash character. A backslash character is not a valid character for a 
regex. What is wanted is \\

A possible solution is to use 
srcfolder.toString()+Pattern.quote(File.separator)

        /**
         * @param modified
         */
        public void reprocessResources(List<IResource> modified) {

                List<IFolder> srcFolders = Environment.INSTANCE.getSourceFolders(project);

                for (IResource resource: modified) {
                        for (IFolder srcfolder : srcFolders) {
                                String pkgname = "";
                                IFolder folder = null;

                                if (resource instanceof IFolder) {
                                        pkgname = resource.toString().replaceFirst(srcfolder.toString(), "");
                                        folder = project.getFolder(resource.getLocation());
                                        Set<String> dep = this.getDependencies(pkgname);
                                        dep.clear();

                                } else if (resource instanceof IFile) {
                                        folder = (IFolder)resource.getParent();
                                        pkgname = resource.getParent().toString().replaceFirst(srcfolder.toString()+File.separator, "");
                                        Set<String> dep = this.getDependencies(pkgname);
                                        dep.clear();
                                }

                                if (folder != null && folder.exists()) {

                                        try {
                                                for (IResource file: folder.members()) {
                                                        processDependencies(srcfolder, file);
                                                }

                                                Set<String> dep = this.getDependencies(pkgname);
                    } catch (IOException e) {
                        Activator.logError(e);
                    } catch (CoreException e) {
                        Activator.logError(e);
                    }
                                }

                        }
                }
    }

Original issue reported on code.google.com by cche...@gmail.com on 6 Jul 2012 at 11:05

GoogleCodeExporter commented 9 years ago

Original comment by st...@kryas.com on 19 Jul 2012 at 6:50