mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Bug 399985: Semantic highlighting for qt signals/slots
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>
This commit is contained in:
parent
94e85e44b1
commit
862099aa7a
7 changed files with 102 additions and 3 deletions
|
@ -11,3 +11,4 @@ Require-Bundle: org.eclipse.core.runtime,
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
|
Export-Package: org.eclipse.cdt.qt.core
|
||||||
|
|
|
@ -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";
|
||||||
|
}
|
|
@ -1,11 +1,15 @@
|
||||||
Manifest-Version: 1.0
|
Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: CDT Qt Support UI
|
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-Version: 1.0.0.qualifier
|
||||||
Bundle-Activator: org.eclipse.cdt.qt.ui.Activator
|
Bundle-Activator: org.eclipse.cdt.qt.ui.Activator
|
||||||
Bundle-Vendor: Eclipse CDT
|
Bundle-Vendor: Eclipse CDT
|
||||||
|
Bundle-Localization: plugin
|
||||||
Require-Bundle: org.eclipse.ui,
|
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-RequiredExecutionEnvironment: JavaSE-1.6
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
source.. = src/
|
source.. = src/
|
||||||
output.. = bin/
|
output.. = bin/
|
||||||
bin.includes = META-INF/,\
|
bin.includes = META-INF/,\
|
||||||
.
|
.,\
|
||||||
|
plugin.xml,\
|
||||||
|
plugin.properties
|
||||||
|
|
8
qt/org.eclipse.cdt.qt.ui/plugin.properties
Normal file
8
qt/org.eclipse.cdt.qt.ui/plugin.properties
Normal file
|
@ -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
|
26
qt/org.eclipse.cdt.qt.ui/plugin.xml
Normal file
26
qt/org.eclipse.cdt.qt.ui/plugin.xml
Normal file
|
@ -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>
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue