Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Corbat2017-05-30 07:29:48 +0000
committerThomas Corbat2017-05-30 07:29:48 +0000
commit7376388a949f82cc32a147c2f1d9603f656e443e (patch)
tree81b59cf964d3c56aaf5edc3a48b3a06b457b3b11
parentcacb84e277e346a42bc49d62c32c793396ad96f3 (diff)
downloadorg.eclipse.cdt-7376388a949f82cc32a147c2f1d9603f656e443e.tar.gz
org.eclipse.cdt-7376388a949f82cc32a147c2f1d9603f656e443e.tar.xz
org.eclipse.cdt-7376388a949f82cc32a147c2f1d9603f656e443e.zip
Bug 517405 - Marker refresh causes editor to open
Changed isApplicable to not retrieve the TU from the editor if it is not open. Applying the quick fix will still open the editor. Change-Id: Ib328ffa2054145eda8b2e72fe646fca2e7fc7905 Signed-off-by: Thomas Corbat <tcorbat@hsr.ch>
-rw-r--r--codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CaseBreakQuickFixFallthroughAttribute.java9
1 files changed, 5 insertions, 4 deletions
diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CaseBreakQuickFixFallthroughAttribute.java b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CaseBreakQuickFixFallthroughAttribute.java
index 84e373fc9d..f72294bfc8 100644
--- a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CaseBreakQuickFixFallthroughAttribute.java
+++ b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CaseBreakQuickFixFallthroughAttribute.java
@@ -20,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNodeFactory;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.parser.StandardAttributes;
+import org.eclipse.cdt.internal.corext.util.CModelUtil;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.BadLocationException;
@@ -31,8 +32,8 @@ public class CaseBreakQuickFixFallthroughAttribute extends AbstractCaseBreakQuic
RootProblemPreference map = (RootProblemPreference) problem.getPreference();
boolean enabled = (boolean) map.getChildValue(CaseBreakChecker.PARAM_ENABLE_FALLTHROUGH_QUICKFIX);
boolean last_case_enabled = (boolean) map.getChildValue(CaseBreakChecker.PARAM_LAST_CASE);
- ITranslationUnit tu = getTranslationUnitViaEditor(marker);
- return enabled && tu.isCXXLanguage() && (!last_case_enabled || validPositionForFallthrough(marker));
+ ITranslationUnit tu = getTranslationUnitViaWorkspace(marker);
+ return enabled && tu != null && tu.isCXXLanguage() && (!last_case_enabled || validPositionForFallthrough(tu, marker));
}
@Override
@@ -53,9 +54,9 @@ public class CaseBreakQuickFixFallthroughAttribute extends AbstractCaseBreakQuic
}
}
- private boolean validPositionForFallthrough(IMarker marker) {
+ private boolean validPositionForFallthrough(ITranslationUnit tu, IMarker marker) {
try {
- IASTTranslationUnit ast = getTranslationUnitViaEditor(marker).getAST(null, ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
+ IASTTranslationUnit ast = CModelUtil.toWorkingCopy(tu).getAST(null, ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
IASTStatement beforeCaseEnd = getStmtBeforeCaseEnd(marker, ast);
if (getNextStatement(beforeCaseEnd) == null)
return false;

Back to the top