summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Eidsness2014-04-07 12:48:47 (EDT)
committerAndrew Eidsness2014-04-10 15:35:00 (EDT)
commit10659aa77f8cafb07e39ba71881cf6f7e78f3b8a (patch)
treeacdc13d7c2fc2055614f5c3095f7db74a17b356d
parentb17bd6b9496e67793d3194c9571f68fb134bf99f (diff)
downloadorg.eclipse.papyrus-10659aa77f8cafb07e39ba71881cf6f7e78f3b8a.zip
org.eclipse.papyrus-10659aa77f8cafb07e39ba71881cf6f7e78f3b8a.tar.gz
org.eclipse.papyrus-10659aa77f8cafb07e39ba71881cf6f7e78f3b8a.tar.bz2
Bug 425208: Duplicate visibility keywordsrefs/changes/76/24576/2
A Java utility function is used to merge adjacent visibitily sections (within a C++ class definition). For example, this: class T { public: void func1(); public: void func2(); }; Should appear as: class T { public: void func1(); void func2(); }; This Java utility maintains internal state so that the visibility keyword is written only once. This problem was raised because the internal state is updated even when the keyword is not written to the file. For example, this happens if the generation templates try to generate an empty section with a different visibility from what was currently written. This patch modifies the utility function so that internal state is only updated when the keyword is actually written out to the file. Change-Id: I052ede33110d382409476cac4cef38a417aaa904 Signed-off-by: Andrew Eidsness <eclipse@jfront.com>
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/CppGenUtils.java12
1 files changed, 6 insertions, 6 deletions
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/CppGenUtils.java b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/CppGenUtils.java
index 42d87d5..807effc 100644
--- a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/CppGenUtils.java
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/utils/CppGenUtils.java
@@ -296,7 +296,6 @@ public class CppGenUtils {
private static Namespace currentNS;
- private static boolean visibilityStale = false;
private static VisibilityKind currVisibility = null;
private static final Pattern EmptySectionRegex = Pattern.compile("^\\s*$"); //$NON-NLS-1$
@@ -306,7 +305,6 @@ public class CppGenUtils {
*/
public static void resetVisibility(VisibilityKind v) {
currVisibility = v;
- visibilityStale = false;
}
/**
@@ -314,9 +312,11 @@ public class CppGenUtils {
* the previously declared visibility (if appropriate). Ignore empty content.
*/
public static String getSection(VisibilityKind visibility, String content) {
+ // Bug 425208: Don't update the visibility until we know for sure that it
+ // will be written to the output.
+ VisibilityKind newVisibility = null;
if (!visibility.equals(currVisibility)) {
- currVisibility = visibility;
- visibilityStale = true;
+ newVisibility = visibility;
}
// Filter out empty sections.
@@ -326,11 +326,11 @@ public class CppGenUtils {
}
// Don't write duplicate visibility modifiers.
- if (!visibilityStale) {
+ if (newVisibility == null) {
return content;
}
- visibilityStale = false;
+ currVisibility = newVisibility;
return currVisibility.toString() + ":\n" + content; //$NON-NLS-1$
}
}