Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2008-03-11 14:15:44 +0000
committerAnton Leherbauer2008-03-11 14:15:44 +0000
commit6b41d222e385cc03d8560c6e5ba978915a69e66b (patch)
treea16b7be809c76ee6a1257610ea6490f562b76d1b
parent64666a50461edb00c269a4ffa2243a2b5b5c7d92 (diff)
downloadorg.eclipse.cdt-6b41d222e385cc03d8560c6e5ba978915a69e66b.tar.gz
org.eclipse.cdt-6b41d222e385cc03d8560c6e5ba978915a69e66b.tar.xz
org.eclipse.cdt-6b41d222e385cc03d8560c6e5ba978915a69e66b.zip
Fix for 222069: CSourceHover popup doesn't work after changing file
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTCache.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CHoverMessages.properties4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java36
3 files changed, 40 insertions, 10 deletions
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTCache.java
index fd0de4832fa..d540343d705 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTCache.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTCache.java
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Anton Leherbauer (Wind River Systems) - initial API and implementation
- * Markus Schorn (Wind River Systems)
+ * Anton Leherbauer (Wind River Systems) - initial API and implementation
+ * Markus Schorn (Wind River Systems)
******************************************************************************/
package org.eclipse.cdt.internal.core.model;
@@ -40,7 +40,7 @@ public class ASTCache {
/** Full parse mode (no PDOM) */
public static int PARSE_MODE_FULL= ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT;
/** Fast parse mode (use PDOM) */
- public static int PARSE_MODE_FAST= ITranslationUnit.AST_SKIP_INDEXED_HEADERS | ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT;
+ public static int PARSE_MODE_FAST= ITranslationUnit.AST_SKIP_ALL_HEADERS | ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT;
/**
* Do something with an AST.
@@ -71,7 +71,7 @@ public class ASTCache {
* write access afterwards.
*/
private long fLastWriteOnIndex;
- /** Inidicates whether the AST is currenty being computed */
+ /** Indicates whether the AST is currently being computed */
private boolean fIsReconciling;
/**
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CHoverMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CHoverMessages.properties
index 673db3a7006..deec214c849 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CHoverMessages.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CHoverMessages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2006 IBM Corporation and others.
+# Copyright (c) 2000, 2008 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -16,3 +16,5 @@ CTextHover.createTextHover= Could not create c text hover
CTextHover.makeStickyHint= Press ''{0}'' for focus.
NoBreakpointAnnotation.addBreakpoint= Add a breakpoint
+
+CSourceHover.jobTitle= Computing Source
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java
index e15ba768cfa..460f933b212 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java
@@ -27,6 +27,8 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
@@ -97,6 +99,16 @@ public class CSourceHover extends AbstractCEditorTextHover implements ITextHover
private static final boolean DEBUG = false;
+ private static class SingletonRule implements ISchedulingRule {
+ public static final ISchedulingRule INSTANCE = new SingletonRule();
+ public boolean contains(ISchedulingRule rule) {
+ return rule == this;
+ }
+ public boolean isConflicting(ISchedulingRule rule) {
+ return rule == this;
+ }
+ }
+
/**
* Computes the source location for a given identifier.
*/
@@ -753,10 +765,26 @@ public class CSourceHover extends AbstractCEditorTextHover implements ITextHover
return source.substring(i);
}
- private String searchInIndex(ITranslationUnit tUnit, IRegion textRegion) {
- IProgressMonitor monitor= new NullProgressMonitor();
- ComputeSourceRunnable computer= new ComputeSourceRunnable(tUnit, textRegion);
- ASTProvider.getASTProvider().runOnAST(tUnit, ASTProvider.WAIT_NO, monitor, computer);
+ private String searchInIndex(final ITranslationUnit tUnit, IRegion textRegion) {
+ final ComputeSourceRunnable computer= new ComputeSourceRunnable(tUnit, textRegion);
+ Job job= new Job(CHoverMessages.getString("CSourceHover.jobTitle")) { //$NON-NLS-1$
+ protected IStatus run(IProgressMonitor monitor) {
+ return ASTProvider.getASTProvider().runOnAST(tUnit, ASTProvider.WAIT_ACTIVE_ONLY, monitor, computer);
+ }
+ };
+ // If the hover thread is interrupted this might have negative
+ // effects on the index - see http://bugs.eclipse.org/219834
+ // Therefore we schedule a job to decouple the parsing from this thread.
+ job.setPriority(Job.DECORATE);
+ job.setSystem(true);
+ job.setRule(SingletonRule.INSTANCE);
+ job.schedule();
+ try {
+ job.join();
+ } catch (InterruptedException exc) {
+ job.cancel();
+ return null;
+ }
return computer.getSource();
}

Back to the top