summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Eidsness2013-02-05 09:56:18 (EST)
committer Doug Schaefer2013-02-05 10:37:02 (EST)
commit862099aa7a6f987337fa7888066135bade4c0e9d (patch)
tree19e35878dbe5a26deea37d394ea9f463a16d8b24
parent94e85e44b12d635d9e75078492a4ae8efbac59c4 (diff)
downloadorg.eclipse.cdt-862099aa7a6f987337fa7888066135bade4c0e9d.zip
org.eclipse.cdt-862099aa7a6f987337fa7888066135bade4c0e9d.tar.gz
org.eclipse.cdt-862099aa7a6f987337fa7888066135bade4c0e9d.tar.bz2
Bug 399985: Semantic highlighting for qt signals/slotsrefs/changes/79/10179/2
The signals, slots, Q_SIGNALS, and Q_SLOTS macros are used as 'keywords' when developing Qt applications. This patch adds a semantic highlighter for these keywords in projects with a qtnature. Change-Id: I7a5906aa69e6d7dab4ce20a16b425ae177f9bd25 Reviewed-on: https://git.eclipse.org/r/10179 Reviewed-by: Doug Schaefer <dschaefer@qnx.com> IP-Clean: Doug Schaefer <dschaefer@qnx.com> Tested-by: Doug Schaefer <dschaefer@qnx.com>
-rw-r--r--qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF1
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtKeywords.java20
-rw-r--r--qt/org.eclipse.cdt.qt.ui/META-INF/MANIFEST.MF8
-rw-r--r--qt/org.eclipse.cdt.qt.ui/build.properties4
-rw-r--r--qt/org.eclipse.cdt.qt.ui/plugin.properties8
-rw-r--r--qt/org.eclipse.cdt.qt.ui/plugin.xml26
-rw-r--r--qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/QtHighlighting.java38
7 files changed, 102 insertions, 3 deletions
diff --git a/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF b/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF
index b4ca9e8..b014adc 100644
--- a/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF
+++ b/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF
@@ -11,3 +11,4 @@ Require-Bundle: org.eclipse.core.runtime,
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
+Export-Package: org.eclipse.cdt.qt.core
diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtKeywords.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtKeywords.java
new file mode 100644
index 0000000..36b2112
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtKeywords.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2013 QNX Software Systems 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
+ */
+
+package org.eclipse.cdt.qt.core;
+
+/**
+ * Declares constants related to tokens that are special in Qt applications.
+ */
+public class QtKeywords
+{
+ public static final String Q_SIGNALS = "Q_SIGNALS";
+ public static final String Q_SLOTS = "Q_SLOTS";
+ public static final String SIGNALS = "signals";
+ public static final String SLOTS = "slots";
+}
diff --git a/qt/org.eclipse.cdt.qt.ui/META-INF/MANIFEST.MF b/qt/org.eclipse.cdt.qt.ui/META-INF/MANIFEST.MF
index 50e1977..0e024d2 100644
--- a/qt/org.eclipse.cdt.qt.ui/META-INF/MANIFEST.MF
+++ b/qt/org.eclipse.cdt.qt.ui/META-INF/MANIFEST.MF
@@ -1,11 +1,15 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: CDT Qt Support UI
-Bundle-SymbolicName: org.eclipse.cdt.qt.ui
+Bundle-SymbolicName: org.eclipse.cdt.qt.ui;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: org.eclipse.cdt.qt.ui.Activator
Bundle-Vendor: Eclipse CDT
+Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime
+ org.eclipse.core.runtime,
+ org.eclipse.cdt.ui,
+ org.eclipse.cdt.core,
+ org.eclipse.cdt.qt.core
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
diff --git a/qt/org.eclipse.cdt.qt.ui/build.properties b/qt/org.eclipse.cdt.qt.ui/build.properties
index 34d2e4d..0dc34f7 100644
--- a/qt/org.eclipse.cdt.qt.ui/build.properties
+++ b/qt/org.eclipse.cdt.qt.ui/build.properties
@@ -1,4 +1,6 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
- .
+ .,\
+ plugin.xml,\
+ plugin.properties
diff --git a/qt/org.eclipse.cdt.qt.ui/plugin.properties b/qt/org.eclipse.cdt.qt.ui/plugin.properties
new file mode 100644
index 0000000..5f970b9
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.ui/plugin.properties
@@ -0,0 +1,8 @@
+# Copyright (c) 2013 QNX Software Systems 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
+
+qtHighlighting.extName=Qt Semantic Highlighting
+qtHighlighting.displayName=Qt Keywords \ No newline at end of file
diff --git a/qt/org.eclipse.cdt.qt.ui/plugin.xml b/qt/org.eclipse.cdt.qt.ui/plugin.xml
new file mode 100644
index 0000000..7d86d31
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.ui/plugin.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.cdt.ui.semanticHighlighting"
+ name="%qtHighlighting.extName"
+ id="org.eclipse.cdt.qt.ui.semanticHighlightings">
+ <semanticHighlighting
+ id="org.eclipse.cdt.qt.ui.keywordHighlighting"
+ priority="5"
+ class="org.eclipse.cdt.internal.qt.ui.QtHighlighting"
+ preferenceKey="qt-keywords"
+ displayName="%qtHighlighting.displayName"
+ defaultTextColor="127,0,85"
+ defaultBold="true"
+ defaultEnabled="true">
+ <enablement>
+ <with variable="projectNatures">
+ <iterate operator="or">
+ <equals value="org.eclipse.cdt.qt.core.qtNature"/>
+ </iterate>
+ </with>
+ </enablement>
+ </semanticHighlighting>
+ </extension>
+</plugin>
diff --git a/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/QtHighlighting.java b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/QtHighlighting.java
new file mode 100644
index 0000000..3e53db1
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/QtHighlighting.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2013 QNX Software Systems 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
+ */
+
+package org.eclipse.cdt.internal.qt.ui;
+
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IMacroBinding;
+import org.eclipse.cdt.qt.core.QtKeywords;
+import org.eclipse.cdt.ui.text.ISemanticHighlighter;
+import org.eclipse.cdt.ui.text.ISemanticToken;
+
+public class QtHighlighting implements ISemanticHighlighter
+{
+ @Override
+ public boolean consumes( ISemanticToken token )
+ {
+ IBinding binding = token.getBinding();
+ if( binding instanceof IMacroBinding )
+ {
+ IASTNode node = token.getNode();
+ if( node instanceof IASTName && ( (IASTName)node ).isReference() )
+ {
+ String n = binding.getName();
+ return QtKeywords.SIGNALS.equals( n ) || QtKeywords.SLOTS.equals( n )
+ || QtKeywords.Q_SIGNALS.equals( n ) || QtKeywords.Q_SLOTS.equals( n );
+ }
+ }
+
+ return false;
+ }
+}