diff options
author | Yvan Lussaud | 2017-03-07 13:50:48 +0000 |
---|---|---|
committer | Laurent Goubet | 2017-03-13 13:20:38 +0000 |
commit | 8484fbca37f6238d8368bed08a6d1699d194f87e (patch) | |
tree | faf06175883e4806a7b19f8e6ce666e739431b73 | |
parent | 42b6a8ca5c7d2088aa889520fb167a8849596789 (diff) | |
download | org.eclipse.acceleo-8484fbca37f6238d8368bed08a6d1699d194f87e.tar.gz org.eclipse.acceleo-8484fbca37f6238d8368bed08a6d1699d194f87e.tar.xz org.eclipse.acceleo-8484fbca37f6238d8368bed08a6d1699d194f87e.zip |
Added AQL viewer configuration
bug: 508445
Change-Id: I4f447b426ac9d9c238e59df98d893cf2c939a4a0
43 files changed, 1996 insertions, 9 deletions
diff --git a/query/plugins/org.eclipse.acceleo.query.ide.ui/.settings/org.eclipse.jdt.ui.prefs b/query/plugins/org.eclipse.acceleo.query.ide.ui/.settings/org.eclipse.jdt.ui.prefs index 3682a8350..66b7f69ee 100644 --- a/query/plugins/org.eclipse.acceleo.query.ide.ui/.settings/org.eclipse.jdt.ui.prefs +++ b/query/plugins/org.eclipse.acceleo.query.ide.ui/.settings/org.eclipse.jdt.ui.prefs @@ -7,7 +7,7 @@ org.eclipse.jdt.ui.importorder=com;fr;java;javax;org; org.eclipse.jdt.ui.javadoc=false org.eclipse.jdt.ui.ondemandthreshold=99 org.eclipse.jdt.ui.staticondemandthreshold=99 -org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment"/><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author ${user}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/**{@inheritDoc}\n *\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="false" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">/*******************************************************************************\n * Copyright (c) 2015 Obeo.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http\://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors\:\n * Obeo - initial API and implementation\n *******************************************************************************/\n${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates> +org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment"/><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author ${user}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/**{@inheritDoc}\n *\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="false" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">/*******************************************************************************\n * Copyright (c) 2017 Obeo.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http\://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors\:\n * Obeo - initial API and implementation\n *******************************************************************************/\n${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates> sp_cleanup.add_default_serial_version_id=true sp_cleanup.add_generated_serial_version_id=false sp_cleanup.add_missing_annotations=true diff --git a/query/plugins/org.eclipse.acceleo.query.ide.ui/META-INF/MANIFEST.MF b/query/plugins/org.eclipse.acceleo.query.ide.ui/META-INF/MANIFEST.MF index 275869947..47c1aa82f 100644 --- a/query/plugins/org.eclipse.acceleo.query.ide.ui/META-INF/MANIFEST.MF +++ b/query/plugins/org.eclipse.acceleo.query.ide.ui/META-INF/MANIFEST.MF @@ -1,13 +1,16 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-SymbolicName: org.eclipse.acceleo.query.ide.ui +Bundle-SymbolicName: org.eclipse.acceleo.query.ide.ui;singleton:=true Bundle-Version: 6.0.0.qualifier Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-Name: %pluginName Bundle-Vendor: %providerName Require-Bundle: org.eclipse.jface;bundle-version="[3.0.0,4.0.0)", + org.eclipse.jface.text;bundle-version="[3.0.0,4.0.0)", org.eclipse.acceleo.query;bundle-version="3.6.0", org.eclipse.emf.edit;bundle-version="[2.8.0,3.0.0)", - org.eclipse.emf.edit.ui;bundle-version="[2.8.0,3.0.0)" -Export-Package: org.eclipse.acceleo.query.ide.ui;x-friends:="org.eclipse.acceleo.query.ide.ui.test" + org.eclipse.emf.edit.ui;bundle-version="[2.8.0,3.0.0)", + org.antlr.runtime;bundle-version="[4.3.0,4.4.0)" +Export-Package: org.eclipse.acceleo.query.ide.ui, + org.eclipse.acceleo.query.ide.ui.viewer Bundle-Localization: plugin diff --git a/query/plugins/org.eclipse.acceleo.query.ide.ui/build.properties b/query/plugins/org.eclipse.acceleo.query.ide.ui/build.properties index 79bdb5288..7f72a53e5 100644 --- a/query/plugins/org.eclipse.acceleo.query.ide.ui/build.properties +++ b/query/plugins/org.eclipse.acceleo.query.ide.ui/build.properties @@ -14,6 +14,5 @@ bin.includes = META-INF/,\ plugin.properties,\ icons/,\ about.html -additional.bundles = org.eclipse.swt src.includes = about.html,\ icons/ diff --git a/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/AQLCompletionProcessor.java b/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/AQLCompletionProcessor.java new file mode 100644 index 000000000..d8944db7c --- /dev/null +++ b/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/AQLCompletionProcessor.java @@ -0,0 +1,136 @@ +/******************************************************************************* + * Copyright (c) 2017 Obeo. + * 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: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.acceleo.query.ide.ui.viewer; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.eclipse.acceleo.query.runtime.ICompletionResult; +import org.eclipse.acceleo.query.runtime.IQueryCompletionEngine; +import org.eclipse.acceleo.query.runtime.IReadOnlyQueryEnvironment; +import org.eclipse.acceleo.query.runtime.impl.BasicFilter; +import org.eclipse.acceleo.query.runtime.impl.QueryCompletionEngine; +import org.eclipse.acceleo.query.validation.type.IType; +import org.eclipse.jface.text.ITextViewer; +import org.eclipse.jface.text.contentassist.ICompletionProposal; +import org.eclipse.jface.text.contentassist.IContentAssistProcessor; +import org.eclipse.jface.text.contentassist.IContextInformation; +import org.eclipse.jface.text.contentassist.IContextInformationValidator; +import org.eclipse.jface.viewers.ILabelProvider; + +/** + * AQL {@link IContentAssistProcessor}. + * + * @author <a href="mailto:yvan.lussaud@obeo.fr">Yvan Lussaud</a> + */ +public class AQLCompletionProcessor implements IContentAssistProcessor { + + /** + * The {@link ILabelProvider}. + */ + private ILabelProvider labelProvider; + + /** + * The {@link IQueryCompletionEngine}. + */ + private final IQueryCompletionEngine engine; + + /** + * The set of defined variables types. + */ + private final Map<String, Set<IType>> variableTypes; + + /** + * Constructor. + * + * @param labelProvider + * the {@link ILabelProvider} + * @param queryEnvironment + * the {@link IReadOnlyQueryEnvironment} + * @param variableTypes + * the set of defined variables types + */ + public AQLCompletionProcessor(ILabelProvider labelProvider, IReadOnlyQueryEnvironment queryEnvironment, + Map<String, Set<IType>> variableTypes) { + this.labelProvider = labelProvider; + engine = new QueryCompletionEngine(queryEnvironment); + this.variableTypes = variableTypes; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, + * int) + */ + public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { + final ICompletionResult completionResult = engine.getCompletion(viewer.getDocument().get(), offset, + variableTypes); + List<org.eclipse.acceleo.query.runtime.ICompletionProposal> proposals = completionResult + .getProposals(new BasicFilter(completionResult)); + + final ICompletionProposal[] result = new ICompletionProposal[proposals.size()]; + int i = 0; + for (org.eclipse.acceleo.query.runtime.ICompletionProposal proposal : proposals) { + result[i++] = new AQLCompletionProposal(labelProvider, completionResult, proposal); + } + + return result; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer, + * int) + */ + public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) { + return null; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters() + */ + public char[] getCompletionProposalAutoActivationCharacters() { + return new char[] {'.', '>', ' ', }; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters() + */ + public char[] getContextInformationAutoActivationCharacters() { + return new char[] {'.', '>', ' ', }; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage() + */ + public String getErrorMessage() { + return null; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationValidator() + */ + public IContextInformationValidator getContextInformationValidator() { + return null; + } + +} diff --git a/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/AQLCompletionProposal.java b/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/AQLCompletionProposal.java new file mode 100644 index 000000000..e92e4aaae --- /dev/null +++ b/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/AQLCompletionProposal.java @@ -0,0 +1,120 @@ +/******************************************************************************* + * Copyright (c) 2017 Obeo. + * 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: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.acceleo.query.ide.ui.viewer; + +import org.eclipse.acceleo.query.runtime.ICompletionProposal; +import org.eclipse.acceleo.query.runtime.ICompletionResult; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.contentassist.IContextInformation; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; + +/** + * AQL {@link org.eclipse.jface.text.contentassist.ICompletionProposal}. + * + * @author <a href="mailto:yvan.lussaud@obeo.fr">Yvan Lussaud</a> + */ +public class AQLCompletionProposal implements org.eclipse.jface.text.contentassist.ICompletionProposal { + + /** + * The {@link ILabelProvider}. + */ + private final ILabelProvider labelProvider; + + /** + * The {@link ICompletionResult}. + */ + private final ICompletionResult completionResult; + + /** + * The {@link ICompletionProposal}. + */ + private final ICompletionProposal proposal; + + /** + * Constructor. + * + * @param labelProvider + * the {@link ILabelProvider} + * @param completionResult + * the {@link ICompletionResult} + * @param proposal + * the {@link ICompletionProposal} + */ + public AQLCompletionProposal(ILabelProvider labelProvider, ICompletionResult completionResult, + ICompletionProposal proposal) { + this.labelProvider = labelProvider; + this.completionResult = completionResult; + this.proposal = proposal; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument) + */ + public void apply(IDocument document) { + try { + document.replace(completionResult.getReplacementOffset(), + completionResult.getReplacementLength(), proposal.getProposal()); + } catch (BadLocationException e) { + // nothing to do here + } + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument) + */ + public Point getSelection(IDocument document) { + return new Point(completionResult.getReplacementOffset() + proposal.getCursorOffset(), 0); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo() + */ + public String getAdditionalProposalInfo() { + return proposal.getDescription(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString() + */ + public String getDisplayString() { + return labelProvider.getText(proposal); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage() + */ + public Image getImage() { + return labelProvider.getImage(proposal); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation() + */ + public IContextInformation getContextInformation() { + return null; + } + +} diff --git a/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/AQLConfiguration.java b/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/AQLConfiguration.java new file mode 100644 index 000000000..763a8f212 --- /dev/null +++ b/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/AQLConfiguration.java @@ -0,0 +1,115 @@ +/******************************************************************************* + * Copyright (c) 2017 Obeo. + * 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: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.acceleo.query.ide.ui.viewer; + +import java.util.Map; +import java.util.Set; + +import org.eclipse.acceleo.query.runtime.IReadOnlyQueryEnvironment; +import org.eclipse.acceleo.query.validation.type.IType; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.ITextDoubleClickStrategy; +import org.eclipse.jface.text.contentassist.ContentAssistant; +import org.eclipse.jface.text.contentassist.IContentAssistant; +import org.eclipse.jface.text.presentation.IPresentationReconciler; +import org.eclipse.jface.text.presentation.PresentationReconciler; +import org.eclipse.jface.text.rules.DefaultDamagerRepairer; +import org.eclipse.jface.text.source.ISourceViewer; +import org.eclipse.jface.text.source.SourceViewerConfiguration; +import org.eclipse.jface.viewers.ILabelProvider; + +/** + * AQL {@link SourceViewerConfiguration}. + * + * @author <a href="mailto:yvan.lussaud@obeo.fr">Yvan Lussaud</a> + */ +public class AQLConfiguration extends SourceViewerConfiguration { + + /** + * The {@link AQLDoubleClickStrategy}. + */ + private final AQLDoubleClickStrategy doubleClickStrategy; + + /** + * The {@link AQLScanner}. + */ + private final AQLScanner scanner; + + /** + * The {@link IContentAssistant}. + */ + private final ContentAssistant assistant; + + /** + * Constructor. + * + * @param colorManager + * the {@link ColorManager} + * @param labelProvider + * the {@link ILabelProvider} + * @param queryEnvironment + * the {@link IReadOnlyQueryEnvironment} + * @param variableTypes + * the variables possible types + */ + public AQLConfiguration(ColorManager colorManager, ILabelProvider labelProvider, + IReadOnlyQueryEnvironment queryEnvironment, Map<String, Set<IType>> variableTypes) { + + doubleClickStrategy = new AQLDoubleClickStrategy(); + + scanner = new AQLScanner(colorManager); + + assistant = new ContentAssistant(); + assistant.setContentAssistProcessor(new AQLCompletionProcessor(labelProvider, queryEnvironment, + variableTypes), IDocument.DEFAULT_CONTENT_TYPE); + + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredContentTypes(org.eclipse.jface.text.source.ISourceViewer) + */ + public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) { + return new String[] {IDocument.DEFAULT_CONTENT_TYPE, }; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getDoubleClickStrategy(org.eclipse.jface.text.source.ISourceViewer, + * java.lang.String) + */ + public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) { + return doubleClickStrategy; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(org.eclipse.jface.text.source.ISourceViewer) + */ + public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) { + PresentationReconciler reconciler = new PresentationReconciler(); + + final DefaultDamagerRepairer dr = new DefaultDamagerRepairer(scanner); + reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE); + reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE); + + return reconciler; + } + + @Override + public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { + return assistant; + } + +} diff --git a/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/AQLDoubleClickStrategy.java b/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/AQLDoubleClickStrategy.java new file mode 100644 index 000000000..1441b6485 --- /dev/null +++ b/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/AQLDoubleClickStrategy.java @@ -0,0 +1,104 @@ +/******************************************************************************* + * Copyright (c) 2017 Obeo. + * 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: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.acceleo.query.ide.ui.viewer; + +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.ITextDoubleClickStrategy; +import org.eclipse.jface.text.ITextViewer; + +/** + * AQL {@link ITextDoubleClickStrategy}. + * + * @author <a href="mailto:yvan.lussaud@obeo.fr">Yvan Lussaud</a> + */ +public class AQLDoubleClickStrategy implements ITextDoubleClickStrategy { + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.text.ITextDoubleClickStrategy#doubleClicked(org.eclipse.jface.text.ITextViewer) + */ + public void doubleClicked(ITextViewer part) { + final int pos = part.getSelectedRange().x; + if (pos >= 0) { + selectWord(part, pos); + } + } + + /** + * Selects a word in the given {@link ITextViewer} at the given caret position. + * + * @param text + * the {@link ITextViewer} + * @param caretPos + * the caret position + * @return <code>true</code> if the selection has been made, <code>false</code> otherwise + */ + protected boolean selectWord(ITextViewer text, int caretPos) { + boolean res; + + IDocument doc = text.getDocument(); + int startPos; + int endPos; + + try { + int pos = caretPos; + char c; + + while (pos >= 0) { + c = doc.getChar(pos); + if (!Character.isJavaIdentifierPart(c)) { + break; + } + pos--; + } + + startPos = pos; + + pos = caretPos; + int length = doc.getLength(); + + while (pos < length) { + c = doc.getChar(pos); + if (!Character.isJavaIdentifierPart(c)) { + break; + } + pos++; + } + + endPos = pos; + selectRange(text, startPos, endPos); + res = true; + + } catch (BadLocationException x) { + res = false; + } + + return res; + } + + /** + * Selects the given range. + * + * @param text + * the {@link ITextViewer} + * @param start + * the start position + * @param stop + * the end position + */ + private void selectRange(ITextViewer text, int start, int stop) { + int offset = start + 1; + int length = stop - offset; + text.setSelectedRange(offset, length); + } +} diff --git a/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/AQLScanner.java b/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/AQLScanner.java new file mode 100644 index 000000000..11046d115 --- /dev/null +++ b/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/AQLScanner.java @@ -0,0 +1,217 @@ +/******************************************************************************* + * Copyright (c) 2017 Obeo. + * 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: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.acceleo.query.ide.ui.viewer; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.TextAttribute; +import org.eclipse.jface.text.rules.IToken; +import org.eclipse.jface.text.rules.ITokenScanner; +import org.eclipse.jface.text.rules.Token; + +/** + * The AQL {@link ITokenScanner}. + * + * @author <a href="mailto:yvan.lussaud@obeo.fr">Yvan Lussaud</a> + */ +public class AQLScanner implements ITokenScanner { + + /** + * Keyword regular expression. + */ + private static final String KEYWORD_REGEX = "if|then|else|endif|let|in|true|false|null"; + + /** + * String literal regular expression. + */ + private static final String STRING_LITERAL_REGEX = "'([^'\\\\]|\\\\.)*'"; + + /** + * Keyword regular expression. + */ + private static final String ECLASSIFIER_TYPE_REGEX = "[a-zA-Z_][a-zA-Z_0-9]*::[a-zA-Z_][a-zA-Z_0-9]*"; + + /** + * Keyword regular expression. + */ + private static final String ECLASSIFIER_SET_TYPE_REGEX = "\\{\\s*" + ECLASSIFIER_TYPE_REGEX + + "(\\s*\\|\\s*" + ECLASSIFIER_TYPE_REGEX + ")*\\s*\\}"; + + /** + * Scanner {@link Pattern}. + */ + private static final Pattern SCANNER = Pattern.compile("(\\s+)|(" + KEYWORD_REGEX + ")|(" + + STRING_LITERAL_REGEX + ")|(String|Integer|Real|Boolean|Sequence(?=\\()|OrderedSet(?=\\()|" + + ECLASSIFIER_SET_TYPE_REGEX + "|" + ECLASSIFIER_TYPE_REGEX + ")"); + + /** + * White spaces group index. + */ + private static final int WS_GROUP = 1; + + /** + * Keyword group index. + */ + private static final int KEYWORD_GROUP = 2; + + /** + * Keyword group index. + */ + private static final int STRING_GROUP = 3; + + /** + * Keyword group index. + */ + private static final int TYPE_LITERAL_GROUP = 5; + + /** + * Keyword. + */ + private final IToken keywordToken; + + /** + * {@link org.eclipse.acceleo.query.ast.StringLiteral StringLiteral}. + */ + private final IToken stringToken; + + /** + * {@link org.eclipse.acceleo.query.ast.TypeLiteral TypeLiteral}. + */ + private final IToken typeLiteralToken; + + /** + * The current {@link Matcher}. + */ + private Matcher matcher; + + /** + * The offset in the document. + */ + private int documentOffset; + + /** + * The expression length. + */ + private int expressionLength; + + /** + * The current token start position. + */ + private int currentOffset; + + /** + * The current token length. + */ + private int currentLength; + + /** + * Tells if the matcher is ready or if we should call find(). + */ + private boolean matcherReady; + + /** + * Constructor. + * + * @param colorManager + * the {@link ColorManager} + */ + public AQLScanner(ColorManager colorManager) { + keywordToken = new Token(new TextAttribute(colorManager.getColor(IAQLColorConstants.KEYWORD))); + stringToken = new Token(new TextAttribute(colorManager.getColor(IAQLColorConstants.STRING))); + typeLiteralToken = new Token( + new TextAttribute(colorManager.getColor(IAQLColorConstants.TYPE_LITERAL))); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.text.rules.ITokenScanner#setRange(org.eclipse.jface.text.IDocument, int, int) + */ + public void setRange(IDocument document, int offset, int length) { + try { + matcher = SCANNER.matcher(document.get(offset, length)); + expressionLength = length; + documentOffset = offset; + currentOffset = 0; + currentLength = 0; + } catch (BadLocationException e) { + // nothing to do here + } + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.text.rules.ITokenScanner#nextToken() + */ + public IToken nextToken() { + final IToken res; + + if (matcherReady || matcher.find()) { + if (matcher.start() == currentOffset + currentLength) { + matcherReady = false; + currentOffset = matcher.start(); + currentLength = matcher.end() - matcher.start(); + if (matcher.group(WS_GROUP) != null) { + res = Token.WHITESPACE; + } else if (matcher.group(KEYWORD_GROUP) != null) { + res = keywordToken; + } else if (matcher.group(STRING_GROUP) != null) { + res = stringToken; + } else if (matcher.group(TYPE_LITERAL_GROUP) != null) { + res = typeLiteralToken; + } else { + throw new IllegalStateException("should not happen."); + } + + } else { + matcherReady = true; + res = Token.UNDEFINED; + currentOffset = currentOffset + currentLength; + currentLength = matcher.start() - currentOffset; + } + } else if (currentOffset + currentLength < expressionLength) { + matcherReady = false; + res = Token.UNDEFINED; + currentOffset = currentOffset + currentLength; + currentLength = expressionLength - currentOffset; + } else { + matcherReady = false; + res = Token.EOF; + currentOffset = expressionLength; + currentLength = 0; + } + + return res; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.text.rules.ITokenScanner#getTokenOffset() + */ + public int getTokenOffset() { + return documentOffset + currentOffset; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.text.rules.ITokenScanner#getTokenLength() + */ + public int getTokenLength() { + return currentLength; + } + +} diff --git a/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/AQLWhitespaceDetector.java b/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/AQLWhitespaceDetector.java new file mode 100644 index 000000000..950fd2432 --- /dev/null +++ b/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/AQLWhitespaceDetector.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2017 Obeo. + * 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: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.acceleo.query.ide.ui.viewer; + +import org.eclipse.jface.text.rules.IWhitespaceDetector; + +/** + * AQL {@link IWhitespaceDetector}. + * + * @author <a href="mailto:yvan.lussaud@obeo.fr">Yvan Lussaud</a> + */ +public class AQLWhitespaceDetector implements IWhitespaceDetector { + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.text.rules.IWhitespaceDetector#isWhitespace(char) + */ + public boolean isWhitespace(char c) { + return c == ' ' || c == '\t' || c == '\n' || c == '\r'; + } +} diff --git a/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/ColorManager.java b/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/ColorManager.java new file mode 100644 index 000000000..3cbc1df2d --- /dev/null +++ b/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/ColorManager.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2017 Obeo. + * 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: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.acceleo.query.ide.ui.viewer; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Display; + +/** + * {@link Color} manager. + * + * @author <a href="mailto:yvan.lussaud@obeo.fr">Yvan Lussaud</a> + */ +public class ColorManager { + + /** + * The {@link RGB} to {@link Color} mapping. + */ + protected Map<RGB, Color> colors = new HashMap<RGB, Color>(10); + + /** + * Disposes all {@link Color}. + */ + public void dispose() { + for (Color color : colors.values()) { + color.dispose(); + } + } + + /** + * Gets the {@link Color} corresponding to the given {@link RGB}. + * + * @param rgb + * the {@link RGB} + * @return the {@link Color} corresponding to the given {@link RGB} + */ + public Color getColor(RGB rgb) { + Color res = colors.get(rgb); + + if (res == null) { + res = new Color(Display.getCurrent(), rgb); + colors.put(rgb, res); + } + + return res; + } +} diff --git a/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/IAQLColorConstants.java b/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/IAQLColorConstants.java new file mode 100644 index 000000000..861f2eed2 --- /dev/null +++ b/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/IAQLColorConstants.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2017 Obeo. + * 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: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.acceleo.query.ide.ui.viewer; + +import org.eclipse.swt.graphics.RGB; + +/** + * AQL color constants. + * + * @author <a href="mailto:yvan.lussaud@obeo.fr">Yvan Lussaud</a> + */ +public interface IAQLColorConstants { + + /** + * Keyword color. + */ + RGB KEYWORD = new RGB(0, 128, 0); + + /** + * {@link org.eclipse.acceleo.query.ast.StringLiteral StringLiteral} color. + */ + RGB STRING = new RGB(128, 128, 128); + + /** + * {@link org.eclipse.acceleo.query.ast.TypeLiteral TypeLiteral}. + */ + RGB TYPE_LITERAL = new RGB(0, 0, 128); +} diff --git a/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/NonRuleBasedDamagerRepairer.java b/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/NonRuleBasedDamagerRepairer.java new file mode 100644 index 000000000..29185d8ee --- /dev/null +++ b/query/plugins/org.eclipse.acceleo.query.ide.ui/src/org/eclipse/acceleo/query/ide/ui/viewer/NonRuleBasedDamagerRepairer.java @@ -0,0 +1,153 @@ +/******************************************************************************* + * Copyright (c) 2017 Obeo. + * 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: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.acceleo.query.ide.ui.viewer; + +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.DocumentEvent; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.IRegion; +import org.eclipse.jface.text.ITypedRegion; +import org.eclipse.jface.text.Region; +import org.eclipse.jface.text.TextAttribute; +import org.eclipse.jface.text.TextPresentation; +import org.eclipse.jface.text.presentation.IPresentationDamager; +import org.eclipse.jface.text.presentation.IPresentationRepairer; +import org.eclipse.swt.custom.StyleRange; + +/** + * Non rule based {@link IPresentationDamager} and {@link IPresentationRepairer}. + * + * @author <a href="mailto:yvan.lussaud@obeo.fr">Yvan Lussaud</a> + */ +public class NonRuleBasedDamagerRepairer implements IPresentationDamager, IPresentationRepairer { + + /** + * The document this object works on. + */ + protected IDocument document; + + /** + * The default text attribute if non is returned as data by the current token. + */ + protected TextAttribute defaultTextAttribute; + + /** + * Constructor. + * + * @param defaultTextAttribute + * default {@link TextAttribute}. + */ + public NonRuleBasedDamagerRepairer(TextAttribute defaultTextAttribute) { + assert defaultTextAttribute != null; + + this.defaultTextAttribute = defaultTextAttribute; + } + + public void setDocument(IDocument doc) { + this.document = doc; + } + + /** + * Returns the end offset of the line that contains the specified offset or if the offset is inside a line + * delimiter, the end offset of the next line. + * + * @param offset + * the offset whose line end offset must be computed + * @return the line end offset for the given offset + * @exception BadLocationException + * if offset is invalid in the current document + */ + protected int endOfLineOf(int offset) throws BadLocationException { + int res; + + IRegion info = document.getLineInformationOfOffset(offset); + if (offset <= info.getOffset() + info.getLength()) { + res = info.getOffset() + info.getLength(); + } else { + int line = document.getLineOfOffset(offset); + try { + info = document.getLineInformation(line + 1); + res = info.getOffset() + info.getLength(); + } catch (BadLocationException x) { + res = document.getLength(); + } + } + + return res; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.text.presentation.IPresentationDamager#getDamageRegion(org.eclipse.jface.text.ITypedRegion, + * org.eclipse.jface.text.DocumentEvent, boolean) + */ + public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent event, + boolean documentPartitioningChanged) { + if (!documentPartitioningChanged) { + try { + + final IRegion info = document.getLineInformationOfOffset(event.getOffset()); + final int start = Math.max(partition.getOffset(), info.getOffset()); + + int end; + if (event.getText() == null) { + end = event.getOffset() + event.getLength(); + } else { + end = event.getOffset() + event.getText().length(); + } + + if (info.getOffset() <= end && end <= info.getOffset() + info.getLength()) { + // optimize the case of the same line + end = info.getOffset() + info.getLength(); + } else { + end = endOfLineOf(end); + } + end = Math.min(partition.getOffset() + partition.getLength(), end); + return new Region(start, end - start); + + } catch (BadLocationException x) { + // nothing to do here + } + } + + return partition; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.text.presentation.IPresentationRepairer#createPresentation(org.eclipse.jface.text.TextPresentation, + * org.eclipse.jface.text.ITypedRegion) + */ + public void createPresentation(TextPresentation presentation, ITypedRegion region) { + addRange(presentation, region.getOffset(), region.getLength(), defaultTextAttribute); + } + + /** + * Adds style information to the given text presentation. + * + * @param presentation + * the text presentation to be extended + * @param offset + * the offset of the range to be styled + * @param length + * the length of the range to be styled + * @param attr + * the attribute describing the style of the range to be styled + */ + protected void addRange(TextPresentation presentation, int offset, int length, TextAttribute attr) { + if (attr != null) { + presentation.addStyleRange(new StyleRange(offset, length, attr.getForeground(), attr + .getBackground(), attr.getStyle())); + } + } +} diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/.project b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/.project new file mode 100644 index 000000000..cbc1f2583 --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/.project @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.acceleo.query.ide.ui.tests.rcptt</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.rcptt.core.builder.q7Builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.rcptt.core.rcpttnature</nature> + </natures> +</projectDescription> diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/AQL Test View.ctx b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/AQL Test View.ctx new file mode 100644 index 000000000..ade5fe1c8 --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/AQL Test View.ctx @@ -0,0 +1,22 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Context-Type: org.eclipse.rcptt.ctx.workbench +Element-Name: AQL Test View +Element-Type: context +Element-Version: 2.0 +Id: _4XuUAP_9EeaWNdFOlwG9mQ +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/3/17 11:41 AM + +------=_.q7.content-3d2e0690-ce48-3609-83e0-c704d49f1eaf +Content-Type: q7/binary +Entry-Name: .q7.content + +UEsDBBQACAgIAAAAIQAAAAAAAAAAAAAAAAAIAAkALmNvbnRlbnRVVAUAAQAAAACVkMtOwzAQRff5Cst7 +xhSxoJGdqkKAkHhVAtpdldpDahHbwXbq8Pc4oFRsWLCdOefe0fDFYFpyQB+0s4LO4JQStNIpbRtB+/h2 +ckEXVcGdbwBlq7uA4GUXIwSJtvbalWvn33fZ2V86G3GIZDC6PCaejYm5w4YyzwXdx9iVjKWUwJkGci7b +3N9OyN81R3Naj+Y3woxT2LIJzL7zSImtDQq6XN2RZwyRvGpMlGgl6PZ8078sn7bzK6zXD+r6sU03c7Oi +VUEIP2QsVL/PqKXEFh189Og/QSuEXkPMkQFGmLMfpeDsHz+qii9QSwcIpV1UB+cAAAB5AQAAUEsBAhQA +FAAICAgAAAAhAKVdVAfnAAAAeQEAAAgACQAAAAAAAAAAAAAAAAAAAC5jb250ZW50VVQFAAEAAAAAUEsF +BgAAAAABAAEAPwAAACYBAAAAAA== +------=_.q7.content-3d2e0690-ce48-3609-83e0-c704d49f1eaf-- diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration BooleanType.test b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration BooleanType.test new file mode 100644 index 000000000..37349a867 --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration BooleanType.test @@ -0,0 +1,31 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Contexts: _4XuUAP_9EeaWNdFOlwG9mQ +Element-Name: Coloration BooleanType +Element-Type: testcase +Element-Version: 3.0 +External-Reference: +Id: _50oT4AAeEeeWNdFOlwG9mQ +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/3/17 4:35 PM +Testcase-Type: ecl + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac +Content-Type: text/ecl +Entry-Name: .content + +with [get-view "AQL Test View" | get-text-viewer] { + key-type "M1+a" + key-type BackSpace + type-text "Boolean" +} +get-eclipse-window | key-type ESC + +with [get-view "AQL Test View" | get-text-viewer] { + get-property "styles[0].start" | equals 0 | verify-true + get-property "styles[0].length" | equals 7 | verify-true + get-property "styles[0].text" | equals "Boolean" | verify-true + get-property "styles[0].fontStyle" | equals normal | verify-true + get-property "styles[0].foregroundColor" | equals "#000080" | verify-true +} +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac-- diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Collection Service Call.test b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Collection Service Call.test new file mode 100644 index 000000000..b9150038f --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Collection Service Call.test @@ -0,0 +1,29 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Contexts: _4XuUAP_9EeaWNdFOlwG9mQ +Element-Name: Coloration Collection Service Call +Element-Type: testcase +Element-Version: 3.0 +External-Reference: +Id: _txdogAAUEeeWNdFOlwG9mQ +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/3/17 4:35 PM +Testcase-Type: ecl + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac +Content-Type: text/ecl +Entry-Name: .content + +with [get-view "AQL Test View" | get-text-viewer] { + key-type "M1+a" + key-type BackSpace + type-text "self->size()" +} +with [get-view "AQL Test View" | get-text-viewer] { + get-property "styles[0].start" | equals 0 | verify-true + get-property "styles[0].length" | equals 12 | verify-true + get-property "styles[0].text" | equals "self->size()" | verify-true + get-property "styles[0].fontStyle" | equals normal | verify-true + get-property "styles[0].foregroundColor" | is-empty | verify-true +} +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac-- diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration EClassifierSetType.test b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration EClassifierSetType.test new file mode 100644 index 000000000..439e77334 --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration EClassifierSetType.test @@ -0,0 +1,30 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Contexts: _4XuUAP_9EeaWNdFOlwG9mQ +Element-Name: Coloration EClassifierSetType +Element-Type: testcase +Element-Version: 3.0 +External-Reference: +Id: _V4J-IAAhEeeWNdFOlwG9mQ +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/3/17 5:03 PM +Testcase-Type: ecl + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac +Content-Type: text/ecl +Entry-Name: .content + +with [get-view "AQL Test View" | get-text-viewer] { + key-type "M1+a" + key-type BackSpace + type-text "{ecore::EPackage|ecore::EClass}" +} + +with [get-view "AQL Test View" | get-text-viewer] { + get-property "styles[0].start" | equals 0 | verify-true + get-property "styles[0].length" | equals 31 | verify-true + get-property "styles[0].text" | equals "{ecore::EPackage|ecore::EClass}" | verify-true + get-property "styles[0].fontStyle" | equals normal | verify-true + get-property "styles[0].foregroundColor" | equals "#000080" | verify-true +} +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac-- diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration EClassifierType.test b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration EClassifierType.test new file mode 100644 index 000000000..5871799ae --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration EClassifierType.test @@ -0,0 +1,30 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Contexts: _4XuUAP_9EeaWNdFOlwG9mQ +Element-Name: Coloration EClassifierType +Element-Type: testcase +Element-Version: 3.0 +External-Reference: +Id: _K9XEgAAhEeeWNdFOlwG9mQ +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/3/17 3:54 PM +Testcase-Type: ecl + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac +Content-Type: text/ecl +Entry-Name: .content + +with [get-view "AQL Test View" | get-text-viewer] { + key-type "M1+a" + key-type BackSpace + type-text "ecore::EPackage" +} + +with [get-view "AQL Test View" | get-text-viewer] { + get-property "styles[0].start" | equals 0 | verify-true + get-property "styles[0].length" | equals 15 | verify-true + get-property "styles[0].text" | equals "ecore::EPackage" | verify-true + get-property "styles[0].fontStyle" | equals normal | verify-true + get-property "styles[0].foregroundColor" | equals "#000080" | verify-true +} +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac-- diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Empty StringLiteral.test b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Empty StringLiteral.test new file mode 100644 index 000000000..f7b66e072 --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Empty StringLiteral.test @@ -0,0 +1,31 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Contexts: _4XuUAP_9EeaWNdFOlwG9mQ +Element-Name: Coloration Empty StringLiteral +Element-Type: testcase +Element-Version: 3.0 +External-Reference: +Id: _RLrFEAAaEeeWNdFOlwG9mQ +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/3/17 4:35 PM +Testcase-Type: ecl + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac +Content-Type: text/ecl +Entry-Name: .content + +with [get-view "AQL Test View" | get-text-viewer] { + key-type "M1+a" + key-type BackSpace + type-text "''" +} +with [get-view "AQL Test View" | get-text-viewer] { + get-property "styles[0].start" | equals 0 | verify-true + get-property "styles[0].length" | equals 2 | verify-true + get-property "styles[0].text" | equals "''" | verify-true + get-property "styles[0].fontStyle" | equals normal | verify-true + get-property "styles[0].foregroundColor" | equals "#808080" | verify-true +} + + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac-- diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Escaped StringLiteral.test b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Escaped StringLiteral.test new file mode 100644 index 000000000..144e6e6dd --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Escaped StringLiteral.test @@ -0,0 +1,30 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Contexts: _4XuUAP_9EeaWNdFOlwG9mQ +Element-Name: Coloration Escaped StringLiteral +Element-Type: testcase +Element-Version: 3.0 +External-Reference: +Id: _wxqwgAAcEeeWNdFOlwG9mQ +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/3/17 4:35 PM +Testcase-Type: ecl + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac +Content-Type: text/ecl +Entry-Name: .content + +with [get-view "AQL Test View" | get-text-viewer] { + key-type "M1+a" + key-type BackSpace + type-text "'a string \\n\\''" +} +with [get-view "AQL Test View" | get-text-viewer] { + get-property "styles[0].start" | equals 0 | verify-true + get-property "styles[0].length" | equals 15 | verify-true + get-property "styles[0].text" | equals "'a string \\n\\''" | verify-true + get-property "styles[0].fontStyle" | equals normal | verify-true + get-property "styles[0].foregroundColor" | equals "#808080" | verify-true +} + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac-- diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Explicit Sequence.test b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Explicit Sequence.test new file mode 100644 index 000000000..21956c69c --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Explicit Sequence.test @@ -0,0 +1,29 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Contexts: _4XuUAP_9EeaWNdFOlwG9mQ +Element-Name: Coloration Explicit Sequence +Element-Type: testcase +Element-Version: 3.0 +External-Reference: +Id: _QIPuoAAZEeeWNdFOlwG9mQ +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/3/17 4:35 PM +Testcase-Type: ecl + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac +Content-Type: text/ecl +Entry-Name: .content + +with [get-view "AQL Test View" | get-text-viewer] { + key-type "M1+a" + key-type BackSpace + type-text "Sequence{self, self, self}" +} +with [get-view "AQL Test View" | get-text-viewer] { + get-property "styles[0].start" | equals 0 | verify-true + get-property "styles[0].length" | equals 26 | verify-true + get-property "styles[0].text" | equals "Sequence{self, self, self}" | verify-true + get-property "styles[0].fontStyle" | equals normal | verify-true + get-property "styles[0].foregroundColor" | is-empty | verify-true +} +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac-- diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Explicit Set.test b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Explicit Set.test new file mode 100644 index 000000000..b403610b1 --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Explicit Set.test @@ -0,0 +1,29 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Contexts: _4XuUAP_9EeaWNdFOlwG9mQ +Element-Name: Coloration Explicit Set +Element-Type: testcase +Element-Version: 3.0 +External-Reference: +Id: _GEswoAAaEeeWNdFOlwG9mQ +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/3/17 4:35 PM +Testcase-Type: ecl + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac +Content-Type: text/ecl +Entry-Name: .content + +with [get-view "AQL Test View" | get-text-viewer] { + key-type "M1+a" + key-type BackSpace + type-text "OrderedSet{self, self, self}" +} +with [get-view "AQL Test View" | get-text-viewer] { + get-property "styles[0].start" | equals 0 | verify-true + get-property "styles[0].length" | equals 28 | verify-true + get-property "styles[0].text" | equals "OrderedSet{self, self, self}" | verify-true + get-property "styles[0].fontStyle" | equals normal | verify-true + get-property "styles[0].foregroundColor" | is-empty | verify-true +} +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac-- diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration False.test b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration False.test new file mode 100644 index 000000000..cac92c28a --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration False.test @@ -0,0 +1,29 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Contexts: _4XuUAP_9EeaWNdFOlwG9mQ +Element-Name: Coloration False +Element-Type: testcase +Element-Version: 3.0 +External-Reference: +Id: _73ytMAAYEeeWNdFOlwG9mQ +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/3/17 4:35 PM +Testcase-Type: ecl + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac +Content-Type: text/ecl +Entry-Name: .content + +with [get-view "AQL Test View" | get-text-viewer] { + key-type "M1+a" + key-type BackSpace + type-text "false" +} +with [get-view "AQL Test View" | get-text-viewer] { + get-property "styles[0].start" | equals 0 | verify-true + get-property "styles[0].length" | equals 5 | verify-true + get-property "styles[0].text" | equals "false" | verify-true + get-property "styles[0].fontStyle" | equals normal | verify-true + get-property "styles[0].foregroundColor" | equals "#008000" | verify-true +} +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac-- diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Feature.test b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Feature.test new file mode 100644 index 000000000..ccad7ebfa --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Feature.test @@ -0,0 +1,29 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Contexts: _4XuUAP_9EeaWNdFOlwG9mQ +Element-Name: Coloration Feature +Element-Type: testcase +Element-Version: 3.0 +External-Reference: +Id: _MpDpwP__EeaWNdFOlwG9mQ +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/3/17 4:36 PM +Testcase-Type: ecl + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac +Content-Type: text/ecl +Entry-Name: .content + +with [get-view "AQL Test View" | get-text-viewer] { + key-type "M1+a" + key-type BackSpace + type-text "self.name" +} +with [get-view "AQL Test View" | get-text-viewer] { + get-property "styles[0].start" | equals 0 | verify-true + get-property "styles[0].length" | equals 9 | verify-true + get-property "styles[0].text" | equals "self.name" | verify-true + get-property "styles[0].fontStyle" | equals normal | verify-true + get-property "styles[0].foregroundColor" | is-empty | verify-true +} +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac-- diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration If.test b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration If.test new file mode 100644 index 000000000..87030ac6a --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration If.test @@ -0,0 +1,65 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Contexts: _4XuUAP_9EeaWNdFOlwG9mQ +Element-Name: Coloration If +Element-Type: testcase +Element-Version: 3.0 +External-Reference: +Id: _LNycQAAYEeeWNdFOlwG9mQ +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/3/17 4:36 PM +Testcase-Type: ecl + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac +Content-Type: text/ecl +Entry-Name: .content + +with [get-view "AQL Test View" | get-text-viewer] { + key-type "M1+a" + key-type BackSpace + type-text "if self.name <> self.name then self else self endif" +} +with [get-view "AQL Test View" | get-text-viewer] { + get-property "styles[0].start" | equals 0 | verify-true + get-property "styles[0].length" | equals 2 | verify-true + get-property "styles[0].text" | equals "if" | verify-true + get-property "styles[0].fontStyle" | equals normal | verify-true + get-property "styles[0].foregroundColor" | equals "#008000" | verify-true + + get-property "styles[1].start" | equals 2 | verify-true + get-property "styles[1].length" | equals 24 | verify-true + get-property "styles[1].text" | equals "self.name <> self.name" | verify-true + get-property "styles[1].fontStyle" | equals normal | verify-true + get-property "styles[1].foregroundColor" | is-empty | verify-true + + get-property "styles[2].start" | equals 26 | verify-true + get-property "styles[2].length" | equals 4 | verify-true + get-property "styles[2].text" | equals "then" | verify-true + get-property "styles[2].fontStyle" | equals normal | verify-true + get-property "styles[2].foregroundColor" | equals "#008000" | verify-true + + get-property "styles[3].start" | equals 30 | verify-true + get-property "styles[3].length" | equals 6 | verify-true + get-property "styles[3].text" | equals "self" | verify-true + get-property "styles[3].fontStyle" | equals normal | verify-true + get-property "styles[3].foregroundColor" | is-empty | verify-true + + get-property "styles[4].start" | equals 36 | verify-true + get-property "styles[4].length" | equals 4 | verify-true + get-property "styles[4].text" | equals "else" | verify-true + get-property "styles[4].fontStyle" | equals normal | verify-true + get-property "styles[4].foregroundColor" | equals "#008000" | verify-true + + get-property "styles[5].start" | equals 40 | verify-true + get-property "styles[5].length" | equals 6 | verify-true + get-property "styles[5].text" | equals "self" | verify-true + get-property "styles[5].fontStyle" | equals normal | verify-true + get-property "styles[5].foregroundColor" | is-empty | verify-true + + get-property "styles[6].start" | equals 46 | verify-true + get-property "styles[6].length" | equals 5 | verify-true + get-property "styles[6].text" | equals "endif" | verify-true + get-property "styles[6].fontStyle" | equals normal | verify-true + get-property "styles[6].foregroundColor" | equals "#008000" | verify-true +} +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac-- diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration IntegerType.test b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration IntegerType.test new file mode 100644 index 000000000..57cbdf464 --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration IntegerType.test @@ -0,0 +1,31 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Contexts: _4XuUAP_9EeaWNdFOlwG9mQ +Element-Name: Coloration IntegerType +Element-Type: testcase +Element-Version: 3.0 +External-Reference: +Id: _jcOugAAeEeeWNdFOlwG9mQ +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/3/17 4:36 PM +Testcase-Type: ecl + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac +Content-Type: text/ecl +Entry-Name: .content + +with [get-view "AQL Test View" | get-text-viewer] { + key-type "M1+a" + key-type BackSpace + type-text "Integer" +} +get-eclipse-window | key-type ESC + +with [get-view "AQL Test View" | get-text-viewer] { + get-property "styles[0].start" | equals 0 | verify-true + get-property "styles[0].length" | equals 7 | verify-true + get-property "styles[0].text" | equals "Integer" | verify-true + get-property "styles[0].fontStyle" | equals normal | verify-true + get-property "styles[0].foregroundColor" | equals "#000080" | verify-true +} +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac-- diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Let.test b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Let.test new file mode 100644 index 000000000..19078b6df --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Let.test @@ -0,0 +1,48 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Contexts: _4XuUAP_9EeaWNdFOlwG9mQ +Element-Name: Coloration Let +Element-Type: testcase +Element-Version: 3.0 +External-Reference: +Id: _3v78cAAXEeeWNdFOlwG9mQ +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/3/17 4:36 PM +Testcase-Type: ecl + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac +Content-Type: text/ecl +Entry-Name: .content + +with [get-view "AQL Test View" | get-text-viewer] { + key-type "M1+a" + key-type BackSpace + type-text "let name = self.name in name" +} + +with [get-view "AQL Test View" | get-editbox] { + get-property "styles[0].start" | equals 0 | verify-true + get-property "styles[0].length" | equals 3 | verify-true + get-property "styles[0].text" | equals let | verify-true + get-property "styles[0].fontStyle" | equals normal | verify-true + get-property "styles[0].foregroundColor" | equals "#008000" | verify-true + + get-property "styles[1].start" | equals 3 | verify-true + get-property "styles[1].length" | equals 18 | verify-true + get-property "styles[1].text" | equals "name = self.name" | verify-true + get-property "styles[1].fontStyle" | equals normal | verify-true + get-property "styles[1].foregroundColor" | is-empty | verify-true + + get-property "styles[2].start" | equals 21 | verify-true + get-property "styles[2].length" | equals 2 | verify-true + get-property "styles[2].text" | equals in | verify-true + get-property "styles[2].fontStyle" | equals normal | verify-true + get-property "styles[2].foregroundColor" | equals "#008000" | verify-true + + get-property "styles[3].start" | equals 23 | verify-true + get-property "styles[3].length" | equals 5 | verify-true + get-property "styles[3].text" | equals name | verify-true + get-property "styles[3].fontStyle" | equals normal | verify-true + get-property "styles[3].foregroundColor" | is-empty | verify-true +} +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac-- diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Null.test b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Null.test new file mode 100644 index 000000000..442bbc854 --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Null.test @@ -0,0 +1,31 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Contexts: _4XuUAP_9EeaWNdFOlwG9mQ +Element-Name: Coloration Null +Element-Type: testcase +Element-Version: 3.0 +External-Reference: +Id: _IFVoIAAZEeeWNdFOlwG9mQ +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/3/17 4:36 PM +Testcase-Type: ecl + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac +Content-Type: text/ecl +Entry-Name: .content + +with [get-view "AQL Test View" | get-text-viewer] { + key-type "M1+a" + key-type BackSpace + type-text "null" +} +get-eclipse-window | key-type ESC + +with [get-view "AQL Test View" | get-text-viewer] { + get-property "styles[0].start" | equals 0 | verify-true + get-property "styles[0].length" | equals 4 | verify-true + get-property "styles[0].text" | equals "null" | verify-true + get-property "styles[0].fontStyle" | equals normal | verify-true + get-property "styles[0].foregroundColor" | equals "#008000" | verify-true +} +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac-- diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration OrderedSetType.test b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration OrderedSetType.test new file mode 100644 index 000000000..be005537a --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration OrderedSetType.test @@ -0,0 +1,48 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Contexts: _4XuUAP_9EeaWNdFOlwG9mQ +Element-Name: Coloration OrderedSetType +Element-Type: testcase +Element-Version: 3.0 +External-Reference: +Id: _kAiqkAAgEeeWNdFOlwG9mQ +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/3/17 3:50 PM +Testcase-Type: ecl + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac +Content-Type: text/ecl +Entry-Name: .content + +with [get-view "AQL Test View" | get-text-viewer] { + key-type "M1+a" + key-type BackSpace + type-text "OrderedSet(Boolean)" +} + +with [get-view "AQL Test View" | get-text-viewer] { + get-property "styles[0].start" | equals 0 | verify-true + get-property "styles[0].length" | equals 10 | verify-true + get-property "styles[0].text" | equals OrderedSet | verify-true + get-property "styles[0].fontStyle" | equals normal | verify-true + get-property "styles[0].foregroundColor" | equals "#000080" | verify-true + + get-property "styles[1].start" | equals 10 | verify-true + get-property "styles[1].length" | equals 1 | verify-true + get-property "styles[1].text" | equals "(" | verify-true + get-property "styles[1].fontStyle" | equals normal | verify-true + get-property "styles[1].foregroundColor" | is-empty | verify-true + + get-property "styles[2].start" | equals 11 | verify-true + get-property "styles[2].length" | equals 7 | verify-true + get-property "styles[2].text" | equals Boolean | verify-true + get-property "styles[2].fontStyle" | equals normal | verify-true + get-property "styles[2].foregroundColor" | equals "#000080" | verify-true + + get-property "styles[3].start" | equals 18 | verify-true + get-property "styles[3].length" | equals 1 | verify-true + get-property "styles[3].text" | equals ")" | verify-true + get-property "styles[3].fontStyle" | equals normal | verify-true + get-property "styles[3].foregroundColor" | is-empty | verify-true +} +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac-- diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration RealType.test b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration RealType.test new file mode 100644 index 000000000..72801f064 --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration RealType.test @@ -0,0 +1,31 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Contexts: _4XuUAP_9EeaWNdFOlwG9mQ +Element-Name: Coloration RealType +Element-Type: testcase +Element-Version: 3.0 +External-Reference: +Id: _pX0jMAAeEeeWNdFOlwG9mQ +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/3/17 4:36 PM +Testcase-Type: ecl + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac +Content-Type: text/ecl +Entry-Name: .content + +with [get-view "AQL Test View" | get-text-viewer] { + key-type "M1+a" + key-type BackSpace + type-text "Real" +} +get-eclipse-window | key-type ESC + +with [get-view "AQL Test View" | get-text-viewer] { + get-property "styles[0].start" | equals 0 | verify-true + get-property "styles[0].length" | equals 4 | verify-true + get-property "styles[0].text" | equals "Real" | verify-true + get-property "styles[0].fontStyle" | equals normal | verify-true + get-property "styles[0].foregroundColor" | equals "#000080" | verify-true +} +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac-- diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration SequenceType.test b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration SequenceType.test new file mode 100644 index 000000000..7fa35ffef --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration SequenceType.test @@ -0,0 +1,48 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Contexts: _4XuUAP_9EeaWNdFOlwG9mQ +Element-Name: Coloration SequenceType +Element-Type: testcase +Element-Version: 3.0 +External-Reference: +Id: _yYmKsAAfEeeWNdFOlwG9mQ +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/3/17 3:48 PM +Testcase-Type: ecl + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac +Content-Type: text/ecl +Entry-Name: .content + +with [get-view "AQL Test View" | get-text-viewer] { + key-type "M1+a" + key-type BackSpace + type-text "Sequence(Boolean)" +} + +with [get-view "AQL Test View" | get-text-viewer] { + get-property "styles[0].start" | equals 0 | verify-true + get-property "styles[0].length" | equals 8 | verify-true + get-property "styles[0].text" | equals Sequence | verify-true + get-property "styles[0].fontStyle" | equals normal | verify-true + get-property "styles[0].foregroundColor" | equals "#000080" | verify-true + + get-property "styles[1].start" | equals 8 | verify-true + get-property "styles[1].length" | equals 1 | verify-true + get-property "styles[1].text" | equals "(" | verify-true + get-property "styles[1].fontStyle" | equals normal | verify-true + get-property "styles[1].foregroundColor" | is-empty | verify-true + + get-property "styles[2].start" | equals 9 | verify-true + get-property "styles[2].length" | equals 7 | verify-true + get-property "styles[2].text" | equals Boolean | verify-true + get-property "styles[2].fontStyle" | equals normal | verify-true + get-property "styles[2].foregroundColor" | equals "#000080" | verify-true + + get-property "styles[3].start" | equals 16 | verify-true + get-property "styles[3].length" | equals 1 | verify-true + get-property "styles[3].text" | equals ")" | verify-true + get-property "styles[3].fontStyle" | equals normal | verify-true + get-property "styles[3].foregroundColor" | is-empty | verify-true +} +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac-- diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Service Call.test b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Service Call.test new file mode 100644 index 000000000..d10e9e3f9 --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration Service Call.test @@ -0,0 +1,29 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Contexts: _4XuUAP_9EeaWNdFOlwG9mQ +Element-Name: Coloration Service Call +Element-Type: testcase +Element-Version: 3.0 +External-Reference: +Id: _LCSTsAAUEeeWNdFOlwG9mQ +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/3/17 4:36 PM +Testcase-Type: ecl + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac +Content-Type: text/ecl +Entry-Name: .content + +with [get-view "AQL Test View" | get-text-viewer] { + key-type "M1+a" + key-type BackSpace + type-text "self.eAllContents()" +} +with [get-view "AQL Test View" | get-text-viewer] { + get-property "styles[0].start" | equals 0 | verify-true + get-property "styles[0].length" | equals 19 | verify-true + get-property "styles[0].text" | equals "self.eAllContents()" | verify-true + get-property "styles[0].fontStyle" | equals normal | verify-true + get-property "styles[0].foregroundColor" | is-empty | verify-true +} +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac-- diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration StringLiteral.test b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration StringLiteral.test new file mode 100644 index 000000000..4825abbdd --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration StringLiteral.test @@ -0,0 +1,31 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Contexts: _4XuUAP_9EeaWNdFOlwG9mQ +Element-Name: Coloration StringLiteral +Element-Type: testcase +Element-Version: 3.0 +External-Reference: +Id: _mcjBsAAaEeeWNdFOlwG9mQ +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/3/17 4:36 PM +Testcase-Type: ecl + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac +Content-Type: text/ecl +Entry-Name: .content + +with [get-view "AQL Test View" | get-text-viewer] { + key-type "M1+a" + key-type BackSpace + type-text "'a string'" +} +with [get-view "AQL Test View" | get-text-viewer] { + get-property "styles[0].start" | equals 0 | verify-true + get-property "styles[0].length" | equals 10 | verify-true + get-property "styles[0].text" | equals "'a string'" | verify-true + get-property "styles[0].fontStyle" | equals normal | verify-true + get-property "styles[0].foregroundColor" | equals "#808080" | verify-true +} + + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac-- diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration StringType.test b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration StringType.test new file mode 100644 index 000000000..a8d6f20b5 --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration StringType.test @@ -0,0 +1,31 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Contexts: _4XuUAP_9EeaWNdFOlwG9mQ +Element-Name: Coloration StringType +Element-Type: testcase +Element-Version: 3.0 +External-Reference: +Id: _bXfcAAAeEeeWNdFOlwG9mQ +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/3/17 4:36 PM +Testcase-Type: ecl + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac +Content-Type: text/ecl +Entry-Name: .content + +with [get-view "AQL Test View" | get-text-viewer] { + key-type "M1+a" + key-type BackSpace + type-text "String" +} +get-eclipse-window | key-type ESC + +with [get-view "AQL Test View" | get-text-viewer] { + get-property "styles[0].start" | equals 0 | verify-true + get-property "styles[0].length" | equals 6 | verify-true + get-property "styles[0].text" | equals "String" | verify-true + get-property "styles[0].fontStyle" | equals normal | verify-true + get-property "styles[0].foregroundColor" | equals "#000080" | verify-true +} +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac-- diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration True.test b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration True.test new file mode 100644 index 000000000..7966d5d3a --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration True.test @@ -0,0 +1,31 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Contexts: _4XuUAP_9EeaWNdFOlwG9mQ +Element-Name: Coloration True +Element-Type: testcase +Element-Version: 3.0 +External-Reference: +Id: _v4GBAAAYEeeWNdFOlwG9mQ +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/3/17 4:36 PM +Testcase-Type: ecl + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac +Content-Type: text/ecl +Entry-Name: .content + +with [get-view "AQL Test View" | get-text-viewer] { + key-type "M1+a" + key-type BackSpace + type-text "true" +} +get-eclipse-window | key-type ESC + +with [get-view "AQL Test View" | get-text-viewer] { + get-property "styles[0].start" | equals 0 | verify-true + get-property "styles[0].length" | equals 4 | verify-true + get-property "styles[0].text" | equals "true" | verify-true + get-property "styles[0].fontStyle" | equals normal | verify-true + get-property "styles[0].foregroundColor" | equals "#008000" | verify-true +} +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac-- diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration VarRef.test b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration VarRef.test new file mode 100644 index 000000000..07dd36c91 --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Coloration VarRef.test @@ -0,0 +1,31 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Contexts: _4XuUAP_9EeaWNdFOlwG9mQ +Element-Name: Coloration VarRef +Element-Type: testcase +Element-Version: 3.0 +External-Reference: +Id: _MJm_kP_9EeaWNdFOlwG9mQ +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/3/17 4:36 PM +Testcase-Type: ecl + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac +Content-Type: text/ecl +Entry-Name: .content + +with [get-view "AQL Test View" | get-text-viewer] { + key-type "M1+a" + key-type BackSpace + type-text "self" +} +with [get-view "AQL Test View" | get-text-viewer] { + get-property "styles[0].start" | equals 0 | verify-true + get-property "styles[0].length" | equals 4 | verify-true + get-property "styles[0].text" | equals "self" | verify-true + get-property "styles[0].fontStyle" | equals normal | verify-true + get-property "styles[0].foregroundColor" | is-empty | verify-true +} + + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac-- diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Completion.test b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Completion.test new file mode 100644 index 000000000..4b9eb4c78 --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/AQL Test View/Completion.test @@ -0,0 +1,25 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Contexts: _4XuUAP_9EeaWNdFOlwG9mQ +Element-Name: Coloration BooleanType +Element-Type: testcase +Element-Version: 3.0 +External-Reference: +Id: _Uj6F0AKDEeeRIrxVYjNhvA +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/6/17 5:14 PM +Testcase-Type: ecl + +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac +Content-Type: text/ecl +Entry-Name: .content + +with [get-view "AQL Test View" | get-text-viewer] { + key-type "M1+a" + key-type BackSpace + type-text "tru" + key-type "M1+SPACE" + key-type Enter +} +get-view "AQL Test View" | get-text-viewer | get-property text | equals "true" | verify-true +------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac-- diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/rcptt.properties b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/rcptt.properties new file mode 100644 index 000000000..b4d61e2fb --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests.rcptt/rcptt.properties @@ -0,0 +1,9 @@ +--- RCPTT testcase --- +Format-Version: 1.0 +Element-Name: Project Settings +Element-Type: projectMetadata +Element-Version: 2.0 +Id: _fQiCkP_8EeaWNdFOlwG9mQ +Runtime-Version: 2.1.0.201606221726 +Save-Time: 3/3/17 11:30 AM + diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests/META-INF/MANIFEST.MF b/query/tests/org.eclipse.acceleo.query.ide.ui.tests/META-INF/MANIFEST.MF index 310ff5bd4..530ae658f 100644 --- a/query/tests/org.eclipse.acceleo.query.ide.ui.tests/META-INF/MANIFEST.MF +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests/META-INF/MANIFEST.MF @@ -1,13 +1,17 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName -Bundle-SymbolicName: org.eclipse.acceleo.query.ide.ui.tests +Bundle-SymbolicName: org.eclipse.acceleo.query.ide.ui.tests;singleton:=true Bundle-Version: 6.0.0.qualifier Bundle-Vendor: %providerName Bundle-RequiredExecutionEnvironment: J2SE-1.5 Require-Bundle: org.eclipse.acceleo.query.ide.ui;bundle-version="3.6.0", org.junit;bundle-version="4.0.0", - org.eclipse.jface;bundle-version="3.8.0", + org.eclipse.jface, + org.eclipse.jface.text, org.eclipse.acceleo.query;bundle-version="3.5.0", - org.eclipse.acceleo.query.tests.anydsl;bundle-version="1.0.0" + org.eclipse.acceleo.query.tests.anydsl;bundle-version="1.0.0", + org.eclipse.ui, + org.eclipse.equinox.registry, + org.eclipse.ui.editors Export-Package: org.eclipse.acceleo.query.ide.ui.test;x-internal:=true diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests/build.properties b/query/tests/org.eclipse.acceleo.query.ide.ui.tests/build.properties index d02a736be..684c5d375 100644 --- a/query/tests/org.eclipse.acceleo.query.ide.ui.tests/build.properties +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests/build.properties @@ -12,6 +12,7 @@ source.. = src/ bin.includes = META-INF/,\ .,\ about.html,\ - plugin.properties + plugin.properties,\ + plugin.xml additional.bundles = org.eclipse.swt src.includes = about.html diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests/plugin.xml b/query/tests/org.eclipse.acceleo.query.ide.ui.tests/plugin.xml new file mode 100644 index 000000000..ddf9f4f4a --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests/plugin.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + <extension + point="org.eclipse.ui.views"> + <category + id="org.eclipse.acceleo.query.ide.ui.tests.category" + name="AQL Test View"> + </category> + <view + allowMultiple="false" + category="org.eclipse.acceleo.query.ide.ui.tests.category" + class="org.eclipse.acceleo.query.ide.ui.test.view.AQLTestView" + id="org.eclipse.acceleo.query.ide.ui.tests.view" + name="AQL Test View" + restorable="true"> + </view> + </extension> + +</plugin> diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests/src/org/eclipse/acceleo/query/ide/ui/test/AllTests.java b/query/tests/org.eclipse.acceleo.query.ide.ui.tests/src/org/eclipse/acceleo/query/ide/ui/test/AllTests.java new file mode 100644 index 000000000..ffa7d6f14 --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests/src/org/eclipse/acceleo/query/ide/ui/test/AllTests.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2015 Obeo. + * 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: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.acceleo.query.ide.ui.test; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +/** + * This class aggregates tests for the org.eclipse.acceleo.query.tests plug-in. + * + * @author <a href="mailto:yvan.lussaud@obeo.fr">Yvan Lussaud</a> + */ +@RunWith(Suite.class) +@SuiteClasses(value = {ProposalLabelProviderTests.class }) +public class AllTests { + +} diff --git a/query/tests/org.eclipse.acceleo.query.ide.ui.tests/src/org/eclipse/acceleo/query/ide/ui/test/view/AQLTestView.java b/query/tests/org.eclipse.acceleo.query.ide.ui.tests/src/org/eclipse/acceleo/query/ide/ui/test/view/AQLTestView.java new file mode 100644 index 000000000..f6f5a45bd --- /dev/null +++ b/query/tests/org.eclipse.acceleo.query.ide.ui.tests/src/org/eclipse/acceleo/query/ide/ui/test/view/AQLTestView.java @@ -0,0 +1,140 @@ +/******************************************************************************* + * Copyright (c) 2015 Obeo. + * 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: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.acceleo.query.ide.ui.test.view; + +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.eclipse.acceleo.query.ide.ui.ProposalLabelProvider; +import org.eclipse.acceleo.query.ide.ui.viewer.AQLConfiguration; +import org.eclipse.acceleo.query.ide.ui.viewer.ColorManager; +import org.eclipse.acceleo.query.runtime.IQueryEnvironment; +import org.eclipse.acceleo.query.runtime.Query; +import org.eclipse.acceleo.query.validation.type.EClassifierType; +import org.eclipse.acceleo.query.validation.type.IType; +import org.eclipse.core.commands.IHandler; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.commands.ActionHandler; +import org.eclipse.jface.text.Document; +import org.eclipse.jface.text.contentassist.IContentAssistant; +import org.eclipse.jface.text.source.SourceViewer; +import org.eclipse.jface.text.source.VerticalRuler; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.handlers.IHandlerActivation; +import org.eclipse.ui.handlers.IHandlerService; +import org.eclipse.ui.part.ViewPart; +import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; + +/** + * Test view for {@link AQLConfiguration}. + * + * @author <a href="mailto:yvan.lussaud@obeo.fr">Yvan Lussaud</a> + */ +public class AQLTestView extends ViewPart { + + /** + * The 12 constant. + */ + private static final int TWELVE = 12; + + /** + * The {@link ColorManager}. + */ + private final ColorManager colorManager = new ColorManager(); + + /** + * The {@link ILabelProvider}. + */ + private final ILabelProvider labelProvider = new ProposalLabelProvider(); + + /** + * The {@link SourceViewer}. + */ + private SourceViewer sourceViewer; + + /** + * Content assist {@link IHandlerActivation}. + */ + private IHandlerActivation contentAssistHandlerActivation; + + @Override + public void createPartControl(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + + final GridLayout layout = new GridLayout(1, false); + composite.setLayout(layout); + + sourceViewer = new SourceViewer(composite, new VerticalRuler(TWELVE), SWT.BORDER); + sourceViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); + + final IQueryEnvironment env = Query.newEnvironmentWithDefaultServices(null); + final Map<String, Set<IType>> variableTypes = new LinkedHashMap<String, Set<IType>>(); + final Set<IType> selfTypes = new LinkedHashSet<IType>(); + selfTypes.add(new EClassifierType(env, EcorePackage.eINSTANCE.getEPackage())); + variableTypes.put("self", selfTypes); + final AQLConfiguration configuration = new AQLConfiguration(colorManager, labelProvider, env, + variableTypes); + sourceViewer.configure(configuration); + + sourceViewer.setInput(new Document("")); + + setUpContentAssist(configuration.getContentAssistant(sourceViewer)); + } + + /** + * Sets up the content assist action for the given source viewer. + * + * @param assistant + * The viewer {@link IContentAssistant} + */ + protected final void setUpContentAssist(final IContentAssistant assistant) { + IHandlerService service = (IHandlerService)getSite().getService(IHandlerService.class); + if (contentAssistHandlerActivation != null) { + service.deactivateHandler(contentAssistHandlerActivation); + } + + IAction contentAssistAction = new Action() { + @Override + public void run() { + assistant.showPossibleCompletions(); + } + }; + IHandler contentAssistHandler = new ActionHandler(contentAssistAction); + + contentAssistHandlerActivation = service.activateHandler( + ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, contentAssistHandler); + } + + @Override + public void dispose() { + super.dispose(); + colorManager.dispose(); + labelProvider.dispose(); + IHandlerService service = (IHandlerService)getSite().getService(IHandlerService.class); + service.deactivateHandler(contentAssistHandlerActivation); + } + + @Override + public void setFocus() { + if (sourceViewer != null) { + sourceViewer.getControl().setFocus(); + } + } + +} |