# HG changeset patch # User Ed Swartz # Date 1271099449 18000 # Node ID fab10c9fae2d8c1037837036eb1d0c56484b9f0d # Parent 7c9ed592cb21bcbbed58c893f7942f9edd193526 Bug 10968: Fix MMP view placement of new SOURCE entries diff -r 7c9ed592cb21 -r fab10c9fae2d project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestMMPView.java --- a/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestMMPView.java Mon Apr 12 11:44:33 2010 -0500 +++ b/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestMMPView.java Mon Apr 12 14:10:49 2010 -0500 @@ -288,6 +288,74 @@ model.dispose(); } + /** bug 10968 */ + public void testSourceChanging7() throws Exception { + makeModel("SOURCEPATH ..\\src\n"+ + "SOURCE a.cpp b.cpp\n"+ + "SOURCE c.cpp\n"+ + "SOURCE d.cpp\n"+ + "SOURCEPATH ..\\data\n" + + "START RESOURCE extra.rss\n"+ + "END\n"); + + IMMPView view = getView(mmpConfig); + assertNotNull(view); + + // when we add files, put them in the right section (DUH) + view.getSources().add(new Path("data/Foo.cpp")); + commitTest(view, "SOURCEPATH ..\\src\n"+ + "SOURCE a.cpp b.cpp\n"+ + "SOURCE c.cpp\n"+ + "SOURCE d.cpp\n"+ + "SOURCEPATH ..\\data\n" + + "START RESOURCE extra.rss\n"+ + "END\n"+ + "SOURCE Foo.cpp\n" + + ""); + + match(new IPath[] { new Path("src"), new Path("data") }, view.getRealSourcePaths()); + + assertTrue(view.getSources().contains(new Path("data/Foo.cpp"))); + + view.dispose(); + model.dispose(); + } + + /** bug 10968 */ + public void testSourceChanging7b() throws Exception { + makeModel("SOURCEPATH ..\\src\n"+ + "SOURCE a.cpp b.cpp\n"+ + "SOURCE c.cpp\n"+ + "SOURCE d.cpp\n"+ + "SOURCEPATH ..\\data\n" + + "SOURCEPATH ..\\empty\n" + + "START RESOURCE extra.rss\n"+ + "END\n"); + + IMMPView view = getView(mmpConfig); + assertNotNull(view); + + // when we add files, put them in the right section (DUH) + view.getSources().add(new Path("data/Foo.cpp")); + commitTest(view, "SOURCEPATH ..\\src\n"+ + "SOURCE a.cpp b.cpp\n"+ + "SOURCE c.cpp\n"+ + "SOURCE d.cpp\n"+ + "SOURCEPATH ..\\empty\n" + + "START RESOURCE extra.rss\n"+ + "END\n"+ + "SOURCEPATH ..\\data\n" + + "SOURCE Foo.cpp\n" + + ""); + + match(new IPath[] { new Path("src"), new Path("empty"), new Path("data") }, view.getRealSourcePaths()); + + assertTrue(view.getSources().contains(new Path("data/Foo.cpp"))); + + view.dispose(); + model.dispose(); + } + public void testSourceChangingCond1() throws Exception { makeModel("SOURCEPATH ..\\src\n#if 1\nSOURCE a.cpp\n#endif\nSOURCE b.cpp c.cpp"); diff -r 7c9ed592cb21 -r fab10c9fae2d project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/mmp/MMPStatementUpdater.java --- a/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/mmp/MMPStatementUpdater.java Mon Apr 12 11:44:33 2010 -0500 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/mmp/MMPStatementUpdater.java Mon Apr 12 14:10:49 2010 -0500 @@ -149,6 +149,15 @@ private void updateSourcePath(IASTMMPSingleArgumentStatement sourcePath) { changeStatement(sourcePath); currentSourcePath = mmpView.fromMmpToProjectPath(sourcePath.getArgument()); + + // These statements depend on the SOURCEPATH, but such statements may + // not actually appear. Thus, if we add a new entry, we should not change + // the previous SOURCE/etc. statement until until there is an actual + // statement to modify (bug 10968) + lastListStmts.remove(EMMPStatement.SOURCE); + lastListStmts.remove(EMMPStatement.DOCUMENT); + lastListStmts.remove(EMMPStatement.RESOURCE); + lastListStmts.remove(EMMPStatement.SYSTEMRESOURCE); } /**