View | Details | Raw Unified | Return to bug 245566 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/ajdt/ui/tests/UITestCase.java (+13 lines)
Lines 28-33 Link Here
28
import org.eclipse.core.resources.IFile;
28
import org.eclipse.core.resources.IFile;
29
import org.eclipse.core.resources.IMarker;
29
import org.eclipse.core.resources.IMarker;
30
import org.eclipse.core.resources.IProject;
30
import org.eclipse.core.resources.IProject;
31
import org.eclipse.core.resources.IWorkspace;
31
import org.eclipse.core.resources.IWorkspaceRoot;
32
import org.eclipse.core.resources.IWorkspaceRoot;
32
import org.eclipse.core.resources.ResourcesPlugin;
33
import org.eclipse.core.resources.ResourcesPlugin;
33
import org.eclipse.core.runtime.CoreException;
34
import org.eclipse.core.runtime.CoreException;
Lines 251-256 Link Here
251
		}
252
		}
252
	}
253
	}
253
254
255
	/**
256
	 * Returns the IWorkspace this test suite is running on.
257
	 */
258
	public IWorkspace getWorkspace() {
259
		return ResourcesPlugin.getWorkspace();
260
	}
261
	
262
	public IWorkspaceRoot getWorkspaceRoot() {
263
		return getWorkspace().getRoot();
264
	}
265
266
	
254
	protected void waitForJobsToComplete(){
267
	protected void waitForJobsToComplete(){
255
		SynchronizationUtils.joinBackgroudActivities();
268
		SynchronizationUtils.joinBackgroudActivities();
256
	}
269
	}
(-)src/org/eclipse/ajdt/ui/tests/ErrorsTest.aj (-1 / +4 lines)
Lines 52-58 Link Here
52
				for (int i = 0; i < numAdded; i++) { // New entries are always added at the start
52
				for (int i = 0; i < numAdded; i++) { // New entries are always added at the start
53
					LogEntry entry = (LogEntry) logs[i];
53
					LogEntry entry = (LogEntry) logs[i];
54
					if(entry.getSeverity() == IStatus.ERROR || entry.getSeverity() == IStatus.WARNING) {
54
					if(entry.getSeverity() == IStatus.ERROR || entry.getSeverity() == IStatus.WARNING) {
55
						failureText += "The test added errors to the log: " + entry.getMessage() + "\n" + entry.getStack() + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
55
						if (entry.getMessage().indexOf("org.eclipse.core.tests.UnknownProvider") == -1) {//$NON-NLS-1$ 
56
							// ignore warnings that are regarding a known missing class.
57
							failureText += "The test added errors to the log: " + entry.getMessage() + "\n" + entry.getStack() + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
58
						}
56
					}
59
					}
57
				}
60
				}
58
				if (failureText.length() > 0) {
61
				if (failureText.length() > 0) {
(-)AllUITests_MaxPermSize.launch (-24 / +26 lines)
Lines 1-35 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
2
<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
3
<stringAttribute key="product" value="org.eclipse.sdk.ide"/>
3
<booleanAttribute key="askclear" value="false"/>
4
<booleanAttribute key="automaticAdd" value="true"/>
5
<booleanAttribute key="automaticValidate" value="false"/>
4
<stringAttribute key="bootstrap" value=""/>
6
<stringAttribute key="bootstrap" value=""/>
5
<booleanAttribute key="useProduct" value="true"/>
7
<stringAttribute key="checked" value="[NONE]"/>
6
<booleanAttribute key="tracing" value="false"/>
8
<booleanAttribute key="clearConfig" value="true"/>
9
<booleanAttribute key="clearws" value="true"/>
10
<booleanAttribute key="clearwslog" value="false"/>
11
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
12
<booleanAttribute key="default" value="true"/>
13
<booleanAttribute key="includeOptional" value="true"/>
14
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
15
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
16
<listEntry value="/org.eclipse.ajdt.ui.tests/src/org/eclipse/ajdt/ui/tests/AllUITests.java"/>
17
</listAttribute>
7
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
18
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
8
<listEntry value="4"/>
19
<listEntry value="1"/>
9
</listAttribute>
20
</listAttribute>
21
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
10
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
22
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
11
<booleanAttribute key="automaticValidate" value="false"/>
12
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
23
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
13
<booleanAttribute key="automaticAdd" value="true"/>
24
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
14
<stringAttribute key="checked" value="[NONE]"/>
25
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
15
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
16
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
17
<booleanAttribute key="clearws" value="true"/>
18
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ajdt.ui.tests.AllUITests"/>
26
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ajdt.ui.tests.AllUITests"/>
19
<stringAttribute key="pde.version" value="3.3"/>
27
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.ajdt.ui.tests"/>
20
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-XX:MaxPermSize=128m"/>
21
<booleanAttribute key="default" value="true"/>
22
<booleanAttribute key="clearConfig" value="true"/>
23
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
24
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
28
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
25
<booleanAttribute key="useDefaultConfigArea" value="false"/>
29
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-XX:MaxPermSize=128m -Xmx1024m"/>
30
<stringAttribute key="pde.version" value="3.3"/>
31
<stringAttribute key="product" value="org.eclipse.sdk.ide"/>
32
<booleanAttribute key="show_selected_only" value="false"/>
33
<booleanAttribute key="tracing" value="false"/>
26
<booleanAttribute key="useDefaultConfig" value="true"/>
34
<booleanAttribute key="useDefaultConfig" value="true"/>
27
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
35
<booleanAttribute key="useDefaultConfigArea" value="false"/>
28
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.ajdt.ui.tests"/>
36
<booleanAttribute key="useProduct" value="true"/>
29
<booleanAttribute key="askclear" value="false"/>
30
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
31
<listEntry value="/org.eclipse.ajdt.ui.tests"/>
32
</listAttribute>
33
<booleanAttribute key="includeOptional" value="true"/>
34
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
35
</launchConfiguration>
37
</launchConfiguration>
(-)src/org/eclipse/ajdt/ui/tests/builder/BuildPathNavigationTests.java (+128 lines)
Added Link Here
1
package org.eclipse.ajdt.ui.tests.builder;
2
3
import org.eclipse.jdt.core.IJavaProject;
4
import org.eclipse.ajdt.core.AspectJCorePreferences;
5
import org.eclipse.ajdt.ui.AspectJUIPlugin;
6
import org.eclipse.ajdt.ui.tests.UITestCase;
7
import org.eclipse.core.resources.IFile;
8
import org.eclipse.core.resources.IMarker;
9
import org.eclipse.core.resources.IProject;
10
import org.eclipse.core.resources.IncrementalProjectBuilder;
11
import org.eclipse.core.runtime.CoreException;
12
import org.eclipse.core.runtime.IPath;
13
import org.eclipse.core.runtime.Path;
14
import org.eclipse.jdt.core.IClasspathAttribute;
15
import org.eclipse.jdt.core.IClasspathContainer;
16
import org.eclipse.jdt.core.IClasspathEntry;
17
import org.eclipse.jdt.core.JavaCore;
18
19
public class BuildPathNavigationTests extends UITestCase {
20
	IClasspathContainer container;
21
    protected void setUp() throws Exception {
22
        super.setUp();
23
        final IProject containerProj = createPredefinedProject("PathTesting-ContainerOnAspectPath"); //$NON-NLS-1$
24
        createPredefinedProject("PathTesting-JarOnAspectPath"); //$NON-NLS-1$
25
        createPredefinedProject("PathTesting-ProjectOnAspectPath"); //$NON-NLS-1$
26
        IProject varProj = createPredefinedProject("PathTesting-VariableOnAspectPath"); //$NON-NLS-1$
27
        JavaCore.setClasspathVariable("Aspect_Path_Var", varProj.getFullPath(), null); //$NON-NLS-1$
28
		IClasspathAttribute[] attribute = new IClasspathAttribute[] {AspectJCorePreferences.ASPECTPATH_ATTRIBUTE };
29
		final IClasspathEntry entry = 
30
				JavaCore.newProjectEntry(
31
						containerProj.getFullPath(), 
32
						null, false, 
33
						attribute, 
34
						false);
35
		
36
		container = new IClasspathContainer() {
37
			public IClasspathEntry[] getClasspathEntries() {
38
				return new IClasspathEntry[] { entry };
39
			}
40
			public String getDescription() {
41
				return "org.eclipse.jdt.USER_LIBRARY/Aspect_Path_Lib"; //$NON-NLS-1$
42
			}
43
			public int getKind() {
44
			      return IClasspathContainer.K_APPLICATION;
45
			}
46
			public IPath getPath() {
47
				return new Path("org.eclipse.jdt.USER_LIBRARY/Aspect_Path_Lib"); //$NON-NLS-1$
48
			}
49
		};
50
    }
51
52
    
53
    /**
54
     * Test to see that the extra location attributes are associated with advice markers for inpaths
55
     * 
56
     * This attribute has the format FFFF:::NNNN:::NNNN:::NNNN
57
     * - The FFFF is the file which contains the source of the advice or ITD in affect
58
     * - The other three NNNN fields are integers indicating (in order) the
59
     *   start line number of the advice in that file, the end line number of the
60
     *   advice in that file and the column number for the advice.
61
     */
62
    public void testInpathMarkers() throws Exception {
63
        try {
64
            IProject inpathProj = createPredefinedProject("PathTesting-HasInpath"); //$NON-NLS-1$
65
    		JavaCore.setClasspathContainer(container.getPath(), new IJavaProject[] { JavaCore.create(inpathProj) }, 
66
    				new IClasspathContainer[] { container }, null);
67
68
            getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null);
69
            waitForJobsToComplete();
70
            IFile aspectFile = inpathProj.getFile("src/aspects/AdviseClassOnInpath.aj"); //$NON-NLS-1$
71
            
72
            IMarker[] markers = aspectFile.findMarkers(IMarker.MARKER, true, 2);
73
            
74
            // should have one marker for each advice (ie- 5)
75
            assertEquals("Invalid number of markers on file " + aspectFile, 5, markers.length); //$NON-NLS-1$
76
            
77
            // each marker should have extra information attached to it
78
            for (int i = 0; i < markers.length; i++) {
79
                IMarker marker = markers[i];
80
                String loc = (String) marker.getAttribute(AspectJUIPlugin.RELATED_LOCATIONS_ATTRIBUTE_PREFIX + 0);
81
                assertNotNull("No location attached to marker number " + i, loc); //$NON-NLS-1$
82
                
83
                String[] s = loc.split(":::"); //$NON-NLS-1$
84
                assertEquals("Invalid extra location attribute format\n    " + loc, 4, s.length); //$NON-NLS-1$
85
            }
86
        } catch (CoreException e) {
87
            fail();
88
        }
89
    }
90
91
    /**
92
     * Test to see that the extra location attributes are associated with advice markers for aspect paths
93
     * 
94
     * This attribute has the format FFFF:::NNNN:::NNNN:::NNNN
95
     * - The FFFF is the file which contains the source of the advice or ITD in affect
96
     * - The other three NNNN fields are integers indicating (in order) the
97
     *   start line number of the advice in that file, the end line number of the
98
     *   advice in that file and the column number for the advice.
99
     */
100
    public void testAspectPathMarkers() {
101
        try {
102
            IProject aspectPathProj = createPredefinedProject("PathTesting-HasAspectPath"); //$NON-NLS-1$
103
    		JavaCore.setClasspathContainer(container.getPath(), new IJavaProject[] { JavaCore.create(aspectPathProj) }, 
104
    				new IClasspathContainer[] { container }, null);
105
106
    		getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null);
107
            waitForJobsToComplete();
108
            IFile aspectFile = aspectPathProj.getFile("src/main/Main.java"); //$NON-NLS-1$
109
            
110
            IMarker[] markers = aspectFile.findMarkers(IMarker.MARKER, true, 2);
111
            
112
            System.out.println(getAllProblemViewMarkers()[0].getAttribute(IMarker.MESSAGE));
113
            // should have one marker for each advised method (ie- 4)
114
            assertEquals("Invalid number of markers on file " + aspectFile, 4, markers.length); //$NON-NLS-1$
115
            // each marker should have extra information attached to it
116
            for (int i = 0; i < markers.length; i++) {
117
                IMarker marker = markers[i];
118
                String loc = (String) marker.getAttribute(AspectJUIPlugin.RELATED_LOCATIONS_ATTRIBUTE_PREFIX + 0);
119
                assertNotNull("No location attached to marker number " + i, loc); //$NON-NLS-1$
120
                
121
                String[] s = loc.split(":::"); //$NON-NLS-1$
122
                assertEquals("Invalid extra location attribute format\n    " + loc, 4, s.length); //$NON-NLS-1$
123
            }
124
        } catch (CoreException e) {
125
            fail();
126
        }
127
    }
128
}
(-)src/org/eclipse/ajdt/core/tests/AllCoreTests.java (-1 / +9 lines)
Lines 14-25 Link Here
14
import junit.framework.Test;
14
import junit.framework.Test;
15
import junit.framework.TestSuite;
15
import junit.framework.TestSuite;
16
16
17
import org.eclipse.ajdt.core.tests.ajde.CoreCompilerConfigurationTests;
18
import org.eclipse.ajdt.core.tests.ajde.CoreCompilerConfigurationTests2;
19
import org.eclipse.ajdt.core.tests.ajde.CoreCompilerFactoryTests;
17
import org.eclipse.ajdt.core.tests.builder.AJBuilderTest;
20
import org.eclipse.ajdt.core.tests.builder.AJBuilderTest;
18
import org.eclipse.ajdt.core.tests.builder.AJBuilderTest2;
21
import org.eclipse.ajdt.core.tests.builder.AJBuilderTest2;
19
import org.eclipse.ajdt.core.tests.builder.AspectPathTests;
22
import org.eclipse.ajdt.core.tests.builder.AspectPathTests;
20
import org.eclipse.ajdt.core.tests.builder.Bug159197Test;
23
import org.eclipse.ajdt.core.tests.builder.Bug159197Test;
21
import org.eclipse.ajdt.core.tests.builder.Bug99133Test;
22
import org.eclipse.ajdt.core.tests.builder.Bug43711Test;
24
import org.eclipse.ajdt.core.tests.builder.Bug43711Test;
25
import org.eclipse.ajdt.core.tests.builder.Bug99133Test;
23
import org.eclipse.ajdt.core.tests.builder.CoreOutputLocationManagerTest;
26
import org.eclipse.ajdt.core.tests.builder.CoreOutputLocationManagerTest;
24
import org.eclipse.ajdt.core.tests.codeconversion.AspectsConvertingParserTest;
27
import org.eclipse.ajdt.core.tests.codeconversion.AspectsConvertingParserTest;
25
import org.eclipse.ajdt.core.tests.codeconversion.CodeCheckerTest;
28
import org.eclipse.ajdt.core.tests.codeconversion.CodeCheckerTest;
Lines 77-82 Link Here
77
		suite.addTest(new TestSuite(AJRelationshipManagerTest.class));
80
		suite.addTest(new TestSuite(AJRelationshipManagerTest.class));
78
		suite.addTest(new TestSuite(BinaryWeavingSupportTest.class));
81
		suite.addTest(new TestSuite(BinaryWeavingSupportTest.class));
79
		
82
		
83
		// core compiler configuration
84
        suite.addTest(new TestSuite(CoreCompilerConfigurationTests.class));
85
        suite.addTest(new TestSuite(CoreCompilerConfigurationTests2.class));
86
        suite.addTest(new TestSuite(CoreCompilerFactoryTests.class));
87
80
		// Java Element tests
88
		// Java Element tests
81
		suite.addTest(new TestSuite(AspectElementTests.class));
89
		suite.addTest(new TestSuite(AspectElementTests.class));
82
90
(-)src/org/eclipse/ajdt/core/tests/testutils/TestLogger.java (-2 / +4 lines)
Lines 133-143 Link Here
133
     * Clears the log
133
     * Clears the log
134
     */
134
     */
135
    public void clearLog() {
135
    public void clearLog() {
136
    	log.clear();
136
        if (log != null) {
137
            log.clear();
138
        }
137
    }
139
    }
138
    
140
    
139
    public boolean isEmpty() {
141
    public boolean isEmpty() {
140
    	return log.isEmpty();
142
    	return log != null && log.isEmpty();
141
    }
143
    }
142
    
144
    
143
    /**
145
    /**
(-)src/org/eclipse/ajdt/core/tests/builder/AJBuilderTest.java (-3 / +3 lines)
Lines 400-406 Link Here
400
		assertTrue(
400
		assertTrue(
401
				"AJDT should have found no source file changes and decided not to build", //$NON-NLS-1$
401
				"AJDT should have found no source file changes and decided not to build", //$NON-NLS-1$
402
				listContainsString(buildLog, "build: Examined delta - no " + //$NON-NLS-1$
402
				listContainsString(buildLog, "build: Examined delta - no " + //$NON-NLS-1$
403
						"source file changes for project bug99133b")); //$NON-NLS-1$
403
						"source file or classpath changes for project bug99133b")); //$NON-NLS-1$
404
		assertFalse("There should be no errors in the build log", //$NON-NLS-1$
404
		assertFalse("There should be no errors in the build log", //$NON-NLS-1$
405
				listContainsString(buildLog, "error")); //$NON-NLS-1$
405
				listContainsString(buildLog, "error")); //$NON-NLS-1$
406
406
Lines 471-477 Link Here
471
		assertTrue(
471
		assertTrue(
472
				"AJDT should have found no source file changes and decided not to build", //$NON-NLS-1$
472
				"AJDT should have found no source file changes and decided not to build", //$NON-NLS-1$
473
				listContainsString(buildLog, "build: Examined delta - no " + //$NON-NLS-1$
473
				listContainsString(buildLog, "build: Examined delta - no " + //$NON-NLS-1$
474
						"source file changes for project bug99133b")); //$NON-NLS-1$
474
						"source file or classpath changes for project bug99133b")); //$NON-NLS-1$
475
		assertFalse("There should be no errors in the build log", //$NON-NLS-1$
475
		assertFalse("There should be no errors in the build log", //$NON-NLS-1$
476
				listContainsString(buildLog, "error")); //$NON-NLS-1$
476
				listContainsString(buildLog, "error")); //$NON-NLS-1$
477
477
Lines 550-556 Link Here
550
		assertTrue(
550
		assertTrue(
551
				"AJDT should have found no source file changes and decided not to build", //$NON-NLS-1$
551
				"AJDT should have found no source file changes and decided not to build", //$NON-NLS-1$
552
				listContainsString(buildLogB, "build: Examined delta - no " + //$NON-NLS-1$
552
				listContainsString(buildLogB, "build: Examined delta - no " + //$NON-NLS-1$
553
						"source file changes for project bug99133b")); //$NON-NLS-1$
553
						"source file or classpath changes for project bug99133b")); //$NON-NLS-1$
554
554
555
		// by checking that we don't have the following messages in the
555
		// by checking that we don't have the following messages in the
556
		// log (and the previous checking for no errors) we know that
556
		// log (and the previous checking for no errors) we know that
(-)workspace/AspectProj2-On (+18 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>AspectProj2-On AspectPath</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.ajdt.core.ajbuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
	</buildSpec>
14
	<natures>
15
		<nature>org.eclipse.ajdt.ui.ajnature</nature>
16
		<nature>org.eclipse.jdt.core.javanature</nature>
17
	</natures>
18
</projectDescription>
(-)workspace/AspectProj1/.project (+18 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>AspectProj1</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.ajdt.core.ajbuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
	</buildSpec>
14
	<natures>
15
		<nature>org.eclipse.ajdt.ui.ajnature</nature>
16
		<nature>org.eclipse.jdt.core.javanature</nature>
17
	</natures>
18
</projectDescription>
(-)workspace/AspectProj3-Has (+7 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5
	<classpathentry kind="con" path="org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
(-)workspace/AspectProj2-On (+7 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5
	<classpathentry kind="con" path="org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
(-)workspace/AspectProjWeCareAbout/.project (+18 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>AspectProjWeCareAbout</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.ajdt.core.ajbuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
	</buildSpec>
14
	<natures>
15
		<nature>org.eclipse.ajdt.ui.ajnature</nature>
16
		<nature>org.eclipse.jdt.core.javanature</nature>
17
	</natures>
18
</projectDescription>
(-)workspace/AspectProj2-On (+5 lines)
Added Link Here
1
package b;
2
3
public class B {
4
5
}
(-)workspace/AspectProjWeCareAbout/.classpath (+21 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5
	<classpathentry kind="con" path="org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"/>
6
	<classpathentry kind="src" path="/JavaProj2-On Inpath">
7
		<attributes>
8
			<attribute name="org.eclipse.ajdt.inpath" value="org.eclipse.ajdt.aspectpath"/>
9
		</attributes>
10
	</classpathentry>
11
	<classpathentry kind="src" path="/AspectProj2-On AspectPath">
12
		<attributes>
13
			<attribute name="org.eclipse.ajdt.aspectpath" value="org.eclipse.ajdt.aspectpath"/>
14
		</attributes>
15
	</classpathentry>
16
	<classpathentry combineaccessrules="false" kind="src" path="/AspectProj1"/>
17
	<classpathentry combineaccessrules="false" kind="src" path="/JavaProj1"/>
18
	<classpathentry kind="lib" path="/JavaProj3-ClassFolder/bin"/>
19
	<classpathentry kind="lib" path="/AspectProj3-Has Outjar/output.jar"/>
20
	<classpathentry kind="output" path="bin"/>
21
</classpath>
(-)workspace/JavaProj2-On (+17 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>JavaProj2-On Inpath</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
	</buildSpec>
14
	<natures>
15
		<nature>org.eclipse.jdt.core.javanature</nature>
16
	</natures>
17
</projectDescription>
(-)workspace/AspectProjWeCareAbout/src/a/B.java (+5 lines)
Added Link Here
1
package a;
2
3
public class B {
4
5
}
(-)workspace/AspectProj3-Has (+18 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>AspectProj3-Has Outjar</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.ajdt.core.ajbuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
	</buildSpec>
14
	<natures>
15
		<nature>org.eclipse.ajdt.ui.ajnature</nature>
16
		<nature>org.eclipse.jdt.core.javanature</nature>
17
	</natures>
18
</projectDescription>
(-)workspace/JavaProj3-ClassFolder/.classpath (+6 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5
	<classpathentry kind="output" path="bin"/>
6
</classpath>
(-)workspace/AspectProj1/.classpath (+7 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5
	<classpathentry kind="con" path="org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
(-)workspace/JavaProj1/bin/c/D.class (+7 lines)
Added Link Here
1
Êþº¾1c/Djava/lang/Object<init>()VCode
2
	LineNumberTableLocalVariableTablethisLc/D;x()I
3
SourceFileD.java!/*·±
4
5
-	¬
6
7
(-)workspace/AspectProj3-Has (+5 lines)
Added Link Here
1
package f;
2
3
public class OnOutJar {
4
 
5
} 
(-)workspace/JavaProj1/.classpath (+6 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5
	<classpathentry kind="output" path="bin"/>
6
</classpath>
(-)workspace/AspectProj3-Has (+3 lines)
Added Link Here
1
#Thu Sep 04 11:34:44 PDT 2008
2
eclipse.preferences.version=1
3
org.eclipse.ajdt.ui.outJar=output.jar
(-)src/org/eclipse/ajdt/core/tests/ajde/CoreCompilerConfigurationTests.java (+280 lines)
Added Link Here
1
package org.eclipse.ajdt.core.tests.ajde;
2
3
import java.io.StringReader;
4
5
import org.eclipse.ajdt.core.AspectJCorePreferences;
6
import org.eclipse.ajdt.core.AspectJPlugin;
7
import org.eclipse.ajdt.core.tests.AJDTCoreTestCase;
8
import org.eclipse.ajdt.core.tests.testutils.ReaderInputStream;
9
import org.eclipse.ajdt.core.tests.testutils.TestLogger;
10
import org.eclipse.ajdt.core.tests.testutils.Utils;
11
import org.eclipse.core.resources.IProject;
12
import org.eclipse.core.resources.IncrementalProjectBuilder;
13
14
15
/**
16
 * This class tests Bug 245566. The use of ICompilerConfiguration's
17
 * api should reduce overhead in preparing for incremenental builds
18
 */
19
public class CoreCompilerConfigurationTests extends AJDTCoreTestCase {
20
    private TestLogger testLog;
21
22
    protected void setUp() throws Exception {
23
        super.setUp();
24
        Utils.setAutobuilding(false);
25
        testLog = new TestLogger();
26
        AspectJPlugin.getDefault().setAJLogger(testLog);
27
        AspectJCorePreferences.setIncrementalCompilationOptimizationsEnabled(true);
28
    }
29
30
    protected void tearDown() throws Exception {
31
        super.tearDown();
32
        Utils.setAutobuilding(true);
33
        AspectJCorePreferences.setIncrementalCompilationOptimizationsEnabled(false);
34
    }
35
    
36
    // test to ensure that when the switch is turned off, optimization does not occur
37
    public void testIncrementalCompilationOptimizationsEnabled() throws Exception {
38
        
39
        assertTrue(AspectJCorePreferences.isIncrementalCompilationOptimizationsEnabled());
40
        AspectJCorePreferences.setIncrementalCompilationOptimizationsEnabled(false);
41
        assertFalse(AspectJCorePreferences.isIncrementalCompilationOptimizationsEnabled());
42
        
43
        // load project and full build
44
        IProject proj = createPredefinedProject("Bean Example");
45
46
        testLog.clearLog();
47
        
48
        proj.getFile("src/bean/Point.java").touch(null);
49
        
50
        // incremental build
51
        getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
52
        waitForAutoBuild();
53
54
        // ensure that the classpath entries list has not been set
55
        assertEquals(0, testLog.numberOfEntriesForMessage("Setting list of classpath elements with modified contents:"));
56
        assertEquals(1, testLog.numberOfEntriesForMessage("Optimizations turned off, so assuming all parts of configuration have changed"));
57
        assertEquals(1, testLog.numberOfEntriesForMessage("Configuration was []"));
58
        assertEquals(1, testLog.numberOfEntriesForMessage("Resetting list of modified source files.  Was [/Users/andrew/Eclipse/Workspaces/junit-workspace/Bean Example/src/bean/Point.java]"));
59
    }
60
    
61
    
62
    public void testChangeSourceFiles() throws Exception {
63
64
        // load project and full build
65
        IProject proj = createPredefinedProject("Bean Example");
66
        
67
        // touch source files (one Java and one AJ)
68
        proj.getFile("src/bean/Point.java").touch(null);
69
        proj.getFile("src/bean/BoundPoint.aj").touch(null);
70
71
        testLog.clearLog();
72
        
73
        // incremental build
74
        getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
75
        waitForAutoBuild();
76
        
77
        // look at AJDT Event trace
78
        // when build is determining which source files have changed
79
        assertEquals(1, testLog.numberOfEntriesForMessage("File: /Users/andrew/Eclipse/Workspaces/junit-workspace/Bean Example/src/bean/Point.java has changed."));
80
        assertEquals(1, testLog.numberOfEntriesForMessage("File: /Users/andrew/Eclipse/Workspaces/junit-workspace/Bean Example/src/bean/BoundPoint.aj has changed."));
81
        
82
        // should not happen.  this line should only be logged when a file is added or deleted
83
        assertEquals(0, testLog.numberOfEntriesForMessage("CoreCompilerConfiguration for project Bean Example registered a configuration change: [PROJECTSOURCEFILES_CHANGED]"));
84
85
        // during a callback from ajc
86
        assertEquals(1, testLog.numberOfEntriesForMessage("build: Examined delta - 2 changed, 0 added, and 0 deleted source files in required project Bean Example"));
87
        
88
        // after compilation can reset configuration
89
        assertEquals(1, testLog.numberOfEntriesForMessage("Resetting list of modified source files.  Was [/Users/andrew/Eclipse/Workspaces/junit-workspace/Bean Example/src/bean/BoundPoint.aj, /Users/andrew/Eclipse/Workspaces/junit-workspace/Bean Example/src/bean/Point.java]"));
90
91
        // when the configuration is being reset
92
        assertEquals(1, testLog.numberOfEntriesForMessage("Configuration was []"));
93
    }
94
    
95
    // also test creating and deleting source files and resources
96
    public void testAddDeleteSourceFiles() throws Exception {
97
        // load project and full build
98
        IProject proj = createPredefinedProject("Bean Example");
99
        
100
        testLog.clearLog();
101
102
        // create a Java file and an Aspect file
103
        proj.getFile("src/MyJavaFile.java").create(new ReaderInputStream(new StringReader("public class MyJavaFile { }")), 
104
                true, null);
105
        proj.getFile("src/MyAspectFile.aj").create(new ReaderInputStream(new StringReader("public aspect MyAspectFile { }")), 
106
                true, null);
107
        
108
        // incremental build
109
        getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
110
        waitForAutoBuild();
111
112
        // now delete the files
113
        proj.getFile("src/MyJavaFile.java").delete(true, null);
114
        proj.getFile("src/MyAspectFile.aj").delete(true, null);
115
        
116
        // incremental build
117
        getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
118
        waitForAutoBuild();
119
120
        // check log
121
        
122
        // should not have found any changes, only additions and deletions
123
        assertEquals(1, testLog.numberOfEntriesForMessage("build: Examined delta - 0 changed, 2 added, and 0 deleted source files in required project Bean Example"));
124
        assertEquals(1, testLog.numberOfEntriesForMessage("build: Examined delta - 0 changed, 0 added, and 2 deleted source files in required project Bean Example"));
125
        
126
        // all of these items should appear twice: once on creation and once on deletion
127
        assertEquals(2, testLog.numberOfEntriesForMessage("Compiler configuration for project Bean Example has been read by compiler.  Resetting."));
128
        assertEquals(2, testLog.numberOfEntriesForMessage("Configuration was [PROJECTSOURCEFILES_CHANGED]"));
129
        assertEquals(2, testLog.numberOfEntriesForMessage("Resetting list of modified source files.  Was []"));
130
131
        // occurs 4 times: twice on creation and twice on deletion
132
        assertEquals(4, testLog.numberOfEntriesForMessage("CoreCompilerConfiguration for project Bean Example registered a configuration change: [PROJECTSOURCEFILES_CHANGED]"));
133
        
134
        // this last entry occurs only once after the aspect is deleted
135
        assertEquals(1, testLog.numberOfEntriesForMessage("Preparing for build: not going to be incremental because an aspect was deleted"));
136
    }
137
    
138
    public void testClasspathChange() throws Exception {
139
        // load project and full build
140
        IProject proj = createPredefinedProject("Bean Example");
141
        
142
        // touch classpath
143
        proj.getFile(".classpath").touch(null);
144
145
        testLog.clearLog();
146
        
147
        // incremental build
148
        getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
149
        waitForAutoBuild();
150
        
151
        // look at AJDT Event trace
152
        // the configuration should have registered a change:
153
        assertEquals(1, testLog.numberOfEntriesForMessage("CoreCompilerConfiguration for project Bean Example registered a configuration change: [ASPECTPATH_CHANGED, CLASSPATH_CHANGED, INPATH_CHANGED]"));
154
        
155
        // classpath has been changed, so should not see this message
156
        assertEquals(0, testLog.numberOfEntriesForMessage("build: Examined delta - no source file or classpath changes for project Bean Example"));
157
    }
158
159
    /**
160
     * before the first build after a clean, any changes to the
161
     * configuration should not be recorded because the compiler has 
162
     * nothing to compare the changes to.
163
     * @throws Exception
164
     */
165
    public void testChangeBeforeBuild() throws Exception {
166
        // load project and full build
167
        IProject proj = createPredefinedProject("Bean Example");
168
169
        testLog.clearLog();
170
        
171
        // now do a clean so that the previous build is forgotten
172
        getWorkspace().build(IncrementalProjectBuilder.CLEAN_BUILD, null);
173
        
174
        proj.getFile("src/bean/Point.java").touch(null);
175
        proj.getFile("src/bean/BoundPoint.aj").touch(null);
176
        proj.getFile(".classpath").touch(null);
177
        
178
        // incremental build
179
        getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
180
        waitForAutoBuild();
181
        
182
        
183
        // since there was no state before and hence no ResourceDelta, 
184
        // we know that there must be certain entries missing from the log
185
        assertEquals(0, testLog.numberOfEntriesForMessage("File: /Users/andrew/Eclipse/Workspaces/junit-workspace/Bean Example/src/bean/Point.java has changed."));
186
        assertEquals(0, testLog.numberOfEntriesForMessage("File: /Users/andrew/Eclipse/Workspaces/junit-workspace/Bean Example/src/bean/BoundPoint.aj has changed."));
187
        assertEquals(0, testLog.numberOfEntriesForMessage("CoreCompilerConfiguration for project Bean Example registered a configuration change: [PROJECTSOURCEFILES_CHANGED]"));
188
189
        assertEquals(1, testLog.numberOfEntriesForMessage("Compiler configuration for project Bean Example doesn't know previous state, so assuming EVERYTHING has changed."));
190
        
191
        // and what should we be seeing about the classpath?
192
        
193
        // the previous set of config changes was *everything*, so
194
        // this was sent to the compiler
195
        assertEquals(1, testLog.numberOfEntriesForMessage("Configuration was [PROJECTSOURCEFILES_CHANGED, JAVAOPTIONS_CHANGED, ASPECTPATH_CHANGED, CLASSPATH_CHANGED, INPATH_CHANGED, NONSTANDARDOPTIONS_CHANGED, OUTJAR_CHANGED, PROJECTSOURCERESOURCES_CHANGED, OUTPUTDESTINATIONS_CHANGED, INJARS_CHANGED]"));
196
    }
197
    
198
    // also test creating and deleting source files and resources
199
    public void testAddDeleteChangeReources() throws Exception {
200
        // load project and full build
201
        IProject proj = createPredefinedProject("Bean Example");
202
        
203
        testLog.clearLog();
204
205
        // create a resource
206
        proj.getFile("src/nothing.txt").create(new ReaderInputStream(new StringReader("nothing interesting")), 
207
                true, null);
208
209
        // incremental build
210
        getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
211
        waitForAutoBuild();
212
213
        // touch the resource
214
        proj.getFile("src/nothing.txt").touch(null);
215
216
        // incremental build
217
        getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
218
        waitForAutoBuild();
219
        
220
        // delete the resource
221
        proj.getFile("src/nothing.txt").delete(true, null);
222
        
223
        // incremental build
224
        getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
225
        waitForAutoBuild();
226
        
227
        // check log
228
        // 3 builds, but only 2 should have resource files changed in it
229
        // only occurs when resources are added or deleted.
230
        assertEquals(2, testLog.numberOfEntriesForMessage("CoreCompilerConfiguration for project Bean Example registered a configuration change: [PROJECTSOURCERESOURCES_CHANGED]"));
231
        
232
        // no source files have changed, though
233
        assertEquals(3, testLog.numberOfEntriesForMessage("build: Examined delta - no source file or classpath changes for project Bean Example"));
234
        
235
        // also make sure the file was copied and deleted properly
236
        assertEquals(1, testLog.numberOfEntriesForMessage("Copying added file nothing.txt"));
237
        assertEquals(1, testLog.numberOfEntriesForMessage("Deleting existing file nothing.txt"));
238
        assertEquals(1, testLog.numberOfEntriesForMessage("Copying changed file nothing.txt"));
239
        assertEquals(1, testLog.numberOfEntriesForMessage("Deleting removed file nothing.txt"));
240
    }
241
    
242
    // now test what happens when the build is broken
243
    // not really sure what the behavior should be.
244
    public void testBadBuild() throws Exception {
245
        // load project and full build
246
        IProject proj = createPredefinedProject("Bean Example");
247
        
248
        testLog.clearLog();
249
250
        // create a source file
251
        proj.getFile("src/MyAspectFile.aj").create(new ReaderInputStream(new StringReader("public aspect MyAspectFile { }")), 
252
                true, null);
253
        
254
        // incremental build
255
        getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
256
        waitForAutoBuild();
257
258
        // add an error to the source file
259
        proj.getFile("src/MyAspectFile.aj").appendContents(new ReaderInputStream(new StringReader("XXX")), 
260
                true, false, null);
261
        
262
        // incremental build
263
        getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
264
        waitForAutoBuild();
265
266
        
267
        // remove the error
268
        proj.getFile("src/MyAspectFile.aj").setContents(new ReaderInputStream(new StringReader("public aspect MyAspectFile { }")), 0, null);
269
        
270
        // incremental build
271
        getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
272
        waitForAutoBuild();
273
        
274
        // check log
275
        testLog.printLog();
276
    }
277
    
278
    
279
280
}
(-)workspace/JavaProj1/src/c/B.java (+5 lines)
Added Link Here
1
package c;
2
3
public class B {
4
5
}
(-)workspace/JavaProj1/bin/c/B.class (+5 lines)
Added Link Here
1
Êþº¾1c/Bjava/lang/Object<init>()VCode
2
	LineNumberTableLocalVariableTablethisLc/B;
3
SourceFileB.java!/*·±
4
5
(-)workspace/AspectProj3-Has (+3 lines)
Added Link Here
1
PKÎ]$9META-INF/MANIFEST.MFþÊóMÌËLK-.Ñ
2
K-*ÎÌϳR0Ô3àår.JM,IMÑuª´Rp,.HM.ñRpÎÏ-ÈÌI-âåâåPK²ÔWŠ97PKÎ]$9f/OnOutJar.classENÁÁPœÕj©¢ñn8hœ‰‹ÄA=÷×zxRmR­ÿr’8ø%¶Eì&³;»³™}¾î#8&*kçú±Ÿg‘šÐ	ÎQ\„‰xïúÁQ†Á˜¨XeS‚Öëoú,ÙJê6ª0mOÅr™Ÿ™®EIBÇKBmDª
3
þêÙA	¶÷w³ÿ*ÉÓPÎU!iþÃâtÁž(‚8ًÑd斨n¨]¹©Àb4Ê¡†£ýpm–ç­RÕ~PK}>¥ÀýPKÎ]$9²ÔWŠ97META-INF/MANIFEST.MFþÊPKÎ]$9}>¥Àýf/OnOutJar.classPK„}
(-)src/org/eclipse/ajdt/core/tests/ajde/CoreCompilerConfigurationTests2.java (+210 lines)
Added Link Here
1
package org.eclipse.ajdt.core.tests.ajde;
2
3
import java.io.StringReader;
4
5
import org.eclipse.ajdt.core.AspectJCorePreferences;
6
import org.eclipse.ajdt.core.AspectJPlugin;
7
import org.eclipse.ajdt.core.tests.AJDTCoreTestCase;
8
import org.eclipse.ajdt.core.tests.testutils.ReaderInputStream;
9
import org.eclipse.ajdt.core.tests.testutils.TestLogger;
10
import org.eclipse.ajdt.core.tests.testutils.Utils;
11
import org.eclipse.core.resources.IProject;
12
import org.eclipse.core.resources.IncrementalProjectBuilder;
13
14
/**
15
 * this set of tests ensures that the CoreCompilerConfiguration.getClasspathElementsWithModifiedContents() method 
16
 * works properly
17
 * 
18
 * Actually, this test class tests the method AJBuilder.getChangedRequiredProjects
19
 */
20
public class CoreCompilerConfigurationTests2 extends AJDTCoreTestCase {
21
22
    private TestLogger testLog;
23
24
    private IProject jp1;
25
//    private IProject jp2;  // not used
26
    private IProject jp3;
27
    private IProject ap1;
28
    private IProject ap2;
29
    private IProject ap3;
30
    private IProject myProj;
31
    
32
    protected void setUp() throws Exception {
33
        super.setUp();
34
        Utils.setAutobuilding(false);
35
        testLog = new TestLogger();
36
        AspectJPlugin.getDefault().setAJLogger(testLog);
37
        
38
        jp1 = createPredefinedProject("JavaProj1");
39
        /* jp2 = */ createPredefinedProject("JavaProj2-On Inpath");
40
        jp3 = createPredefinedProject("JavaProj3-ClassFolder");
41
        ap1 = createPredefinedProject("AspectProj1");
42
        ap2 = createPredefinedProject("AspectProj2-On AspectPath");
43
        ap3 = createPredefinedProject("AspectProj3-Has Outjar");
44
        myProj = createPredefinedProject("AspectProjWeCareAbout");
45
        
46
        AspectJCorePreferences.setIncrementalCompilationOptimizationsEnabled(true);
47
    }
48
49
    protected void tearDown() throws Exception {
50
        super.tearDown();
51
        Utils.setAutobuilding(true);
52
        AspectJCorePreferences.setIncrementalCompilationOptimizationsEnabled(false);
53
    }
54
    
55
    /*
56
     * When there are no changes, only the
57
     * projects on the inpath should be listed as modified
58
     */
59
    public void testNoChange() throws Exception {
60
        testLog.clearLog();
61
62
        // change myProj
63
        myProj.getFile("src/a/B.java").touch(null);
64
        
65
        // incremental build
66
        getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
67
        waitForAutoBuild();
68
        
69
        // check log
70
        // should see that the project on the inpath was considered changed.
71
        assertEquals(1, testLog.numberOfEntriesForMessage("[/Users/andrew/Eclipse/Workspaces/junit-workspace/JavaProj2-On Inpath/bin]"));
72
        
73
        // ensure that this is the only time the list has been set
74
        assertEquals(1, testLog.numberOfEntriesForMessage("Setting list of classpath elements with modified contents:"));
75
    }
76
77
    /*
78
     * the project as well as the in path project should appear
79
     */
80
    public void testChangeAspectProject() throws Exception {
81
        testLog.clearLog();
82
83
        // change the project
84
        ap1.getFile("src/AFile.java").create(new ReaderInputStream(new StringReader("class AFile {}")), false, null);
85
        
86
        // incremental build
87
        getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
88
        waitForAutoBuild();
89
        
90
        // check log
91
        // This first entry is from when project ap1 is built
92
        assertEquals(1, testLog.numberOfEntriesForMessage("   []"));
93
        // this message comes from the project we care about
94
        assertEquals(1, testLog.numberOfEntriesForMessage("[/Users/andrew/Eclipse/Workspaces/junit-workspace/AspectProj1/bin, /Users/andrew/Eclipse/Workspaces/junit-workspace/JavaProj2-On Inpath/bin]"));
95
96
        // ensure that these are the only 2 times the list has been set
97
        assertEquals(2, testLog.numberOfEntriesForMessage("Setting list of classpath elements with modified contents:"));
98
    }
99
    
100
    public void testChangeAspectProjectOnAspectPath() throws Exception {
101
        testLog.clearLog();
102
103
        // change the project
104
        ap2.getFile("src/AFile.java").create(new ReaderInputStream(new StringReader("class AFile {}")), false, null);
105
        
106
        // incremental build
107
        getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
108
        waitForAutoBuild();
109
        
110
        // check log
111
        // This first entry is from when project ap2 is built
112
        assertEquals(1, testLog.numberOfEntriesForMessage("   []"));
113
        // this message comes from the project we care about
114
        assertEquals(1, testLog.numberOfEntriesForMessage("[/Users/andrew/Eclipse/Workspaces/junit-workspace/AspectProj2-On AspectPath/bin, /Users/andrew/Eclipse/Workspaces/junit-workspace/JavaProj2-On Inpath/bin]"));
115
116
        // ensure that these are the only 2 times the list has been set
117
        assertEquals(2, testLog.numberOfEntriesForMessage("Setting list of classpath elements with modified contents:"));
118
    }
119
    
120
    public void testChangeJavaProject() throws Exception {
121
        testLog.clearLog();
122
123
        // change the project
124
        jp1.getFile("src/AFile.java").create(new ReaderInputStream(new StringReader("class AFile {}")), false, null);
125
        
126
        // incremental build
127
        getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
128
        waitForAutoBuild();
129
        
130
        // check log
131
        // this message comes from the project we care about
132
        assertEquals(1, testLog.numberOfEntriesForMessage("[/Users/andrew/Eclipse/Workspaces/junit-workspace/JavaProj1/bin, /Users/andrew/Eclipse/Workspaces/junit-workspace/JavaProj2-On Inpath/bin]"));
133
134
        // ensure that this is the only time the list has been set
135
        assertEquals(1, testLog.numberOfEntriesForMessage("Setting list of classpath elements with modified contents:"));
136
    }
137
    
138
    public void testChangeJavaProjectNonStructuralChange() throws Exception {
139
        testLog.clearLog();
140
141
        // change the project---non-structural change
142
        jp1.getFile("src/c/B.java").touch(null);
143
        
144
        // incremental build
145
        getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
146
        waitForAutoBuild();
147
        
148
        // check log
149
        // this message comes from the project we care about
150
        // nothing other than the inpath should be on the list
151
        assertEquals(1, testLog.numberOfEntriesForMessage("[/Users/andrew/Eclipse/Workspaces/junit-workspace/JavaProj2-On Inpath/bin]"));
152
153
        // ensure that this is the only time the list has been set
154
        assertEquals(1, testLog.numberOfEntriesForMessage("Setting list of classpath elements with modified contents:"));
155
    }
156
    
157
    public void testChangeClassFolder() throws Exception {
158
        testLog.clearLog();
159
160
        // change the project
161
        jp3.getFile("src/AFile.java").create(new ReaderInputStream(new StringReader("class AFile {}")), false, null);
162
        
163
        // incremental build
164
        getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
165
        waitForAutoBuild();
166
        
167
        // incremental build...again
168
        // we have a situation where there is a double build because there 
169
        // is a binary folder dependency.  
170
        // In general, we don't recommend binary folder dependencies for
171
        // this reason (should use project dependencies instead)
172
        getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
173
        waitForAutoBuild();
174
175
        
176
        // check log
177
        // this message comes from the project we care about on the first build
178
        assertEquals(1, testLog.numberOfEntriesForMessage("[/Users/andrew/Eclipse/Workspaces/junit-workspace/JavaProj2-On Inpath/bin]"));
179
180
        // this message comes from the project we care about on the second build
181
        assertEquals(1, testLog.numberOfEntriesForMessage("[/Users/andrew/Eclipse/Workspaces/junit-workspace/JavaProj3-ClassFolder/bin, /Users/andrew/Eclipse/Workspaces/junit-workspace/JavaProj2-On Inpath/bin]"));
182
183
        // ensure that this is the only time the list has been set
184
        assertEquals(2, testLog.numberOfEntriesForMessage("Setting list of classpath elements with modified contents:"));
185
    }
186
    
187
    public void testChangeJar() throws Exception {
188
        // incremental build
189
        getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
190
        waitForAutoBuild();
191
192
        testLog.clearLog();
193
194
        // change the project
195
        ap3.getFile("src/AFile.java").create(new ReaderInputStream(new StringReader("class AFile {}")), false, null);
196
        
197
        // incremental build
198
        getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
199
        waitForAutoBuild();
200
        
201
        // check log
202
        // This first entry is from when project ap3 is built
203
        assertEquals(1, testLog.numberOfEntriesForMessage("   []"));
204
        // this message comes from the project we care about
205
        assertEquals(1, testLog.numberOfEntriesForMessage("[/Users/andrew/Eclipse/Workspaces/junit-workspace/AspectProj3-Has Outjar/output.jar, /Users/andrew/Eclipse/Workspaces/junit-workspace/JavaProj2-On Inpath/bin]"));
206
207
        // ensure that this is the only time the list has been set
208
        assertEquals(2, testLog.numberOfEntriesForMessage("Setting list of classpath elements with modified contents:"));
209
    }
210
}
(-)workspace/JavaProj2-On (+6 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5
	<classpathentry kind="output" path="bin"/>
6
</classpath>
(-)workspace/JavaProj1/src/c/D.java (+7 lines)
Added Link Here
1
package c;
2
3
public class D {
4
  int x() {
5
	  return 9;
6
  }
7
}
(-)workspace/JavaProj1/.project (+17 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>JavaProj1</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
	</buildSpec>
14
	<natures>
15
		<nature>org.eclipse.jdt.core.javanature</nature>
16
	</natures>
17
</projectDescription>
(-)workspace/JavaProj3-ClassFolder/.project (+17 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>JavaProj3-ClassFolder</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
	</buildSpec>
14
	<natures>
15
		<nature>org.eclipse.jdt.core.javanature</nature>
16
	</natures>
17
</projectDescription>
(-)src/org/eclipse/ajdt/internal/core/ResourceChangeListener.java (-69 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     Luzius Meisser - initial implementation
10
 *******************************************************************************/
11
package org.eclipse.ajdt.internal.core;
12
13
import org.eclipse.ajdt.core.AspectJPlugin;
14
import org.eclipse.core.resources.IProject;
15
import org.eclipse.core.resources.IResource;
16
import org.eclipse.core.resources.IResourceChangeEvent;
17
import org.eclipse.core.resources.IResourceChangeListener;
18
import org.eclipse.core.resources.IResourceDelta;
19
import org.eclipse.core.runtime.CoreException;
20
21
public class ResourceChangeListener implements IResourceChangeListener {
22
23
	private ResourceDeltaVisitor myDeltaVisitor;
24
25
	/*
26
	 * (non-Javadoc)
27
	 * 
28
	 * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
29
	 */
30
	public ResourceChangeListener() {
31
		myDeltaVisitor = new ResourceDeltaVisitor();
32
	}
33
34
	public void resourceChanged(IResourceChangeEvent event) {
35
		if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
36
			IResourceDelta delta = event.getDelta();
37
			// avoid processing deltas for non-AspectJ projects,
38
			if (delta != null) {
39
				IResourceDelta[] cd = delta.getAffectedChildren();
40
				if (cd == null) {
41
					try {
42
						delta.accept(myDeltaVisitor);
43
					} catch (CoreException e) {
44
					}
45
				} else {
46
					for (int i = 0; i < cd.length; i++) {
47
						try {
48
							IResource res = cd[i].getResource();
49
							if (res == null) {
50
								cd[i].accept(myDeltaVisitor);
51
							} else {
52
								IProject proj = res.getProject();
53
								// if we don't know the project, or it is
54
								// no longer accessible, we'd better process
55
								// the delta. Otherwise we only process it
56
								// if it is an AspectJ project.
57
								if ((proj == null) || !proj.isAccessible()
58
										|| AspectJPlugin.isAJProject(proj)) {
59
									cd[i].accept(myDeltaVisitor);
60
								}
61
							}
62
						} catch (CoreException e) {
63
						}
64
					}
65
				}
66
			}
67
		}
68
	}
69
}
(-)src/org/eclipse/ajdt/internal/core/ResourceDeltaVisitor.java (-57 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     Luzius Meisser - initial implementation
10
 *	   Matthew Ford - Bug 154339
11
 *     Helen Hawkins - updated for new ajde interface (bug 148190)
12
 *******************************************************************************/
13
package org.eclipse.ajdt.internal.core;
14
15
import org.eclipse.ajdt.core.AspectJPlugin;
16
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.IResourceDelta;
18
import org.eclipse.core.resources.IResourceDeltaVisitor;
19
20
public class ResourceDeltaVisitor implements IResourceDeltaVisitor {
21
22
	/*
23
	 * (non-Javadoc)
24
	 * 
25
	 * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
26
	 */
27
	public ResourceDeltaVisitor() {
28
	}
29
30
	/*
31
	 * (non-Javadoc)
32
	 * 
33
	 * @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
34
	 */
35
	public boolean visit(IResourceDelta delta) {
36
		IResource myRes = delta.getResource();
37
		if (myRes.getType() == IResource.PROJECT) {
38
			switch (delta.getKind()) {
39
			case IResourceDelta.REMOVED:
40
				// remove the compiler associated with this project from the factory
41
				AspectJPlugin.getDefault().getCompilerFactory()
42
						.removeCompilerForProject(myRes.getProject());
43
				break;
44
			case IResourceDelta.CHANGED:
45
				if (!myRes.getProject().isOpen()) {
46
					// remove the compiler associated with this project from the 
47
					// factory - project could remain closed indefinitely, therefore, 
48
					// don't want to hang on to the compiler instance
49
					AspectJPlugin.getDefault().getCompilerFactory()
50
							.removeCompilerForProject(myRes.getProject());
51
				}
52
				break;
53
			}
54
		}
55
		return true;
56
	}
57
}
(-)src/org/eclipse/ajdt/internal/core/ajde/CoreCompilerConfiguration.java (-20 / +176 lines)
Lines 22-27 Link Here
22
22
23
import org.aspectj.ajde.core.ICompilerConfiguration;
23
import org.aspectj.ajde.core.ICompilerConfiguration;
24
import org.aspectj.ajde.core.IOutputLocationManager;
24
import org.aspectj.ajde.core.IOutputLocationManager;
25
import org.aspectj.ajdt.internal.core.builder.CompilerConfigurationChangeFlags;
25
import org.eclipse.ajdt.core.AJLog;
26
import org.eclipse.ajdt.core.AJLog;
26
import org.eclipse.ajdt.core.AspectJCorePreferences;
27
import org.eclipse.ajdt.core.AspectJCorePreferences;
27
import org.eclipse.ajdt.core.AspectJPlugin;
28
import org.eclipse.ajdt.core.AspectJPlugin;
Lines 47-54 Link Here
47
import org.eclipse.osgi.util.NLS;
48
import org.eclipse.osgi.util.NLS;
48
49
49
/**
50
/**
50
 * ICompilerConfiguration implementation which returns information for all methods except getNonStandardOptions().
51
 * ICompilerConfiguration implementation which returns information for all 
51
 * 
52
 * methods except getNonStandardOptions().  This implementation is used
53
 * if ajdt.core plugin is not present in the platform
52
 */
54
 */
53
public class CoreCompilerConfiguration implements ICompilerConfiguration {
55
public class CoreCompilerConfiguration implements ICompilerConfiguration {
54
56
Lines 56-63 Link Here
56
	protected IProject project;
58
	protected IProject project;
57
	private CoreOutputLocationManager locationManager;
59
	private CoreOutputLocationManager locationManager;
58
60
59
	public CoreCompilerConfiguration(IProject project) {
61
	// fully qualified list of file names that have been touched since
62
    // last build
63
    // set to null originally since we don't know anything 
64
    // about build state when first created.  Assume everything 
65
    // has changed.
66
    private List/* File */ modifiedFiles = null;
67
    // set of flags describing what has changed since last
68
    // build
69
    // initially set to EVERYTHING since we don't know
70
    // build state when first created.
71
    private int configurationChanges;
72
    
73
    // list of classpath entries that have been rebuilt since last build
74
    private List /*String*/ classpathElementsWithModifiedContents = null;
75
76
    public CoreCompilerConfiguration(IProject project) {
60
		this.project = project;
77
		this.project = project;
78
		AJLog.log(AJLog.BUILDER, "Compiler configuration for project " + project.getName() + " doesn't know previous state, so assuming EVERYTHING has changed.");
79
		configurationChanges = EVERYTHING;
61
	}
80
	}
62
81
63
	public Map getJavaOptionsMap() {
82
	public Map getJavaOptionsMap() {
Lines 434-443 Link Here
434
		return result;
453
		return result;
435
	}
454
	}
436
455
437
	// List modifiedFiles = new ArrayList();
456
	public void addModifiedFile(File changedFile) {
438
457
	    AJLog.log(AJLog.BUILDER, "File: " + changedFile + " has changed.");
439
	public void addModifiedFile(String string) {
458
	    if (modifiedFiles != null) {
440
		// modifiedFiles.add(string);
459
	        modifiedFiles.add(changedFile);
460
	    } else {
461
	        AJLog.log(AJLog.BUILDER, "    but, we don't have any state yet, so not recording the change.");
462
	    }
463
	}
464
	
465
	/**
466
	 * Flag this compiler configuration as having had a change.
467
	 * This is reset after a call to {@link #configurationRead()}
468
	 * @param changeFlag change flag from 
469
	 * {@link CompilerConfigurationChangeFlags}
470
	 */
471
	public void configurationChanged(int changeFlag) {
472
	    configurationChanges |= changeFlag;
473
	    logConfigurationChange(changeFlag);
474
	}
475
476
	private void logConfigurationChange(int changeFlag) {
477
	    List changeKind = new ArrayList();
478
        if ((changeFlag & PROJECTSOURCEFILES_CHANGED) != NO_CHANGES) {
479
            changeKind.add("PROJECTSOURCEFILES_CHANGED");
480
        }
481
        if ((changeFlag & JAVAOPTIONS_CHANGED) != NO_CHANGES) {
482
            changeKind.add("JAVAOPTIONS_CHANGED");
483
        }
484
        if ((changeFlag & ASPECTPATH_CHANGED) != NO_CHANGES) {
485
            changeKind.add("ASPECTPATH_CHANGED");
486
        }
487
        if ((changeFlag & CLASSPATH_CHANGED) != NO_CHANGES) {
488
            changeKind.add("CLASSPATH_CHANGED");
489
        }
490
        if ((changeFlag & INPATH_CHANGED) != NO_CHANGES) {
491
            changeKind.add("INPATH_CHANGED");
492
        }
493
        if ((changeFlag & NONSTANDARDOPTIONS_CHANGED) != NO_CHANGES) {
494
            changeKind.add("NONSTANDARDOPTIONS_CHANGED");
495
        }
496
        if ((changeFlag & OUTJAR_CHANGED) != NO_CHANGES) {
497
            changeKind.add("OUTJAR_CHANGED");
498
        }
499
        if ((changeFlag & PROJECTSOURCERESOURCES_CHANGED) != NO_CHANGES) {
500
            changeKind.add("PROJECTSOURCERESOURCES_CHANGED");
501
        }
502
        if ((changeFlag & OUTPUTDESTINATIONS_CHANGED) != NO_CHANGES) {
503
            changeKind.add("OUTPUTDESTINATIONS_CHANGED");
504
        }
505
        // deprecated
506
        if ((changeFlag & INJARS_CHANGED) != NO_CHANGES) {
507
            changeKind.add("INJARS_CHANGED");
508
        }
509
        AJLog.log(AJLog.BUILDER, "CoreCompilerConfiguration for project " + project.getName() + " registered a configuration change: " + changeKind);
510
	}
511
	
512
	/**
513
	 * converts the current configuration change list to a 
514
	 * human readable string
515
	 * @return human readable string denoting all configuration
516
	 * changes since last read.
517
	 */
518
	private String toConfigurationString() {
519
        List changeKind = new ArrayList();
520
        if ((configurationChanges & PROJECTSOURCEFILES_CHANGED) != NO_CHANGES) {
521
            changeKind.add("PROJECTSOURCEFILES_CHANGED");
522
        }
523
        if ((configurationChanges & JAVAOPTIONS_CHANGED) != NO_CHANGES) {
524
            changeKind.add("JAVAOPTIONS_CHANGED");
525
        }
526
        if ((configurationChanges & ASPECTPATH_CHANGED) != NO_CHANGES) {
527
            changeKind.add("ASPECTPATH_CHANGED");
528
        }
529
        if ((configurationChanges & CLASSPATH_CHANGED) != NO_CHANGES) {
530
            changeKind.add("CLASSPATH_CHANGED");
531
        }
532
        if ((configurationChanges & INPATH_CHANGED) != NO_CHANGES) {
533
            changeKind.add("INPATH_CHANGED");
534
        }
535
        if ((configurationChanges & NONSTANDARDOPTIONS_CHANGED) != NO_CHANGES) {
536
            changeKind.add("NONSTANDARDOPTIONS_CHANGED");
537
        }
538
        if ((configurationChanges & OUTJAR_CHANGED) != NO_CHANGES) {
539
            changeKind.add("OUTJAR_CHANGED");
540
        }
541
        if ((configurationChanges & PROJECTSOURCERESOURCES_CHANGED) != NO_CHANGES) {
542
            changeKind.add("PROJECTSOURCERESOURCES_CHANGED");
543
        }
544
        if ((configurationChanges & OUTPUTDESTINATIONS_CHANGED) != NO_CHANGES) {
545
            changeKind.add("OUTPUTDESTINATIONS_CHANGED");
546
        }
547
        // deprecated
548
        if ((configurationChanges & INJARS_CHANGED) != NO_CHANGES) {
549
            changeKind.add("INJARS_CHANGED");
550
        }
551
        return changeKind.toString();
441
	}
552
	}
442
553
443
	/**
554
	/**
Lines 445-458 Link Here
445
	 * build.
556
	 * build.
446
	 */
557
	 */
447
	public void configurationRead() {
558
	public void configurationRead() {
559
	    // we now know nothing has changed
560
	    AJLog.log(AJLog.BUILDER, "Compiler configuration for project " + project.getName() + " has been read by compiler.  Resetting.");
561
	    AJLog.log(AJLog.BUILDER, "     Configuration was " + toConfigurationString());
562
	    
563
	    // we are still not keeping track of some changes:
564
	    // JAVAOPTIONS_CHANGED | NONSTANDARDOPTIONS_CHANGED | OUTJAR_CHANGED |
565
        // OUTPUTDESTINATIONS_CHANGED | INJARS_CHANGED
566
	    configurationChanges = NO_CHANGES;
567
	    resetModifiedList();
448
	}
568
	}
449
569
450
	/**
570
	/**
451
	 * Need to tell AspectJ what has changed in the configuration since the last build was done - the lazy answer (which causes it
571
	 * Need to tell AspectJ what has changed in the configuration since the last build was done - the lazy answer (which causes it
452
	 * to behave as it always used to) is EVERYTHING.
572
	 * to behave as it always used to) is EVERYTHING.
573
	 * 
574
	 * @see CompilerConfigurationChangeFlags
575
	 * @see AspectJCorePreferences#isIncrementalCompilationOptimizationsEnabled
453
	 */
576
	 */
454
	public int getConfigurationChanges() {
577
	public int getConfigurationChanges() {
455
		return EVERYTHING;
578
	    // if the optimization flag is turned off, then return EVERYTHING
579
	    if (!AspectJCorePreferences.isIncrementalCompilationOptimizationsEnabled()) {
580
            AJLog.log(AJLog.BUILDER, "Optimizations turned off, so assuming all parts of configuration have changed");
581
            return EVERYTHING;
582
	    } else {
583
	        AJLog.log(AJLog.BUILDER, "Sending the following configuration changes to the compiler: " + toConfigurationString());
584
	        return AspectJCorePreferences.isIncrementalCompilationOptimizationsEnabled() ? configurationChanges : EVERYTHING;
585
	    }
456
	}
586
	}
457
587
458
	/**
588
	/**
Lines 460-481 Link Here
460
	 * analysing delta changes. Returning null means we have no idea and will cause AspectJ to do the analysis to work it out.
590
	 * analysing delta changes. Returning null means we have no idea and will cause AspectJ to do the analysis to work it out.
461
	 */
591
	 */
462
	public List getProjectSourceFilesChanged() {
592
	public List getProjectSourceFilesChanged() {
463
		return null;// null means we dont know
593
	    if (!AspectJCorePreferences.isIncrementalCompilationOptimizationsEnabled()) {
464
		// if (modifiedFiles == null) {
594
            AJLog.log(AJLog.BUILDER, "Optimizations turned off, so assuming all source files have changed");
465
		// AJLog.log("Nothing changed??");
595
            return null;
466
		// } else {
596
        } else if (modifiedFiles == null) {
467
		// AJLog.log(modifiedFiles.size() + " changes");
597
            // null means we dont know
468
		// }
598
	        AJLog.log(AJLog.BUILDER, "We don't know what has changed since last build, so assuming all source files have changed");
469
		// if (modifiedFiles.isEmpty())
599
	        return null;
470
		// return null;
600
	    } else {
471
		// return modifiedFiles;
601
	        AJLog.log(AJLog.BUILDER, modifiedFiles.size() + " source file changes since last build");
602
	        return modifiedFiles;
603
	    }
472
	}
604
	}
473
605
474
	public void resetModifiedList() {
606
	public void resetModifiedList() {
475
		// modifiedFiles.clear();
607
	    AJLog.log(AJLog.BUILDER, "Resetting list of modified source files.  Was " + 
608
	            (modifiedFiles == null ? "null" : modifiedFiles.toString()));
609
	    modifiedFiles = new ArrayList();
610
	}
611
	
612
    public void resetClasspathElementsWithModifiedContents() {
613
        classpathElementsWithModifiedContents = null;
614
    }
615
    public void setClasspathElementsWithModifiedContents(List /*String*/ modifiedContents) {
616
        AJLog.log(AJLog.BUILDER, "Setting list of classpath elements with modified contents:");
617
        AJLog.log(AJLog.BUILDER, "      " + modifiedContents.toString());
618
        classpathElementsWithModifiedContents = modifiedContents;
619
    }
620
	
621
	// must go through the classpath and look at projects we depend on that have been built before our
622
	// most recent last build
623
	public List getClasspathElementsWithModifiedContents() {
624
	    return classpathElementsWithModifiedContents;
476
	}
625
	}
477
626
478
	public List getClasspathElementsWithModifiedContents() {
627
	
479
		return null;
628
	/**
629
	 * helper method that grabs the compiler configuration for a particular project
630
	 * creates one if it does not exist
631
	 * @param project
632
	 * @return the project's compiler configuration
633
	 */
634
	public static CoreCompilerConfiguration getCompilerConfigurationForProject(IProject project) {
635
	    return (CoreCompilerConfiguration) AspectJPlugin.getDefault().getCompilerFactory().getCompilerForProject(project).getCompilerConfiguration();
480
	}
636
	}
481
}
637
}
(-)src/org/eclipse/ajdt/internal/core/ajde/CoreCompilerFactory.java (-4 / +10 lines)
Lines 19-24 Link Here
19
/**
19
/**
20
 * ICompilerFactory implementation which returns AjCompilers with
20
 * ICompilerFactory implementation which returns AjCompilers with
21
 * core implementations of the required interfaces.
21
 * core implementations of the required interfaces.
22
 * 
23
 * This class is only used if ajdt.ui plugin is not available
24
 * 
22
 */ 
25
 */ 
23
public class CoreCompilerFactory implements ICompilerFactory {
26
public class CoreCompilerFactory implements ICompilerFactory {
24
27
Lines 45-54 Link Here
45
	 * No longer record the AjCompiler for the given project.
48
	 * No longer record the AjCompiler for the given project.
46
	 */
49
	 */
47
	public void removeCompilerForProject(IProject project) {
50
	public void removeCompilerForProject(IProject project) {
48
		// firstly clean up any state associated with the compiler
51
        // firstly clean up any state associated with the compiler
49
		getCompilerForProject(project).clearLastState();
52
	    AjCompiler compiler = (AjCompiler) compilerMap.get(project);
50
		// remove compiler from the map
53
	    if (compiler != null) {
51
		compilerMap.remove(project);
54
            compiler.clearLastState();
55
            // remove compiler from the map
56
            compilerMap.remove(project);
57
        }
52
	}
58
	}
53
	
59
	
54
	/**
60
	/**
(-)src/org/eclipse/ajdt/core/BuildConfig.java (-1 / +45 lines)
Lines 12-20 Link Here
12
package org.eclipse.ajdt.core;
12
package org.eclipse.ajdt.core;
13
13
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.HashSet;
15
import java.util.Iterator;
16
import java.util.Iterator;
16
import java.util.List;
17
import java.util.List;
17
import java.util.Map;
18
import java.util.Map;
19
import java.util.Set;
18
import java.util.WeakHashMap;
20
import java.util.WeakHashMap;
19
21
20
import org.eclipse.core.resources.IContainer;
22
import org.eclipse.core.resources.IContainer;
Lines 33-39 Link Here
33
35
34
public class BuildConfig {
36
public class BuildConfig {
35
	
37
	
36
	private static Map projectsToIncludedSourceFiles = new WeakHashMap();
38
	private static Map /*IProject, List<IFile>*/ projectsToIncludedSourceFiles = new WeakHashMap();
37
	
39
	
38
	/**
40
	/**
39
	 * Returns all of the currently included source files in a project
41
	 * Returns all of the currently included source files in a project
Lines 74-79 Link Here
74
		projectsToIncludedSourceFiles.put(project, sourceFiles);
76
		projectsToIncludedSourceFiles.put(project, sourceFiles);
75
		return sourceFiles;
77
		return sourceFiles;
76
	}
78
	}
79
80
	
81
	
82
	/**
83
	 * Experimental version of above that uses a set, not a list
84
	 * @param project
85
	 * @return
86
	 */
87
	public static Set /* IFile */getIncludedSourceFilesSet(IProject project) {
88
        if (projectsToIncludedSourceFiles.get(project) instanceof List) {
89
            return (Set) projectsToIncludedSourceFiles.get(project);
90
        }
91
        Set sourceFiles = new HashSet();
92
        try {
93
            IJavaProject jp = JavaCore.create(project);
94
            IClasspathEntry[] cpes = jp.getRawClasspath();
95
            for (int i = 0; i < cpes.length; i++) {
96
                if ((cpes[i] instanceof ClasspathEntry)
97
                        && (cpes[i].getEntryKind() == IClasspathEntry.CPE_SOURCE)) {
98
                    ClasspathEntry cp = (ClasspathEntry) cpes[i];
99
                    char[][] incl = cp.fullInclusionPatternChars();
100
                    char[][] excl = cp.fullExclusionPatternChars();
101
                    IPath path = cpes[i].getPath();
102
                    IResource res = project.findMember(path
103
                            .removeFirstSegments(1));
104
                    if ((res != null) && (res instanceof IContainer)) {
105
                        List l = allFiles((IContainer) res);
106
                        for (Iterator iter = l.iterator(); iter.hasNext();) {
107
                            IFile file = (IFile) iter.next();
108
                            if (!Util.isExcluded(file, incl, excl)) {
109
                                sourceFiles.add(file);
110
                            }
111
                        }
112
                    }
113
                }
114
            }
115
        } catch (JavaModelException e) {
116
        }
117
        projectsToIncludedSourceFiles.put(project, sourceFiles);
118
        return sourceFiles;
119
    }
120
77
	
121
	
78
	/**
122
	/**
79
	 * Invalidate the list of included source files for a project
123
	 * Invalidate the list of included source files for a project
(-)src/org/eclipse/ajdt/core/AspectJCorePreferences.java (+18 lines)
Lines 45-50 Link Here
45
public class AspectJCorePreferences {
45
public class AspectJCorePreferences {
46
			
46
			
47
    public static final String OPTION_AutobuildSuppressed = "org.eclipse.ajdt.ui.builder.autobuildSuppressed"; //$NON-NLS-1$
47
    public static final String OPTION_AutobuildSuppressed = "org.eclipse.ajdt.ui.builder.autobuildSuppressed"; //$NON-NLS-1$
48
    public static final String OPTION_IncrementalCompilationOptimizations = "org.eclipse.ajdt.ui.builder.incrementalCompilationOptimizations"; //$NON-NLS-1$
48
49
49
    
50
    
50
	private static final String ASPECTPATH_ATTRIBUTE_NAME = "org.eclipse.ajdt.aspectpath"; //$NON-NLS-1$
51
	private static final String ASPECTPATH_ATTRIBUTE_NAME = "org.eclipse.ajdt.aspectpath"; //$NON-NLS-1$
Lines 990-994 Link Here
990
                .getPluginPreferences();
991
                .getPluginPreferences();
991
        store.setValue(OPTION_AutobuildSuppressed, done);
992
        store.setValue(OPTION_AutobuildSuppressed, done);
992
    }
993
    }
994
    
995
    /**
996
     * Checks to see if the compiler option for incremental build optimizations
997
     * is on or off
998
     * @return
999
     */
1000
    public static boolean isIncrementalCompilationOptimizationsEnabled() {
1001
        Preferences store = AspectJPlugin.getDefault()
1002
                .getPluginPreferences();
1003
        return store.getBoolean(OPTION_IncrementalCompilationOptimizations);
1004
    }
1005
    
1006
    public static void setIncrementalCompilationOptimizationsEnabled(boolean value) {
1007
        Preferences store = AspectJPlugin.getDefault()
1008
                .getPluginPreferences();
1009
        store.setValue(OPTION_IncrementalCompilationOptimizations, value);
1010
    }
993
1011
994
}
1012
}
(-)src/org/eclipse/ajdt/core/AspectJPlugin.java (-2 / +2 lines)
Lines 13-19 Link Here
13
package org.eclipse.ajdt.core;
13
package org.eclipse.ajdt.core;
14
14
15
import org.eclipse.ajdt.core.model.AJModel;
15
import org.eclipse.ajdt.core.model.AJModel;
16
import org.eclipse.ajdt.internal.core.ResourceChangeListener;
16
import org.eclipse.ajdt.internal.core.CompilerConfigResourceChangeListener;
17
import org.eclipse.ajdt.internal.core.ajde.CoreCompilerFactory;
17
import org.eclipse.ajdt.internal.core.ajde.CoreCompilerFactory;
18
import org.eclipse.ajdt.internal.core.ajde.ICompilerFactory;
18
import org.eclipse.ajdt.internal.core.ajde.ICompilerFactory;
19
import org.eclipse.core.resources.IProject;
19
import org.eclipse.core.resources.IProject;
Lines 119-125 Link Here
119
		super.start(context);
119
		super.start(context);
120
		checkForCUprovider();
120
		checkForCUprovider();
121
		getWorkspace().addResourceChangeListener(
121
		getWorkspace().addResourceChangeListener(
122
				new ResourceChangeListener(),
122
				new CompilerConfigResourceChangeListener(),
123
				IResourceChangeEvent.POST_CHANGE);
123
				IResourceChangeEvent.POST_CHANGE);
124
		setCompilerFactory(new CoreCompilerFactory());
124
		setCompilerFactory(new CoreCompilerFactory());
125
	}
125
	}
(-)src/org/eclipse/ajdt/core/builder/AJBuilder.java (-63 / +322 lines)
Lines 14-21 Link Here
14
package org.eclipse.ajdt.core.builder;
14
package org.eclipse.ajdt.core.builder;
15
15
16
import java.io.File;
16
import java.io.File;
17
import java.lang.reflect.Field;
17
import java.util.ArrayList;
18
import java.util.ArrayList;
18
import java.util.Arrays;
19
import java.util.Arrays;
20
import java.util.Collection;
19
import java.util.Hashtable;
21
import java.util.Hashtable;
20
import java.util.Iterator;
22
import java.util.Iterator;
21
import java.util.List;
23
import java.util.List;
Lines 23-29 Link Here
23
import java.util.Set;
25
import java.util.Set;
24
26
25
import org.aspectj.ajde.core.AjCompiler;
27
import org.aspectj.ajde.core.AjCompiler;
28
import org.aspectj.ajde.core.ICompilerConfiguration;
26
import org.aspectj.ajdt.internal.core.builder.AjState;
29
import org.aspectj.ajdt.internal.core.builder.AjState;
30
import org.aspectj.ajdt.internal.core.builder.CompilerConfigurationChangeFlags;
27
import org.aspectj.ajdt.internal.core.builder.IStateListener;
31
import org.aspectj.ajdt.internal.core.builder.IStateListener;
28
import org.aspectj.ajdt.internal.core.builder.IncrementalStateManager;
32
import org.aspectj.ajdt.internal.core.builder.IncrementalStateManager;
29
import org.eclipse.ajdt.core.AJLog;
33
import org.eclipse.ajdt.core.AJLog;
Lines 37-49 Link Here
37
import org.eclipse.ajdt.core.text.CoreMessages;
41
import org.eclipse.ajdt.core.text.CoreMessages;
38
import org.eclipse.ajdt.internal.core.AspectJRTInitializer;
42
import org.eclipse.ajdt.internal.core.AspectJRTInitializer;
39
import org.eclipse.ajdt.internal.core.ajde.CoreCompilerConfiguration;
43
import org.eclipse.ajdt.internal.core.ajde.CoreCompilerConfiguration;
40
import org.eclipse.ajdt.internal.core.ajde.CoreOutputLocationManager;
44
import org.eclipse.core.internal.resources.ResourceException;
41
import org.eclipse.core.resources.IContainer;
45
import org.eclipse.core.resources.IContainer;
46
import org.eclipse.core.resources.IFile;
42
import org.eclipse.core.resources.IFolder;
47
import org.eclipse.core.resources.IFolder;
43
import org.eclipse.core.resources.IMarker;
48
import org.eclipse.core.resources.IMarker;
44
import org.eclipse.core.resources.IProject;
49
import org.eclipse.core.resources.IProject;
45
import org.eclipse.core.resources.IResource;
50
import org.eclipse.core.resources.IResource;
46
import org.eclipse.core.resources.IResourceDelta;
51
import org.eclipse.core.resources.IResourceDelta;
52
import org.eclipse.core.resources.IResourceDeltaVisitor;
47
import org.eclipse.core.resources.IResourceStatus;
53
import org.eclipse.core.resources.IResourceStatus;
48
import org.eclipse.core.resources.IResourceVisitor;
54
import org.eclipse.core.resources.IResourceVisitor;
49
import org.eclipse.core.resources.IWorkspaceRoot;
55
import org.eclipse.core.resources.IWorkspaceRoot;
Lines 52-59 Link Here
52
import org.eclipse.core.runtime.CoreException;
58
import org.eclipse.core.runtime.CoreException;
53
import org.eclipse.core.runtime.IPath;
59
import org.eclipse.core.runtime.IPath;
54
import org.eclipse.core.runtime.IProgressMonitor;
60
import org.eclipse.core.runtime.IProgressMonitor;
61
import org.eclipse.core.runtime.IStatus;
55
import org.eclipse.core.runtime.NullProgressMonitor;
62
import org.eclipse.core.runtime.NullProgressMonitor;
56
import org.eclipse.core.runtime.Path;
63
import org.eclipse.core.runtime.Path;
64
import org.eclipse.core.runtime.Status;
57
import org.eclipse.core.runtime.SubProgressMonitor;
65
import org.eclipse.core.runtime.SubProgressMonitor;
58
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
66
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
59
import org.eclipse.jdt.core.IClasspathEntry;
67
import org.eclipse.jdt.core.IClasspathEntry;
Lines 62-68 Link Here
62
import org.eclipse.jdt.core.JavaCore;
70
import org.eclipse.jdt.core.JavaCore;
63
import org.eclipse.jdt.core.JavaModelException;
71
import org.eclipse.jdt.core.JavaModelException;
64
import org.eclipse.jdt.internal.core.ClasspathEntry;
72
import org.eclipse.jdt.internal.core.ClasspathEntry;
73
import org.eclipse.jdt.internal.core.JavaModelManager;
65
import org.eclipse.jdt.internal.core.JavaProject;
74
import org.eclipse.jdt.internal.core.JavaProject;
75
import org.eclipse.jdt.internal.core.builder.State;
66
import org.eclipse.jdt.internal.core.util.Util;
76
import org.eclipse.jdt.internal.core.util.Util;
67
import org.eclipse.osgi.util.NLS;
77
import org.eclipse.osgi.util.NLS;
68
import org.osgi.service.prefs.BackingStoreException;
78
import org.osgi.service.prefs.BackingStoreException;
Lines 156-164 Link Here
156
		}
166
		}
157
167
158
		if (kind != FULL_BUILD) {
168
		if (kind != FULL_BUILD) {
159
		    // XXX need to add check here for whether the classpath has changed
169
		    if (!sourceFilesChanged(dta, project) && !classpathChanged(dta, project)){
160
		    if (!sourceFilesChanged(dta, project)){
170
				AJLog.log(AJLog.BUILDER,"build: Examined delta - no source file or classpath changes for project "  //$NON-NLS-1$
161
				AJLog.log(AJLog.BUILDER,"build: Examined delta - no source file changes for project "  //$NON-NLS-1$
162
								+ project.getName() );
171
								+ project.getName() );
163
				
172
				
164
				// if the source files of any projects which the current
173
				// if the source files of any projects which the current
Lines 186-191 Link Here
186
195
187
		IAJCompilerMonitor compilerMonitor = (IAJCompilerMonitor) compiler.getBuildProgressMonitor();
196
		IAJCompilerMonitor compilerMonitor = (IAJCompilerMonitor) compiler.getBuildProgressMonitor();
188
		
197
		
198
		
189
		// Bug 43711 must do a clean and rebuild if we can't 
199
		// Bug 43711 must do a clean and rebuild if we can't 
190
		// find a buildConfig file from a previous compilation
200
		// find a buildConfig file from a previous compilation
191
		if (kind == FULL_BUILD ||
201
		if (kind == FULL_BUILD ||
Lines 197-206 Link Here
197
			} else {
207
			} else {
198
				AJLog.log(AJLog.BUILDER,"Unable to empty output folder on build all - why cant we find the IJavaProject?"); //$NON-NLS-1$
208
				AJLog.log(AJLog.BUILDER,"Unable to empty output folder on build all - why cant we find the IJavaProject?"); //$NON-NLS-1$
199
			}
209
			}
210
		} else {
211
		    // doing an incremental build
212
		    if (AspectJCorePreferences.isIncrementalCompilationOptimizationsEnabled()) {
213
    		    // Bug 245566:
214
		        // facilitate incremental compilation by checking 
215
		        // classpath for projects that have changed since the last build
216
		        long timestamp = getLastBuildTimeStamp(compiler);
217
		        compilerConfig.setClasspathElementsWithModifiedContents(getChangedRequiredProjects(timestamp));
218
		    }
200
		}
219
		}
201
		compilerMonitor.prepare(new SubProgressMonitor(progressMonitor,100));
220
		compilerMonitor.prepare(new SubProgressMonitor(progressMonitor,100));
202
221
203
		AJLog.log(AJLog.BUILDER_CLASSPATH,"Classpath="+compilerConfig.getClasspath()); //$NON-NLS-1$
222
		AJLog.log(AJLog.BUILDER_CLASSPATH,"Classpath = " + compilerConfig.getClasspath()); //$NON-NLS-1$
204
		
223
		
205
        // ----------------------------------------
224
        // ----------------------------------------
206
		// Do the compilation
225
		// Do the compilation
Lines 217-226 Link Here
217
		
236
		
218
		doRefreshAfterBuild(project, dependingProjects, javaProject);
237
		doRefreshAfterBuild(project, dependingProjects, javaProject);
219
		
238
		
220
		// update the relationship map
239
        // not needed now. This will be used to help create the relationship
221
        CoreOutputLocationManager outputLocManager = (CoreOutputLocationManager) 
240
		// map more efficiently
222
                compilerConfig.getOutputLocationManager();
241
//        CoreOutputLocationManager outputLocManager = (CoreOutputLocationManager) 
223
        Set/*File*/ touchedFiles = outputLocManager.getTouchedClassFiles();
242
//                compilerConfig.getOutputLocationManager();
243
//        Set/*File*/ touchedFiles = outputLocManager.getTouchedClassFiles();
244
245
	      // update the relationship map
224
		boolean inc = (kind == IncrementalProjectBuilder.INCREMENTAL_BUILD) || (kind == IncrementalProjectBuilder.AUTO_BUILD);
246
		boolean inc = (kind == IncrementalProjectBuilder.INCREMENTAL_BUILD) || (kind == IncrementalProjectBuilder.AUTO_BUILD);
225
		AJModel.getInstance().createMap(project,true,inc);
247
		AJModel.getInstance().createMap(project,true,inc);
226
		
248
		
Lines 235-240 Link Here
235
		return requiredProjects;
257
		return requiredProjects;
236
	}
258
	}
237
259
260
	// check to see if the .classpath has changed.
261
	// we know exactly where it is located, so no need for a visitor
262
    private boolean classpathChanged(IResourceDelta dta, IProject project) {
263
        IResourceDelta[] children = dta.getAffectedChildren();
264
        for (int i = 0; i < children.length; i++) {
265
            IResourceDelta child = children[i];
266
            if (child.getResource().getName().equals(".classpath")) {
267
                return true;
268
            }
269
        }
270
        return false;
271
    }
272
273
    private long getLastBuildTimeStamp(AjCompiler compiler) {
274
        AjState state = IncrementalStateManager.retrieveStateFor(compiler.getId());
275
        if (state != null) {
276
            return state.getLastBuildTime();
277
        } else {
278
            return 0;
279
        }
280
    }
281
238
    private String buildKindString(int kind) {
282
    private String buildKindString(int kind) {
239
        switch(kind) {
283
        switch(kind) {
240
            case IncrementalProjectBuilder.AUTO_BUILD:
284
            case IncrementalProjectBuilder.AUTO_BUILD:
Lines 250-256 Link Here
250
        }
294
        }
251
    }
295
    }
252
296
253
	/**
297
    /**
298
     * returns a list of fully qualified names of entries on the classpath
299
     * that have been rebuilt since last build
300
     * @return
301
     */
302
    private List /*String*/ getChangedRequiredProjects(long lastBuildTimestamp) {
303
        try {
304
            // first find all the projects that have changed since last build
305
            IProject[] projectsOnClasspath = getRequiredProjects(getProject(), true);
306
            List /*IProject*/ changedProjects = new ArrayList();
307
            for (int i = 0; i < projectsOnClasspath.length; i++) {
308
                IProject project = projectsOnClasspath[i];
309
    
310
                // get timestamp of last build for this project
311
                long otherTimestamp = -1;
312
                if (AspectJPlugin.isAJProject(project)) {
313
                    AjCompiler compiler = AspectJPlugin.getDefault().getCompilerFactory().getCompilerForProject(project);
314
                    otherTimestamp = getLastBuildTimeStamp(compiler);
315
                } else if (project.hasNature(JavaCore.NATURE_ID)) {
316
                    Object s = JavaModelManager.getJavaModelManager().getLastBuiltState(project, null);
317
                    if (s != null && s instanceof State) {
318
                        State state = (State) s;
319
                        // need to use reflection to get at the last build time
320
                        otherTimestamp = getLastBuildTime(state);
321
                    }
322
                } else {
323
                    otherTimestamp = -1;
324
                }
325
                if (lastBuildTimestamp <= otherTimestamp) {
326
                    changedProjects.add(project);
327
                }
328
            }
329
            List /*String*/ changedEntries = new ArrayList();
330
            
331
            // now that we have all the projects, need to find out what they contribute to
332
            // this project's path.  could be itself, a jar, or a class folder
333
            if (changedProjects.size() > 0) {
334
                IClasspathEntry[] thisClasspath = JavaCore.create(getProject()).getResolvedClasspath(true);
335
                for (Iterator projIter = changedProjects.iterator(); projIter
336
                        .hasNext();) {
337
                    IProject changedProject = (IProject) projIter.next();
338
                    for (int i = 0; i < thisClasspath.length; i++) {
339
                        IClasspathEntry classpathEntry = thisClasspath[i];
340
                        switch (classpathEntry.getEntryKind()) {
341
                        case IClasspathEntry.CPE_PROJECT:
342
                            if (changedProject.getFullPath().equals(classpathEntry.getPath())) {
343
                                // resolve project and add all entries
344
                                changedEntries.addAll(listOfClassPathEntriesToListOfString(AspectJCorePreferences.resolveDependentProjectClasspath(
345
                                        changedProject, classpathEntry)));
346
                            }
347
                            break;
348
                        case IClasspathEntry.CPE_LIBRARY:
349
                            if (changedProject.getFullPath().isPrefixOf(classpathEntry.getPath())) {
350
                                // only add if this path exists
351
                                IWorkspaceRoot root = getProject().getWorkspace().getRoot();
352
                                IFile onPath = root.getFile(classpathEntry.getPath());
353
                                if (onPath.exists() || 
354
                                        root.getFolder(onPath.getFullPath()).exists()) {  // may be a folder
355
                                    changedEntries.add(onPath.getLocation().toPortableString());
356
                                }
357
                            }
358
                        }
359
                    }
360
                }
361
            }            
362
            // if all else went well, also add the inpath the the list of changed projects.
363
            // Adding the inpath always is just a conservative estimate of what has changed.
364
            // 
365
            // For Java projects, we only know the last structural build time.  Usually this is 
366
            // fine, but if the Java project is on the inpath, then we care about the last 
367
            // build of any kind, which we can't be sure of.  
368
            // (Actually, we need to know this for Aspect path projects, but aspectj can give us
369
            // precise time of the last build.
370
            // 
371
            // So, as a conservative estimate, put all inpath entries onto the list.
372
            Set inPathFiles = CoreCompilerConfiguration.getCompilerConfigurationForProject(getProject()).getInpath();
373
            if (inPathFiles != null) {
374
                for (Iterator fileIter = inPathFiles.iterator(); fileIter.hasNext();) {
375
                    File inpathFile = (File) fileIter.next();
376
                    changedEntries.add(inpathFile.getAbsolutePath());
377
                }
378
            }            
379
            return changedEntries;
380
        } catch (Exception e) {
381
            // something went wrong.
382
            // return null to imply everything's changed
383
            AspectJPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, AspectJPlugin.PLUGIN_ID, 
384
                    "Error determining list of entries on classpath that have changed.", e));
385
            return null;
386
        }
387
    }
388
    
389
    private List/*String*/ listOfClassPathEntriesToListOfString(
390
            List/*IClassPathEntry*/ entries) {
391
        IWorkspaceRoot root = getProject().getWorkspace().getRoot();
392
        List strings = new ArrayList(entries.size());
393
        for (Iterator iterator = entries.iterator(); iterator
394
                .hasNext();) {
395
            IClasspathEntry entry = (IClasspathEntry) iterator.next();
396
            IFile onPath = root.getFile(entry.getPath());
397
            // only add if exists
398
            if (onPath.exists() || 
399
                    root.getFolder(onPath.getFullPath()).exists()) {  // may be a class folder
400
401
                strings.add(onPath.getLocation().toPortableString());
402
            }
403
        }
404
        return strings;
405
    }
406
407
    private static Field state_lastStructuralBuildTime = null;
408
	private static long getLastBuildTime(State state) throws Exception {
409
	    if (state_lastStructuralBuildTime == null) {
410
	        state_lastStructuralBuildTime = State.class.getDeclaredField("lastStructuralBuildTime");
411
	        state_lastStructuralBuildTime.setAccessible(true);
412
	    }
413
        return state_lastStructuralBuildTime.getLong(state);
414
    }
415
416
    /**
254
	 * Refreshes the project's out folders after a build
417
	 * Refreshes the project's out folders after a build
255
	 * try to be as precise as possible because this can be a time consuming task 
418
	 * try to be as precise as possible because this can be a time consuming task 
256
	 * 
419
	 * 
Lines 442-448 Link Here
442
	/**
605
	/**
443
	 * Copies non-src resources to the output directory (bug 78579). The main
606
	 * Copies non-src resources to the output directory (bug 78579). The main
444
	 * part of this method was taken from 
607
	 * part of this method was taken from 
445
	 * org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.findSourceFiles(IResourceDelta)
608
	 * {@link org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.findSourceFiles(IResourceDelta)}
446
	 * 
609
	 * 
447
	 * @param IJavaProject - the project which is being built
610
	 * @param IJavaProject - the project which is being built
448
	 * @param IResourceDelta - the projects delta
611
	 * @param IResourceDelta - the projects delta
Lines 456-467 Link Here
456
			IPath srcPath = srcEntry.getPath().removeFirstSegments(1);			
619
			IPath srcPath = srcEntry.getPath().removeFirstSegments(1);			
457
			IContainer srcContainer = getContainerForGivenPath(srcPath,project.getProject());
620
			IContainer srcContainer = getContainerForGivenPath(srcPath,project.getProject());
458
621
459
			if(srcContainer.equals(project.getProject())) {				
622
			// handle case where project root is a source folder
623
			if (srcContainer.equals(project.getProject())) {				
460
				int segmentCount = delta.getFullPath().segmentCount();
624
				int segmentCount = delta.getFullPath().segmentCount();
461
				IResourceDelta[] children = delta.getAffectedChildren();
625
				IResourceDelta[] children = delta.getAffectedChildren();
462
				for (int j = 0, m = children.length; j < m; j++)
626
				for (int j = 0, m = children.length; j < m; j++) {
463
					if (!isExcludedFromProject(project,children[j].getFullPath(),srcEntries))
627
					if (!isExcludedFromProject(project,children[j].getFullPath(),srcEntries)) {
464
						copyResources(project, children[j], srcEntry, segmentCount);
628
						copyResources(project, children[j], srcEntry, segmentCount);
629
					}
630
				}
465
			} else {
631
			} else {
466
				IPath projectRelativePath = srcEntry.getPath().removeFirstSegments(1);
632
				IPath projectRelativePath = srcEntry.getPath().removeFirstSegments(1);
467
				projectRelativePath.makeRelative();
633
				projectRelativePath.makeRelative();
Lines 474-482 Link Here
474
					int segmentCount = sourceDelta.getFullPath().segmentCount();
640
					int segmentCount = sourceDelta.getFullPath().segmentCount();
475
					IResourceDelta[] children = sourceDelta.getAffectedChildren();
641
					IResourceDelta[] children = sourceDelta.getAffectedChildren();
476
					try {
642
					try {
477
						for (int j = 0, m = children.length; j < m; j++)
643
						for (int j = 0, m = children.length; j < m; j++) {
478
							copyResources(project, children[j], srcEntry, segmentCount);
644
							copyResources(project, children[j], srcEntry, segmentCount);
479
					} catch (org.eclipse.core.internal.resources.ResourceException e) {
645
						}
646
					} catch (ResourceException e) {
480
						// catch the case that a package has been renamed and collides on disk with an as-yet-to-be-deleted package
647
						// catch the case that a package has been renamed and collides on disk with an as-yet-to-be-deleted package
481
						if (e.getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) {
648
						if (e.getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) {
482
							return false;
649
							return false;
Lines 530-537 Link Here
530
						// fall thru & collect all the resource files
697
						// fall thru & collect all the resource files
531
					case IResourceDelta.CHANGED :
698
					case IResourceDelta.CHANGED :
532
						IResourceDelta[] children = sourceDelta.getAffectedChildren();
699
						IResourceDelta[] children = sourceDelta.getAffectedChildren();
533
						for (int i = 0, l = children.length; i < l; i++)
700
						for (int i = 0, l = children.length; i < l; i++) {
534
							copyResources(javaProject, children[i],srcEntry, segmentCount);
701
							copyResources(javaProject, children[i],srcEntry, segmentCount);
702
						}
535
						return;
703
						return;
536
					case IResourceDelta.REMOVED :
704
					case IResourceDelta.REMOVED :
537
						IPath removedPackagePath = resource.getFullPath().removeFirstSegments(segmentCount);
705
						IPath removedPackagePath = resource.getFullPath().removeFirstSegments(segmentCount);
Lines 544-558 Link Here
544
									// only a package fragment was removed, same as removing multiple source files
712
									// only a package fragment was removed, same as removing multiple source files
545
									createFolder(removedPackagePath, outputFolder); // ensure package exists in the output folder
713
									createFolder(removedPackagePath, outputFolder); // ensure package exists in the output folder
546
									IResourceDelta[] removedChildren = sourceDelta.getAffectedChildren();
714
									IResourceDelta[] removedChildren = sourceDelta.getAffectedChildren();
547
									for (int j = 0, m = removedChildren.length; j < m; j++)
715
									for (int j = 0, m = removedChildren.length; j < m; j++) {
548
										copyResources(javaProject,removedChildren[j], srcEntry, segmentCount);
716
										copyResources(javaProject,removedChildren[j], srcEntry, segmentCount);
717
									}
549
									return;
718
									return;
550
								}
719
								}
551
							}
720
							}
552
						}
721
						}
553
						IFolder removedPackageFolder = outputFolder.getFolder(removedPackagePath);
722
						IFolder removedPackageFolder = outputFolder.getFolder(removedPackagePath);
554
						if (removedPackageFolder.exists())
723
						if (removedPackageFolder.exists()) {
555
							removedPackageFolder.delete(IResource.FORCE, null);
724
							removedPackageFolder.delete(IResource.FORCE, null);
725
						}
556
				}
726
				}
557
				return;
727
				return;
558
			case IResource.FILE :
728
			case IResource.FILE :
Lines 567-572 Link Here
567
			        				|| resourcePath.getFileExtension().equals("java"))) { //$NON-NLS-1$
737
			        				|| resourcePath.getFileExtension().equals("java"))) { //$NON-NLS-1$
568
						return;
738
						return;
569
					}
739
					}
740
			        
570
			        IResource outputFile = outputFolder.getFile(resourcePath);
741
			        IResource outputFile = outputFolder.getFile(resourcePath);
571
					switch (sourceDelta.getKind()) {
742
					switch (sourceDelta.getKind()) {
572
						case IResourceDelta.ADDED :
743
						case IResourceDelta.ADDED :
Lines 580-596 Link Here
580
							outputFile.setDerived(true);
751
							outputFile.setDerived(true);
581
							Util.setReadOnly(outputFile, false); // just in case the original was read only
752
							Util.setReadOnly(outputFile, false); // just in case the original was read only
582
							outputFile.refreshLocal(IResource.DEPTH_ZERO,null);
753
							outputFile.refreshLocal(IResource.DEPTH_ZERO,null);
754
		                    // mark this change so compiler knows about it.
755
		                    CoreCompilerConfiguration.getCompilerConfigurationForProject(getProject())
756
		                            .configurationChanged(
757
		                                    CompilerConfigurationChangeFlags.PROJECTSOURCERESOURCES_CHANGED);
583
							return;
758
							return;
584
						case IResourceDelta.REMOVED :
759
						case IResourceDelta.REMOVED :
585
							if (outputFile.exists()) {
760
							if (outputFile.exists()) {
586
								AJLog.log(AJLog.BUILDER,"Deleting removed file " + resourcePath);//$NON-NLS-1$
761
								AJLog.log(AJLog.BUILDER,"Deleting removed file " + resourcePath);//$NON-NLS-1$
587
								outputFile.delete(IResource.FORCE, null);
762
								outputFile.delete(IResource.FORCE, null);
588
							}
763
							}
764
		                    // mark this change so compiler knows about it.
765
		                    CoreCompilerConfiguration.getCompilerConfigurationForProject(getProject())
766
		                            .configurationChanged(
767
		                                    CompilerConfigurationChangeFlags.PROJECTSOURCERESOURCES_CHANGED);
589
							return;
768
							return;
590
						case IResourceDelta.CHANGED :
769
						case IResourceDelta.CHANGED :
591
							if ((sourceDelta.getFlags() & IResourceDelta.CONTENT) == 0
770
							if ((sourceDelta.getFlags() & IResourceDelta.CONTENT) == 0
592
									&& (sourceDelta.getFlags() & IResourceDelta.ENCODING) == 0)
771
									&& (sourceDelta.getFlags() & IResourceDelta.ENCODING) == 0) {
593
								return; // skip it since it really isn't changed
772
								return; // skip it since it really isn't changed
773
							}
594
							if (outputFile.exists()) {
774
							if (outputFile.exists()) {
595
								AJLog.log(AJLog.BUILDER,"Deleting existing file " + resourcePath);//$NON-NLS-1$
775
								AJLog.log(AJLog.BUILDER,"Deleting existing file " + resourcePath);//$NON-NLS-1$
596
								outputFile.delete(IResource.FORCE, null);
776
								outputFile.delete(IResource.FORCE, null);
Lines 922-932 Link Here
922
	    // clean the output folders and do a refresh if not
1102
	    // clean the output folders and do a refresh if not
923
	    // automatically building (so that output dir reflects the
1103
	    // automatically building (so that output dir reflects the
924
	    // changes)
1104
	    // changes)
925
	    if (AspectJPlugin.getWorkspace().getDescription().isAutoBuilding()) {
1105
		cleanOutputFolders(JavaCore.create(project),
926
	        cleanOutputFolders(JavaCore.create(project),false);
1106
		        !AspectJPlugin.getWorkspace().getDescription().isAutoBuilding());
927
        } else {
928
            cleanOutputFolders(JavaCore.create(project),true);
929
        }
930
	}
1107
	}
931
	
1108
	
932
	private void removeProblemsAndTasksFor(IResource resource) {
1109
	private void removeProblemsAndTasksFor(IResource resource) {
Lines 937-996 Link Here
937
			}
1114
			}
938
		} catch (CoreException e) {
1115
		} catch (CoreException e) {
939
		}
1116
		}
940
		AJLog.log(AJLog.BUILDER,"Removed problems and tasks for project "+resource.getName()); //$NON-NLS-1$
1117
		if (resource != null) {
1118
		    AJLog.log(AJLog.BUILDER,"Removed problems and tasks for project "+resource.getName()); //$NON-NLS-1$
1119
		}
941
	}
1120
	}
942
		
1121
	
943
	public boolean sourceFilesChanged(IResourceDelta delta, IProject project) { 
1122
	
944
		if (delta!=null && delta.getAffectedChildren().length!=0) {
1123
	/**
945
			List includedFileNames = BuildConfig.getIncludedSourceFiles(project);
1124
	 * Determine if any source files have changed and if so	record it in the compiler configuration for the
1125
	 * project
1126
	 * @param delta
1127
	 * @param project
1128
	 * @return true if a source file has changed.  False otherwise
1129
	 */
1130
	public boolean sourceFilesChanged(IResourceDelta delta, IProject project) {
1131
	    AJLog.logStart("SourceFilesChanged");
1132
		if (delta != null && delta.getAffectedChildren().length != 0) {
1133
		    
1134
		    // XXX might be better if this were a Set.
1135
		    // look into this
1136
			List /*IFile*/ includedFileNames = BuildConfig.getIncludedSourceFiles(project);
1137
//	          Set /*IFile*/ includedFileNames = BuildConfig.getIncludedSourceFilesSet(project);
1138
946
			IJavaProject ijp = JavaCore.create(project);		
1139
			IJavaProject ijp = JavaCore.create(project);		
947
			if (ijp == null) {
1140
			if (ijp == null) {
948
				return true;
1141
				return true;
949
			}			
1142
			}			
950
			try {
1143
			try {
951
				IPath outputPath = ijp.getOutputLocation();
1144
			    SourceFilesChangedVisitor visitor = new SourceFilesChangedVisitor(project, includedFileNames);
952
				if (project.getFullPath().equals(outputPath)) {
1145
			    delta.accept(visitor);
953
					outputPath = null;
1146
				if (visitor.hasChanges()) {
954
				}
1147
					AJLog.log(AJLog.BUILDER,"build: Examined delta - " + visitor.getNumberChanged() + //$NON-NLS-1$ 
955
				if (sourceFilesChanged(delta, includedFileNames,outputPath)) {
1148
					        " changed, " + visitor.getNumberAdded() + " added, and " + //$NON-NLS-1$ //$NON-NLS-2$
956
					AJLog.log(AJLog.BUILDER,"build: Examined delta - source file changes in " //$NON-NLS-1$
1149
					        visitor.getNumberRemoved() + " deleted source files in " //$NON-NLS-1$
957
							+ "required project " + project.getName() ); //$NON-NLS-1$
1150
							+ "required project " + project.getName() ); //$NON-NLS-1$
958
					return true;
1151
					return true;
959
				} else {
1152
				} else {
960
					return false;
1153
					return false;
961
				}
1154
				}
962
			} catch (JavaModelException e) {}
1155
			} catch (CoreException e) {
1156
			    AspectJPlugin.getDefault().getLog().log(
1157
			            new Status(IStatus.ERROR, 
1158
			                    AspectJPlugin.PLUGIN_ID, "Error finding source file changes", e));
1159
			}
963
		}
1160
		}
1161
        AJLog.logEnd(AJLog.BUILDER,"SourceFilesChanged");
964
		return true;
1162
		return true;
965
	}
1163
	}
966
	
1164
	
967
	private boolean sourceFilesChanged(IResourceDelta dta, List includedFileNames,IPath outputLocation) { //IProject project) {
1165
	private class SourceFilesChangedVisitor implements IResourceDeltaVisitor {
968
		if (dta == null) return false;
1166
	    private final List includedFileNames;
1167
	    private final CoreCompilerConfiguration compilerConfiguration;
1168
	    private final IProject affectedProject;
1169
	    private int numberChanged;
1170
	    private int numberAdded;
1171
	    private int numberRemoved;
1172
	    
1173
	    private SourceFilesChangedVisitor(IProject affectedProject,
1174
                List includedFileNames) {
1175
            this.includedFileNames = includedFileNames;
1176
            this.affectedProject = affectedProject;
1177
            compilerConfiguration = CoreCompilerConfiguration.getCompilerConfigurationForProject(affectedProject);
1178
            numberChanged = 0;
1179
            numberAdded = 0;
1180
            numberRemoved = 0;
1181
        }
969
1182
970
		if (outputLocation!=null && outputLocation.equals(dta.getFullPath()) ) {
1183
	    /**
971
			return false;
1184
	     * Look for changed resources that we care about.
972
		}
1185
	     */
973
		String resname = dta.getFullPath().toString();
1186
        public boolean visit(IResourceDelta delta) throws CoreException {
974
		
1187
            String resname = delta.getFullPath().toString();
975
		if (CoreUtils.ASPECTJ_SOURCE_FILTER.accept(resname)) {
1188
976
		    if ((includedFileNames==null) || includedFileNames.contains(dta.getResource())
1189
            if (delta.getResource().getType() == IResource.FILE) {
977
		    		|| dta.getKind() == IResourceDelta.REMOVED) {
1190
                if (CoreUtils.ASPECTJ_SOURCE_FILTER.accept(resname)) {
978
                return true;
1191
                        
979
            } else {
1192
                    switch (delta.getKind()) {
1193
                    case IResourceDelta.REMOVED:
1194
                    case IResourceDelta.REMOVED_PHANTOM:
1195
                        // don't check to see if these files are on the list of included 
1196
                        // files because they have already been removed and we won't find
1197
                        // them on the list.
1198
                        // be conservative and set the flag regardless.
1199
                        compilerConfiguration.configurationChanged(
1200
                                CompilerConfigurationChangeFlags.PROJECTSOURCEFILES_CHANGED);
1201
                        numberRemoved++;
1202
                        break;
1203
1204
                    case IResourceDelta.ADDED:
1205
                    case IResourceDelta.ADDED_PHANTOM:
1206
                        if (includedFileNames.contains(delta.getResource())) {
1207
                            compilerConfiguration.configurationChanged(
1208
                                    CompilerConfigurationChangeFlags.PROJECTSOURCEFILES_CHANGED);
1209
                            numberAdded++;
1210
                            break;
1211
                        }
1212
                    case IResourceDelta.CHANGED:
1213
                        if (includedFileNames.contains(delta.getResource())) {
1214
                            compilerConfiguration.addModifiedFile(new File(delta.getResource()
1215
                                    .getLocation().toPortableString()));
1216
                            numberChanged++;
1217
                        }
1218
                    }
1219
                } else if (resname.endsWith(".classpath")) { //$NON-NLS-1$
1220
                    // also need to ensure that this is a project classpath
1221
                    IContainer parent = delta.getResource().getParent();
1222
                    if (parent.getFullPath().equals(affectedProject.getFullPath())) {
1223
                        // we don't know what has changed exactly.  
1224
                        // be conservative
1225
                        compilerConfiguration.configurationChanged(
1226
                                CompilerConfigurationChangeFlags.CLASSPATH_CHANGED |
1227
                                CompilerConfigurationChangeFlags.ASPECTPATH_CHANGED |
1228
                                CompilerConfigurationChangeFlags.INPATH_CHANGED);
1229
                    }
1230
                }
980
                return false;
1231
                return false;
1232
            } else {
1233
                
1234
                // want to fully traverse this delta if not 
1235
                // a leaf node
1236
                return true;
981
            }
1237
            }
982
		} else if (resname.endsWith(".classpath")){ //$NON-NLS-1$
1238
        }
983
			return true;
1239
        public int getNumberChanged() {
984
		} else {
1240
            return numberChanged;
985
			boolean kids_results = false;
1241
        }
986
			int i = 0;
1242
        public int getNumberAdded() {
987
			IResourceDelta[] kids = dta.getAffectedChildren();
1243
            return numberAdded;
988
			while (!kids_results && i < kids.length) {
1244
        }
989
				kids_results = kids_results | sourceFilesChanged(kids[i], includedFileNames, outputLocation);
1245
        public int getNumberRemoved() {
990
				i++;
1246
            return numberRemoved;
991
			}
1247
        }
992
			return kids_results;
1248
        
993
		}
1249
        public boolean hasChanges() {
1250
            return numberAdded + numberChanged + numberRemoved > 0;
1251
        }
994
	}
1252
	}
995
	
1253
	
996
	public static void addStateListener() {
1254
	public static void addStateListener() {
Lines 1006-1013 Link Here
1006
				public void pathChangeDetected() {
1264
				public void pathChangeDetected() {
1007
				}
1265
				}
1008
1266
1009
				public void buildSuccessful(boolean arg0) {
1267
				public void buildSuccessful(boolean wasFull) {
1010
					AJLog.log(AJLog.COMPILER,"AspectJ reports build successful, build was: "+(arg0?"FULL":"INCREMENTAL")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1268
					AJLog.log(AJLog.COMPILER,"AspectJ reports build successful, build was: " + //$NON-NLS-1$ 
1269
					        (wasFull ? "FULL" : "INCREMENTAL")); //$NON-NLS-1$ //$NON-NLS-2$ 
1011
				}
1270
				}
1012
1271
1013
				public void detectedAspectDeleted(File f) {
1272
				public void detectedAspectDeleted(File f) {
(-)src/org/eclipse/ajdt/internal/core/CompilerConfigResourceDeltaVisitor.java (+61 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     Luzius Meisser - initial implementation
10
 *	   Matthew Ford - Bug 154339
11
 *     Helen Hawkins - updated for new ajde interface (bug 148190)
12
 *******************************************************************************/
13
package org.eclipse.ajdt.internal.core;
14
15
import org.eclipse.ajdt.core.AspectJPlugin;
16
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.IResourceDelta;
18
import org.eclipse.core.resources.IResourceDeltaVisitor;
19
20
/**
21
 * Removes stored compiler info for projects when they are deleted or closed.
22
 *
23
 */
24
public class CompilerConfigResourceDeltaVisitor implements IResourceDeltaVisitor {
25
26
	/*
27
	 * (non-Javadoc)
28
	 * 
29
	 * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
30
	 */
31
	public CompilerConfigResourceDeltaVisitor() {
32
	}
33
34
	/*
35
	 * (non-Javadoc)
36
	 * 
37
	 * @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
38
	 */
39
	public boolean visit(IResourceDelta delta) {
40
		IResource myRes = delta.getResource();
41
		if (myRes.getType() == IResource.PROJECT) {
42
			switch (delta.getKind()) {
43
			case IResourceDelta.REMOVED:
44
				// remove the compiler associated with this project from the factory
45
				AspectJPlugin.getDefault().getCompilerFactory()
46
						.removeCompilerForProject(myRes.getProject());
47
				break;
48
			case IResourceDelta.CHANGED:
49
				if (!myRes.getProject().isOpen()) {
50
					// remove the compiler associated with this project from the 
51
					// factory - project could remain closed indefinitely, therefore, 
52
					// don't want to hang on to the compiler instance
53
					AspectJPlugin.getDefault().getCompilerFactory()
54
							.removeCompilerForProject(myRes.getProject());
55
				}
56
				break;
57
			}
58
		}
59
		return true;
60
	}
61
}
(-)src/org/eclipse/ajdt/internal/core/CompilerConfigResourceChangeListener.java (+73 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     Luzius Meisser - initial implementation
10
 *******************************************************************************/
11
package org.eclipse.ajdt.internal.core;
12
13
import org.eclipse.ajdt.core.AspectJPlugin;
14
import org.eclipse.core.resources.IProject;
15
import org.eclipse.core.resources.IResource;
16
import org.eclipse.core.resources.IResourceChangeEvent;
17
import org.eclipse.core.resources.IResourceChangeListener;
18
import org.eclipse.core.resources.IResourceDelta;
19
import org.eclipse.core.runtime.CoreException;
20
21
/**
22
 * This listener will add or remove compilers for projects when they are removed or closed
23
 *
24
 */
25
public class CompilerConfigResourceChangeListener implements IResourceChangeListener {
26
27
	private CompilerConfigResourceDeltaVisitor myDeltaVisitor;
28
29
	/*
30
	 * (non-Javadoc)
31
	 * 
32
	 * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
33
	 */
34
	public CompilerConfigResourceChangeListener() {
35
		myDeltaVisitor = new CompilerConfigResourceDeltaVisitor();
36
	}
37
38
	public void resourceChanged(IResourceChangeEvent event) {
39
		if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
40
			IResourceDelta delta = event.getDelta();
41
			// avoid processing deltas for non-AspectJ projects,
42
			if (delta != null) {
43
				IResourceDelta[] cd = delta.getAffectedChildren();
44
				if (cd == null) {
45
					try {
46
						delta.accept(myDeltaVisitor);
47
					} catch (CoreException e) {
48
					}
49
				} else {
50
					for (int i = 0; i < cd.length; i++) {
51
						try {
52
							IResource res = cd[i].getResource();
53
							if (res == null) {
54
								cd[i].accept(myDeltaVisitor);
55
							} else {
56
								IProject proj = res.getProject();
57
								// if we don't know the project, or it is
58
								// no longer accessible, we'd better process
59
								// the delta. Otherwise we only process it
60
								// if it is an AspectJ project.
61
								if ((proj == null) || !proj.isAccessible()
62
										|| AspectJPlugin.isAJProject(proj)) {
63
									cd[i].accept(myDeltaVisitor);
64
								}
65
							}
66
						} catch (CoreException e) {
67
						}
68
					}
69
				}
70
			}
71
		}
72
	}
73
}
(-)src/org/eclipse/ajdt/ui/AspectJUIPlugin.java (-2 / +2 lines)
Lines 24-30 Link Here
24
import org.eclipse.ajdt.core.javaelements.AJCompilationUnitManager;
24
import org.eclipse.ajdt.core.javaelements.AJCompilationUnitManager;
25
import org.eclipse.ajdt.internal.builder.UIBuildListener;
25
import org.eclipse.ajdt.internal.builder.UIBuildListener;
26
import org.eclipse.ajdt.internal.core.ajde.ICompilerFactory;
26
import org.eclipse.ajdt.internal.core.ajde.ICompilerFactory;
27
import org.eclipse.ajdt.internal.javamodel.ResourceChangeListener;
27
import org.eclipse.ajdt.internal.javamodel.AJCompilationUnitResourceChangeListener;
28
import org.eclipse.ajdt.internal.ui.ajde.UICompilerFactory;
28
import org.eclipse.ajdt.internal.ui.ajde.UICompilerFactory;
29
import org.eclipse.ajdt.internal.ui.editor.AspectJTextTools;
29
import org.eclipse.ajdt.internal.ui.editor.AspectJTextTools;
30
import org.eclipse.ajdt.internal.ui.lazystart.Utils;
30
import org.eclipse.ajdt.internal.ui.lazystart.Utils;
Lines 277-283 Link Here
277
		// listener for aspectj model
277
		// listener for aspectj model
278
		if (!AspectJPlugin.usingCUprovider) {
278
		if (!AspectJPlugin.usingCUprovider) {
279
			AspectJPlugin.getWorkspace().addResourceChangeListener(
279
			AspectJPlugin.getWorkspace().addResourceChangeListener(
280
					new ResourceChangeListener(),
280
					new AJCompilationUnitResourceChangeListener(),
281
					IResourceChangeEvent.PRE_CLOSE
281
					IResourceChangeEvent.PRE_CLOSE
282
							| IResourceChangeEvent.PRE_DELETE
282
							| IResourceChangeEvent.PRE_DELETE
283
							| IResourceChangeEvent.POST_CHANGE
283
							| IResourceChangeEvent.POST_CHANGE
(-)src/org/eclipse/ajdt/internal/ui/preferences/AJCompilerPreferencePage.java (+12 lines)
Lines 121-126 Link Here
121
                AspectJCorePreferences.OPTION_AutobuildSuppressed,
121
                AspectJCorePreferences.OPTION_AutobuildSuppressed,
122
                AspectJPreferences.VALUE_FALSE);
122
                AspectJPreferences.VALUE_FALSE);
123
        defaultValueMap.put(
123
        defaultValueMap.put(
124
                AspectJCorePreferences.OPTION_IncrementalCompilationOptimizations,
125
                AspectJPreferences.VALUE_FALSE);
126
        defaultValueMap.put(
124
                AspectJPreferences.OPTION_ReportInvalidAbsoluteTypeName,
127
                AspectJPreferences.OPTION_ReportInvalidAbsoluteTypeName,
125
                AspectJPreferences.VALUE_WARNING);
128
                AspectJPreferences.VALUE_WARNING);
126
		defaultValueMap.put(
129
		defaultValueMap.put(
Lines 426-431 Link Here
426
    		excomposite.setClient(othersComposite);
429
    		excomposite.setClient(othersComposite);
427
    		othersComposite.setLayout(new GridLayout(nColumns, false));
430
    		othersComposite.setLayout(new GridLayout(nColumns, false));
428
    		
431
    		
432
    		// suppress autobuild
429
            label = UIMessages.CompilerConfigurationBlock_aj_suppressAutoBuild;
433
            label = UIMessages.CompilerConfigurationBlock_aj_suppressAutoBuild;
430
            Button b = addCheckBox(othersComposite, label, AspectJCorePreferences.OPTION_AutobuildSuppressed, enableDisableValues, 0, false);
434
            Button b = addCheckBox(othersComposite, label, AspectJCorePreferences.OPTION_AutobuildSuppressed, enableDisableValues, 0, false);
431
            useAspectJCorePreferences(b);
435
            useAspectJCorePreferences(b);
Lines 433-438 Link Here
433
            // ignoring the original value.
437
            // ignoring the original value.
434
            b.setSelection(getAspectJCorePLuginPreferences().getBoolean(AspectJCorePreferences.OPTION_AutobuildSuppressed));
438
            b.setSelection(getAspectJCorePLuginPreferences().getBoolean(AspectJCorePreferences.OPTION_AutobuildSuppressed));
435
439
440
            // incremental compiler optimizations
441
            label = UIMessages.CompilerConfigurationBlock_aj_incrementalCompilerOptimizations;
442
            b = addCheckBox(othersComposite, label, AspectJCorePreferences.OPTION_IncrementalCompilationOptimizations, enableDisableValues, 0, false);
443
            useAspectJCorePreferences(b);
444
            // a little kludgy, but here we re-set the selection to be what is stored in AJ core preferences.
445
            // ignoring the original value.
446
            b.setSelection(getAspectJCorePLuginPreferences().getBoolean(AspectJCorePreferences.OPTION_IncrementalCompilationOptimizations));
447
436
		}
448
		}
437
		
449
		
438
        label = UIMessages.CompilerConfigurationBlock_aj_messages_matching;
450
        label = UIMessages.CompilerConfigurationBlock_aj_messages_matching;
(-)src/org/eclipse/ajdt/internal/ui/text/UIMessages.java (+1 lines)
Lines 416-421 Link Here
416
	
416
	
417
	public static String CompilerConfigurationBlock_aj_builder_settings;
417
	public static String CompilerConfigurationBlock_aj_builder_settings;
418
	public static String CompilerConfigurationBlock_aj_suppressAutoBuild;
418
	public static String CompilerConfigurationBlock_aj_suppressAutoBuild;
419
	public static String CompilerConfigurationBlock_aj_incrementalCompilerOptimizations;
419
420
420
	static {
421
	static {
421
		NLS.initializeMessages(BUNDLE_NAME, UIMessages.class);
422
		NLS.initializeMessages(BUNDLE_NAME, UIMessages.class);
(-)src/org/eclipse/ajdt/internal/ui/text/UIMessages.properties (+1 lines)
Lines 564-569 Link Here
564
CompilerConfigurationBlock_aj_suppressAutoBuild=Suppress autobuild - Suppress automatic building of AspectJ projects \n\
564
CompilerConfigurationBlock_aj_suppressAutoBuild=Suppress autobuild - Suppress automatic building of AspectJ projects \n\
565
(select this option if incremental building of\n\
565
(select this option if incremental building of\n\
566
AspectJ projects is taking too long)
566
AspectJ projects is taking too long)
567
CompilerConfigurationBlock_aj_incrementalCompilerOptimizations=Incremental Compiler Optimizations - Enable/disable experimental incremental compiler optimizations
567
568
568
BuildPathsBlock_ChooseOutputFolderDialog_title=
569
BuildPathsBlock_ChooseOutputFolderDialog_title=
569
BuildPathsBlock_ChooseOutputFolderDialog_description=
570
BuildPathsBlock_ChooseOutputFolderDialog_description=
(-)src/org/eclipse/ajdt/internal/ui/ajde/UIComplierConfiguration.java (+5 lines)
Lines 14-19 Link Here
14
import org.eclipse.ajdt.internal.ui.preferences.AspectJPreferences;
14
import org.eclipse.ajdt.internal.ui.preferences.AspectJPreferences;
15
import org.eclipse.core.resources.IProject;
15
import org.eclipse.core.resources.IProject;
16
16
17
/**
18
 * A complete implementation of ICompilerConfiguration.  If the ajdt.ui 
19
 * plugin is not present in the platform, then CoreCompilerConfiguration
20
 * is used instead.
21
 */
17
public class UIComplierConfiguration extends CoreCompilerConfiguration {
22
public class UIComplierConfiguration extends CoreCompilerConfiguration {
18
23
19
	public UIComplierConfiguration(IProject project) {
24
	public UIComplierConfiguration(IProject project) {
(-)src/org/eclipse/ajdt/internal/ui/ajde/UICompilerFactory.java (-3 / +15 lines)
Lines 14-22 Link Here
14
import java.util.Map;
14
import java.util.Map;
15
15
16
import org.aspectj.ajde.core.AjCompiler;
16
import org.aspectj.ajde.core.AjCompiler;
17
import org.eclipse.ajdt.internal.core.ajde.CoreCompilerFactory;
17
import org.eclipse.ajdt.internal.core.ajde.ICompilerFactory;
18
import org.eclipse.ajdt.internal.core.ajde.ICompilerFactory;
18
import org.eclipse.core.resources.IProject;
19
import org.eclipse.core.resources.IProject;
19
20
21
/**
22
 * ICompilerFactory implementation which returns AjCompilers with
23
 * core implementations of the required interfaces.
24
 * 
25
 * If ajdt.ui plugin is not present, then CoreCompilerFactory is used instead
26
 * 
27
 * @see CoreCompilerFactory
28
 */ 
20
public class UICompilerFactory implements ICompilerFactory {
29
public class UICompilerFactory implements ICompilerFactory {
21
30
22
	private Map compilerMap = new HashMap();
31
	private Map compilerMap = new HashMap();
Lines 37-45 Link Here
37
46
38
	public void removeCompilerForProject(IProject project) {
47
	public void removeCompilerForProject(IProject project) {
39
		// firstly clean up any state associated with the compiler
48
		// firstly clean up any state associated with the compiler
40
		getCompilerForProject(project).clearLastState();
49
	    AjCompiler compiler = (AjCompiler) compilerMap.get(project);
41
		// remove compiler from the map
50
	    if (compiler != null) {
42
		compilerMap.remove(project);
51
	        compiler.clearLastState();
52
	        // remove compiler from the map
53
	        compilerMap.remove(project);
54
	    }
43
	}
55
	}
44
	
56
	
45
	public boolean hasCompilerForProject(IProject project) {
57
	public boolean hasCompilerForProject(IProject project) {
(-)src/org/eclipse/ajdt/internal/javamodel/ResourceChangeListener.java (-69 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     Luzius Meisser - initial implementation
10
 *******************************************************************************/
11
package org.eclipse.ajdt.internal.javamodel;
12
import org.eclipse.ajdt.core.AspectJPlugin;
13
import org.eclipse.core.resources.IProject;
14
import org.eclipse.core.resources.IResource;
15
import org.eclipse.core.resources.IResourceChangeEvent;
16
import org.eclipse.core.resources.IResourceChangeListener;
17
import org.eclipse.core.resources.IResourceDelta;
18
import org.eclipse.core.runtime.CoreException;
19
/**
20
 * @author Luzius Meisser
21
 * 
22
 */
23
public class ResourceChangeListener implements IResourceChangeListener {
24
	private ResourceDeltaVisitor myDeltaVisitor;
25
	/*
26
	 * (non-Javadoc)
27
	 * 
28
	 * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
29
	 */
30
	public ResourceChangeListener() {
31
		myDeltaVisitor = new ResourceDeltaVisitor();
32
	}
33
	
34
	public void resourceChanged(IResourceChangeEvent event) {
35
		if (event.getType() == IResourceChangeEvent.POST_CHANGE){
36
			IResourceDelta delta = event.getDelta();
37
			// avoid processing deltas for non-AspectJ projects,
38
			if (delta != null) {
39
				IResourceDelta[] cd = delta.getAffectedChildren();
40
				if (cd == null) {
41
					try {
42
						delta.accept(myDeltaVisitor);
43
					} catch (CoreException e) {
44
					}
45
				} else {
46
					for (int i = 0; i < cd.length; i++) {
47
						try {
48
							IResource res = cd[i].getResource();
49
							if (res == null) {
50
								cd[i].accept(myDeltaVisitor);
51
							} else {
52
								IProject proj = res.getProject();
53
								// if we don't know the project, or it is
54
								// no longer accessible, we'd better process
55
								// the delta. Otherwise we only process it
56
								// if it is an AspectJ project.
57
								if ((proj == null) || !proj.isAccessible()
58
										|| AspectJPlugin.isAJProject(proj)) {
59
									cd[i].accept(myDeltaVisitor);
60
								}
61
							}
62
						} catch (CoreException e) {
63
						}
64
					}
65
				}
66
			}
67
		}
68
	}
69
}
(-)src/org/eclipse/ajdt/internal/javamodel/ResourceDeltaVisitor.java (-57 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     Luzius Meisser - initial implementation
10
 *******************************************************************************/
11
package org.eclipse.ajdt.internal.javamodel;
12
13
import org.eclipse.ajdt.core.javaelements.AJCompilationUnitManager;
14
import org.eclipse.ajdt.internal.utils.AJDTUtils;
15
import org.eclipse.core.resources.IFile;
16
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.IResourceDelta;
18
import org.eclipse.core.resources.IResourceDeltaVisitor;
19
20
/**
21
 * Notifies the AJCompilationUnitManager if files got added or removed.
22
 * 
23
 */
24
public class ResourceDeltaVisitor implements IResourceDeltaVisitor {
25
26
	/*
27
	 * (non-Javadoc)
28
	 * 
29
	 * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
30
	 */
31
	public ResourceDeltaVisitor() {
32
	}
33
34
	/*
35
	 * (non-Javadoc)
36
	 * 
37
	 * @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
38
	 */
39
	public boolean visit(IResourceDelta delta) {
40
		IResource myRes = delta.getResource();
41
		if (myRes.getType() == IResource.FILE) {
42
			switch (delta.getKind()) {
43
			case IResourceDelta.REMOVED:
44
				AJCompilationUnitUtils
45
						.removeFileFromModelAndCloseEditors((IFile) myRes);
46
				AJDTUtils.refreshPackageExplorer();
47
				break;
48
			case IResourceDelta.ADDED:
49
				AJCompilationUnitManager.INSTANCE
50
						.getAJCompilationUnit((IFile) myRes);
51
				AJDTUtils.refreshPackageExplorer();
52
				break;
53
			}
54
		}
55
		return true;
56
	}
57
}
(-)src/org/eclipse/ajdt/internal/javamodel/AJCompilationUnitResourceDeltaVisitor.java (+57 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     Luzius Meisser - initial implementation
10
 *******************************************************************************/
11
package org.eclipse.ajdt.internal.javamodel;
12
13
import org.eclipse.ajdt.core.javaelements.AJCompilationUnitManager;
14
import org.eclipse.ajdt.internal.utils.AJDTUtils;
15
import org.eclipse.core.resources.IFile;
16
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.IResourceDelta;
18
import org.eclipse.core.resources.IResourceDeltaVisitor;
19
20
/**
21
 * Notifies the AJCompilationUnitManager if files got added or removed.
22
 * 
23
 */
24
public class AJCompilationUnitResourceDeltaVisitor implements IResourceDeltaVisitor {
25
26
	/*
27
	 * (non-Javadoc)
28
	 * 
29
	 * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
30
	 */
31
	public AJCompilationUnitResourceDeltaVisitor() {
32
	}
33
34
	/*
35
	 * (non-Javadoc)
36
	 * 
37
	 * @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
38
	 */
39
	public boolean visit(IResourceDelta delta) {
40
		IResource myRes = delta.getResource();
41
		if (myRes.getType() == IResource.FILE) {
42
			switch (delta.getKind()) {
43
			case IResourceDelta.REMOVED:
44
				AJCompilationUnitUtils
45
						.removeFileFromModelAndCloseEditors((IFile) myRes);
46
				AJDTUtils.refreshPackageExplorer();
47
				break;
48
			case IResourceDelta.ADDED:
49
				AJCompilationUnitManager.INSTANCE
50
						.getAJCompilationUnit((IFile) myRes);
51
				AJDTUtils.refreshPackageExplorer();
52
				break;
53
			}
54
		}
55
		return true;
56
	}
57
}
(-)src/org/eclipse/ajdt/internal/javamodel/AJCompilationUnitResourceChangeListener.java (+69 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2004 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     Luzius Meisser - initial implementation
10
 *******************************************************************************/
11
package org.eclipse.ajdt.internal.javamodel;
12
import org.eclipse.ajdt.core.AspectJPlugin;
13
import org.eclipse.core.resources.IProject;
14
import org.eclipse.core.resources.IResource;
15
import org.eclipse.core.resources.IResourceChangeEvent;
16
import org.eclipse.core.resources.IResourceChangeListener;
17
import org.eclipse.core.resources.IResourceDelta;
18
import org.eclipse.core.runtime.CoreException;
19
/**
20
 * @author Luzius Meisser
21
 * 
22
 */
23
public class AJCompilationUnitResourceChangeListener implements IResourceChangeListener {
24
	private AJCompilationUnitResourceDeltaVisitor myDeltaVisitor;
25
	/*
26
	 * (non-Javadoc)
27
	 * 
28
	 * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
29
	 */
30
	public AJCompilationUnitResourceChangeListener() {
31
		myDeltaVisitor = new AJCompilationUnitResourceDeltaVisitor();
32
	}
33
	
34
	public void resourceChanged(IResourceChangeEvent event) {
35
		if (event.getType() == IResourceChangeEvent.POST_CHANGE){
36
			IResourceDelta delta = event.getDelta();
37
			// avoid processing deltas for non-AspectJ projects,
38
			if (delta != null) {
39
				IResourceDelta[] cd = delta.getAffectedChildren();
40
				if (cd == null) {
41
					try {
42
						delta.accept(myDeltaVisitor);
43
					} catch (CoreException e) {
44
					}
45
				} else {
46
					for (int i = 0; i < cd.length; i++) {
47
						try {
48
							IResource res = cd[i].getResource();
49
							if (res == null) {
50
								cd[i].accept(myDeltaVisitor);
51
							} else {
52
								IProject proj = res.getProject();
53
								// if we don't know the project, or it is
54
								// no longer accessible, we'd better process
55
								// the delta. Otherwise we only process it
56
								// if it is an AspectJ project.
57
								if ((proj == null) || !proj.isAccessible()
58
										|| AspectJPlugin.isAJProject(proj)) {
59
									cd[i].accept(myDeltaVisitor);
60
								}
61
							}
62
						} catch (CoreException e) {
63
						}
64
					}
65
				}
66
			}
67
		}
68
	}
69
}

Return to bug 245566