summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Kucera2013-04-04 13:55:23 (EDT)
committerChris Recoskie2013-04-04 14:27:56 (EDT)
commitdbc024acd622c71fb8a1702b36b0876bede94703 (patch)
tree2d053c660c7e1524c85cd9957ead31d622f138a0
parent64a1d1bac56da01e4cf2da1a4f773c616f1dc007 (diff)
downloadorg.eclipse.ptp-dbc024acd622c71fb8a1702b36b0876bede94703.zip
org.eclipse.ptp-dbc024acd622c71fb8a1702b36b0876bede94703.tar.gz
org.eclipse.ptp-dbc024acd622c71fb8a1702b36b0876bede94703.tar.bz2
Bug 404045 - Remote Inactive Code Highlighting in the Remote C/C++
Editor
-rw-r--r--rdt/org.eclipse.ptp.rdt.core/miners/org/eclipse/ptp/internal/rdt/core/miners/CDTMiner.java46
-rw-r--r--rdt/org.eclipse.ptp.rdt.core/miners/org/eclipse/ptp/internal/rdt/core/miners/RemoteInactiveHighlightingHandler.java129
-rwxr-xr-xrdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/internal/rdt/core/subsystems/ICIndexSubsystem.java4
-rw-r--r--rdt/org.eclipse.ptp.rdt.editor/src/org/eclipse/ptp/internal/rdt/editor/RemoteCEditor.java35
-rw-r--r--rdt/org.eclipse.ptp.rdt.editor/src/org/eclipse/ptp/rdt/editor/info/IRemoteCEditorInfoProvider.java20
-rw-r--r--rdt/org.eclipse.ptp.rdt.server.dstore/META-INF/MANIFEST.MF2
-rw-r--r--rdt/org.eclipse.ptp.rdt.server.dstore/pom.xml2
-rw-r--r--rdt/org.eclipse.ptp.rdt.server.dstore/src/org/eclipse/ptp/rdt/server/dstore/core/RemoteToolsCIndexSubsystem.java37
-rwxr-xr-xrdt/org.eclipse.ptp.rdt.ui/META-INF/MANIFEST.MF2
-rw-r--r--rdt/org.eclipse.ptp.rdt.ui/pom.xml2
-rw-r--r--rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/editor/IRemoteInactiveHighlightingService.java23
-rw-r--r--rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/editor/RemoteCEditorInfoProvider.java38
-rw-r--r--rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/editor/RemoteInactiveHighlightPosition.java26
-rw-r--r--rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/editor/RemoteInactiveHighlighting.java239
-rw-r--r--rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/editor/RemoteInactiveHighlightingService.java90
-rwxr-xr-xrdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/IIndexServiceProvider2.java21
-rw-r--r--rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/IIndexServiceProvider3.java24
-rw-r--r--rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/LocalCIndexServiceProvider.java20
-rw-r--r--rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/NullCIndexServiceProvider.java18
-rwxr-xr-xrdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/RSECIndexServiceProvider.java20
-rwxr-xr-xrdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/subsystems/RSECIndexSubsystem.java41
21 files changed, 799 insertions, 40 deletions
diff --git a/rdt/org.eclipse.ptp.rdt.core/miners/org/eclipse/ptp/internal/rdt/core/miners/CDTMiner.java b/rdt/org.eclipse.ptp.rdt.core/miners/org/eclipse/ptp/internal/rdt/core/miners/CDTMiner.java
index fdd7ab0..237d6e4 100644
--- a/rdt/org.eclipse.ptp.rdt.core/miners/org/eclipse/ptp/internal/rdt/core/miners/CDTMiner.java
+++ b/rdt/org.eclipse.ptp.rdt.core/miners/org/eclipse/ptp/internal/rdt/core/miners/CDTMiner.java
@@ -24,6 +24,7 @@ import java.util.Map;
import java.util.Set;
import java.util.Stack;
+import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
import org.eclipse.cdt.core.dom.ast.IASTName;
@@ -167,6 +168,8 @@ public class CDTMiner extends Miner {
//semantic highlighting and code folding
public static final String C_SEMANTIC_HIGHTLIGHTING_COMPUTE_POSITIONS = "C_SEMANTIC_HIGHTLIGHTING_COMPUTE_POSITIONS"; //$NON-NLS-1$
public static final String T_HIGHTLIGHTING_POSITIONS_RESULT = "Highlighting.Positions.Result"; //$NON-NLS-1$
+ public static final String C_INACTIVE_HIGHTLIGHTING_COMPUTE_POSITIONS = "C_INACTIVE_HIGHTLIGHTING_COMPUTE_POSITIONS"; //$NON-NLS-1$
+ public static final String T_INACTIVE_HIGHTLIGHTING_POSITIONS_RESULT = "InactiveHighlighting.Positions.Result"; //$NON-NLS-1$
public static final String C_CODE_FOLDING_COMPUTE_REGIONS = "C_CODE_FOLDING_COMPUTE_REGIONS"; //$NON-NLS-1$
public static final String T_CODE_FOLDING_RESULT = "Folding.Region.Result"; //$NON-NLS-1$
@@ -768,6 +771,18 @@ public class CDTMiner extends Miner {
UniversalServerUtilities.logError(LOG_TAG, e.toString(), e, _dataStore);
}
}
+ else if (name.equals(C_INACTIVE_HIGHTLIGHTING_COMPUTE_POSITIONS)) {
+ try {
+ String scopeName = getString(theCommand, 1);
+ ITranslationUnit tu = (ITranslationUnit) Serializer.deserialize(getString(theCommand, 2));
+
+ handleComputeInactiveHightlightingPositions(scopeName, tu, status);
+ } catch (IOException e) {
+ UniversalServerUtilities.logError(LOG_TAG, e.toString(), e, _dataStore);
+ } catch (ClassNotFoundException e) {
+ UniversalServerUtilities.logError(LOG_TAG, e.toString(), e, _dataStore);
+ }
+ }
else if (name.equals(C_CODE_FOLDING_COMPUTE_REGIONS)) {
try {
String scopeName = getString(theCommand, 1);
@@ -810,7 +825,8 @@ public class CDTMiner extends Miner {
IIndex index = RemoteIndexManager.getInstance().getIndexForScope(scopeName, _dataStore);
index.acquireReadLock();
try {
- IASTTranslationUnit ast = tu.getAST(index, ITranslationUnit.AST_SKIP_ALL_HEADERS);
+ // what's the right style flag to use here?
+ IASTTranslationUnit ast = tu.getAST(index, ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
RemoteCodeFormatterVisitor codeFormatter = new RemoteCodeFormatterVisitor(preferences, offset, length, LOG_TAG, _dataStore);
TextEdit edit= codeFormatter.format(source, ast);
@@ -885,7 +901,32 @@ public class CDTMiner extends Miner {
statusDone(status);
}
}
-
+
+
+ protected void handleComputeInactiveHightlightingPositions(String scopeName, ITranslationUnit tu, DataElement status) {
+ try {
+ IIndex index = RemoteIndexManager.getInstance().getIndexForScope(scopeName, _dataStore);
+ index.acquireReadLock();
+
+ try {
+ IASTTranslationUnit ast = tu.getAST(index, ITranslationUnit.AST_SKIP_ALL_HEADERS | ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT);
+ String positions = RemoteInactiveHighlightingHandler.collectInactiveCodePositions(ast);
+ status.getDataStore().createObject(status, T_INACTIVE_HIGHTLIGHTING_POSITIONS_RESULT, positions);
+ }
+ finally {
+ index.releaseReadLock();
+ }
+ } catch (CoreException e) {
+ UniversalServerUtilities.logError(LOG_TAG, e.toString(), e, _dataStore);
+ } catch (InterruptedException e) {
+ UniversalServerUtilities.logError(LOG_TAG, e.toString(), e, _dataStore);
+ }
+ finally {
+ statusDone(status);
+ }
+ }
+
+
protected void handleComputeCodeFoldingRegions(String scopeName, ITranslationUnit tu, DataElement status,
boolean statementsFoldingEnabled, boolean preprocessorFoldingEnabled, int docSize) {
try {
@@ -1835,6 +1876,7 @@ public class CDTMiner extends Miner {
// semantic highlighting and code folding
createCommandDescriptor(schemaRoot, "Compute added & removed positions for semantic highlighting", C_SEMANTIC_HIGHTLIGHTING_COMPUTE_POSITIONS, false); //$NON-NLS-1$
+ createCommandDescriptor(schemaRoot, "Compute added & removed positions for inactive highlighting", C_INACTIVE_HIGHTLIGHTING_COMPUTE_POSITIONS, false); //$NON-NLS-1$
createCommandDescriptor(schemaRoot, "Compute code folding regions for the Remote C Editor", C_CODE_FOLDING_COMPUTE_REGIONS, false); //$NON-NLS-1$
// navigation
diff --git a/rdt/org.eclipse.ptp.rdt.core/miners/org/eclipse/ptp/internal/rdt/core/miners/RemoteInactiveHighlightingHandler.java b/rdt/org.eclipse.ptp.rdt.core/miners/org/eclipse/ptp/internal/rdt/core/miners/RemoteInactiveHighlightingHandler.java
new file mode 100644
index 0000000..ec9459e
--- /dev/null
+++ b/rdt/org.eclipse.ptp.rdt.core/miners/org/eclipse/ptp/internal/rdt/core/miners/RemoteInactiveHighlightingHandler.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.ptp.internal.rdt.core.miners;
+
+import java.util.EmptyStackException;
+import java.util.Stack;
+
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorElifStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorElseStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorEndifStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIfStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIfdefStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIfndefStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+
+public class RemoteInactiveHighlightingHandler {
+
+ public static String collectInactiveCodePositions(IASTTranslationUnit translationUnit) {
+
+ if (translationUnit == null) {
+ return ""; //$NON-NLS-1$
+ }
+
+ String fileName = translationUnit.getFilePath();
+ if (fileName == null) {
+ return ""; //$NON-NLS-1$
+ }
+
+ StringBuilder sb = new StringBuilder();
+
+ int inactiveCodeStart = -1;
+ boolean inInactiveCode = false;
+ Stack<Boolean> inactiveCodeStack = new Stack<Boolean>();
+
+ IASTPreprocessorStatement[] preprocStmts = translationUnit.getAllPreprocessorStatements();
+
+ for (IASTPreprocessorStatement statement : preprocStmts) {
+ IASTFileLocation floc = statement.getFileLocation();
+ if (floc == null || !fileName.equals(floc.getFileName())) {
+ // preprocessor directive is from a different file
+ continue;
+ }
+ if (statement instanceof IASTPreprocessorIfStatement) {
+ IASTPreprocessorIfStatement ifStmt = (IASTPreprocessorIfStatement) statement;
+ inactiveCodeStack.push(Boolean.valueOf(inInactiveCode));
+ if (!ifStmt.taken()) {
+ if (!inInactiveCode) {
+ inactiveCodeStart = floc.getNodeOffset();
+ inInactiveCode = true;
+ }
+ }
+ } else if (statement instanceof IASTPreprocessorIfdefStatement) {
+ IASTPreprocessorIfdefStatement ifdefStmt = (IASTPreprocessorIfdefStatement) statement;
+ inactiveCodeStack.push(Boolean.valueOf(inInactiveCode));
+ if (!ifdefStmt.taken()) {
+ if (!inInactiveCode) {
+ inactiveCodeStart = floc.getNodeOffset();
+ inInactiveCode = true;
+ }
+ }
+ } else if (statement instanceof IASTPreprocessorIfndefStatement) {
+ IASTPreprocessorIfndefStatement ifndefStmt = (IASTPreprocessorIfndefStatement) statement;
+ inactiveCodeStack.push(Boolean.valueOf(inInactiveCode));
+ if (!ifndefStmt.taken()) {
+ if (!inInactiveCode) {
+ inactiveCodeStart = floc.getNodeOffset();
+ inInactiveCode = true;
+ }
+ }
+ } else if (statement instanceof IASTPreprocessorElseStatement) {
+ IASTPreprocessorElseStatement elseStmt = (IASTPreprocessorElseStatement) statement;
+ if (!elseStmt.taken() && !inInactiveCode) {
+ inactiveCodeStart = floc.getNodeOffset();
+ inInactiveCode = true;
+ } else if (elseStmt.taken() && inInactiveCode) {
+ int inactiveCodeEnd = floc.getNodeOffset();
+ addHighlightPosition(sb, inactiveCodeStart, inactiveCodeEnd, false);
+ inInactiveCode = false;
+ }
+ } else if (statement instanceof IASTPreprocessorElifStatement) {
+ IASTPreprocessorElifStatement elifStmt = (IASTPreprocessorElifStatement) statement;
+ if (!elifStmt.taken() && !inInactiveCode) {
+ inactiveCodeStart = floc.getNodeOffset();
+ inInactiveCode = true;
+ } else if (elifStmt.taken() && inInactiveCode) {
+ int inactiveCodeEnd = floc.getNodeOffset();
+ addHighlightPosition(sb, inactiveCodeStart, inactiveCodeEnd, false);
+ inInactiveCode = false;
+ }
+ } else if (statement instanceof IASTPreprocessorEndifStatement) {
+ try {
+ boolean wasInInactiveCode = inactiveCodeStack.pop().booleanValue();
+ if (inInactiveCode && !wasInInactiveCode) {
+ int inactiveCodeEnd = floc.getNodeOffset() + floc.getNodeLength();
+ addHighlightPosition(sb, inactiveCodeStart, inactiveCodeEnd, true);
+ }
+ inInactiveCode = wasInInactiveCode;
+ } catch (EmptyStackException e) {
+ }
+ }
+ }
+ if (inInactiveCode) {
+ // handle unterminated #if - http://bugs.eclipse.org/255018
+ int inactiveCodeEnd = Integer.MAX_VALUE; // fDocument.getLength();
+ addHighlightPosition(sb, inactiveCodeStart, inactiveCodeEnd, true);
+ }
+
+ String result = sb.toString();
+ if (result.startsWith(",")) { //$NON-NLS-1$
+ result = result.substring(1);
+ }
+ return result;
+ }
+
+ private static void addHighlightPosition(StringBuilder sb, int start, int end, boolean inclusive) {
+ sb.append(String.format(",%d,%d,%b", start, end, inclusive)); //$NON-NLS-1$
+ }
+}
diff --git a/rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/internal/rdt/core/subsystems/ICIndexSubsystem.java b/rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/internal/rdt/core/subsystems/ICIndexSubsystem.java
index c4241df..4e78972 100755
--- a/rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/internal/rdt/core/subsystems/ICIndexSubsystem.java
+++ b/rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/internal/rdt/core/subsystems/ICIndexSubsystem.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 IBM Corporation and others.
+ * Copyright (c) 2008, 2013 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
@@ -298,6 +298,8 @@ public interface ICIndexSubsystem {
public String computeHighlightPositions(ITranslationUnit targetUnit);
+ public String computeInactiveHighlightPositions(ITranslationUnit targetUnit);
+
public FoldingRegionsResult computeFoldingRegions(ITranslationUnit targetUnit, int docLength, boolean fPreprocessorBranchFoldingEnabled, boolean fStatementsFoldingEnabled);
public TextEdit computeCodeFormatting(Scope scope, ITranslationUnit targetUnit, String source, RemoteDefaultCodeFormatterOptions preferences, int offset, int length, IProgressMonitor monitor);
diff --git a/rdt/org.eclipse.ptp.rdt.editor/src/org/eclipse/ptp/internal/rdt/editor/RemoteCEditor.java b/rdt/org.eclipse.ptp.rdt.editor/src/org/eclipse/ptp/internal/rdt/editor/RemoteCEditor.java
index c761cb6..1d14d1b 100644
--- a/rdt/org.eclipse.ptp.rdt.editor/src/org/eclipse/ptp/internal/rdt/editor/RemoteCEditor.java
+++ b/rdt/org.eclipse.ptp.rdt.editor/src/org/eclipse/ptp/internal/rdt/editor/RemoteCEditor.java
@@ -101,6 +101,9 @@ public class RemoteCEditor extends CEditor implements HelpListener {
if (provider != null){
if (isSemanticHighlightingEnabled())
provider.installSemanticHighlighting(getSourceViewer(), getPreferenceStore());
+ if(provider.isInactiveHighlightingEnabled(getPreferenceStore())) {
+ provider.installInactiveHighlighting(getPreferenceStore(), getSharedColors());
+ }
provider.doPostCreatePartControl(parent);
}
}
@@ -414,22 +417,34 @@ public class RemoteCEditor extends CEditor implements HelpListener {
}
return result;
}
-
+
protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
super.handlePreferenceStoreChanged(event);
-
- if (provider != null && SemanticHighlightings.affectsEnablement(getPreferenceStore(), event )
- || (isEnableScalablilityMode() && PreferenceConstants.SCALABILITY_SEMANTIC_HIGHLIGHT.equals(event.getProperty()))) {
- if (isSemanticHighlightingEnabled()) {
- provider.installSemanticHighlighting(getSourceViewer(), getPreferenceStore());
- provider.refreshRemoteSemanticManager();
+
+ if (provider != null) {
+ IPreferenceStore store = getPreferenceStore();
+
+ if (SemanticHighlightings.affectsEnablement(store, event)
+ || (isEnableScalablilityMode() && PreferenceConstants.SCALABILITY_SEMANTIC_HIGHLIGHT.equals(event.getProperty()))) {
+ if (isSemanticHighlightingEnabled()) {
+ provider.installSemanticHighlighting(getSourceViewer(), store);
+ provider.refreshRemoteSemanticManager();
+ } else {
+ provider.uninstallSemanticHighlighting();
+ }
+ }
+
+ if (provider.isInactiveHighlightingEnabled(store)) {
+ provider.installInactiveHighlighting(store, getSharedColors());
+ if (event.getProperty().equals(provider.getInactiveHighlightColorKey())) {
+ provider.updateInactiveHighlightColor();
+ }
} else {
- provider.uninstallSemanticHighlighting();
+ provider.uninstallInactiveHighlighting();
}
- return;
}
}
-
+
public void uninstallProjectionModelUpdater() {
super.uninstallProjectionModelUpdater();
}
diff --git a/rdt/org.eclipse.ptp.rdt.editor/src/org/eclipse/ptp/rdt/editor/info/IRemoteCEditorInfoProvider.java b/rdt/org.eclipse.ptp.rdt.editor/src/org/eclipse/ptp/rdt/editor/info/IRemoteCEditorInfoProvider.java
index 1e2e785..de28e57 100644
--- a/rdt/org.eclipse.ptp.rdt.editor/src/org/eclipse/ptp/rdt/editor/info/IRemoteCEditorInfoProvider.java
+++ b/rdt/org.eclipse.ptp.rdt.editor/src/org/eclipse/ptp/rdt/editor/info/IRemoteCEditorInfoProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 IBM Corporation and others.
+ * Copyright (c) 2013 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
@@ -17,6 +17,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.source.ISharedTextColors;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
@@ -127,14 +128,25 @@ public interface IRemoteCEditorInfoProvider {
public boolean shouldProcessLocalParsingCompletions();
public boolean isSemanticHighlightingEnabled(IPreferenceStore store);
-
+
public void installSemanticHighlighting(ISourceViewer sourceViewer, IPreferenceStore prefStore);
public void installRemoteCodeFolding(ISourceViewer sourceViewer);
-
+
public void uninstallRemoteCodeFolding();
public void uninstallSemanticHighlighting();
-
+
public void refreshRemoteSemanticManager();
+
+ public boolean isInactiveHighlightingEnabled(IPreferenceStore prefStore);
+
+ public void installInactiveHighlighting(IPreferenceStore prefStore, ISharedTextColors colors);
+
+ public void uninstallInactiveHighlighting();
+
+ public String getInactiveHighlightColorKey();
+
+ public void updateInactiveHighlightColor();
+
}
diff --git a/rdt/org.eclipse.ptp.rdt.server.dstore/META-INF/MANIFEST.MF b/rdt/org.eclipse.ptp.rdt.server.dstore/META-INF/MANIFEST.MF
index 787c501..43c9298 100644
--- a/rdt/org.eclipse.ptp.rdt.server.dstore/META-INF/MANIFEST.MF
+++ b/rdt/org.eclipse.ptp.rdt.server.dstore/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.ptp.rdt.server.dstore;singleton:=true
-Bundle-Version: 3.1.0.qualifier
+Bundle-Version: 3.2.0.qualifier
Bundle-Activator: org.eclipse.ptp.rdt.server.dstore.Activator
Bundle-Vendor: %pluginProvider
Require-Bundle: org.eclipse.core.runtime,
diff --git a/rdt/org.eclipse.ptp.rdt.server.dstore/pom.xml b/rdt/org.eclipse.ptp.rdt.server.dstore/pom.xml
index c9f3653..a8eff66 100644
--- a/rdt/org.eclipse.ptp.rdt.server.dstore/pom.xml
+++ b/rdt/org.eclipse.ptp.rdt.server.dstore/pom.xml
@@ -11,6 +11,6 @@
</parent>
<artifactId>org.eclipse.ptp.rdt.server.dstore</artifactId>
- <version>3.1.0-SNAPSHOT</version>
+ <version>3.2.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/rdt/org.eclipse.ptp.rdt.server.dstore/src/org/eclipse/ptp/rdt/server/dstore/core/RemoteToolsCIndexSubsystem.java b/rdt/org.eclipse.ptp.rdt.server.dstore/src/org/eclipse/ptp/rdt/server/dstore/core/RemoteToolsCIndexSubsystem.java
index 4c0833d..29fa256 100644
--- a/rdt/org.eclipse.ptp.rdt.server.dstore/src/org/eclipse/ptp/rdt/server/dstore/core/RemoteToolsCIndexSubsystem.java
+++ b/rdt/org.eclipse.ptp.rdt.server.dstore/src/org/eclipse/ptp/rdt/server/dstore/core/RemoteToolsCIndexSubsystem.java
@@ -1273,6 +1273,43 @@ public class RemoteToolsCIndexSubsystem implements ICIndexSubsystem {
return ""; //$NON-NLS-1$
}
+
+ /**
+ * @since 3.2
+ */
+ public String computeInactiveHighlightPositions(ITranslationUnit targetUnit) {
+ DataStore dataStore = getDataStore(null);
+ if (dataStore == null) {
+ return ""; //$NON-NLS-1$
+ }
+ DataElement queryCmd = dataStore.localDescriptorQuery(dataStore.getDescriptorRoot(), CDTMiner.C_INACTIVE_HIGHTLIGHTING_COMPUTE_POSITIONS);
+ if (queryCmd == null) {
+ return ""; //$NON-NLS-1$
+ }
+
+ Scope scope = new Scope(targetUnit.getCProject().getProject());
+
+ ArrayList<Object> args = new ArrayList<Object>();
+ args.add(dataStore.createObject(null, CDTMiner.T_SCOPE_SCOPENAME_DESCRIPTOR, scope.getName()));
+ args.add(createSerializableElement(dataStore, targetUnit));
+
+ DataElement status = dataStore.command(queryCmd, args, dataStore.getDescriptorRoot());
+
+ StatusMonitor smonitor = StatusMonitor.getStatusMonitorFor(fProvider.getConnection(), dataStore);
+ try {
+ smonitor.waitForUpdate(status, new NullProgressMonitor());
+ } catch (Exception e) {
+ RDTLog.logError(e);
+ }
+
+ DataElement element = status.get(0);
+ if (element == null)
+ return ""; //$NON-NLS-1$
+ String result = element.getName();
+ return result == null ? "" : result; //$NON-NLS-1$
+ }
+
+
/**
* @since 3.0
*/
diff --git a/rdt/org.eclipse.ptp.rdt.ui/META-INF/MANIFEST.MF b/rdt/org.eclipse.ptp.rdt.ui/META-INF/MANIFEST.MF
index 1439726..17dea71 100755
--- a/rdt/org.eclipse.ptp.rdt.ui/META-INF/MANIFEST.MF
+++ b/rdt/org.eclipse.ptp.rdt.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.ptp.rdt.ui;singleton:=true
-Bundle-Version: 4.2.0.qualifier
+Bundle-Version: 4.3.0.qualifier
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.eclipse.cdt.core;bundle-version="5.0.2",
org.eclipse.cdt.ui;bundle-version="5.0.2",
diff --git a/rdt/org.eclipse.ptp.rdt.ui/pom.xml b/rdt/org.eclipse.ptp.rdt.ui/pom.xml
index af9a36b..c0de215 100644
--- a/rdt/org.eclipse.ptp.rdt.ui/pom.xml
+++ b/rdt/org.eclipse.ptp.rdt.ui/pom.xml
@@ -11,6 +11,6 @@
</parent>
<artifactId>org.eclipse.ptp.rdt.ui</artifactId>
- <version>4.2.0-SNAPSHOT</version>
+ <version>4.3.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/editor/IRemoteInactiveHighlightingService.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/editor/IRemoteInactiveHighlightingService.java
new file mode 100644
index 0000000..ab9fdf5
--- /dev/null
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/editor/IRemoteInactiveHighlightingService.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.ptp.internal.rdt.ui.editor;
+
+import java.util.List;
+
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
+
+public interface IRemoteInactiveHighlightingService {
+
+ List<Position> computeInactiveHighlightingPositions(IDocument document, IWorkingCopy wc);
+}
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/editor/RemoteCEditorInfoProvider.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/editor/RemoteCEditorInfoProvider.java
index c7fcf39..0a221dd 100644
--- a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/editor/RemoteCEditorInfoProvider.java
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/editor/RemoteCEditorInfoProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 IBM Corporation and others.
+ * Copyright (c) 2008, 2013 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
@@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.internal.ui.editor.CContentOutlinePage;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.editor.CSourceViewer;
import org.eclipse.cdt.internal.ui.editor.SemanticHighlightings;
import org.eclipse.cdt.internal.ui.text.CTextTools;
@@ -28,6 +29,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.help.IContextProvider;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.source.ISharedTextColors;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
@@ -70,6 +72,9 @@ public class RemoteCEditorInfoProvider implements IRemoteCEditorInfoProvider {
private RemoteSemanticHighlightingManager fRemoteSemanticManager;
private RemoteCFoldingStructureProvider fRemoteFoldingProvider;
+
+ private RemoteInactiveHighlighting fRemoteInactiveCodeHighlighting;
+
/* (non-Javadoc)
* @see org.eclipse.ptp.rdt.editor.info.IRemoteCEditorInfoProvider#initializeEditor(org.eclipse.ptp.internal.rdt.editor.RemoteCEditor)
@@ -474,4 +479,35 @@ public class RemoteCEditorInfoProvider implements IRemoteCEditorInfoProvider {
fRemoteSemanticManager= null;
}
}
+
+ public boolean isInactiveHighlightingEnabled(IPreferenceStore prefStore) {
+ return prefStore.getBoolean(CEditor.INACTIVE_CODE_ENABLE) && !editor.isEnableScalablilityMode();
+ }
+
+ public void installInactiveHighlighting(IPreferenceStore prefStore, ISharedTextColors colors) {
+ if (fRemoteInactiveCodeHighlighting == null && !isLocalServiceProvider()
+ && isInactiveHighlightingEnabled(prefStore)) {
+ fRemoteInactiveCodeHighlighting = new RemoteInactiveHighlighting(prefStore, colors);
+ fRemoteInactiveCodeHighlighting.install(editor);
+ } else if (isLocalServiceProvider()) {
+ uninstallInactiveHighlighting();
+ }
+ }
+
+ public void uninstallInactiveHighlighting() {
+ if (fRemoteInactiveCodeHighlighting != null) {
+ fRemoteInactiveCodeHighlighting.uninstall();
+ fRemoteInactiveCodeHighlighting = null;
+ }
+ }
+
+ public String getInactiveHighlightColorKey() {
+ return RemoteInactiveHighlighting.INACTIVE_CODE_COLOR;
+ }
+
+ public void updateInactiveHighlightColor() {
+ if (fRemoteInactiveCodeHighlighting != null)
+ fRemoteInactiveCodeHighlighting.updateInactiveCodeColor();
+ }
+
}
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/editor/RemoteInactiveHighlightPosition.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/editor/RemoteInactiveHighlightPosition.java
new file mode 100644
index 0000000..750ea9d
--- /dev/null
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/editor/RemoteInactiveHighlightPosition.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.ptp.internal.rdt.ui.editor;
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.TypedPosition;
+
+public class RemoteInactiveHighlightPosition extends TypedPosition implements IRegion {
+
+ public RemoteInactiveHighlightPosition(int offset, int length, String type) {
+ super(offset, length, type);
+ }
+
+ public RemoteInactiveHighlightPosition(IRegion region, String type) {
+ super(region.getOffset(), region.getLength(), type);
+ }
+}
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/editor/RemoteInactiveHighlighting.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/editor/RemoteInactiveHighlighting.java
new file mode 100644
index 0000000..a47ab24
--- /dev/null
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/editor/RemoteInactiveHighlighting.java
@@ -0,0 +1,239 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2013 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)
+ * IBM - derivative work
+ *******************************************************************************/
+package org.eclipse.ptp.internal.rdt.ui.editor;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.internal.ui.LineBackgroundPainter;
+import org.eclipse.cdt.internal.ui.editor.CEditorMessages;
+import org.eclipse.cdt.internal.ui.text.ICReconcilingListener;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IWorkingCopyManager;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextInputListener;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.ITextViewerExtension2;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.source.ISharedTextColors;
+import org.eclipse.ptp.internal.rdt.editor.RemoteCEditor;
+import org.eclipse.ptp.rdt.core.services.IRDTServiceConstants;
+import org.eclipse.ptp.rdt.ui.serviceproviders.IIndexServiceProvider2;
+import org.eclipse.ptp.rdt.ui.serviceproviders.IIndexServiceProvider3;
+import org.eclipse.ptp.services.core.IService;
+import org.eclipse.ptp.services.core.IServiceConfiguration;
+import org.eclipse.ptp.services.core.IServiceModelManager;
+import org.eclipse.ptp.services.core.IServiceProvider;
+import org.eclipse.ptp.services.core.ServiceModelManager;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Paints code lines disabled by preprocessor directives (#ifdef etc.) with a
+ * configurable background color (default light gray).
+ *
+ * @see LineBackgroundPainter
+ * @since 4.2
+ */
+public class RemoteInactiveHighlighting implements ICReconcilingListener, ITextInputListener {
+
+ public static final String INACTIVE_CODE_ENABLE = "inactiveCodeEnable"; //$NON-NLS-1$
+ public static final String INACTIVE_CODE_COLOR = "inactiveCodeColor"; //$NON-NLS-1$
+ public static final String INACTIVE_CODE_KEY = "inactiveCode"; //$NON-NLS-1$
+
+ private LineBackgroundPainter fLineBackgroundPainter;
+ private Job fUpdateJob;
+ private Object fJobLock = new Object();
+ private RemoteCEditor fEditor;
+ private List<Position> fInactiveCodePositions = Collections.emptyList();
+ private IDocument fDocument;
+
+ private IPreferenceStore fPrefStore;
+ private ISharedTextColors fSharedColors;
+
+ public RemoteInactiveHighlighting(IPreferenceStore store, ISharedTextColors sharedColors) {
+ this.fPrefStore = store;
+ this.fSharedColors = sharedColors;
+ }
+
+ /**
+ * Schedule update of the inactive code positions in the background.
+ */
+ private void scheduleJob() {
+ synchronized (fJobLock) {
+ if (fUpdateJob == null) {
+ fUpdateJob = new Job(CEditorMessages.InactiveCodeHighlighting_job) {
+ @Override
+ protected IStatus run(final IProgressMonitor monitor) {
+ reconciled(null, true, monitor);
+ return Status.OK_STATUS;
+ }
+ };
+ fUpdateJob.setPriority(Job.DECORATE);
+ }
+ if (fUpdateJob.getState() == Job.NONE) {
+ fUpdateJob.schedule();
+ }
+ }
+ }
+
+ public void install(RemoteCEditor editor) {
+ fEditor = editor;
+ installLinePainter();
+ fDocument = fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
+ fEditor.getViewer().addTextInputListener(this);
+ fEditor.addReconcileListener(this);
+ }
+
+ private void installLinePainter() {
+ ITextViewer viewer = fEditor.getViewer();
+ fLineBackgroundPainter = new LineBackgroundPainter(viewer);
+ fLineBackgroundPainter.enableCursorLine(false);
+ fLineBackgroundPainter.setBackgroundColor(INACTIVE_CODE_KEY, getColor(INACTIVE_CODE_COLOR));
+ ((ITextViewerExtension2) viewer).addPainter(fLineBackgroundPainter);
+ }
+
+ private void uninstallLinePainter() {
+ ITextViewer viewer = fEditor.getViewer();
+ if (fLineBackgroundPainter != null && !fLineBackgroundPainter.isDisposed()) {
+ fLineBackgroundPainter.removeHighlightPositions(fInactiveCodePositions);
+ fInactiveCodePositions = Collections.emptyList();
+ fLineBackgroundPainter.deactivate(true);
+ fLineBackgroundPainter.dispose();
+ ((ITextViewerExtension2) viewer).removePainter(fLineBackgroundPainter);
+ fLineBackgroundPainter = null;
+ }
+ }
+
+ public void updateInactiveCodeColor() {
+ if (fLineBackgroundPainter != null) {
+ fLineBackgroundPainter.setBackgroundColor(INACTIVE_CODE_KEY, getColor(INACTIVE_CODE_COLOR));
+ fLineBackgroundPainter.redraw();
+ }
+ }
+
+ private Color getColor(String key) {
+ if (fPrefStore != null) {
+ RGB rgb = PreferenceConverter.getColor(fPrefStore, key);
+ return fSharedColors.getColor(rgb);
+ }
+ return null;
+ }
+
+ public void uninstall() {
+ synchronized (fJobLock) {
+ if (fUpdateJob != null && fUpdateJob.getState() == Job.RUNNING) {
+ fUpdateJob.cancel();
+ }
+ }
+ uninstallLinePainter();
+ if (fEditor != null) {
+ fEditor.removeReconcileListener(this);
+ if (fEditor.getViewer() != null) {
+ fEditor.getViewer().removeTextInputListener(this);
+ }
+ fEditor = null;
+ fDocument = null;
+ }
+ }
+
+ /**
+ * Force refresh.
+ */
+ public void refresh() {
+ scheduleJob();
+ }
+
+ /*
+ * @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#aboutToBeReconciled()
+ */
+ public void aboutToBeReconciled() {
+ }
+
+ /*
+ * @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled(IASTTranslationUnit, boolean, IProgressMonitor)
+ */
+ public void reconciled(IASTTranslationUnit ast, final boolean force, IProgressMonitor progressMonitor) {
+ // local ast is null, don't use it
+ if (progressMonitor != null && progressMonitor.isCanceled()) {
+ return;
+ }
+ final List<Position> newInactiveCodePositions = collectInactiveCodePositions();
+ Runnable updater = new Runnable() {
+ public void run() {
+ if (fEditor != null && fLineBackgroundPainter != null && !fLineBackgroundPainter.isDisposed()) {
+ fLineBackgroundPainter.replaceHighlightPositions(fInactiveCodePositions, newInactiveCodePositions);
+ fInactiveCodePositions = newInactiveCodePositions;
+ }
+ }
+ };
+ if (fEditor != null) {
+ Display.getDefault().asyncExec(updater);
+ }
+ }
+
+ private List<Position> collectInactiveCodePositions() {
+ IProject project = ((RemoteCEditor) fEditor).getInputCElement().getCProject().getProject();
+ IRemoteInactiveHighlightingService service = getInactiveHighlightingService(project);
+ if(service == null)
+ return Collections.emptyList();
+
+ IWorkingCopyManager manager = CUIPlugin.getDefault().getWorkingCopyManager();
+ IWorkingCopy workingCopy = manager.getWorkingCopy(fEditor.getEditorInput());
+
+ List<Position> positions = service.computeInactiveHighlightingPositions(fDocument, workingCopy);
+ if (positions == null)
+ positions = Collections.emptyList();
+
+ return positions;
+ }
+
+ private IRemoteInactiveHighlightingService getInactiveHighlightingService(IProject project) {
+ IServiceModelManager smm = ServiceModelManager.getInstance();
+ IServiceConfiguration serviceConfig = smm.getActiveConfiguration(project);
+ IService indexingService = smm.getService(IRDTServiceConstants.SERVICE_C_INDEX);
+ IServiceProvider serviceProvider = serviceConfig.getServiceProvider(indexingService);
+ if(serviceProvider instanceof IIndexServiceProvider3) {
+ return ((IIndexServiceProvider3) serviceProvider).getRemoteInactiveHighlightingService();
+ }
+ return null;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.ITextInputListener#inputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
+ */
+ public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
+ if (fEditor != null && fLineBackgroundPainter != null && !fLineBackgroundPainter.isDisposed()) {
+ fLineBackgroundPainter.removeHighlightPositions(fInactiveCodePositions);
+ fInactiveCodePositions = Collections.emptyList();
+ }
+ }
+
+ /*
+ * @see org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
+ */
+ public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
+ fDocument = newInput;
+ }
+
+}
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/editor/RemoteInactiveHighlightingService.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/editor/RemoteInactiveHighlightingService.java
new file mode 100644
index 0000000..2c0cad0
--- /dev/null
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/editor/RemoteInactiveHighlightingService.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.ptp.internal.rdt.ui.editor;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
+import org.eclipse.ptp.internal.rdt.core.serviceproviders.AbstractRemoteService;
+import org.eclipse.ptp.internal.rdt.core.subsystems.ICIndexSubsystem;
+import org.eclipse.ptp.rdt.core.RDTLog;
+import org.eclipse.rse.core.subsystems.IConnectorService;
+
+public class RemoteInactiveHighlightingService extends AbstractRemoteService implements IRemoteInactiveHighlightingService {
+
+ public RemoteInactiveHighlightingService(IConnectorService connectorService) {
+ super(connectorService);
+ }
+
+ public RemoteInactiveHighlightingService(ICIndexSubsystem subsystem) {
+ super(subsystem);
+ }
+
+ public List<Position> computeInactiveHighlightingPositions(IDocument document, IWorkingCopy workingCopy) {
+ ICIndexSubsystem subsystem = getSubSystem();
+
+ subsystem.checkProject(workingCopy.getCProject().getProject(), new NullProgressMonitor());
+
+ ITranslationUnit unit;
+ try {
+ unit = adaptWorkingCopy(workingCopy);
+ } catch (CModelException e) {
+ RDTLog.logError(e);
+ return Collections.emptyList();
+ }
+
+ String result = subsystem.computeInactiveHighlightPositions(unit);
+ return parsePositions(document, result);
+ }
+
+ private List<Position> parsePositions(IDocument document, String positionString) {
+ if (positionString == null || positionString.length() == 0)
+ return Collections.emptyList();
+
+ String[] elements = positionString.split(","); //$NON-NLS-1$
+ List<Position> positions = new ArrayList<Position>(elements.length / 3);
+
+ for (int i = 0; i < elements.length; i += 3) {
+ int start = Integer.parseInt(elements[i]);
+ int end = Integer.parseInt(elements[i + 1]);
+ boolean inclusive = Boolean.parseBoolean(elements[i + 2]);
+ positions.add(createHighlightPosition(document, start, end, inclusive));
+ }
+
+ return positions;
+ }
+
+ private RemoteInactiveHighlightPosition createHighlightPosition(IDocument document, int startOffset, int endOffset, boolean inclusive) {
+ try {
+ if (document != null) {
+ int start = document.getLineOfOffset(startOffset);
+ int end = document.getLineOfOffset(endOffset);
+ startOffset = document.getLineOffset(start);
+ if (!inclusive) {
+ endOffset = document.getLineOffset(end);
+ }
+ }
+ } catch (BadLocationException x) {
+ // concurrent modification?
+ }
+ return new RemoteInactiveHighlightPosition(startOffset, endOffset - startOffset, RemoteInactiveHighlighting.INACTIVE_CODE_KEY);
+ }
+
+}
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/IIndexServiceProvider2.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/IIndexServiceProvider2.java
index 028c396..78d23a0 100755
--- a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/IIndexServiceProvider2.java
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/IIndexServiceProvider2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 IBM Corporation and others.
+ * Copyright (c) 2008, 2013 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
@@ -13,39 +13,40 @@ package org.eclipse.ptp.rdt.ui.serviceproviders;
import org.eclipse.ptp.internal.rdt.ui.contentassist.IContentAssistService;
import org.eclipse.ptp.internal.rdt.ui.editor.IRemoteCCodeFoldingService;
import org.eclipse.ptp.internal.rdt.ui.editor.IRemoteCodeFormattingService;
+import org.eclipse.ptp.internal.rdt.ui.editor.IRemoteInactiveHighlightingService;
import org.eclipse.ptp.internal.rdt.ui.editor.IRemoteSemanticHighlightingService;
import org.eclipse.ptp.internal.rdt.ui.navigation.INavigationService;
import org.eclipse.ptp.internal.rdt.ui.search.ISearchService;
import org.eclipse.ptp.rdt.core.serviceproviders.IIndexServiceProvider;
/**
- * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
- * part of a work in progress. There is no guarantee that this API will work or
- * that it will remain the same. Please do not use this API without consulting
- * with the RDT team.
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as part
+ * of a work in progress. There is no guarantee that this API will work or that
+ * it will remain the same. Please do not use this API without consulting with
+ * the RDT team.
+ *
*
- *
*/
public interface IIndexServiceProvider2 extends IIndexServiceProvider {
public ISearchService getSearchService();
public IContentAssistService getContentAssistService();
-
+
/**
* @since 4.1
*/
public INavigationService getNavigationService();
-
+
/**
* @since 4.1
*/
public IRemoteSemanticHighlightingService getRemoteSemanticHighlightingService();
-
+
/**
* @since 4.1
*/
public IRemoteCCodeFoldingService getRemoteCodeFoldingService();
-
+
/**
* @since 4.2
*/
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/IIndexServiceProvider3.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/IIndexServiceProvider3.java
new file mode 100644
index 0000000..7b07c4e
--- /dev/null
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/IIndexServiceProvider3.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ptp.rdt.ui.serviceproviders;
+
+import org.eclipse.ptp.internal.rdt.ui.editor.IRemoteInactiveHighlightingService;
+
+/**
+ * @since 4.3
+ */
+public interface IIndexServiceProvider3 extends IIndexServiceProvider2 {
+
+ /**
+ * @since 4.2
+ */
+ public IRemoteInactiveHighlightingService getRemoteInactiveHighlightingService();
+}
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/LocalCIndexServiceProvider.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/LocalCIndexServiceProvider.java
index cd13859..d68a26b 100644
--- a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/LocalCIndexServiceProvider.java
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/LocalCIndexServiceProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 IBM Corporation and others.
+ * Copyright (c) 2011, 2013 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,9 +16,11 @@ import org.eclipse.ptp.internal.rdt.ui.contentassist.IContentAssistService;
import org.eclipse.ptp.internal.rdt.ui.contentassist.LocalContentAssistService;
import org.eclipse.ptp.internal.rdt.ui.editor.IRemoteCCodeFoldingService;
import org.eclipse.ptp.internal.rdt.ui.editor.IRemoteCodeFormattingService;
+import org.eclipse.ptp.internal.rdt.ui.editor.IRemoteInactiveHighlightingService;
import org.eclipse.ptp.internal.rdt.ui.editor.IRemoteSemanticHighlightingService;
import org.eclipse.ptp.internal.rdt.ui.editor.RemoteCCodeFoldingService;
import org.eclipse.ptp.internal.rdt.ui.editor.RemoteCodeFormattingService;
+import org.eclipse.ptp.internal.rdt.ui.editor.RemoteInactiveHighlightingService;
import org.eclipse.ptp.internal.rdt.ui.editor.RemoteSemanticHighlightingService;
import org.eclipse.ptp.internal.rdt.ui.navigation.INavigationService;
import org.eclipse.ptp.internal.rdt.ui.navigation.LocalNavigationService;
@@ -30,13 +32,14 @@ import org.eclipse.ptp.internal.rdt.ui.search.LocalSearchService;
* @since 4.1
*
*/
-public class LocalCIndexServiceProvider extends AbstractLocalCIndexServiceProvider implements IIndexServiceProvider2 {
+public class LocalCIndexServiceProvider extends AbstractLocalCIndexServiceProvider implements IIndexServiceProvider3 {
public static final String ID = "org.eclipse.ptp.rdt.ui.LocalCIndexServiceProvider"; //$NON-NLS-1$
private ISearchService fSearchService;
private IContentAssistService fContentAssistService;
private INavigationService fNavigationService;
private IRemoteSemanticHighlightingService fRemoteSemanticHighlightingService;
+ private IRemoteInactiveHighlightingService fRemoteInactiveHighlightingService;
private IRemoteCCodeFoldingService fRemoteCCodeFoldingService;
private IRemoteCodeFormattingService fRemoteCodeFormattingService;
@@ -72,6 +75,19 @@ public class LocalCIndexServiceProvider extends AbstractLocalCIndexServiceProvid
return fRemoteSemanticHighlightingService;
}
+ /**
+ * @since 4.3
+ */
+ public IRemoteInactiveHighlightingService getRemoteInactiveHighlightingService() {
+ if(!isConfigured())
+ return null;
+
+ if(fRemoteInactiveHighlightingService== null)
+ fRemoteInactiveHighlightingService = new RemoteInactiveHighlightingService(fConnectorService);
+
+ return fRemoteInactiveHighlightingService;
+ }
+
public IRemoteCCodeFoldingService getRemoteCodeFoldingService() {
if(!isConfigured())
return null;
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/NullCIndexServiceProvider.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/NullCIndexServiceProvider.java
index 717279d..325d01f 100644
--- a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/NullCIndexServiceProvider.java
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/NullCIndexServiceProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 IBM Corporation and others.
+ * Copyright (c) 2008, 2013 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
@@ -28,7 +28,9 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.Position;
import org.eclipse.ptp.internal.rdt.core.callhierarchy.CalledByResult;
import org.eclipse.ptp.internal.rdt.core.callhierarchy.CallsToResult;
import org.eclipse.ptp.internal.rdt.core.callhierarchy.ICallHierarchyService;
@@ -46,6 +48,7 @@ import org.eclipse.ptp.internal.rdt.core.typehierarchy.THGraph;
import org.eclipse.ptp.internal.rdt.ui.contentassist.IContentAssistService;
import org.eclipse.ptp.internal.rdt.ui.editor.IRemoteCCodeFoldingService;
import org.eclipse.ptp.internal.rdt.ui.editor.IRemoteCodeFormattingService;
+import org.eclipse.ptp.internal.rdt.ui.editor.IRemoteInactiveHighlightingService;
import org.eclipse.ptp.internal.rdt.ui.editor.IRemoteSemanticHighlightingService;
import org.eclipse.ptp.internal.rdt.ui.navigation.INavigationService;
import org.eclipse.ptp.internal.rdt.ui.search.ISearchService;
@@ -70,7 +73,7 @@ import org.eclipse.ui.texteditor.ITextEditor;
*
*/
public class NullCIndexServiceProvider extends
- AbstractRemoteCIndexServiceProvider implements IIndexServiceProvider2 {
+ AbstractRemoteCIndexServiceProvider implements IIndexServiceProvider3 {
/**
@@ -334,6 +337,17 @@ public class NullCIndexServiceProvider extends
}
/**
+ * @since 4.3
+ */
+ public IRemoteInactiveHighlightingService getRemoteInactiveHighlightingService() {
+ return new IRemoteInactiveHighlightingService() {
+ public List<Position> computeInactiveHighlightingPositions(IDocument document, IWorkingCopy wc) {
+ return null;
+ }
+ };
+ }
+
+ /**
* @since 4.1
*/
public IRemoteCCodeFoldingService getRemoteCodeFoldingService() {
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/RSECIndexServiceProvider.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/RSECIndexServiceProvider.java
index 27dfeda..44924f4 100755
--- a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/RSECIndexServiceProvider.java
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/RSECIndexServiceProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 IBM Corporation and others.
+ * Copyright (c) 2008, 2013 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
@@ -15,9 +15,11 @@ import org.eclipse.ptp.internal.rdt.ui.contentassist.IContentAssistService;
import org.eclipse.ptp.internal.rdt.ui.contentassist.RemoteContentAssistService;
import org.eclipse.ptp.internal.rdt.ui.editor.IRemoteCCodeFoldingService;
import org.eclipse.ptp.internal.rdt.ui.editor.IRemoteCodeFormattingService;
+import org.eclipse.ptp.internal.rdt.ui.editor.IRemoteInactiveHighlightingService;
import org.eclipse.ptp.internal.rdt.ui.editor.IRemoteSemanticHighlightingService;
import org.eclipse.ptp.internal.rdt.ui.editor.RemoteCCodeFoldingService;
import org.eclipse.ptp.internal.rdt.ui.editor.RemoteCodeFormattingService;
+import org.eclipse.ptp.internal.rdt.ui.editor.RemoteInactiveHighlightingService;
import org.eclipse.ptp.internal.rdt.ui.editor.RemoteSemanticHighlightingService;
import org.eclipse.ptp.internal.rdt.ui.navigation.INavigationService;
import org.eclipse.ptp.internal.rdt.ui.navigation.RemoteNavigationService;
@@ -41,7 +43,7 @@ import org.eclipse.rse.core.subsystems.IConnectorService;
* @since 2.0
*
*/
-public class RSECIndexServiceProvider extends AbstractRemoteCIndexServiceProvider implements IIndexServiceProvider2 {
+public class RSECIndexServiceProvider extends AbstractRemoteCIndexServiceProvider implements IIndexServiceProvider3 {
public static final String ID = "org.eclipse.ptp.rdt.ui.RSECIndexServiceProvider"; //$NON-NLS-1$
@@ -49,6 +51,7 @@ public class RSECIndexServiceProvider extends AbstractRemoteCIndexServiceProvide
private IContentAssistService fContentAssistService;
private INavigationService fNavigationService;
private IRemoteSemanticHighlightingService fRemoteSemanticHighlightingService;
+ private IRemoteInactiveHighlightingService fRemoteInactiveHighlightingService;
private IRemoteCCodeFoldingService fRemoteCCodeFoldingService;
private IRemoteCodeFormattingService fRemoteCodeFormattingService;
@@ -159,6 +162,19 @@ public class RSECIndexServiceProvider extends AbstractRemoteCIndexServiceProvide
}
/**
+ * @since 4.3
+ */
+ public IRemoteInactiveHighlightingService getRemoteInactiveHighlightingService() {
+ if(!isConfigured())
+ return null;
+
+ if(fRemoteInactiveHighlightingService== null)
+ fRemoteInactiveHighlightingService = new RemoteInactiveHighlightingService(fConnectorService);
+
+ return fRemoteInactiveHighlightingService;
+ }
+
+ /**
* @since 4.1
*/
public IRemoteCCodeFoldingService getRemoteCodeFoldingService() {
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/subsystems/RSECIndexSubsystem.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/subsystems/RSECIndexSubsystem.java
index 7ef9d0c..ea31dc9 100755
--- a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/subsystems/RSECIndexSubsystem.java
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/subsystems/RSECIndexSubsystem.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 IBM Corporation and others.
+ * Copyright (c) 2008, 2013 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
@@ -903,7 +903,44 @@ public class RSECIndexSubsystem extends SubSystem implements ICIndexSubsystem {
}
return ""; //$NON-NLS-1$
}
-
+
+
+ /**
+ * @since 4.3
+ */
+ public String computeInactiveHighlightPositions(ITranslationUnit targetUnit) {
+ DataStore dataStore = getDataStore(null);
+ if (dataStore == null) {
+ return ""; //$NON-NLS-1$
+ }
+ DataElement queryCmd = dataStore.localDescriptorQuery(dataStore.getDescriptorRoot(), CDTMiner.C_INACTIVE_HIGHTLIGHTING_COMPUTE_POSITIONS);
+ if (queryCmd == null) {
+ return ""; //$NON-NLS-1$
+ }
+
+ Scope scope = new Scope(targetUnit.getCProject().getProject());
+
+ ArrayList<Object> args = new ArrayList<Object>();
+ args.add(dataStore.createObject(null, CDTMiner.T_SCOPE_SCOPENAME_DESCRIPTOR, scope.getName()));
+ args.add(createSerializableElement(dataStore, targetUnit));
+
+ DataElement status = dataStore.command(queryCmd, args, dataStore.getDescriptorRoot());
+
+ StatusMonitor smonitor = StatusMonitorFactory.getInstance().getStatusMonitorFor(getConnectorService(), dataStore);
+ try {
+ smonitor.waitForUpdate(status, new NullProgressMonitor());
+ } catch (Exception e) {
+ RDTLog.logError(e);
+ }
+
+ DataElement element = status.get(0);
+ if (element == null)
+ return ""; //$NON-NLS-1$
+ String result = element.getName();
+ return result == null ? "" : result; //$NON-NLS-1$
+ }
+
+
/**
* @since 4.1
*/