├── .gitignore ├── plugin ├── .gitignore ├── .settings │ ├── org.moreunit.prefs │ ├── org.eclipse.core.runtime.prefs │ └── org.eclipse.core.resources.prefs ├── lib │ └── mockito-all-1.9.5.jar ├── src │ ├── main │ │ ├── resources │ │ │ ├── robo1.png │ │ │ └── robo32x32.png │ │ └── java │ │ │ └── com │ │ │ └── nitorcreations │ │ │ └── robotframework │ │ │ └── eclipseide │ │ │ ├── internal │ │ │ ├── util │ │ │ │ ├── FileType.java │ │ │ │ ├── Prioritizer.java │ │ │ │ ├── VisitorInterest.java │ │ │ │ ├── BaseDefinitionMatchVisitor.java │ │ │ │ ├── DefinitionMatchVisitor.java │ │ │ │ ├── LineMatchVisitor.java │ │ │ │ ├── PriorityDeque.java │ │ │ │ ├── Reporter.java │ │ │ │ └── DefinitionFinder.java │ │ │ ├── hyperlinks │ │ │ │ ├── util │ │ │ │ │ └── KeywordMatchResult.java │ │ │ │ ├── Hyperlink.java │ │ │ │ ├── ResourceHyperlinkDetector.java │ │ │ │ ├── LibraryHyperlinkDetector.java │ │ │ │ └── HyperlinkDetector.java │ │ │ ├── assistant │ │ │ │ ├── proposalgenerator │ │ │ │ │ ├── AttemptVisitor.java │ │ │ │ │ ├── IRelevantProposalsFilter.java │ │ │ │ │ ├── IAttemptGenerator.java │ │ │ │ │ ├── IProposalSuitabilityDeterminer.java │ │ │ │ │ ├── IProposalGeneratorFactory.java │ │ │ │ │ ├── KeywordCallAttemptVisitor.java │ │ │ │ │ ├── RobotCompletionProposalSet.java │ │ │ │ │ ├── ProposalGeneratorFactory.java │ │ │ │ │ ├── SettingTableAttemptVisitor.java │ │ │ │ │ ├── CompletionMatchVisitor.java │ │ │ │ │ ├── VariableAttemptVisitor.java │ │ │ │ │ ├── VisitorInfo.java │ │ │ │ │ ├── VariableCompletionMatchVisitor.java │ │ │ │ │ ├── AttemptGenerator.java │ │ │ │ │ └── RelevantProposalsFilter.java │ │ │ │ ├── IVariableReplacementRegionCalculator.java │ │ │ │ └── IRobotContentAssistant2.java │ │ │ └── rules │ │ │ │ ├── RobotWhitespace.java │ │ │ │ └── VariableUtils.java │ │ │ ├── structure │ │ │ ├── api │ │ │ │ ├── IParsedKeywordString.java │ │ │ │ ├── IDynamicParsedKeywordString.java │ │ │ │ ├── IVariableDefinition.java │ │ │ │ ├── ILibraryFile.java │ │ │ │ ├── IKeywordCall.java │ │ │ │ ├── IKeywordSequence.java │ │ │ │ ├── IDynamicParsedString.java │ │ │ │ ├── AvailableFrom.java │ │ │ │ ├── IUserKeywordDefinition.java │ │ │ │ ├── IKeywordString.java │ │ │ │ ├── IRobotFileContents.java │ │ │ │ ├── NotAllowedInTestSuiteInitializationFiles.java │ │ │ │ ├── NotAllowedInResourceFiles.java │ │ │ │ ├── IParsedString.java │ │ │ │ ├── ITestCaseDefinition.java │ │ │ │ └── ISettings.java │ │ │ ├── ParsedStringOffsetComparator.java │ │ │ ├── VariableDefinition.java │ │ │ ├── KeywordCall.java │ │ │ ├── DynamicParsedString.java │ │ │ ├── LibraryFile.java │ │ │ ├── UserKeywordDefinition.java │ │ │ └── KeywordSequence.java │ │ │ ├── builder │ │ │ ├── parser │ │ │ │ ├── TableType.java │ │ │ │ ├── FileInfo.java │ │ │ │ ├── util │ │ │ │ │ └── ParserUtil.java │ │ │ │ ├── SeverityConfig.java │ │ │ │ ├── state │ │ │ │ │ ├── Ignore.java │ │ │ │ │ ├── TestcaseTableActive.java │ │ │ │ │ ├── KeywordTableActive.java │ │ │ │ │ ├── VariableTable.java │ │ │ │ │ ├── TestcaseTableInitial.java │ │ │ │ │ └── KeywordTableInitial.java │ │ │ │ ├── LineType.java │ │ │ │ ├── CountingLineReader.java │ │ │ │ ├── ParsedLineInfo.java │ │ │ │ └── TxtArgumentSplitter.java │ │ │ ├── util │ │ │ │ ├── DamagedRegion.java │ │ │ │ ├── MarkerManager.java │ │ │ │ └── FileMarkerManager.java │ │ │ ├── BaseResourceVisitor.java │ │ │ ├── ResourceVisitor.java │ │ │ ├── ResourceDeltaVisitor.java │ │ │ ├── RobotNature.java │ │ │ └── ToggleNatureAction.java │ │ │ ├── editors │ │ │ ├── ResourceLocation.java │ │ │ ├── util │ │ │ │ ├── PendingToken.java │ │ │ │ └── TokenQueue.java │ │ │ ├── IResourceManager.java │ │ │ ├── RobotPresentationReconciler.java │ │ │ ├── ColorManager.java │ │ │ └── Resource.java │ │ │ ├── PluginContext.java │ │ │ ├── preferences │ │ │ ├── TableNamingPreferencePage.java │ │ │ ├── PreferenceConstants.java │ │ │ ├── MainPreferencePage.java │ │ │ └── PreferenceInitializer.java │ │ │ └── Activator.java │ └── test │ │ ├── resources │ │ └── RFEParser │ │ │ └── robo.txt │ │ └── java │ │ └── com │ │ └── nitorcreations │ │ └── robotframework │ │ └── eclipseide │ │ ├── internal │ │ └── assistant │ │ │ ├── proposalgenerator │ │ │ ├── TestKeywordCallAttemptVisitor.java │ │ │ └── TestVariableCompletionMatchVisitor.java │ │ │ └── Content.java │ │ └── builder │ │ └── TestRobotParserWithStaticFiles.java ├── robot-indices │ ├── DatabaseLibrary-1.0 │ │ └── org.robot.database.keywords.DatabaseLibrary.index │ ├── Collections-2.6.3 │ │ └── Collections.index │ ├── RobotFramework-2.6.3 │ │ └── BuiltIn.index │ └── SeleniumLibrary-2.8 │ │ └── SeleniumLibrary.index ├── build.properties ├── .classpath ├── .project ├── META-INF │ └── MANIFEST.MF └── about.ini ├── .githooks └── license-maintainer │ ├── .gitignore │ ├── .gitattributes │ ├── LICENSE-hash │ ├── LICENSE-javadoc │ └── install ├── update-site ├── .gitignore ├── .project └── site.xml ├── feature ├── build.properties ├── .project └── feature.xml ├── .gitattributes └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | -------------------------------------------------------------------------------- /plugin/.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | -------------------------------------------------------------------------------- /.githooks/license-maintainer/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | -------------------------------------------------------------------------------- /update-site/.gitignore: -------------------------------------------------------------------------------- 1 | artifacts.jar 2 | content.jar 3 | features/ 4 | plugins/ 5 | -------------------------------------------------------------------------------- /feature/build.properties: -------------------------------------------------------------------------------- 1 | bin.includes = feature.xml,\ 2 | feature.properties 3 | -------------------------------------------------------------------------------- /plugin/.settings/org.moreunit.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.moreunit.preferences.version=2 3 | -------------------------------------------------------------------------------- /plugin/.settings/org.eclipse.core.runtime.prefs: -------------------------------------------------------------------------------- 1 | #Tue Nov 17 09:22:24 EET 2009 2 | eclipse.preferences.version=1 3 | line.separator=\n 4 | -------------------------------------------------------------------------------- /plugin/lib/mockito-all-1.9.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NitorCreations/RobotFramework-EclipseIDE/HEAD/plugin/lib/mockito-all-1.9.5.jar -------------------------------------------------------------------------------- /plugin/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | #Mon Nov 09 08:54:29 EET 2009 2 | eclipse.preferences.version=1 3 | encoding/=UTF-8 4 | -------------------------------------------------------------------------------- /plugin/src/main/resources/robo1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NitorCreations/RobotFramework-EclipseIDE/HEAD/plugin/src/main/resources/robo1.png -------------------------------------------------------------------------------- /plugin/src/main/resources/robo32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NitorCreations/RobotFramework-EclipseIDE/HEAD/plugin/src/main/resources/robo32x32.png -------------------------------------------------------------------------------- /plugin/robot-indices/DatabaseLibrary-1.0/org.robot.database.keywords.DatabaseLibrary.index: -------------------------------------------------------------------------------- 1 | Check If Exists In Database 2 | Check If Not Exists In Database 3 | Connect To Database 4 | Disconnect From Database 5 | Execute Sql Script 6 | Query 7 | -------------------------------------------------------------------------------- /.githooks/license-maintainer/.gitattributes: -------------------------------------------------------------------------------- 1 | * -licensefile 2 | /license.pm licensefile=.githooks/license-maintainer/LICENSE-hash 3 | /pre-commit licensefile=.githooks/license-maintainer/LICENSE-hash 4 | /install licensefile=.githooks/license-maintainer/LICENSE-hash 5 | -------------------------------------------------------------------------------- /plugin/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/main/java/ 2 | output.. = bin/ 3 | bin.includes = plugin.xml,\ 4 | META-INF/,\ 5 | .,\ 6 | src/main/resources/,\ 7 | LICENSE,\ 8 | about.ini 9 | src.excludes = src/test/java/ 10 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # -*-sh-*- 2 | 3 | # When committing text files, convert platform line endings to LF in 4 | # repository (and back) 5 | 6 | * text=auto 7 | *.robot licensefile=.githooks/LICENSE-hash 8 | *.txt licensefile=.githooks/LICENSE-hash 9 | *.java licensefile=.githooks/LICENSE-javadoc 10 | -------------------------------------------------------------------------------- /feature/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | RobotFrameworkEclipseIdeFeature 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.pde.FeatureBuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.pde.FeatureNature 16 | 17 | 18 | -------------------------------------------------------------------------------- /update-site/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | RobotFrameworkEclipseIdeUpdateSite 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.pde.UpdateSiteBuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.pde.UpdateSiteNature 16 | 17 | 18 | -------------------------------------------------------------------------------- /plugin/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.githooks/license-maintainer/LICENSE-hash: -------------------------------------------------------------------------------- 1 | # Copyright YEAR AUTHORS 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | -------------------------------------------------------------------------------- /.githooks/license-maintainer/LICENSE-javadoc: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright YEAR AUTHORS 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | -------------------------------------------------------------------------------- /plugin/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | RobotFrameworkEclipseIdePlugin 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.pde.PluginNature 26 | org.eclipse.jdt.core.javanature 27 | 28 | 29 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/FileType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.util; 17 | 18 | public enum FileType { 19 | RESOURCE, LIBRARY, VARIABLE, BUILTIN_VARIABLE 20 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/Prioritizer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.util; 17 | 18 | public interface Prioritizer { 19 | 20 | int prioritize(T t); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /plugin/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Robot Framework Textfile Editor 4 | Bundle-SymbolicName: com.nitorcreations.robotframework.eclipseide;singleton:=true 5 | Bundle-Version: 1.4.0 6 | Bundle-Activator: com.nitorcreations.robotframework.eclipseide.Activator 7 | Require-Bundle: org.eclipse.ui, 8 | org.eclipse.core.runtime, 9 | org.eclipse.jdt.core, 10 | org.eclipse.jface.text, 11 | org.eclipse.ui.editors, 12 | org.eclipse.core.resources, 13 | org.eclipse.ui.ide, 14 | org.eclipse.ui.views, 15 | org.junit;resolution:=optional 16 | Bundle-ActivationPolicy: lazy 17 | Bundle-RequiredExecutionEnvironment: JavaSE-1.6 18 | Export-Package: com.nitorcreations.robotframework.eclipseide, 19 | com.nitorcreations.robotframework.eclipseide.editors, 20 | com.nitorcreations.robotframework.eclipseide.internal.rules;x-internal:=true 21 | Bundle-Vendor: Nitor Creations Oy 22 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/structure/api/IParsedKeywordString.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.structure.api; 17 | 18 | public interface IParsedKeywordString extends IParsedString, IKeywordString { 19 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/builder/parser/TableType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.builder.parser; 17 | 18 | public enum TableType { 19 | IGNORE, SETTING, VARIABLE, TESTCASE, KEYWORD, UNKNOWN, 20 | } 21 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/hyperlinks/util/KeywordMatchResult.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.hyperlinks.util; 17 | 18 | public enum KeywordMatchResult { 19 | DIFFERENT, WILDCARD, EXACT 20 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/structure/api/IDynamicParsedKeywordString.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.structure.api; 17 | 18 | public interface IDynamicParsedKeywordString extends IDynamicParsedString, IKeywordString { 19 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/VisitorInterest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.util; 17 | 18 | public enum VisitorInterest { 19 | CONTINUE, CONTINUE_TO_END_OF_CURRENT_PRIORITY_LEVEL, CONTINUE_TO_END_OF_CURRENT_FILE, STOP 20 | } 21 | -------------------------------------------------------------------------------- /plugin/about.ini: -------------------------------------------------------------------------------- 1 | 2 | aboutText = RobotFramework-EclipseIDE [1] is an Eclipse IDE plugin for the Robot Framework test automation tool [2].\n\nSee Release Notes [3] for issues implemented in release.\n\nRobot Framework is a generic test automation framework for acceptance testing and acceptance test-driven development (ATDD). Acceptance Test-Driven Development [4] is a process used to construct executable requirements before the implementation starts.\n\nThis plugin helps you to write tests with Robot Framework directly from the comfort of your Eclipse IDE.\n\n(c) Copyright Nitor Creations Oy 2011-2013. All rights reserved.\n\nReferences:\n [1] https://github.com/NitorCreations/RobotFramework-EclipseIDE/wiki\n [2] https://code.google.com/p/robotframework/\n [3] https://github.com/NitorCreations/RobotFramework-EclipseIDE/wiki/ReleaseNotes\n [4] http://testobsessed.com/2008/12/acceptance-test-driven-development-atdd-an-overview/ 3 | 4 | featureImage = src/main/resources/robo32x32.png 5 | -------------------------------------------------------------------------------- /plugin/robot-indices/Collections-2.6.3/Collections.index: -------------------------------------------------------------------------------- 1 | Append To List 2 | Combine Lists 3 | Convert To List 4 | Copy Dictionary 5 | Copy List 6 | Count Values In List 7 | Create Dictionary 8 | Dictionaries Should Be Equal 9 | Dictionary Should Contain Key 10 | Dictionary Should Contain Sub Dictionary 11 | Dictionary Should Contain Value 12 | Dictionary Should Not Contain Key 13 | Dictionary Should Not Contain Value 14 | Get Dictionary Items 15 | Get Dictionary Keys 16 | Get Dictionary Values 17 | Get From Dictionary 18 | Get From List 19 | Get Index From List 20 | Get Slice From List 21 | Insert Into List 22 | Keep In Dictionary 23 | List Should Contain Sub List 24 | List Should Contain Value 25 | List Should Not Contain Duplicates 26 | List Should Not Contain Value 27 | Lists Should Be Equal 28 | Log Dictionary 29 | Log List 30 | Remove From Dictionary 31 | Remove From List 32 | Remove Values From List 33 | Reverse List 34 | Set List Value 35 | Set To Dictionary 36 | Sort List 37 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/builder/parser/FileInfo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.builder.parser; 17 | 18 | public class FileInfo { 19 | RobotFile onDisk; 20 | RobotFile inEditor; 21 | 22 | boolean isEmpty() { 23 | return onDisk == null && inEditor == null; 24 | } 25 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/structure/api/IVariableDefinition.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.structure.api; 17 | 18 | import java.util.List; 19 | 20 | public interface IVariableDefinition { 21 | 22 | IParsedString getVariable(); 23 | 24 | List getValues(); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /update-site/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | RobotFramework-EclipseIDE is an Eclipse IDE plugin for the Robot Framework test automation tool. 5 | 6 | Robot Framework is a generic test automation framework for acceptance testing and acceptance test-driven development (ATDD). Acceptance Test-Driven Development is a process used to construct executable requirements before the implementation starts. 7 | 8 | This plugin helps you to write tests with Robot Framework directly from the comfort of your Eclipse IDE. 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /feature/feature.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | %descriptionText 12 | 13 | 14 | 15 | %copyrightText 16 | 17 | 18 | 19 | %licenseText 20 | 21 | 22 | 23 | 24 | 25 | 26 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/structure/api/ILibraryFile.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.structure.api; 17 | 18 | import java.util.List; 19 | 20 | public interface ILibraryFile { 21 | IDynamicParsedString getRealName(); 22 | 23 | IDynamicParsedString getCustomName(); 24 | 25 | List getArguments(); 26 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/assistant/proposalgenerator/AttemptVisitor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.assistant.proposalgenerator; 17 | 18 | import org.eclipse.jface.text.IRegion; 19 | 20 | 21 | public interface AttemptVisitor { 22 | RobotCompletionProposalSet visitAttempt(String attempt, IRegion replacementRegion); 23 | } 24 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/builder/util/DamagedRegion.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.builder.util; 17 | 18 | import org.eclipse.jface.text.reconciler.DirtyRegion; 19 | 20 | public class DamagedRegion extends DirtyRegion { 21 | 22 | public DamagedRegion(int offset, int length) { 23 | super(offset, length, null, null); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/editors/ResourceLocation.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.editors; 17 | 18 | public class ResourceLocation { 19 | public final Resource resource; 20 | public final int line; 21 | 22 | public ResourceLocation(Resource resource, int line) { 23 | this.resource = resource; 24 | this.line = line; 25 | } 26 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/editors/util/PendingToken.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.editors.util; 17 | 18 | import org.eclipse.jface.text.rules.IToken; 19 | 20 | public class PendingToken { 21 | final IToken token; 22 | final int len; 23 | 24 | public PendingToken(IToken token, int len) { 25 | assert token != null; 26 | this.token = token; 27 | this.len = len; 28 | } 29 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/structure/api/IKeywordCall.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.structure.api; 17 | 18 | import java.util.List; 19 | 20 | public interface IKeywordCall { 21 | /** 22 | * Returns null if a template keyword is active, except if the keyword is 23 | * ":FOR". 24 | */ 25 | IDynamicParsedKeywordString getKeyword(); 26 | 27 | List getArguments(); 28 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/assistant/IVariableReplacementRegionCalculator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.assistant; 17 | 18 | import org.eclipse.jface.text.IRegion; 19 | 20 | import com.nitorcreations.robotframework.eclipseide.structure.ParsedString; 21 | 22 | public interface IVariableReplacementRegionCalculator { 23 | IRegion calculate(ParsedString argument, int cursorOffsetInDocument); 24 | } 25 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/builder/parser/util/ParserUtil.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.builder.parser.util; 17 | 18 | import java.util.regex.Pattern; 19 | 20 | public class ParserUtil { 21 | private static final Pattern PAT_ASTERISKS_AND_BLANKS = Pattern.compile("[* ]+"); 22 | 23 | public static String parseTable(String line) { 24 | return PAT_ASTERISKS_AND_BLANKS.matcher(line).replaceAll("").toLowerCase(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/assistant/proposalgenerator/IRelevantProposalsFilter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.assistant.proposalgenerator; 17 | 18 | import java.util.List; 19 | 20 | import org.eclipse.jface.text.contentassist.ICompletionProposal; 21 | 22 | public interface IRelevantProposalsFilter { 23 | 24 | ICompletionProposal[] extractMostRelevantProposals(List proposalSets); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/builder/util/MarkerManager.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.builder.util; 17 | 18 | import org.eclipse.core.resources.IMarker; 19 | import org.eclipse.core.resources.IResource; 20 | import org.eclipse.core.runtime.CoreException; 21 | 22 | public interface MarkerManager { 23 | /** 24 | * @see IResource#createMarker(String) 25 | */ 26 | IMarker createMarker(String type) throws CoreException; 27 | 28 | void eraseMarkers(); 29 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/structure/ParsedStringOffsetComparator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.structure; 17 | 18 | import java.util.Comparator; 19 | 20 | import com.nitorcreations.robotframework.eclipseide.structure.api.IParsedString; 21 | 22 | public class ParsedStringOffsetComparator implements Comparator { 23 | @Override 24 | public int compare(IParsedString o1, IParsedString o2) { 25 | return o1.getArgCharPos() - o2.getArgCharPos(); 26 | } 27 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/assistant/proposalgenerator/IAttemptGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.assistant.proposalgenerator; 17 | 18 | import java.util.Collection; 19 | 20 | import com.nitorcreations.robotframework.eclipseide.structure.ParsedString; 21 | 22 | public interface IAttemptGenerator { 23 | 24 | void acceptAttempts(ParsedString argument, int documentOffset, Collection proposalSets, AttemptVisitor attemptVisitor); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /.githooks/license-maintainer/install: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright 2015 Nitor Creations Oy 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -e 18 | 19 | if [ "$#" -gt 0 ]; then 20 | echo "usage: $0" 21 | echo 22 | echo "Installs the git hooks in this directory into .git/hooks/" 23 | echo "Any existing destination file is backed up first if necessary." 24 | exit 1 25 | fi 26 | 27 | cd "$(dirname "$0")/../.." 28 | 29 | for i in pre-commit ; do 30 | oldlink="$(readlink .git/hooks/${i} ||:)" 31 | newlink="../../.githooks/license-maintainer/${i}" 32 | if [ "$newlink" != "$oldlink" ]; then 33 | ln -snv --backup=numbered "${newlink}" .git/hooks/ 34 | fi 35 | done 36 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/assistant/proposalgenerator/IProposalSuitabilityDeterminer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.assistant.proposalgenerator; 17 | 18 | import java.util.List; 19 | 20 | import org.eclipse.core.resources.IFile; 21 | 22 | import com.nitorcreations.robotframework.eclipseide.structure.ParsedString; 23 | 24 | public interface IProposalSuitabilityDeterminer { 25 | 26 | List generateAttemptVisitors(IFile file, ParsedString argument, int documentOffset, int lineCharPos); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/structure/api/IKeywordSequence.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.structure.api; 17 | 18 | import java.util.List; 19 | 20 | public interface IKeywordSequence { 21 | 22 | IParsedString getSequenceName(); 23 | 24 | List getDocumentation(); 25 | 26 | /** 27 | * Since 2.5.6, the special keyword "NONE" can be used. 28 | */ 29 | IDynamicParsedString getTimeout(); 30 | 31 | IParsedString getTimeoutMessage(); 32 | 33 | List getKeywordCalls(); 34 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/structure/api/IDynamicParsedString.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.structure.api; 17 | 18 | import java.util.List; 19 | 20 | public interface IDynamicParsedString extends IParsedString { 21 | 22 | /** 23 | * Returns the static and dynamic parts, one by one. 24 | * 25 | * @return when {@link #getValue()} returns "Get ${someVar} contents", this 26 | * returns a list with [ "Get ", "${someVar}", " contents" ] 27 | */ 28 | List getParts(); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/assistant/IRobotContentAssistant2.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.assistant; 17 | 18 | import java.util.List; 19 | 20 | import org.eclipse.core.resources.IFile; 21 | import org.eclipse.jface.text.contentassist.ICompletionProposal; 22 | 23 | import com.nitorcreations.robotframework.eclipseide.builder.parser.RobotLine; 24 | 25 | public interface IRobotContentAssistant2 { 26 | 27 | ICompletionProposal[] generateProposals(IFile file, int documentOffset, String documentText, List lines, int lineNo); 28 | 29 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/PluginContext.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide; 17 | 18 | import com.nitorcreations.robotframework.eclipseide.editors.IResourceManager; 19 | import com.nitorcreations.robotframework.eclipseide.editors.ResourceManager; 20 | 21 | public class PluginContext { 22 | private static IResourceManager resourceManager = new ResourceManager(); 23 | 24 | public static IResourceManager getResourceManager() { 25 | return resourceManager; 26 | } 27 | 28 | public static void setResourceManager(IResourceManager resourceManager) { 29 | PluginContext.resourceManager = resourceManager; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/structure/api/AvailableFrom.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.structure.api; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * This is used to tag methods whose return value should always be null for 25 | * robot files prior to a specific version. 26 | */ 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @Target(ElementType.METHOD) 29 | public @interface AvailableFrom { 30 | /** 31 | * @return since which Robot Framework version is it available? 32 | */ 33 | String value(); 34 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/structure/api/IUserKeywordDefinition.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.structure.api; 17 | 18 | import java.util.List; 19 | 20 | public interface IUserKeywordDefinition extends IKeywordSequence { 21 | 22 | @Override 23 | IDynamicParsedString getSequenceName(); 24 | 25 | /** 26 | * When arguments have default values, 27 | * {@link IDynamicParsedString#getParts()} returns two parts, "${argument}" 28 | * and "=value". 29 | */ 30 | List getArguments(); 31 | 32 | List getReturnValues(); 33 | 34 | @AvailableFrom("2.6") 35 | IKeywordCall getKeywordTeardown(); 36 | 37 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/structure/api/IKeywordString.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.structure.api; 17 | 18 | /** 19 | * This represents the additional functionality available for 20 | * {@link IParsedString}s that happen to be keywords. 21 | * 22 | * @author xkr47 23 | */ 24 | public interface IKeywordString { 25 | 26 | /** 27 | * @return If the keyword (returned by {@link IParsedString#getValue()}) 28 | * starts with one of the "Given", "When", "Then" or "And" prefixes, 29 | * the alternate keyword with the prefix stripped is returned. 30 | * Otherwise, null is returned. 31 | */ 32 | String getAlternateValue(); 33 | 34 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/builder/BaseResourceVisitor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.builder; 17 | 18 | import java.util.LinkedHashSet; 19 | import java.util.Set; 20 | 21 | import org.eclipse.core.resources.IFile; 22 | import org.eclipse.core.runtime.IProgressMonitor; 23 | 24 | public abstract class BaseResourceVisitor { 25 | protected final Set visitedFiles = new LinkedHashSet(); 26 | protected final RobotBuilder robotBuilder; 27 | protected final IProgressMonitor monitor; 28 | 29 | public BaseResourceVisitor(RobotBuilder robotBuilder, IProgressMonitor monitor) { 30 | this.robotBuilder = robotBuilder; 31 | this.monitor = monitor; 32 | } 33 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/BaseDefinitionMatchVisitor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.util; 17 | 18 | import org.eclipse.core.resources.IFile; 19 | 20 | public abstract class BaseDefinitionMatchVisitor implements DefinitionMatchVisitor { 21 | 22 | protected final IFile file; 23 | 24 | public BaseDefinitionMatchVisitor(IFile file) { 25 | this.file = file; 26 | } 27 | 28 | protected String getDisplayString(String proposal, FileWithType proposalLocation) { 29 | if (proposalLocation.getFile() == file) { 30 | return proposal; 31 | } 32 | return '[' + proposalLocation.getName() + "] " + proposal; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/structure/api/IRobotFileContents.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.structure.api; 17 | 18 | import java.util.Map; 19 | 20 | /** 21 | * This interface provides bean-ish access to the parsed structure of a robot 22 | * file. 23 | * 24 | * @author xkr47 25 | */ 26 | public interface IRobotFileContents { 27 | 28 | // TODO check the IParsedString:s in all interfaces, could some of them be 29 | // dynamic ? 30 | 31 | ISettings getSettings(); 32 | 33 | Map getVariables(); 34 | 35 | Map getTestCases(); 36 | 37 | Map getKeywords(); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/builder/parser/SeverityConfig.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.builder.parser; 17 | 18 | import org.eclipse.core.resources.IMarker; 19 | 20 | public class SeverityConfig { 21 | 22 | // usable severities: IMarker.SEVERITY_* and State.SEVERITY_IGNORE 23 | 24 | public static final int UNKNOWN_TABLE = IMarker.SEVERITY_ERROR; 25 | public static final int IGNORED_LINE_OUTSIDE_RECOGNIZED_TABLE = IMarker.SEVERITY_INFO; 26 | public static final int IGNORED_LINE_IN_SETTING_TABLE = IMarker.SEVERITY_WARNING; 27 | /** 28 | * As per documentation. 29 | */ 30 | public static final int IGNORED_LINE_OUTSIDE_RECOGNIZED_TESTCASE_OR_KEYWORD = IMarker.SEVERITY_ERROR; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/builder/parser/state/Ignore.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.builder.parser.state; 17 | 18 | import org.eclipse.core.runtime.CoreException; 19 | 20 | import com.nitorcreations.robotframework.eclipseide.builder.parser.ParsedLineInfo; 21 | import com.nitorcreations.robotframework.eclipseide.builder.parser.SeverityConfig; 22 | 23 | public class Ignore extends State { 24 | 25 | public static final State STATE = new Ignore(); 26 | 27 | @Override 28 | public void parse(ParsedLineInfo info) throws CoreException { 29 | if (tryParseTableSwitch(info)) { 30 | return; 31 | } 32 | warnIgnoredLine(info, SeverityConfig.IGNORED_LINE_OUTSIDE_RECOGNIZED_TABLE); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/builder/ResourceVisitor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.builder; 17 | 18 | import org.eclipse.core.resources.IResource; 19 | import org.eclipse.core.resources.IResourceVisitor; 20 | import org.eclipse.core.runtime.IProgressMonitor; 21 | 22 | public class ResourceVisitor extends BaseResourceVisitor implements IResourceVisitor { 23 | 24 | public ResourceVisitor(RobotBuilder robotBuilder, IProgressMonitor monitor) { 25 | super(robotBuilder, monitor); 26 | } 27 | 28 | @Override 29 | public boolean visit(IResource resource) { 30 | this.robotBuilder.parse(visitedFiles, resource, monitor); 31 | // return true to continue visiting children. 32 | return true; 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/assistant/proposalgenerator/IProposalGeneratorFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.assistant.proposalgenerator; 17 | 18 | import org.eclipse.core.resources.IFile; 19 | 20 | import com.nitorcreations.robotframework.eclipseide.structure.ParsedString; 21 | 22 | public interface IProposalGeneratorFactory { 23 | 24 | AttemptVisitor createTableAttemptVisitor(); 25 | 26 | AttemptVisitor createSettingTableAttemptVisitor(); 27 | 28 | AttemptVisitor createKeywordDefinitionAttemptVisitor(final IFile file, ParsedString argument); 29 | 30 | AttemptVisitor createKeywordCallAttemptVisitor(IFile file); 31 | 32 | AttemptVisitor createVariableAttemptVisitor(IFile file, int maxVariableCharPos, int maxSettingCharPos); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/structure/api/NotAllowedInTestSuiteInitializationFiles.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.structure.api; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * This is used to tag methods whose return value should always be null for test 25 | * suite initialization files, e.g. "__init__.txt". 26 | */ 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @Target(ElementType.METHOD) 29 | public @interface NotAllowedInTestSuiteInitializationFiles { 30 | /** 31 | * @return since which Robot Framework version is it not allowed? (i.e. it 32 | * was allowed before this version) 33 | */ 34 | String value() default ""; 35 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/structure/api/NotAllowedInResourceFiles.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.structure.api; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * This is used to tag methods whose return value should always be null for 25 | * resource files. I.e. the resource file is syntactically broken if the 26 | * annotated method returns a non-null value. 27 | */ 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Target(ElementType.METHOD) 30 | public @interface NotAllowedInResourceFiles { 31 | /** 32 | * @return since which Robot Framework version is it not allowed? (i.e. it 33 | * was allowed before this version) 34 | */ 35 | String value() default ""; 36 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/rules/RobotWhitespace.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.rules; 17 | 18 | public class RobotWhitespace { 19 | 20 | public static boolean isWhitespace(char c) { 21 | return (c == ' ' || c == '\t' || c == '\n' || c == '\r'); 22 | } 23 | 24 | public static int skipMinimumRobotWhitespace(String line, int startPos) { 25 | boolean gotOne = false; 26 | int i; 27 | for (i = startPos; i < line.length(); ++i) { 28 | char ch = line.charAt(i); 29 | if (!RobotWhitespace.isWhitespace(ch)) { 30 | // I don't think this should ever happen 31 | return line.length() + 1; 32 | } 33 | if (ch == '\t' || gotOne) { 34 | return i + 1; 35 | } 36 | gotOne = true; 37 | } 38 | return i; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/builder/util/FileMarkerManager.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.builder.util; 17 | 18 | import org.eclipse.core.resources.IFile; 19 | import org.eclipse.core.resources.IMarker; 20 | import org.eclipse.core.resources.IResource; 21 | import org.eclipse.core.runtime.CoreException; 22 | 23 | import com.nitorcreations.robotframework.eclipseide.builder.RobotBuilder; 24 | 25 | public class FileMarkerManager implements MarkerManager { 26 | private final IFile file; 27 | 28 | public FileMarkerManager(IFile file) { 29 | this.file = file; 30 | } 31 | 32 | @Override 33 | public IMarker createMarker(String type) throws CoreException { 34 | return file.createMarker(type); 35 | } 36 | 37 | @Override 38 | public void eraseMarkers() { 39 | try { 40 | file.deleteMarkers(RobotBuilder.MARKER_TYPE, false, IResource.DEPTH_ZERO); 41 | } catch (CoreException ce) {} 42 | } 43 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/editors/IResourceManager.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012, 2014 Nitor Creations Oy, SmallGreenET 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.editors; 17 | 18 | import java.io.File; 19 | import java.util.Map; 20 | 21 | import org.eclipse.core.resources.IFile; 22 | import org.eclipse.core.runtime.IPath; 23 | import org.eclipse.jface.text.IDocument; 24 | import org.eclipse.ui.IEditorPart; 25 | 26 | public interface IResourceManager { 27 | 28 | IEditorPart openOrReuseEditorFor(IFile file, boolean isRobotFile); 29 | 30 | IFile getRelativeFile(IFile originalFile, String pathRelativeToOriginalFile); 31 | 32 | Map getJavaFiles(String fullyQualifiedName); 33 | 34 | IDocument resolveDocumentFor(IFile file); 35 | 36 | IFile resolveFileFor(IDocument document); 37 | 38 | void unregisterEditor(RobotFrameworkTextfileEditor editor); 39 | 40 | void registerEditor(RobotFrameworkTextfileEditor editor); 41 | 42 | Resource getResource(File path); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/DefinitionMatchVisitor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.util; 17 | 18 | import org.eclipse.core.resources.IFile; 19 | 20 | import com.nitorcreations.robotframework.eclipseide.builder.parser.LineType; 21 | import com.nitorcreations.robotframework.eclipseide.builder.parser.RobotLine; 22 | import com.nitorcreations.robotframework.eclipseide.structure.ParsedString; 23 | 24 | public interface DefinitionMatchVisitor { 25 | 26 | /** 27 | * @param match 28 | * the match 29 | * @param matchLocation 30 | * where match is located - null if the match is located in a variable file or a library 31 | */ 32 | VisitorInterest visitMatch(ParsedString match, FileWithType matchLocation); 33 | 34 | LineType getWantedLineType(); 35 | 36 | /** 37 | * @return true if {@link DefinitionFinder} should descend into the given import, false if not 38 | */ 39 | boolean visitImport(IFile currentFile, RobotLine line); 40 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/LineMatchVisitor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.util; 17 | 18 | import java.util.Set; 19 | 20 | import org.eclipse.core.resources.IFile; 21 | 22 | import com.nitorcreations.robotframework.eclipseide.builder.parser.LineType; 23 | import com.nitorcreations.robotframework.eclipseide.builder.parser.RobotLine; 24 | 25 | public interface LineMatchVisitor { 26 | 27 | /** 28 | * @param line 29 | * the line 30 | * @param lineLocation 31 | * where line is located - null if the proposal is located in a variable file or a library 32 | */ 33 | VisitorInterest visitMatch(RobotLine line, FileWithType lineLocation); 34 | 35 | Set getWantedLineTypes(); 36 | 37 | boolean wantsLibraryKeywords(); 38 | 39 | boolean wantsLibraryVariables(); 40 | 41 | /** 42 | * @return true if {@link DefinitionFinder} should descend into the given import, false if not 43 | */ 44 | boolean visitImport(IFile currentFile, RobotLine line); 45 | } 46 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/assistant/proposalgenerator/KeywordCallAttemptVisitor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.assistant.proposalgenerator; 17 | 18 | import org.eclipse.core.resources.IFile; 19 | import org.eclipse.jface.text.IRegion; 20 | 21 | import com.nitorcreations.robotframework.eclipseide.internal.util.DefinitionFinder; 22 | 23 | public class KeywordCallAttemptVisitor implements AttemptVisitor { 24 | private final IFile file; 25 | 26 | public KeywordCallAttemptVisitor(IFile file) { 27 | this.file = file; 28 | } 29 | 30 | @Override 31 | public RobotCompletionProposalSet visitAttempt(String attempt, IRegion replacementRegion) { 32 | assert attempt.equals(attempt.toLowerCase()); 33 | RobotCompletionProposalSet ourProposalSet = new RobotCompletionProposalSet(); 34 | CompletionMatchVisitor visitor = new KeywordCompletionMatchVisitor(file, attempt, ourProposalSet.getProposals(), replacementRegion); 35 | DefinitionFinder.acceptMatches(file, visitor); 36 | return ourProposalSet; 37 | } 38 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RobotFramework-EclipseIDE 1.4.0 2 | 3 | 4 | RobotFramework-EclipseIDE is an Eclipse IDE plugin for the [Robot Framework test automation tool](https://code.google.com/p/robotframework/). It is developed by [Nitor Creations Oy](http://nitorcreations.com/). 5 | 6 | Robot Framework is a generic test automation framework for acceptance testing and acceptance test-driven development (ATDD). [Acceptance Test-Driven Development](http://testobsessed.com/2008/12/acceptance-test-driven-development-atdd-an-overview/) is a process used to construct executable requirements before the implementation starts. 7 | 8 | This plugin helps you to write tests with Robot Framework directly from the comfort of your Eclipse IDE. 9 | 10 | ## IDE Features 11 | 12 | * Support for .txt and (since 1.4.0) .robot files using the "two spaces or tab" format 13 | * Syntax coloring (colors configurable since 1.2.0) 14 | * Hyperlinks to keyword definitions 15 | * Hyperlinks to global variable definitions 16 | * Hyperlinks to resource files 17 | * Hyperlinks to variable files 18 | * Code completion for keyword calls 19 | * Code completion for global variables 20 | * Code completion for missing keyword definitions (since 1.3.0) 21 | * Code completion for tables, formatting configurable (since 1.3.0) 22 | * Code completion for Setting table keys (since 1.3.0) 23 | 24 | ## Requirements 25 | 26 | * Eclipse Indigo (3.7) or later (earlier might work, untested) 27 | 28 | ## Installation 29 | 30 | See [Installation instructions](https://github.com/NitorCreations/RobotFramework-EclipseIDE/wiki/Installation). 31 | 32 | ## Usage 33 | 34 | See [Usage](https://github.com/NitorCreations/RobotFramework-EclipseIDE/wiki/Usage). 35 | 36 | ## More info 37 | 38 | See [Wiki pages](https://github.com/NitorCreations/RobotFramework-EclipseIDE/wiki). 39 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/structure/VariableDefinition.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.structure; 17 | 18 | import java.util.Collections; 19 | import java.util.List; 20 | 21 | import com.nitorcreations.robotframework.eclipseide.structure.api.IDynamicParsedString; 22 | import com.nitorcreations.robotframework.eclipseide.structure.api.IParsedString; 23 | import com.nitorcreations.robotframework.eclipseide.structure.api.IVariableDefinition; 24 | 25 | public class VariableDefinition implements IVariableDefinition { 26 | 27 | private IParsedString variable; 28 | private List valuesIMM; 29 | 30 | // singles 31 | 32 | public void setVariable(IParsedString variable) { 33 | this.variable = variable; 34 | } 35 | 36 | // lists 37 | 38 | public void setValues(List values) { 39 | this.valuesIMM = Collections.unmodifiableList(values); 40 | } 41 | 42 | // getters 43 | 44 | @Override 45 | public IParsedString getVariable() { 46 | return variable; 47 | } 48 | 49 | @Override 50 | public List getValues() { 51 | return valuesIMM; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/structure/api/IParsedString.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.structure.api; 17 | 18 | public interface IParsedString { 19 | 20 | int SYNTHESIZED_VALUE_CHAR_POS = -1; 21 | 22 | /** 23 | * @return the string value. 24 | */ 25 | String getValue(); 26 | 27 | /** 28 | * @return the character offset (from the beginning of the file) where 29 | * {@link #getValue()} begins. If the value is synthesized, the 30 | * value {@link #SYNTHESIZED_VALUE_CHAR_POS} is returned. 31 | */ 32 | int getArgCharPos(); 33 | 34 | /** 35 | * @return the character offset (from the beginning of the file) where 36 | * {@link #getValue()} ends, exclusively. 37 | */ 38 | int getArgEndCharPos(); 39 | 40 | /** 41 | * @return a debug string representing this string. 42 | */ 43 | String getDebugString(); 44 | 45 | /** 46 | * @return the hash code of {@link #getValue()}. 47 | */ 48 | @Override 49 | public int hashCode(); 50 | 51 | /** 52 | * @return getValue().equals(obj.getValue()) 53 | */ 54 | @Override 55 | public boolean equals(Object obj); 56 | 57 | } 58 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/structure/KeywordCall.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.structure; 17 | 18 | import java.util.Collections; 19 | import java.util.List; 20 | 21 | import com.nitorcreations.robotframework.eclipseide.structure.api.IDynamicParsedKeywordString; 22 | import com.nitorcreations.robotframework.eclipseide.structure.api.IDynamicParsedString; 23 | import com.nitorcreations.robotframework.eclipseide.structure.api.IKeywordCall; 24 | 25 | public class KeywordCall implements IKeywordCall { 26 | 27 | private IDynamicParsedKeywordString keyword; 28 | private List argumentsIMM; 29 | 30 | // singles 31 | 32 | public void setKeyword(IDynamicParsedKeywordString keyword) { 33 | this.keyword = keyword; 34 | } 35 | 36 | // lists 37 | 38 | public void setArguments(List arguments) { 39 | this.argumentsIMM = Collections.unmodifiableList(arguments); 40 | } 41 | 42 | // getters 43 | 44 | @Override 45 | public IDynamicParsedKeywordString getKeyword() { 46 | return keyword; 47 | } 48 | 49 | @Override 50 | public List getArguments() { 51 | return argumentsIMM; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/builder/parser/LineType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.builder.parser; 17 | 18 | public enum LineType { 19 | IGNORE(TableType.UNKNOWN), // 20 | IGNORE_TABLE(TableType.IGNORE), // 21 | SETTING_TABLE_BEGIN(TableType.SETTING), // 22 | SETTING_TABLE_LINE(TableType.SETTING), // 23 | VARIABLE_TABLE_BEGIN(TableType.VARIABLE), // 24 | VARIABLE_TABLE_LINE(TableType.VARIABLE), // 25 | TESTCASE_TABLE_BEGIN(TableType.TESTCASE), // 26 | TESTCASE_TABLE_IGNORE(TableType.TESTCASE), // 27 | TESTCASE_TABLE_TESTCASE_BEGIN(TableType.TESTCASE), // 28 | TESTCASE_TABLE_TESTCASE_LINE(TableType.TESTCASE), // 29 | KEYWORD_TABLE_BEGIN(TableType.KEYWORD), // 30 | KEYWORD_TABLE_IGNORE(TableType.KEYWORD), // 31 | KEYWORD_TABLE_KEYWORD_BEGIN(TableType.KEYWORD), // 32 | KEYWORD_TABLE_KEYWORD_LINE(TableType.KEYWORD), // 33 | CONTINUATION_LINE(TableType.UNKNOWN), // 34 | COMMENT_LINE(TableType.UNKNOWN), // 35 | ; 36 | public final TableType tableType; 37 | 38 | LineType(TableType tableType) { 39 | this.tableType = tableType; 40 | } 41 | 42 | public boolean isTestCaseLine() { 43 | return this == TESTCASE_TABLE_TESTCASE_BEGIN || this == TESTCASE_TABLE_TESTCASE_LINE; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/builder/parser/state/TestcaseTableActive.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.builder.parser.state; 17 | 18 | import org.eclipse.core.runtime.CoreException; 19 | 20 | import com.nitorcreations.robotframework.eclipseide.builder.parser.ParsedLineInfo; 21 | import com.nitorcreations.robotframework.eclipseide.structure.TestCaseDefinition; 22 | 23 | public class TestcaseTableActive extends State { 24 | 25 | public static final State STATE = new TestcaseTableActive(); 26 | 27 | @Override 28 | public void parse(ParsedLineInfo info) throws CoreException { 29 | if (tryParseTableSwitch(info)) { 30 | return; 31 | } 32 | if (!info.arguments.get(0).getValue().isEmpty()) { 33 | // start new testcase 34 | if (!tryParseArgument(info, 0, "test case name")) { 35 | // warnIgnoredLine(info, IMarker.SEVERITY_ERROR); 36 | return; 37 | } 38 | TestCaseDefinition tc = new TestCaseDefinition(info.fc()); 39 | tc.setSequenceName(info.arguments.get(0)); 40 | info.fc().addTestCase(tc); 41 | info.setState(STATE, tc); 42 | if (info.arguments.size() == 1) { 43 | return; 44 | } 45 | } 46 | parseTestcaseLine(info); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /plugin/robot-indices/RobotFramework-2.6.3/BuiltIn.index: -------------------------------------------------------------------------------- 1 | Call Method 2 | Catenate 3 | Comment 4 | Convert To Binary 5 | Convert To Boolean 6 | Convert To Hex 7 | Convert To Integer 8 | Convert To Number 9 | Convert To Octal 10 | Convert To String 11 | Create List 12 | Evaluate 13 | Exit For Loop 14 | Fail 15 | Fatal Error 16 | Get Count 17 | Get Length 18 | Get Library Instance 19 | Get Time 20 | Get Variable Value 21 | Get Variables 22 | Import Library 23 | Import Resource 24 | Import Variables 25 | Keyword Should Exist 26 | Length Should Be 27 | Log 28 | Log Many 29 | Log Variables 30 | No Operation 31 | Regexp Escape 32 | Remove Tags 33 | Repeat Keyword 34 | Replace Variables 35 | Run Keyword 36 | Run Keyword And Continue On Failure 37 | Run Keyword And Expect Error 38 | Run Keyword And Ignore Error 39 | Run Keyword If 40 | Run Keyword If All Critical Tests Passed 41 | Run Keyword If All Tests Passed 42 | Run Keyword If Any Critical Tests Failed 43 | Run Keyword If Any Tests Failed 44 | Run Keyword If Test Failed 45 | Run Keyword If Test Passed 46 | Run Keyword If Timeout Occurred 47 | Run Keyword Unless 48 | Run Keywords 49 | Set Global Variable 50 | Set Library Search Order 51 | Set Log Level 52 | Set Suite Variable 53 | Set Tags 54 | Set Test Message 55 | Set Test Variable 56 | Set Variable 57 | Set Variable If 58 | Should Be Empty 59 | Should Be Equal 60 | Should Be Equal As Integers 61 | Should Be Equal As Numbers 62 | Should Be Equal As Strings 63 | Should Be True 64 | Should Contain 65 | Should Contain X Times 66 | Should End With 67 | Should Match 68 | Should Match Regexp 69 | Should Not Be Empty 70 | Should Not Be Equal 71 | Should Not Be Equal As Integers 72 | Should Not Be Equal As Numbers 73 | Should Not Be Equal As Strings 74 | Should Not Be True 75 | Should Not Contain 76 | Should Not End With 77 | Should Not Match 78 | Should Not Match Regexp 79 | Should Not Start With 80 | Should Start With 81 | Sleep 82 | Variable Should Exist 83 | Variable Should Not Exist 84 | Wait Until Keyword Succeeds 85 | ${CURDIR} 86 | ${TEMPDIR} 87 | ${EXECDIR} 88 | ${/} 89 | ${:} 90 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/assistant/proposalgenerator/RobotCompletionProposalSet.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.assistant.proposalgenerator; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | public class RobotCompletionProposalSet { 22 | 23 | private final List proposals = new ArrayList(); 24 | private Boolean basedOnInput; 25 | private boolean priorityProposal; 26 | 27 | public List getProposals() { 28 | return proposals; 29 | } 30 | 31 | public boolean isBasedOnInput() { 32 | if (basedOnInput == null) { 33 | throw new IllegalStateException("basedOnInput not set"); 34 | } 35 | return basedOnInput; 36 | } 37 | 38 | public void setBasedOnInput(boolean basedOnInput) { 39 | this.basedOnInput = basedOnInput; 40 | } 41 | 42 | public boolean isPriorityProposal() { 43 | return priorityProposal; 44 | } 45 | 46 | public void setPriorityProposal() { 47 | priorityProposal = true; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "RobotCompletionProposalSet [proposals=" + proposals + ", basedOnInput=" + basedOnInput + ", priorityProposal=" + priorityProposal + "]"; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/structure/DynamicParsedString.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.structure; 17 | 18 | import java.util.Collections; 19 | import java.util.List; 20 | 21 | import com.nitorcreations.robotframework.eclipseide.structure.api.IDynamicParsedKeywordString; 22 | import com.nitorcreations.robotframework.eclipseide.structure.api.IDynamicParsedString; 23 | 24 | public class DynamicParsedString extends ParsedString implements IDynamicParsedKeywordString { 25 | 26 | private final List parts; 27 | 28 | /** 29 | * @param parts 30 | * non-null automatically wrapped using 31 | * {@link Collections#unmodifiableList(List)} 32 | */ 33 | public DynamicParsedString(String value, int argCharPos, List parts) { 34 | super(value, argCharPos); 35 | if (parts != null && parts.isEmpty()) { 36 | throw new IllegalArgumentException("parts list is empty"); 37 | } 38 | this.parts = parts == null ? null : Collections.unmodifiableList(parts); 39 | } 40 | 41 | @Override 42 | public List getParts() { 43 | return parts; 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return parts == null ? super.toString() : parts.toString(); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/PriorityDeque.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.util; 17 | 18 | import java.util.Deque; 19 | 20 | /** 21 | * Double-ended queue with priority level support. Extends the Deque interface with methods for explicitly specifying 22 | * priority levels. It is up to implementations of this interface whether to support and how to determine the priority 23 | * for methods of the Deque interface that do not specify the priority level - one option is to use the 24 | * {@link Prioritizer} interface. 25 | */ 26 | public interface PriorityDeque extends Deque { 27 | 28 | void addFirst(int priority, T e); 29 | 30 | void addLast(int priority, T e); 31 | 32 | boolean add(int priority, T e); 33 | 34 | boolean offerFirst(int priority, T e); 35 | 36 | boolean offerLast(int priority, T e); 37 | 38 | boolean offer(int priority, T e); 39 | 40 | void push(int priority, T e); 41 | 42 | void clear(int priority); 43 | 44 | void clear(int minPriority, int maxPriority); 45 | 46 | int getNumberOfPriorityLevels(); 47 | 48 | /** 49 | * @return -1 if empty, lowest priority level otherwise 50 | */ 51 | int peekLowestPriority(); 52 | 53 | /** 54 | * @return -1 if empty, highest priority level otherwise 55 | */ 56 | int peekHighestPriority(); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/builder/parser/state/KeywordTableActive.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.builder.parser.state; 17 | 18 | import org.eclipse.core.runtime.CoreException; 19 | 20 | import com.nitorcreations.robotframework.eclipseide.builder.parser.ParsedLineInfo; 21 | import com.nitorcreations.robotframework.eclipseide.structure.UserKeywordDefinition; 22 | 23 | public class KeywordTableActive extends State { 24 | 25 | public static final State STATE = new KeywordTableActive(); 26 | 27 | @Override 28 | public void parse(ParsedLineInfo info) throws CoreException { 29 | if (tryParseTableSwitch(info)) { 30 | return; 31 | } 32 | if (!info.arguments.get(0).getValue().isEmpty()) { 33 | // start new testcase 34 | if (!tryParseArgument(info, 0, "user keyword name")) { 35 | // warnIgnoredLine(info, IMarker.SEVERITY_ERROR); 36 | return; 37 | } 38 | UserKeywordDefinition ukw = new UserKeywordDefinition(); 39 | ukw.setSequenceName(info.arguments.get(0).splitRegularArgument()); 40 | info.fc().addKeyword(ukw); 41 | info.setState(KeywordTableActive.STATE, ukw); 42 | if (info.arguments.size() == 1) { 43 | return; 44 | } 45 | } 46 | parseUserKeywordLine(info); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/builder/parser/state/VariableTable.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.builder.parser.state; 17 | 18 | import java.util.List; 19 | 20 | import org.eclipse.core.runtime.CoreException; 21 | 22 | import com.nitorcreations.robotframework.eclipseide.builder.parser.ParsedLineInfo; 23 | import com.nitorcreations.robotframework.eclipseide.structure.DynamicParsedString; 24 | import com.nitorcreations.robotframework.eclipseide.structure.ParsedString; 25 | import com.nitorcreations.robotframework.eclipseide.structure.VariableDefinition; 26 | 27 | public class VariableTable extends State { 28 | 29 | public static final State STATE = new VariableTable(); 30 | 31 | @Override 32 | public void parse(ParsedLineInfo info) throws CoreException { 33 | if (tryParseTableSwitch(info)) { 34 | return; 35 | } 36 | if (!tryParseVariable(info, 0)) { 37 | return; 38 | } 39 | ParsedString varArg = info.arguments.get(0); 40 | // TODO tryParseArgument(info, 1, "variable content"); 41 | List values = splitRegularArguments(info, 1, 0); 42 | VariableDefinition varDef = new VariableDefinition(); 43 | varDef.setVariable(varArg); 44 | varDef.setValues(values); 45 | info.fc().addVariable(varDef); 46 | info.setContinuationList(values); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /plugin/src/test/resources/RFEParser/robo.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Nitor Creations Oy 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Woo! 16 | 17 | ***Settings*** # lol 18 | Library OperatingSystem 19 | Resource resource.txt 20 | # foo 21 | 22 | ***Settings*** 23 | Library OperatingSystem 24 | Resource resource.txt 25 | # foo 26 | 27 | ***Variables*** 28 | ${MESSAGE} Hello, world! 29 | ${MESSAGE} Hello, worl d! ${OTHERMESSAGE} 30 | ${MESSAGE Hello, worl d! ${OTHERMESSAGE} 31 | {MESSAGE} Hello, worl d! ${OTHERMESSAGE} 32 | MESSAGE} Hello, worl d! ${OTHERMESSAGE} 33 | MESSAGE Hello, worl d! ${OTHERMESSAGE} 34 | ${MESS}AGE} Hello, worl d! ${OTHERMESSAGE} 35 | # foo 36 | 37 | ***Test Cases*** 38 | # foo 39 | 40 | My Test [Documentation] Example test 41 | Log ${MESSAGE} 42 | My Keyword /tmp 43 | # foo 44 | 45 | Another Test 46 | Should Be Equal ${MESSAGE} Hello, world! 47 | 48 | ***Keywords*** 49 | # foo 50 | My Keyword is the ${foo} greatest [Arguments] ${path} 51 | [Arguments] ${path} 52 | Directory Should Exist ${path} # ${fooled} 53 | Directory Sho${foo}uld Exist ${path} lol${path}lol 54 | Directory Should Exis\##t ${path} lol${path}lol 55 | Fooo 56 | Fooo 57 | Fooo 58 | Fooo 59 | Fooo 60 | Fooo 61 | Fooo foo 62 | Fooo foo 63 | Fooo foo 64 | Fooo foo 65 | Fooo foo 66 | Fooo\ 67 | Fooo \ 68 | Fooo \ 69 | Fooo \ 70 | Fooo\ 71 | Fooo\ 72 | Fooo\ 73 | Fooo\ 74 | Bar\ \ \ zot 75 | #hello world 76 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/preferences/TableNamingPreferencePage.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.preferences; 17 | 18 | import org.eclipse.jface.preference.FieldEditorPreferencePage; 19 | import org.eclipse.jface.preference.StringFieldEditor; 20 | import org.eclipse.ui.IWorkbench; 21 | import org.eclipse.ui.IWorkbenchPreferencePage; 22 | 23 | import com.nitorcreations.robotframework.eclipseide.Activator; 24 | 25 | public class TableNamingPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { 26 | 27 | public TableNamingPreferencePage() { 28 | super(GRID); 29 | setPreferenceStore(Activator.getDefault().getPreferenceStore()); 30 | setDescription("Preferred formatting of table names for the Robot Framework editor"); 31 | } 32 | 33 | @Override 34 | public void createFieldEditors() { 35 | addField(new StringFieldEditor(PreferenceConstants.P_VARIABLE_TABLE_FORMAT, "&Variable table:", getFieldEditorParent())); 36 | addField(new StringFieldEditor(PreferenceConstants.P_SETTING_TABLE_FORMAT, "&Setting/Metadata table:", getFieldEditorParent())); 37 | addField(new StringFieldEditor(PreferenceConstants.P_TESTCASE_TABLE_FORMAT, "&Testcase table:", getFieldEditorParent())); 38 | addField(new StringFieldEditor(PreferenceConstants.P_KEYWORD_TABLE_FORMAT, "User &keyword table:", getFieldEditorParent())); 39 | } 40 | 41 | @Override 42 | public void init(IWorkbench workbench) {} 43 | } 44 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/builder/parser/state/TestcaseTableInitial.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.builder.parser.state; 17 | 18 | import org.eclipse.core.runtime.CoreException; 19 | 20 | import com.nitorcreations.robotframework.eclipseide.builder.parser.ParsedLineInfo; 21 | import com.nitorcreations.robotframework.eclipseide.builder.parser.SeverityConfig; 22 | import com.nitorcreations.robotframework.eclipseide.structure.TestCaseDefinition; 23 | 24 | public class TestcaseTableInitial extends State { 25 | 26 | public static final State STATE = new TestcaseTableInitial(); 27 | 28 | @Override 29 | public void parse(ParsedLineInfo info) throws CoreException { 30 | if (tryParseTableSwitch(info)) { 31 | return; 32 | } 33 | if (info.arguments.get(0).getValue().isEmpty()) { 34 | warnIgnoredLine(info, SeverityConfig.IGNORED_LINE_OUTSIDE_RECOGNIZED_TESTCASE_OR_KEYWORD); 35 | return; 36 | } 37 | if (!tryParseArgument(info, 0, "test case name")) { 38 | // warnIgnoredLine(info, IMarker.SEVERITY_ERROR); 39 | return; 40 | } 41 | // start new testcase 42 | TestCaseDefinition tc = new TestCaseDefinition(info.fc()); 43 | tc.setSequenceName(info.arguments.get(0)); 44 | info.fc().addTestCase(tc); 45 | info.setState(TestcaseTableActive.STATE, tc); 46 | if (info.arguments.size() == 1) { 47 | return; 48 | } 49 | parseTestcaseLine(info); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/editors/RobotPresentationReconciler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.editors; 17 | 18 | import org.eclipse.jface.text.DocumentEvent; 19 | import org.eclipse.jface.text.IDocument; 20 | import org.eclipse.jface.text.IRegion; 21 | import org.eclipse.jface.text.ITypedRegion; 22 | import org.eclipse.jface.text.presentation.PresentationReconciler; 23 | import org.eclipse.jface.text.rules.DefaultDamagerRepairer; 24 | import org.eclipse.jface.text.rules.ITokenScanner; 25 | 26 | import com.nitorcreations.robotframework.eclipseide.PluginContext; 27 | 28 | public class RobotPresentationReconciler extends PresentationReconciler { 29 | 30 | public RobotPresentationReconciler(ColorManager colorManager) { 31 | ITokenScanner coloringScanner = new ColoringScanner(colorManager); 32 | DefaultDamagerRepairer dr = new DefaultDamagerRepairer(coloringScanner) { 33 | @Override 34 | public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent e, boolean documentPartitioningChanged) { 35 | System.out.println("Document " + PluginContext.getResourceManager().resolveFileFor(e.getDocument()) + " region changed: " + e); 36 | // force damaging entire document for now; we don't support 37 | // partial reparsing just yet 38 | return partition; 39 | } 40 | }; 41 | setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE); 42 | setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/assistant/proposalgenerator/ProposalGeneratorFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.assistant.proposalgenerator; 17 | 18 | import org.eclipse.core.resources.IFile; 19 | import org.eclipse.jface.preference.IPreferenceStore; 20 | 21 | import com.nitorcreations.robotframework.eclipseide.Activator; 22 | import com.nitorcreations.robotframework.eclipseide.structure.ParsedString; 23 | 24 | public class ProposalGeneratorFactory implements IProposalGeneratorFactory { 25 | 26 | @Override 27 | public AttemptVisitor createTableAttemptVisitor() { 28 | IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); 29 | return new TableAttemptVisitor(preferenceStore); 30 | } 31 | 32 | @Override 33 | public AttemptVisitor createSettingTableAttemptVisitor() { 34 | return new SettingTableAttemptVisitor(); 35 | } 36 | 37 | @Override 38 | public AttemptVisitor createKeywordDefinitionAttemptVisitor(final IFile file, ParsedString argument) { 39 | return new KeywordDefinitionAttemptVisitor(file, argument); 40 | } 41 | 42 | @Override 43 | public AttemptVisitor createKeywordCallAttemptVisitor(IFile file) { 44 | return new KeywordCallAttemptVisitor(file); 45 | } 46 | 47 | @Override 48 | public AttemptVisitor createVariableAttemptVisitor(IFile file, int maxVariableCharPos, int maxSettingCharPos) { 49 | return new VariableAttemptVisitor(file, maxVariableCharPos, maxSettingCharPos); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/builder/parser/state/KeywordTableInitial.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.builder.parser.state; 17 | 18 | import org.eclipse.core.runtime.CoreException; 19 | 20 | import com.nitorcreations.robotframework.eclipseide.builder.parser.ParsedLineInfo; 21 | import com.nitorcreations.robotframework.eclipseide.builder.parser.SeverityConfig; 22 | import com.nitorcreations.robotframework.eclipseide.structure.UserKeywordDefinition; 23 | 24 | public class KeywordTableInitial extends State { 25 | 26 | public static final State STATE = new KeywordTableInitial(); 27 | 28 | @Override 29 | public void parse(ParsedLineInfo info) throws CoreException { 30 | if (tryParseTableSwitch(info)) { 31 | return; 32 | } 33 | if (info.arguments.get(0).getValue().isEmpty()) { 34 | warnIgnoredLine(info, SeverityConfig.IGNORED_LINE_OUTSIDE_RECOGNIZED_TESTCASE_OR_KEYWORD); 35 | return; 36 | } 37 | if (!tryParseArgument(info, 0, "user keyword name")) { 38 | // warnIgnoredLine(info, IMarker.SEVERITY_ERROR); 39 | return; 40 | } 41 | // start new user keyword 42 | UserKeywordDefinition ukw = new UserKeywordDefinition(); 43 | ukw.setSequenceName(info.arguments.get(0).splitRegularArgument()); 44 | info.fc().addKeyword(ukw); 45 | info.setState(KeywordTableActive.STATE, ukw); 46 | if (info.arguments.size() == 1) { 47 | return; 48 | } 49 | parseUserKeywordLine(info); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/Reporter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.util; 17 | 18 | import java.util.HashMap; 19 | import java.util.Iterator; 20 | import java.util.Map; 21 | 22 | public class Reporter { 23 | 24 | private static final long REPORT_INTERVAL = 10000; 25 | private static final long CLEAN_INTERVAL = 60000; 26 | 27 | private static final Map reportedMessages = new HashMap(); // msg, lastReportedTimestamp 28 | 29 | private static long lastCleaned; 30 | 31 | /** 32 | * Report message to console unless the exact same message has already been reported within REPORT_INTERVAL. 33 | * 34 | * @param msg 35 | * the message to report 36 | */ 37 | public static synchronized void report(String msg) { 38 | Long lastReported = reportedMessages.get(msg); 39 | long now = System.currentTimeMillis(); 40 | if (lastReported != null && now - lastReported < REPORT_INTERVAL) { 41 | return; 42 | } 43 | reportedMessages.put(msg, now); 44 | System.out.println(msg); 45 | conditionallyClean(now); 46 | } 47 | 48 | private static void conditionallyClean(long now) { 49 | if (now - lastCleaned < CLEAN_INTERVAL) { 50 | return; 51 | } 52 | Iterator it = reportedMessages.values().iterator(); 53 | while (it.hasNext()) { 54 | if (now - it.next() >= REPORT_INTERVAL) { 55 | it.remove(); 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/structure/LibraryFile.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.structure; 17 | 18 | import java.util.Collections; 19 | import java.util.List; 20 | 21 | import com.nitorcreations.robotframework.eclipseide.structure.api.IDynamicParsedKeywordString; 22 | import com.nitorcreations.robotframework.eclipseide.structure.api.IDynamicParsedString; 23 | import com.nitorcreations.robotframework.eclipseide.structure.api.ILibraryFile; 24 | 25 | public class LibraryFile implements ILibraryFile { 26 | 27 | private IDynamicParsedKeywordString realName; 28 | private IDynamicParsedKeywordString customName; 29 | private List argumentsIMM; 30 | 31 | // single 32 | 33 | public void setRealName(IDynamicParsedKeywordString realName) { 34 | this.realName = realName; 35 | } 36 | 37 | public void setCustomName(IDynamicParsedKeywordString customName) { 38 | this.customName = customName; 39 | } 40 | 41 | // lists 42 | 43 | public void setArguments(List arguments) { 44 | this.argumentsIMM = Collections.unmodifiableList(arguments); 45 | } 46 | 47 | // interface-specified getters 48 | 49 | @Override 50 | public IDynamicParsedKeywordString getRealName() { 51 | return realName; 52 | } 53 | 54 | @Override 55 | public IDynamicParsedKeywordString getCustomName() { 56 | return customName; 57 | } 58 | 59 | @Override 60 | public List getArguments() { 61 | return argumentsIMM; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/Activator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide; 17 | 18 | import org.eclipse.jface.resource.ImageDescriptor; 19 | import org.eclipse.ui.plugin.AbstractUIPlugin; 20 | import org.osgi.framework.BundleContext; 21 | 22 | /** 23 | * The activator class controls the plug-in life cycle 24 | */ 25 | public class Activator extends AbstractUIPlugin { 26 | 27 | // The plug-in ID 28 | public static final String PLUGIN_ID = "com.nitorcreations.robotframework.eclipseide"; //$NON-NLS-1$ 29 | 30 | // The shared instance 31 | private static Activator plugin; 32 | 33 | /** 34 | * The constructor 35 | */ 36 | public Activator() { 37 | } 38 | 39 | @Override 40 | public void start(BundleContext context) throws Exception { 41 | super.start(context); 42 | plugin = this; 43 | } 44 | 45 | @Override 46 | public void stop(BundleContext context) throws Exception { 47 | plugin = null; 48 | super.stop(context); 49 | } 50 | 51 | /** 52 | * Returns the shared instance 53 | * 54 | * @return the shared instance 55 | */ 56 | public static Activator getDefault() { 57 | return plugin; 58 | } 59 | 60 | /** 61 | * Returns an image descriptor for the image file at the given plug-in 62 | * relative path 63 | * 64 | * @param path 65 | * the path 66 | * @return the image descriptor 67 | */ 68 | public static ImageDescriptor getImageDescriptor(String path) { 69 | return imageDescriptorFromPlugin(PLUGIN_ID, path); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/builder/ResourceDeltaVisitor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.builder; 17 | 18 | import org.eclipse.core.resources.IFile; 19 | import org.eclipse.core.resources.IResource; 20 | import org.eclipse.core.resources.IResourceDelta; 21 | import org.eclipse.core.resources.IResourceDeltaVisitor; 22 | import org.eclipse.core.runtime.CoreException; 23 | import org.eclipse.core.runtime.IProgressMonitor; 24 | 25 | import com.nitorcreations.robotframework.eclipseide.builder.parser.RobotFile; 26 | 27 | public class ResourceDeltaVisitor extends BaseResourceVisitor implements IResourceDeltaVisitor { 28 | 29 | public ResourceDeltaVisitor(RobotBuilder robotBuilder, IProgressMonitor monitor) { 30 | super(robotBuilder, monitor); 31 | } 32 | 33 | @Override 34 | public boolean visit(IResourceDelta delta) throws CoreException { 35 | IResource resource = delta.getResource(); 36 | switch (delta.getKind()) { 37 | case IResourceDelta.ADDED: 38 | // handle added resource 39 | this.robotBuilder.parse(visitedFiles, resource, monitor); 40 | break; 41 | case IResourceDelta.REMOVED: 42 | // handle removed resource 43 | if (resource instanceof IFile) { 44 | RobotFile.erase((IFile) resource); 45 | } 46 | break; 47 | case IResourceDelta.CHANGED: 48 | // handle changed resource 49 | this.robotBuilder.parse(visitedFiles, resource, monitor); 50 | break; 51 | } 52 | // return true to continue visiting children. 53 | return true; 54 | } 55 | 56 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/assistant/proposalgenerator/SettingTableAttemptVisitor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.assistant.proposalgenerator; 17 | 18 | import java.util.ArrayList; 19 | import java.util.Collections; 20 | import java.util.List; 21 | 22 | import org.eclipse.jface.text.IRegion; 23 | import org.eclipse.swt.graphics.Image; 24 | 25 | import com.nitorcreations.robotframework.eclipseide.builder.parser.ArgumentPreParser; 26 | 27 | public class SettingTableAttemptVisitor implements AttemptVisitor { 28 | 29 | private final List settingKeys; 30 | 31 | public SettingTableAttemptVisitor() { 32 | settingKeys = new ArrayList(ArgumentPreParser.getSettingKeys()); 33 | Collections.sort(settingKeys); 34 | } 35 | 36 | @Override 37 | public RobotCompletionProposalSet visitAttempt(String attempt, IRegion replacementRegion) { 38 | assert attempt.equals(attempt.toLowerCase()); 39 | RobotCompletionProposalSet ourProposalSet = new RobotCompletionProposalSet(); 40 | for (String key : settingKeys) { 41 | if (key.toLowerCase().startsWith(attempt)) { 42 | String proposal = key; 43 | Image image = null; 44 | String displayString = key; 45 | String additionalProposalInfo = null; 46 | String informationDisplayString = null; 47 | ourProposalSet.getProposals().add(new RobotCompletionProposal(proposal, null, replacementRegion, image, displayString, informationDisplayString, additionalProposalInfo)); 48 | } 49 | } 50 | return ourProposalSet; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/builder/parser/CountingLineReader.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.builder.parser; 17 | 18 | import java.io.IOException; 19 | import java.io.Reader; 20 | 21 | /** 22 | * Tested indirectly through {@link TestLexer}. 23 | */ 24 | public class CountingLineReader { 25 | 26 | private final Reader reader; 27 | 28 | private int charsConsumed; 29 | 30 | private boolean eof; 31 | 32 | private final StringBuilder sb = new StringBuilder(); 33 | 34 | public CountingLineReader(Reader reader) { 35 | this.reader = reader; 36 | } 37 | 38 | public void close() throws IOException { 39 | reader.close(); 40 | } 41 | 42 | public int getCharPos() { 43 | return charsConsumed; 44 | } 45 | 46 | public String readLine() throws IOException { 47 | if (eof) { 48 | return null; 49 | } 50 | int lf; 51 | do { 52 | lf = sb.indexOf("\n"); 53 | } while (lf == -1 && fill()); 54 | String ret; 55 | if (lf == -1) { 56 | eof = true; 57 | ret = sb.toString(); 58 | sb.setLength(0); 59 | charsConsumed += ret.length(); 60 | } else { 61 | ret = sb.substring(0, lf); 62 | sb.delete(0, lf + 1); 63 | charsConsumed += lf + 1; 64 | } 65 | return ret.replace("\r", ""); 66 | } 67 | 68 | private boolean fill() throws IOException { 69 | char[] buf = new char[1024]; 70 | int read = reader.read(buf); 71 | if (read == -1) { 72 | return false; 73 | } 74 | sb.append(buf, 0, read); 75 | return true; 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/builder/parser/ParsedLineInfo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.builder.parser; 17 | 18 | import java.util.Collections; 19 | import java.util.List; 20 | 21 | import com.nitorcreations.robotframework.eclipseide.builder.parser.state.State; 22 | import com.nitorcreations.robotframework.eclipseide.builder.util.MarkerManager; 23 | import com.nitorcreations.robotframework.eclipseide.structure.KeywordSequence; 24 | import com.nitorcreations.robotframework.eclipseide.structure.ParsedString; 25 | import com.nitorcreations.robotframework.eclipseide.structure.RobotFileContents; 26 | import com.nitorcreations.robotframework.eclipseide.structure.api.IDynamicParsedString; 27 | 28 | public class ParsedLineInfo { 29 | private final RobotParser parser; 30 | public final List arguments; 31 | public final int lineNo; 32 | public final int lineCharPos; 33 | 34 | public ParsedLineInfo(RobotParser parser, List arguments, int lineNo, int charPos) { 35 | this.parser = parser; 36 | this.arguments = Collections.unmodifiableList(arguments); 37 | this.lineNo = lineNo; 38 | this.lineCharPos = charPos; 39 | } 40 | 41 | public RobotFileContents fc() { 42 | return parser.fc; 43 | } 44 | 45 | public void setState(State state, KeywordSequence testcaseOrKeywordBeingParsed) { 46 | parser.setState(state, testcaseOrKeywordBeingParsed); 47 | } 48 | 49 | public void clearContinuationList() { 50 | parser.clearContinuationList(); 51 | } 52 | 53 | public void setContinuationList(List listToContinue) { 54 | parser.setContinuationList(listToContinue); 55 | } 56 | 57 | public MarkerManager markerManager() { 58 | return parser.getMarkerManager(); 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/assistant/proposalgenerator/CompletionMatchVisitor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.assistant.proposalgenerator; 17 | 18 | import java.util.HashSet; 19 | import java.util.List; 20 | 21 | import org.eclipse.core.resources.IFile; 22 | import org.eclipse.jface.text.IRegion; 23 | import org.eclipse.swt.graphics.Image; 24 | 25 | import com.nitorcreations.robotframework.eclipseide.internal.util.BaseDefinitionMatchVisitor; 26 | import com.nitorcreations.robotframework.eclipseide.internal.util.FileWithType; 27 | 28 | public abstract class CompletionMatchVisitor extends BaseDefinitionMatchVisitor { 29 | protected final String userInput; 30 | protected final List proposals; 31 | private final IRegion replacementRegion; 32 | protected final HashSet addedProposals = new HashSet(); 33 | 34 | public CompletionMatchVisitor(IFile file, String userInput, List proposals, IRegion replacementRegion) { 35 | super(file); 36 | this.userInput = userInput; 37 | this.proposals = proposals; 38 | this.replacementRegion = replacementRegion; 39 | } 40 | 41 | protected void addProposal(String proposal, FileWithType proposalLocation) { 42 | Image image = null; 43 | String displayString = getDisplayString(proposal, proposalLocation); 44 | String replacementString = proposal; 45 | String additionalProposalInfo = "I recommend: " + replacementString; 46 | String informationDisplayString = "You chose: " + replacementString; 47 | proposals.add(new RobotCompletionProposal(proposal, proposalLocation, replacementRegion, image, displayString, informationDisplayString, additionalProposalInfo)); 48 | addedProposals.add(proposal.toLowerCase()); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/structure/api/ITestCaseDefinition.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.structure.api; 17 | 18 | import java.util.List; 19 | 20 | public interface ITestCaseDefinition extends IKeywordSequence { 21 | 22 | /** 23 | * @return may return the special keyword "NONE" to override suite-default 24 | * tags declared with {@link IRobotFileContents#getDefaultTestTags()}. 25 | */ 26 | List getDeclaredStaticTags(); 27 | 28 | /** 29 | * Calculated by combining {@link IRobotFileContents#getForcedTestTags()} with 30 | * either {@link IRobotFileContents#getDefaultTestTags()} or 31 | * {@link #getDeclaredStaticTags()}. 32 | * 33 | * Please note that additional tags can be given from the command line, and 34 | * the tag set can also be manipulated dynamically when the test case 35 | * executes. These are not included in the returned set, only the "static" 36 | * tags as defined above. 37 | * 38 | * @return the "effective" set of static tags for this keyword. 39 | */ 40 | List getDeclaredAndInheritedStaticTags(); 41 | 42 | /** 43 | * Since Robot Framework 2.5.6, the {@link IKeywordCall#getKeyword()} may 44 | * exceptionally return one of the special values "" or "NONE" when the user 45 | * wants to override the file-default test setup with a no-op. (It's unknown 46 | * why the "No Operation" keyword wasn't reused). 47 | */ 48 | IKeywordCall getTestSetup(); 49 | 50 | /** 51 | * Same special circumstances as documented in {@link #getTestSetup()} 52 | * apply. 53 | */ 54 | IKeywordCall getTestTeardown(); 55 | 56 | /** 57 | * Since Robot Framework 2.5.6, the special template "NONE" indicates no 58 | * template should be used. 59 | */ 60 | IParsedKeywordString getTemplate(); // not dynamic 61 | 62 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/editors/util/TokenQueue.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.editors.util; 17 | 18 | import java.util.LinkedList; 19 | import java.util.List; 20 | 21 | import org.eclipse.jface.text.rules.IToken; 22 | import org.eclipse.jface.text.rules.Token; 23 | 24 | import com.nitorcreations.robotframework.eclipseide.structure.ParsedString; 25 | 26 | public class TokenQueue { 27 | private final List pendingTokens = new LinkedList(); 28 | private int nextTokenStart = 0; 29 | private int curTokenOff, curTokenLen; 30 | 31 | public void reset() { 32 | nextTokenStart = 0; 33 | assert pendingTokens.isEmpty(); 34 | pendingTokens.clear(); 35 | curTokenOff = curTokenLen = 0; 36 | } 37 | 38 | public IToken take() { 39 | PendingToken removed = pendingTokens.remove(0); 40 | curTokenOff += curTokenLen; 41 | curTokenLen = removed.len; 42 | assert removed.token != null; 43 | return removed.token; 44 | } 45 | 46 | public void addEof() { 47 | addToken(0, Token.EOF); 48 | } 49 | 50 | public boolean hasPending() { 51 | return !pendingTokens.isEmpty(); 52 | } 53 | 54 | public void add(ParsedString arg, IToken token) { 55 | add(arg.getArgCharPos(), arg.getArgEndCharPos(), token); 56 | } 57 | 58 | public void add(int off, int eoff, IToken token) { 59 | if (off > nextTokenStart) { 60 | addToken(off - nextTokenStart, Token.UNDEFINED); 61 | } 62 | addToken(eoff - off, token); 63 | nextTokenStart = eoff; 64 | } 65 | 66 | private void addToken(int len, IToken token) { 67 | pendingTokens.add(new PendingToken(token, len)); 68 | } 69 | 70 | public int getLastTakenTokenOffset() { 71 | return curTokenOff; 72 | } 73 | 74 | public int getLastTakenTokenLength() { 75 | return curTokenLen; 76 | } 77 | 78 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/structure/api/ISettings.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.structure.api; 17 | 18 | import java.util.List; 19 | import java.util.Map; 20 | 21 | public interface ISettings { 22 | 23 | // suite stuff 24 | 25 | List getResourceFiles(); 26 | 27 | Map> getVariableFiles(); 28 | 29 | /** 30 | * Libraries to load, mapping to their arguments. TODO a library can be 31 | * loaded many times with different names (see section 2.4.2) 32 | */ 33 | Map getLibraryFiles(); 34 | 35 | @NotAllowedInResourceFiles 36 | IKeywordCall getSuiteSetup(); 37 | 38 | @NotAllowedInResourceFiles 39 | IKeywordCall getSuiteTeardown(); 40 | 41 | List getDocumentation(); 42 | 43 | @NotAllowedInResourceFiles 44 | Map> getMetadata(); 45 | 46 | // test case stuff 47 | 48 | @NotAllowedInResourceFiles 49 | List getForcedTestTags(); 50 | 51 | @NotAllowedInResourceFiles 52 | @NotAllowedInTestSuiteInitializationFiles("2.5") 53 | List getDefaultTestTags(); 54 | 55 | @NotAllowedInResourceFiles 56 | IKeywordCall getDefaultTestSetup(); 57 | 58 | @NotAllowedInResourceFiles 59 | IKeywordCall getDefaultTestTeardown(); 60 | 61 | @NotAllowedInResourceFiles 62 | @NotAllowedInTestSuiteInitializationFiles("2.5") 63 | IParsedKeywordString getTemplate(); // not dynamic 64 | 65 | /** 66 | * Since 2.5.6, the special keyword "NONE" can be used. 67 | */ 68 | @NotAllowedInResourceFiles 69 | @NotAllowedInTestSuiteInitializationFiles("2.5") 70 | IDynamicParsedString getDefaultTestTimeout(); 71 | 72 | @NotAllowedInResourceFiles 73 | @NotAllowedInTestSuiteInitializationFiles("2.5") 74 | IParsedString getDefaultTestTimeoutMessage(); 75 | 76 | } 77 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/assistant/proposalgenerator/VariableAttemptVisitor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.assistant.proposalgenerator; 17 | 18 | import org.eclipse.core.resources.IFile; 19 | import org.eclipse.jface.text.IRegion; 20 | 21 | import com.nitorcreations.robotframework.eclipseide.internal.util.DefinitionFinder; 22 | 23 | public class VariableAttemptVisitor implements AttemptVisitor { 24 | private final IFile file; 25 | private final int maxVariableCharPos; 26 | private final int maxSettingCharPos; 27 | 28 | public VariableAttemptVisitor(IFile file, int maxVariableCharPos, int maxSettingCharPos) { 29 | this.file = file; 30 | this.maxVariableCharPos = maxVariableCharPos; 31 | this.maxSettingCharPos = maxSettingCharPos; 32 | } 33 | 34 | @Override 35 | public RobotCompletionProposalSet visitAttempt(String attempt, IRegion replacementRegion) { 36 | assert attempt.equals(attempt.toLowerCase()); 37 | RobotCompletionProposalSet ourProposalSet = new RobotCompletionProposalSet(); 38 | CompletionMatchVisitor visitor = new VariableCompletionMatchVisitor(file, attempt, ourProposalSet.getProposals(), replacementRegion, maxVariableCharPos, maxSettingCharPos); 39 | DefinitionFinder.acceptMatches(file, visitor); 40 | if (replacementRegion.getLength() > 0) { 41 | // the cursor is positioned for replacing a variable, so mark the variable proposals high priority 42 | ourProposalSet.setPriorityProposal(); 43 | } 44 | return ourProposalSet; 45 | 46 | // TODO 47 | // if (replacementRegion.getLength() > 0) { 48 | // // the cursor is positioned for replacing a variable, so put the variable proposals first 49 | // proposalSets.add(0, variableProposals); 50 | // } else { 51 | // // default positioning of proposals 52 | // proposalSets.add(variableProposals); 53 | // } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/structure/UserKeywordDefinition.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.structure; 17 | 18 | import java.util.Collections; 19 | import java.util.List; 20 | 21 | import com.nitorcreations.robotframework.eclipseide.structure.api.IDynamicParsedString; 22 | import com.nitorcreations.robotframework.eclipseide.structure.api.IKeywordCall; 23 | import com.nitorcreations.robotframework.eclipseide.structure.api.IUserKeywordDefinition; 24 | 25 | public class UserKeywordDefinition extends KeywordSequence implements IUserKeywordDefinition { 26 | 27 | private IDynamicParsedString sequenceName; 28 | private List argumentsIMM; 29 | private List returnValuesIMM; 30 | private IKeywordCall keywordTeardown; 31 | 32 | // singles 33 | 34 | public void setSequenceName(IDynamicParsedString sequenceName) { 35 | this.sequenceName = sequenceName; 36 | } 37 | 38 | public void setKeywordTeardown(IKeywordCall keywordTeardown) { 39 | this.keywordTeardown = keywordTeardown; 40 | } 41 | 42 | // lists 43 | 44 | public void setArguments(List arguments) { 45 | this.argumentsIMM = Collections.unmodifiableList(arguments); 46 | } 47 | 48 | public void setReturnValues(List returnValues) { 49 | this.returnValuesIMM = Collections.unmodifiableList(returnValues); 50 | } 51 | 52 | // getters 53 | 54 | @Override 55 | public IDynamicParsedString getSequenceName() { 56 | return sequenceName; 57 | } 58 | 59 | @Override 60 | public List getArguments() { 61 | return argumentsIMM; 62 | } 63 | 64 | @Override 65 | public List getReturnValues() { 66 | return returnValuesIMM; 67 | } 68 | 69 | @Override 70 | public IKeywordCall getKeywordTeardown() { 71 | return keywordTeardown; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/assistant/proposalgenerator/VisitorInfo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.assistant.proposalgenerator; 17 | 18 | import com.nitorcreations.robotframework.eclipseide.structure.ParsedString; 19 | 20 | public class VisitorInfo { 21 | public final AttemptVisitor visitior; 22 | public final ParsedString visitorArgument; 23 | 24 | public VisitorInfo(ParsedString visitorArgument, AttemptVisitor visitor) { 25 | if (visitorArgument == null || visitor == null) { 26 | throw new IllegalArgumentException("visitorArgument=" + visitorArgument + " visitor=" + visitor); 27 | } 28 | this.visitior = visitor; 29 | this.visitorArgument = visitorArgument; 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return "VisitorInfo [visitior=" + visitior + ", visitorArgument=" + visitorArgument + "]"; 35 | } 36 | 37 | @Override 38 | public int hashCode() { 39 | final int prime = 31; 40 | int result = 1; 41 | result = prime * result + ((visitior == null) ? 0 : visitior.hashCode()); 42 | result = prime * result + ((visitorArgument == null) ? 0 : visitorArgument.hashCode()); 43 | return result; 44 | } 45 | 46 | @Override 47 | public boolean equals(Object obj) { 48 | if (this == obj) 49 | return true; 50 | if (obj == null) 51 | return false; 52 | if (getClass() != obj.getClass()) 53 | return false; 54 | VisitorInfo other = (VisitorInfo) obj; 55 | if (visitior == null) { 56 | if (other.visitior != null) 57 | return false; 58 | } else if (!visitior.equals(other.visitior)) 59 | return false; 60 | if (visitorArgument == null) { 61 | if (other.visitorArgument != null) 62 | return false; 63 | } else if (!visitorArgument.equals(other.visitorArgument)) 64 | return false; 65 | return true; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/rules/VariableUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.rules; 17 | 18 | public final class VariableUtils { 19 | 20 | /** 21 | * Finds the start of the next variable, when scanning from the offset 22 | * given. The name of the variable must be at least one character for it to 23 | * be detected as a link. 24 | * 25 | * @param line 26 | * the line to scan 27 | * @param start 28 | * the position to start scanning on 29 | * @return the position at which the next variable starts, or -1 if no more 30 | * variables are found. 31 | */ 32 | public static int findNextVariableStart(String line, int start) { 33 | for (; start < line.length() - 3; ++start) { 34 | if (line.charAt(start) == '$' && line.charAt(start + 1) == '{') { 35 | return start; 36 | } 37 | if (line.charAt(start) == '#') { 38 | return -1; 39 | } 40 | if (line.charAt(start) == '\\') { 41 | // skip next character, possibly $ 42 | ++start; 43 | } 44 | } 45 | return -1; 46 | } 47 | 48 | /** 49 | * Calculate the length of the variable starting at the given position, or 50 | * -1 if the variable does not end with }. 51 | * 52 | * @param line 53 | * the line to scan 54 | * @param start 55 | * the start position of the variable 56 | * @return the number of characters in the variable 57 | */ 58 | public static int calculateVariableLength(String line, int start) { 59 | final int origStart = start; 60 | for (; start < line.length(); ++start) { 61 | if (line.charAt(start) == '}') { 62 | return start - origStart + 1; 63 | } 64 | if (line.charAt(start) == '\\') { 65 | // skip next character, possibly } 66 | ++start; 67 | } 68 | } 69 | // if we get here, variable did not end with } 70 | return -1; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/hyperlinks/Hyperlink.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.hyperlinks; 17 | 18 | import org.eclipse.core.resources.IFile; 19 | import org.eclipse.jface.text.IRegion; 20 | import org.eclipse.jface.text.hyperlink.IHyperlink; 21 | import org.eclipse.ui.IEditorPart; 22 | import org.eclipse.ui.texteditor.AbstractTextEditor; 23 | 24 | import com.nitorcreations.robotframework.eclipseide.PluginContext; 25 | import com.nitorcreations.robotframework.eclipseide.internal.util.FileWithType; 26 | 27 | public class Hyperlink implements IHyperlink { 28 | 29 | protected final IRegion linkRegion; 30 | protected final String linkText; 31 | private final IRegion targetRegion; 32 | private final IFile targetFile; 33 | private final boolean isRobotFile; 34 | 35 | public Hyperlink(IRegion linkRegion, String linkText, IRegion targetRegion, FileWithType targetFileWithType) { 36 | if (targetFileWithType == null) { 37 | throw new IllegalArgumentException("targetFileWithType can't be null"); 38 | } 39 | if (targetFileWithType.getFile() == null) { 40 | throw new IllegalArgumentException("targetFileWithType.getFile() can't be null"); 41 | } 42 | this.linkRegion = linkRegion; 43 | this.linkText = linkText; 44 | this.targetRegion = targetRegion; 45 | this.targetFile = targetFileWithType.getFile(); 46 | this.isRobotFile = targetFileWithType.isRobotFile(); 47 | } 48 | 49 | @Override 50 | public IRegion getHyperlinkRegion() { 51 | return linkRegion; 52 | } 53 | 54 | @Override 55 | public String getTypeLabel() { 56 | return null; 57 | } 58 | 59 | @Override 60 | public String getHyperlinkText() { 61 | return linkText; 62 | } 63 | 64 | @Override 65 | public void open() { 66 | IEditorPart editor = PluginContext.getResourceManager().openOrReuseEditorFor(targetFile, isRobotFile); 67 | if (targetRegion != null) { 68 | ((AbstractTextEditor) editor).selectAndReveal(targetRegion.getOffset(), targetRegion.getLength()); 69 | } 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/preferences/PreferenceConstants.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.preferences; 17 | 18 | /** 19 | * Constant definitions for plug-in preferences 20 | */ 21 | public class PreferenceConstants { 22 | 23 | private static final String base = "com.nitorcreations.robotframework.eclipseide.preferences."; 24 | private static final String baseSyntaxColoring = base + "syntaxcoloring."; 25 | private static final String baseTableNaming = base + "tablenaming."; 26 | 27 | public static final String P_COMMENT = baseSyntaxColoring + "comment"; 28 | public static final String P_TABLE = baseSyntaxColoring + "table"; 29 | public static final String P_SETTING = baseSyntaxColoring + "setting"; 30 | public static final String P_SETTING_VALUE = baseSyntaxColoring + "setting_value"; 31 | public static final String P_SETTING_FILE = baseSyntaxColoring + "setting_file"; 32 | public static final String P_SETTING_FILE_ARG = baseSyntaxColoring + "setting_file_arg"; 33 | public static final String P_SETTING_FILE_WITH_NAME = baseSyntaxColoring + "setting_file_with_name"; 34 | public static final String P_VARIABLE = baseSyntaxColoring + "variable"; 35 | public static final String P_VARIABLE_VALUE = baseSyntaxColoring + "variable_value"; 36 | public static final String P_TESTCASE_NEW = baseSyntaxColoring + "testcase_new"; 37 | public static final String P_KEYWORD_NEW = baseSyntaxColoring + "keyword_new"; 38 | public static final String P_KEYWORD_LVALUE = baseSyntaxColoring + "keyword_lvalue"; 39 | public static final String P_KEYWORD = baseSyntaxColoring + "keyword"; 40 | public static final String P_KEYWORD_ARG = baseSyntaxColoring + "keyword_arg"; 41 | public static final String P_FOR_PART = baseSyntaxColoring + "for_part"; 42 | 43 | public static final String P_VARIABLE_TABLE_FORMAT = baseTableNaming + "variableTableFormat"; 44 | public static final String P_SETTING_TABLE_FORMAT = baseTableNaming + "settingTableFormat"; 45 | public static final String P_TESTCASE_TABLE_FORMAT = baseTableNaming + "testcaseTableFormat"; 46 | public static final String P_KEYWORD_TABLE_FORMAT = baseTableNaming + "keywordTableFormat"; 47 | } 48 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/hyperlinks/ResourceHyperlinkDetector.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.hyperlinks; 17 | 18 | import java.util.List; 19 | 20 | import org.eclipse.core.resources.IFile; 21 | import org.eclipse.jface.text.IRegion; 22 | import org.eclipse.jface.text.Region; 23 | import org.eclipse.jface.text.hyperlink.IHyperlink; 24 | 25 | import com.nitorcreations.robotframework.eclipseide.PluginContext; 26 | import com.nitorcreations.robotframework.eclipseide.builder.parser.RobotLine; 27 | import com.nitorcreations.robotframework.eclipseide.internal.util.FileType; 28 | import com.nitorcreations.robotframework.eclipseide.internal.util.FileWithType; 29 | import com.nitorcreations.robotframework.eclipseide.structure.ParsedString; 30 | 31 | /** 32 | * This hyperlink detector creates hyperlinks for resource references, e.g. 33 | *
    34 | *
  • Resource foo.txt - "foo.txt" is linked
  • 35 | *
  • Variables  foo.py  argument - "foo.py" is linked
  • 36 | *
37 | */ 38 | public class ResourceHyperlinkDetector extends HyperlinkDetector { 39 | 40 | @Override 41 | protected void getLinks(IFile file, RobotLine rfeLine, ParsedString argument, int offset, List links) { 42 | boolean isResourceSetting = rfeLine.isResourceSetting(); 43 | boolean isVariableSetting = rfeLine.isVariableSetting(); 44 | if (!isResourceSetting && !isVariableSetting) { 45 | return; 46 | } 47 | ParsedString secondArgument = rfeLine.arguments.get(1); 48 | if (argument != secondArgument) { 49 | return; 50 | } 51 | String linkString = argument.getUnescapedValue(); 52 | IFile targetFile = PluginContext.getResourceManager().getRelativeFile(file, linkString); 53 | if (!targetFile.exists()) { 54 | return; 55 | } 56 | IRegion linkRegion = new Region(argument.getArgCharPos(), argument.getValue().length()); 57 | FileType targetType = isResourceSetting ? FileType.RESOURCE : FileType.VARIABLE; 58 | FileWithType targetFileWithType = new FileWithType(targetType, targetFile); 59 | links.add(new Hyperlink(linkRegion, linkString, null, targetFileWithType)); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/DefinitionFinder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.util; 17 | 18 | import java.util.Collections; 19 | import java.util.Set; 20 | 21 | import org.eclipse.core.resources.IFile; 22 | 23 | import com.nitorcreations.robotframework.eclipseide.builder.parser.LineType; 24 | import com.nitorcreations.robotframework.eclipseide.builder.parser.RobotLine; 25 | 26 | public class DefinitionFinder { 27 | 28 | private static class LineMatchVisitorAdapter implements LineMatchVisitor { 29 | 30 | private final DefinitionMatchVisitor delegate; 31 | 32 | LineMatchVisitorAdapter(DefinitionMatchVisitor delegate) { 33 | this.delegate = delegate; 34 | } 35 | 36 | @Override 37 | public VisitorInterest visitMatch(RobotLine line, FileWithType lineLocation) { 38 | return delegate.visitMatch(line.arguments.get(0), lineLocation); 39 | } 40 | 41 | @Override 42 | public Set getWantedLineTypes() { 43 | return Collections.singleton(delegate.getWantedLineType()); 44 | } 45 | 46 | @Override 47 | public boolean wantsLibraryKeywords() { 48 | return delegate.getWantedLineType() == LineType.KEYWORD_TABLE_KEYWORD_BEGIN; 49 | } 50 | 51 | @Override 52 | public boolean wantsLibraryVariables() { 53 | return delegate.getWantedLineType() == LineType.VARIABLE_TABLE_LINE; 54 | } 55 | 56 | @Override 57 | public boolean visitImport(IFile currentFile, RobotLine line) { 58 | return delegate.visitImport(currentFile, line); 59 | } 60 | 61 | } 62 | 63 | /** 64 | * This iterates the given resource file and recursively included resource files to locate definitions of keywords 65 | * and global variables. It passes the matches to the given {@link DefinitionMatchVisitor} instance. 66 | * 67 | * @param file 68 | * the starting file 69 | * @param visitor 70 | * the visitor of the matches found 71 | */ 72 | public static void acceptMatches(IFile file, DefinitionMatchVisitor visitor) { 73 | LineFinder.acceptMatches(file, new LineMatchVisitorAdapter(visitor)); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/editors/ColorManager.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.editors; 17 | 18 | import java.util.HashMap; 19 | import java.util.HashSet; 20 | import java.util.Iterator; 21 | import java.util.Map; 22 | import java.util.Set; 23 | 24 | import org.eclipse.jface.preference.IPreferenceStore; 25 | import org.eclipse.jface.util.IPropertyChangeListener; 26 | import org.eclipse.jface.util.PropertyChangeEvent; 27 | import org.eclipse.swt.graphics.Color; 28 | import org.eclipse.swt.graphics.RGB; 29 | import org.eclipse.swt.widgets.Display; 30 | 31 | import com.nitorcreations.robotframework.eclipseide.Activator; 32 | 33 | public class ColorManager { 34 | 35 | protected Set colorPreferences = new HashSet(); 36 | protected Map fColorTable = new HashMap(10); 37 | private boolean listenerRegistered; 38 | 39 | public void dispose() { 40 | Iterator e = fColorTable.values().iterator(); 41 | while (e.hasNext()) 42 | e.next().dispose(); 43 | fColorTable.clear(); 44 | } 45 | 46 | public Color getColor(String preferenceId) { 47 | colorPreferences.add(preferenceId); 48 | IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); 49 | if (!listenerRegistered) { 50 | preferenceStore.addPropertyChangeListener(new IPropertyChangeListener() { 51 | @Override 52 | public void propertyChange(PropertyChangeEvent event) { 53 | dispose(); 54 | } 55 | }); 56 | listenerRegistered = true; 57 | } 58 | String rgbString = preferenceStore.getString(preferenceId); 59 | String[] rgbArr = rgbString.split(","); 60 | RGB irftColor = new RGB(Integer.parseInt(rgbArr[0]), Integer.parseInt(rgbArr[1]), Integer.parseInt(rgbArr[2])); 61 | Color color = fColorTable.get(irftColor); 62 | if (color == null) { 63 | color = new Color(Display.getCurrent(), irftColor); 64 | fColorTable.put(irftColor, color); 65 | } 66 | return color; 67 | } 68 | 69 | public boolean isColorPreference(String preferenceId) { 70 | return colorPreferences.contains(preferenceId); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/assistant/proposalgenerator/VariableCompletionMatchVisitor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.assistant.proposalgenerator; 17 | 18 | import java.util.List; 19 | 20 | import org.eclipse.core.resources.IFile; 21 | import org.eclipse.jface.text.IRegion; 22 | 23 | import com.nitorcreations.robotframework.eclipseide.builder.parser.LineType; 24 | import com.nitorcreations.robotframework.eclipseide.builder.parser.RobotLine; 25 | import com.nitorcreations.robotframework.eclipseide.internal.util.FileWithType; 26 | import com.nitorcreations.robotframework.eclipseide.internal.util.VisitorInterest; 27 | import com.nitorcreations.robotframework.eclipseide.structure.ParsedString; 28 | 29 | public class VariableCompletionMatchVisitor extends CompletionMatchVisitor { 30 | 31 | private final int maxVariableCharPos; 32 | private final int maxSettingCharPos; 33 | 34 | public VariableCompletionMatchVisitor(IFile file, String userInput, List proposals, IRegion replacementRegion, int maxVariableCharPos, int maxSettingCharPos) { 35 | super(file, userInput, proposals, replacementRegion); 36 | this.maxVariableCharPos = maxVariableCharPos; 37 | this.maxSettingCharPos = maxSettingCharPos; 38 | } 39 | 40 | @Override 41 | public VisitorInterest visitMatch(ParsedString match, FileWithType matchLocation) { 42 | if (match.getArgCharPos() > maxVariableCharPos) { 43 | return VisitorInterest.STOP; 44 | } 45 | 46 | if (userInput == null || match.getUnescapedValue().toLowerCase().contains(getUnescapedUserInputLowerCase())) { 47 | if (!addedProposals.contains(match.getValue().toLowerCase())) { 48 | addProposal(match.getValue(), matchLocation); 49 | } 50 | } 51 | 52 | return VisitorInterest.CONTINUE; 53 | } 54 | 55 | private String getUnescapedUserInputLowerCase() { 56 | return new ParsedString(userInput, 0).getUnescapedValue().toLowerCase(); 57 | } 58 | 59 | @Override 60 | public LineType getWantedLineType() { 61 | return LineType.VARIABLE_TABLE_LINE; 62 | } 63 | 64 | @Override 65 | public boolean visitImport(IFile sourceFile, RobotLine line) { 66 | return line.lineCharPos <= maxSettingCharPos; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/structure/KeywordSequence.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.structure; 17 | 18 | import java.util.ArrayList; 19 | import java.util.Collections; 20 | import java.util.List; 21 | 22 | import com.nitorcreations.robotframework.eclipseide.structure.api.IDynamicParsedString; 23 | import com.nitorcreations.robotframework.eclipseide.structure.api.IKeywordCall; 24 | import com.nitorcreations.robotframework.eclipseide.structure.api.IKeywordSequence; 25 | import com.nitorcreations.robotframework.eclipseide.structure.api.IParsedString; 26 | 27 | public abstract class KeywordSequence implements IKeywordSequence { 28 | 29 | private List documentationIMM; 30 | private IDynamicParsedString timeout; 31 | private IParsedString timeoutMessage; 32 | private List keywordCalls; 33 | 34 | // immutable versions of above returned by getters 35 | private List keywordCallsIMM; 36 | 37 | // singles 38 | 39 | public void setTimeout(IDynamicParsedString timeout) { 40 | this.timeout = timeout; 41 | } 42 | 43 | public void setTimeoutMessage(IParsedString timeoutMessage) { 44 | this.timeoutMessage = timeoutMessage; 45 | } 46 | 47 | // lists 48 | 49 | public void setDocumentation(List documentation) { 50 | this.documentationIMM = Collections.unmodifiableList(documentation); 51 | } 52 | 53 | public void addKeywordCall(IKeywordCall keywordCall) { 54 | if (this.keywordCalls == null) { 55 | this.keywordCalls = new ArrayList(); 56 | this.keywordCallsIMM = Collections.unmodifiableList(this.keywordCalls); 57 | } 58 | this.keywordCalls.add(keywordCall); 59 | } 60 | 61 | // getters 62 | 63 | @Override 64 | public abstract IParsedString getSequenceName(); 65 | 66 | @Override 67 | public List getDocumentation() { 68 | return documentationIMM; 69 | } 70 | 71 | @Override 72 | public IDynamicParsedString getTimeout() { 73 | return timeout; 74 | } 75 | 76 | @Override 77 | public IParsedString getTimeoutMessage() { 78 | return timeoutMessage; 79 | } 80 | 81 | @Override 82 | public List getKeywordCalls() { 83 | return keywordCallsIMM; 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/preferences/MainPreferencePage.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.preferences; 17 | 18 | import org.eclipse.jface.preference.FieldEditorPreferencePage; 19 | import org.eclipse.ui.IWorkbench; 20 | import org.eclipse.ui.IWorkbenchPreferencePage; 21 | 22 | import com.nitorcreations.robotframework.eclipseide.Activator; 23 | 24 | /** 25 | * This class represents a preference page that is contributed to the Preferences dialog. By subclassing 26 | * FieldEditorPreferencePage, we can use the field support built into JFace that allows us to create a page 27 | * that is small and knows how to save, restore and apply itself. 28 | *

29 | * This page is used to modify preferences only. They are stored in the preference store that belongs to the main 30 | * plug-in class. That way, preferences can be accessed directly via the preference store. 31 | */ 32 | public class MainPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { 33 | 34 | public MainPreferencePage() { 35 | super(GRID); 36 | setPreferenceStore(Activator.getDefault().getPreferenceStore()); 37 | setDescription("General preferences for the Robot Framework editor - see subpages."); 38 | } 39 | 40 | /** 41 | * Creates the field editors. Field editors are abstractions of the common GUI blocks needed to manipulate various 42 | * types of preferences. Each field editor knows how to save and restore itself. 43 | */ 44 | @Override 45 | public void createFieldEditors() { 46 | // addField(new DirectoryFieldEditor(PreferenceConstants.P_PATH, "&Directory preference:", 47 | // getFieldEditorParent())); 48 | // addField(new BooleanFieldEditor(PreferenceConstants.P_BOOLEAN, "&An example of a boolean preference", 49 | // getFieldEditorParent())); 50 | // 51 | // addField(new RadioGroupFieldEditor(PreferenceConstants.P_CHOICE, 52 | // "An example of a multiple-choice preference", 1, new String[][] { { "&Choice 1", "choice1" }, { "C&hoice 2", 53 | // "choice2" } }, getFieldEditorParent())); 54 | // addField(new StringFieldEditor(PreferenceConstants.P_STRING, "A &text preference:", getFieldEditorParent())); 55 | // addField(new ColorFieldEditor(PreferenceConstants.P_COLOR, "&Color", getFieldEditorParent())); 56 | } 57 | 58 | @Override 59 | public void init(IWorkbench workbench) {} 60 | 61 | } -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/assistant/proposalgenerator/AttemptGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.assistant.proposalgenerator; 17 | 18 | import java.util.ArrayList; 19 | import java.util.Collection; 20 | import java.util.List; 21 | 22 | import org.eclipse.jface.text.IRegion; 23 | import org.eclipse.jface.text.Region; 24 | 25 | import com.nitorcreations.robotframework.eclipseide.structure.ParsedString; 26 | 27 | public class AttemptGenerator implements IAttemptGenerator { 28 | 29 | @Override 30 | public void acceptAttempts(ParsedString argument, int documentOffset, Collection proposalSets, AttemptVisitor attemptVisitor) { 31 | IRegion replacementRegion = new Region(argument.getArgCharPos(), argument.getValue().length()); 32 | List attempts = generateAttempts(argument, documentOffset); 33 | for (String attempt : attempts) { 34 | RobotCompletionProposalSet proposalSet = attemptVisitor.visitAttempt(attempt, replacementRegion); 35 | if (proposalsContainsOnly(proposalSet.getProposals(), argument)) { 36 | // Found a single exact hit - probably means it was content-assisted earlier and the user now wants to 37 | // change it to something else 38 | continue; 39 | } 40 | if (!proposalSet.getProposals().isEmpty()) { 41 | proposalSet.setBasedOnInput(!attempt.isEmpty()); 42 | proposalSets.add(proposalSet); 43 | return; 44 | } 45 | } 46 | } 47 | 48 | private static boolean proposalsContainsOnly(List proposals, ParsedString argument) { 49 | return proposals.size() == 1 && proposals.get(0).getMatchArgument().equals(argument.getValue()); 50 | } 51 | 52 | private static List generateAttempts(ParsedString argument, int documentOffset) { 53 | String lookFor = argument.getValue().toLowerCase(); 54 | List attempts = new ArrayList(3); 55 | attempts.add(lookFor); 56 | int argumentOffset = documentOffset - argument.getArgCharPos(); 57 | if (argumentOffset > 0 && lookFor.length() > argumentOffset) { 58 | attempts.add(lookFor.substring(0, argumentOffset)); 59 | } 60 | if (!lookFor.isEmpty()) { 61 | attempts.add(""); 62 | } 63 | return attempts; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/editors/Resource.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.editors; 17 | 18 | import java.io.File; 19 | import java.util.ArrayList; 20 | import java.util.LinkedHashMap; 21 | import java.util.List; 22 | import java.util.Map; 23 | 24 | import com.nitorcreations.robotframework.eclipseide.PluginContext; 25 | 26 | /** 27 | * A representation of a robot framework file, which is here called a 28 | * "resource". 29 | * 30 | * @author xkr47 31 | */ 32 | public class Resource { 33 | 34 | /** 35 | * The resource. 36 | */ 37 | public final File resourceFile; 38 | 39 | /** 40 | * The list of included resource files. 41 | */ 42 | public final List includedResources = new ArrayList(); 43 | 44 | /** 45 | * Map of defined variables, mapping to line numbers. 46 | */ 47 | public final Map definedVariables = new LinkedHashMap(); 48 | 49 | /** 50 | * Map of defined keywords, mapping to line numbers. 51 | */ 52 | public final Map definedKeywords = new LinkedHashMap(); 53 | 54 | public Resource(File resourceFile) { 55 | this.resourceFile = resourceFile; 56 | } 57 | 58 | public ResourceLocation findVariable(String name) { 59 | Integer line = definedVariables.get(name); 60 | if (line != null) { 61 | return new ResourceLocation(this, line); 62 | } 63 | for (File f : includedResources) { 64 | Resource r = PluginContext.getResourceManager().getResource(f); 65 | if (r == null) { 66 | continue; 67 | } 68 | ResourceLocation l = r.findVariable(name); 69 | if (l != null) { 70 | return l; 71 | } 72 | } 73 | return null; 74 | } 75 | 76 | public ResourceLocation findKeyword(String name) { 77 | Integer line = definedKeywords.get(name); 78 | if (line != null) { 79 | return new ResourceLocation(this, line); 80 | } 81 | for (File f : includedResources) { 82 | Resource r = PluginContext.getResourceManager().getResource(f); 83 | if (r == null) { 84 | continue; 85 | } 86 | ResourceLocation l = r.findKeyword(name); 87 | if (l != null) { 88 | return l; 89 | } 90 | } 91 | return null; 92 | } 93 | 94 | public void loadFromDisk() { 95 | // TODO 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/hyperlinks/LibraryHyperlinkDetector.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Nitor Creations Oy, SmallGreenET 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.hyperlinks; 17 | 18 | import java.util.List; 19 | import java.util.Map; 20 | import java.util.Map.Entry; 21 | 22 | import org.eclipse.core.resources.IFile; 23 | import org.eclipse.core.runtime.IPath; 24 | import org.eclipse.jface.text.IRegion; 25 | import org.eclipse.jface.text.Region; 26 | import org.eclipse.jface.text.hyperlink.IHyperlink; 27 | 28 | import com.nitorcreations.robotframework.eclipseide.PluginContext; 29 | import com.nitorcreations.robotframework.eclipseide.builder.parser.RobotLine; 30 | import com.nitorcreations.robotframework.eclipseide.internal.util.FileType; 31 | import com.nitorcreations.robotframework.eclipseide.internal.util.FileWithType; 32 | import com.nitorcreations.robotframework.eclipseide.structure.ParsedString; 33 | import com.nitorcreations.robotframework.eclipseide.structure.ParsedString.ArgumentType; 34 | 35 | /** 36 | * This hyperlink detector creates hyperlinks for library references in any projects of the workspace, e.g. 37 | *

    38 | *
  • Library com.company.TestLib - "TestLib.java" is linked
  • 39 | *
40 | */ 41 | public class LibraryHyperlinkDetector extends HyperlinkDetector { 42 | 43 | @Override 44 | protected void getLinks(IFile file, RobotLine rfeLine, ParsedString argument, int offset, List links) { 45 | if (isLibraryLineWithFileArgument(rfeLine, argument)) { 46 | String fullyQualifiedName = argument.getUnescapedValue(); 47 | Map targetJavaFiles = PluginContext.getResourceManager().getJavaFiles(fullyQualifiedName); 48 | for (Entry targetJavaFile : targetJavaFiles.entrySet()) { 49 | String linkText = fullyQualifiedName + " in " + targetJavaFile.getValue().toString(); 50 | links.add(createLinkForArgument(argument, targetJavaFile.getKey(), linkText)); 51 | } 52 | } 53 | } 54 | 55 | private boolean isLibraryLineWithFileArgument(RobotLine rfeLine, ParsedString argument) { 56 | return rfeLine.isLibrarySetting() && argument.getType() == ArgumentType.SETTING_FILE; 57 | } 58 | 59 | private Hyperlink createLinkForArgument(ParsedString argument, IFile targetFile, String linkText) { 60 | IRegion linkRegion = new Region(argument.getArgCharPos(), argument.getValue().length()); 61 | FileWithType targetFileWithType = new FileWithType(FileType.LIBRARY, targetFile); 62 | return new Hyperlink(linkRegion, linkText, null, targetFileWithType); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/builder/RobotNature.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.builder; 17 | 18 | import org.eclipse.core.resources.ICommand; 19 | import org.eclipse.core.resources.IProject; 20 | import org.eclipse.core.resources.IProjectDescription; 21 | import org.eclipse.core.resources.IProjectNature; 22 | import org.eclipse.core.runtime.CoreException; 23 | 24 | import com.nitorcreations.robotframework.eclipseide.Activator; 25 | 26 | public class RobotNature implements IProjectNature { 27 | 28 | public static final String NATURE_ID = Activator.PLUGIN_ID + ".rfeNature"; 29 | 30 | private IProject project; 31 | 32 | @Override 33 | public void configure() throws CoreException { 34 | IProjectDescription desc = project.getDescription(); 35 | ICommand[] commands = desc.getBuildSpec(); 36 | 37 | for (int i = 0; i < commands.length; ++i) { 38 | if (commands[i].getBuilderName().equals(RobotBuilder.BUILDER_ID)) { 39 | return; 40 | } 41 | } 42 | 43 | ICommand[] newCommands = new ICommand[commands.length + 1]; 44 | System.arraycopy(commands, 0, newCommands, 0, commands.length); 45 | ICommand command = desc.newCommand(); 46 | command.setBuilderName(RobotBuilder.BUILDER_ID); 47 | newCommands[newCommands.length - 1] = command; 48 | desc.setBuildSpec(newCommands); 49 | project.setDescription(desc, null); 50 | System.out.println("Robot Framework builder now active"); 51 | } 52 | 53 | @Override 54 | public void deconfigure() throws CoreException { 55 | IProjectDescription description = getProject().getDescription(); 56 | ICommand[] commands = description.getBuildSpec(); 57 | for (int i = 0; i < commands.length; ++i) { 58 | if (commands[i].getBuilderName().equals(RobotBuilder.BUILDER_ID)) { 59 | ICommand[] newCommands = new ICommand[commands.length - 1]; 60 | System.arraycopy(commands, 0, newCommands, 0, i); 61 | System.arraycopy(commands, i + 1, newCommands, i, commands.length - i - 1); 62 | description.setBuildSpec(newCommands); 63 | project.setDescription(description, null); 64 | // TODO RFEBuilder.clearAllMarkers(); 65 | System.out.println("Robot Framework builder removed"); 66 | return; 67 | } 68 | } 69 | } 70 | 71 | @Override 72 | public IProject getProject() { 73 | return project; 74 | } 75 | 76 | @Override 77 | public void setProject(IProject project) { 78 | this.project = project; 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /plugin/src/test/java/com/nitorcreations/robotframework/eclipseide/internal/assistant/proposalgenerator/TestKeywordCallAttemptVisitor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.assistant.proposalgenerator; 17 | 18 | import static org.junit.Assert.assertEquals; 19 | import static org.junit.Assert.assertFalse; 20 | import static org.mockito.Mockito.when; 21 | 22 | import org.eclipse.core.resources.IFile; 23 | import org.eclipse.jface.text.Region; 24 | import org.junit.Test; 25 | 26 | public class TestKeywordCallAttemptVisitor extends BaseTestAttemptVisitor { 27 | static final String LINKED_PREFIX = "[linked] "; 28 | static final String LINKED_FILENAME = "linked.txt"; 29 | static final String LINKED_KEYWORD = "Say Hello"; 30 | 31 | @Test 32 | public void should_propose_keyword_from_included_resource_file() throws Exception { 33 | IFile origFile = addFile("orig.txt", "*Settings\nResource " + LINKED_FILENAME + "\n"); 34 | IFile linkedFile = addFile(LINKED_FILENAME, "*Keywords\n" + LINKED_KEYWORD + "\n"); 35 | when(resourceManager.getRelativeFile(origFile, LINKED_FILENAME)).thenReturn(linkedFile); 36 | 37 | RobotCompletionProposalSet proposalSet = new KeywordCallAttemptVisitor(origFile).visitAttempt("", new Region(0, 0)); 38 | 39 | assertEquals("Got wrong amount of proposals: " + proposalSet.getProposals(), 2, proposalSet.getProposals().size()); 40 | verifyProposal(proposalSet, 0, LINKED_PREFIX + LINKED_KEYWORD, LINKED_KEYWORD); 41 | verifyProposal(proposalSet, 1, BUILTIN_PREFIX + BUILTIN_KEYWORD, BUILTIN_KEYWORD); 42 | assertFalse("Should be false always for keyword call attempts", proposalSet.isPriorityProposal()); 43 | } 44 | 45 | @Test 46 | // #35 47 | public void should_propose_keyword_only_once_from_resource_file_included_twice() throws Exception { 48 | IFile origFile = addFile("orig.txt", "*Settings\nResource " + LINKED_FILENAME + "\nResource " + LINKED_FILENAME + "\n"); 49 | IFile linkedFile = addFile(LINKED_FILENAME, "*Keywords\n" + LINKED_KEYWORD + "\n"); 50 | when(resourceManager.getRelativeFile(origFile, LINKED_FILENAME)).thenReturn(linkedFile); 51 | 52 | RobotCompletionProposalSet proposalSet = new KeywordCallAttemptVisitor(origFile).visitAttempt("", new Region(0, 0)); 53 | 54 | assertEquals("Got wrong amount of proposals: " + proposalSet.getProposals(), 2, proposalSet.getProposals().size()); 55 | verifyProposal(proposalSet, 0, LINKED_PREFIX + LINKED_KEYWORD, LINKED_KEYWORD); 56 | verifyProposal(proposalSet, 1, BUILTIN_PREFIX + BUILTIN_KEYWORD, BUILTIN_KEYWORD); 57 | assertFalse("Should be false always for keyword call attempts", proposalSet.isPriorityProposal()); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /plugin/src/test/java/com/nitorcreations/robotframework/eclipseide/internal/assistant/proposalgenerator/TestVariableCompletionMatchVisitor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.assistant.proposalgenerator; 17 | 18 | import static junit.framework.Assert.assertEquals; 19 | import static junit.framework.Assert.assertTrue; 20 | 21 | import java.util.ArrayList; 22 | import java.util.List; 23 | 24 | import org.eclipse.jface.text.Region; 25 | import org.junit.Test; 26 | 27 | import com.nitorcreations.robotframework.eclipseide.internal.util.FileType; 28 | import com.nitorcreations.robotframework.eclipseide.internal.util.FileWithType; 29 | import com.nitorcreations.robotframework.eclipseide.internal.util.VisitorInterest; 30 | import com.nitorcreations.robotframework.eclipseide.structure.ParsedString; 31 | 32 | public class TestVariableCompletionMatchVisitor { 33 | private static final ParsedString PROPOSAL = new ParsedString("${foo}", 0); 34 | private static final FileWithType DUMMY_LOCATION = new FileWithType(FileType.LIBRARY, "TestLibrary", null); 35 | 36 | @Test 37 | public void testVisitMatchAddsProposalIfMatchIsFound() throws Exception { 38 | List proposals = new ArrayList(); 39 | VariableCompletionMatchVisitor visitor = getVisitor(proposals, "${fo"); 40 | assertEquals(VisitorInterest.CONTINUE, visitor.visitMatch(PROPOSAL, DUMMY_LOCATION)); 41 | assertEquals(1, proposals.size()); 42 | assertEquals(PROPOSAL.getValue(), proposals.get(0).getMatchArgument()); 43 | } 44 | 45 | @Test 46 | public void testVisitMatchAddsProposalIfMatchArgumentIsNull() throws Exception { 47 | List proposals = new ArrayList(); 48 | VariableCompletionMatchVisitor visitor = getVisitor(proposals, null); 49 | assertEquals(VisitorInterest.CONTINUE, visitor.visitMatch(PROPOSAL, DUMMY_LOCATION)); 50 | assertEquals(1, proposals.size()); 51 | assertEquals(PROPOSAL.getValue(), proposals.get(0).getMatchArgument()); 52 | } 53 | 54 | @Test 55 | public void testVisitMatchDoesNotAddProposalIfMatchIsNotFound() throws Exception { 56 | List proposals = new ArrayList(); 57 | VariableCompletionMatchVisitor visitor = getVisitor(proposals, "${for"); 58 | assertEquals(VisitorInterest.CONTINUE, visitor.visitMatch(PROPOSAL, DUMMY_LOCATION)); 59 | assertTrue(proposals.isEmpty()); 60 | } 61 | 62 | private VariableCompletionMatchVisitor getVisitor(List proposals, String userInput) { 63 | return new VariableCompletionMatchVisitor(null, userInput, proposals, new Region(0, 0), Integer.MAX_VALUE, Integer.MAX_VALUE); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/hyperlinks/HyperlinkDetector.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.hyperlinks; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | import org.eclipse.core.resources.IFile; 22 | import org.eclipse.jface.text.BadLocationException; 23 | import org.eclipse.jface.text.IDocument; 24 | import org.eclipse.jface.text.IRegion; 25 | import org.eclipse.jface.text.ITextViewer; 26 | import org.eclipse.jface.text.hyperlink.IHyperlink; 27 | import org.eclipse.jface.text.hyperlink.IHyperlinkDetector; 28 | 29 | import com.nitorcreations.robotframework.eclipseide.PluginContext; 30 | import com.nitorcreations.robotframework.eclipseide.builder.parser.RobotFile; 31 | import com.nitorcreations.robotframework.eclipseide.builder.parser.RobotLine; 32 | import com.nitorcreations.robotframework.eclipseide.structure.ParsedString; 33 | 34 | public abstract class HyperlinkDetector implements IHyperlinkDetector { 35 | 36 | protected List lines; 37 | 38 | /** 39 | * This detector assumes generated hyperlinks are static, i.e. the link target is calculated at detection time and 40 | * not changed even if the code would update later. 41 | */ 42 | @Override 43 | public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) { 44 | if (region == null || textViewer == null) { 45 | return null; 46 | } 47 | 48 | IDocument document = textViewer.getDocument(); 49 | if (document == null) { 50 | return null; 51 | } 52 | 53 | int offset = region.getOffset(); 54 | int lineNumber; 55 | try { 56 | lineNumber = document.getLineOfOffset(offset); 57 | } catch (BadLocationException ex) { 58 | return null; 59 | } 60 | lines = RobotFile.get(document).getLines(); 61 | List links; 62 | try { 63 | RobotLine rfeLine = lines.get(lineNumber); 64 | ParsedString argument = rfeLine.getArgumentAt(offset); 65 | if (argument == null) { 66 | return null; 67 | } 68 | IFile file = PluginContext.getResourceManager().resolveFileFor(document); 69 | links = new ArrayList(); 70 | getLinks(file, rfeLine, argument, offset, links); 71 | } finally { 72 | lines = null; 73 | } 74 | if (links.isEmpty()) { 75 | return null; 76 | } 77 | if (!canShowMultipleHyperlinks) { 78 | return new IHyperlink[] { links.get(0) }; 79 | 80 | } 81 | return links.toArray(new IHyperlink[links.size()]); 82 | } 83 | 84 | protected abstract void getLinks(IFile file, RobotLine rfeLine, ParsedString argument, int offset, List links); 85 | 86 | } 87 | -------------------------------------------------------------------------------- /plugin/src/test/java/com/nitorcreations/robotframework/eclipseide/builder/TestRobotParserWithStaticFiles.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.builder; 17 | 18 | import java.io.File; 19 | import java.lang.reflect.InvocationHandler; 20 | import java.lang.reflect.Method; 21 | import java.lang.reflect.Proxy; 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | 25 | import org.eclipse.core.resources.IMarker; 26 | import org.eclipse.core.runtime.CoreException; 27 | import org.junit.Test; 28 | import org.junit.runner.RunWith; 29 | import org.junit.runners.Parameterized.Parameters; 30 | 31 | import com.nitorcreations.junit.runners.NicelyParameterized; 32 | import com.nitorcreations.robotframework.eclipseide.builder.parser.Lexer; 33 | import com.nitorcreations.robotframework.eclipseide.builder.parser.RobotLine; 34 | import com.nitorcreations.robotframework.eclipseide.builder.parser.RobotParser; 35 | import com.nitorcreations.robotframework.eclipseide.builder.util.MarkerManager; 36 | 37 | @RunWith(NicelyParameterized.class) 38 | public class TestRobotParserWithStaticFiles { 39 | 40 | private static final class NullMarkerParser implements MarkerManager { 41 | 42 | @Override 43 | public IMarker createMarker(String type) throws CoreException { 44 | System.out.println(" New marker"); 45 | InvocationHandler handler = new InvocationHandler() { 46 | @Override 47 | public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { 48 | if (method.getName().equals("setAttribute")) { 49 | System.out.println(" " + args[0] + " = \"" + args[1] + '"'); 50 | } 51 | return null; 52 | } 53 | }; 54 | return (IMarker) Proxy.newProxyInstance(NullMarkerParser.class.getClassLoader(), new Class[] { IMarker.class }, handler); 55 | } 56 | 57 | @Override 58 | public void eraseMarkers() { 59 | // when testing partial parsing perhaps 60 | } 61 | } 62 | 63 | @Parameters 64 | public static List files() { 65 | File dir = new File("src/test/resources/RFEParser"); 66 | List files = new ArrayList(); 67 | for (File entry : dir.listFiles()) { 68 | if (entry.isFile() && entry.getName().endsWith(".txt")) { 69 | files.add(new Object[] { entry }); 70 | } 71 | } 72 | return files; 73 | } 74 | 75 | private final File file; 76 | 77 | public TestRobotParserWithStaticFiles(File file) { 78 | this.file = file; 79 | } 80 | 81 | @Test 82 | public void testFile() throws Exception { 83 | List lines = new Lexer(file, "UTF-8").lex(); 84 | new RobotParser(file, lines, new NullMarkerParser()).parse(); 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/preferences/PreferenceInitializer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.preferences; 17 | 18 | import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; 19 | import org.eclipse.jface.preference.IPreferenceStore; 20 | 21 | import com.nitorcreations.robotframework.eclipseide.Activator; 22 | 23 | /** 24 | * Class used to initialize default preference values. 25 | */ 26 | public class PreferenceInitializer extends AbstractPreferenceInitializer { 27 | 28 | /* 29 | * (non-Javadoc) 30 | * 31 | * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() 32 | */ 33 | @Override 34 | public void initializeDefaultPreferences() { 35 | IPreferenceStore store = Activator.getDefault().getPreferenceStore(); 36 | // store.setDefault(PreferenceConstants.P_BOOLEAN, true); 37 | // store.setDefault(PreferenceConstants.P_CHOICE, "choice2"); 38 | // store.setDefault(PreferenceConstants.P_STRING, "Default value"); 39 | 40 | // syntax coloring preferences 41 | // commented colors are for dark background 42 | store.setDefault(PreferenceConstants.P_COMMENT, "128,128,128"); // 128,128,128 43 | store.setDefault(PreferenceConstants.P_TABLE, "192,0,192"); // 192,0,192 44 | store.setDefault(PreferenceConstants.P_SETTING, "0,128,0"); // 0,192,0 45 | store.setDefault(PreferenceConstants.P_SETTING_VALUE, "0,192,0"); // 0,255,0 46 | store.setDefault(PreferenceConstants.P_SETTING_FILE, "0,0,0"); // 255,255,255 47 | store.setDefault(PreferenceConstants.P_SETTING_FILE_ARG, "0,192,64"); // 0,255,64 48 | store.setDefault(PreferenceConstants.P_SETTING_FILE_WITH_NAME, "192,192,192"); // 192,192,192 49 | store.setDefault(PreferenceConstants.P_VARIABLE, "0,170,180"); // 0,170,180 50 | store.setDefault(PreferenceConstants.P_VARIABLE_VALUE, "115,124,133"); // 180,192,202 51 | store.setDefault(PreferenceConstants.P_TESTCASE_NEW, "222,0,0"); // 222,0,0 52 | store.setDefault(PreferenceConstants.P_KEYWORD_NEW, "128,128,50"); // 255,255,50 53 | store.setDefault(PreferenceConstants.P_KEYWORD_LVALUE, "225,0,159"); // 255,0,180 54 | store.setDefault(PreferenceConstants.P_KEYWORD, "212,149,0"); // 255,180,0 55 | store.setDefault(PreferenceConstants.P_KEYWORD_ARG, "255,100,0"); // 255,100,0 56 | store.setDefault(PreferenceConstants.P_FOR_PART, "0,128,128"); // 0,255,255 57 | 58 | // table naming preferences 59 | store.setDefault(PreferenceConstants.P_VARIABLE_TABLE_FORMAT, "* Variables"); 60 | store.setDefault(PreferenceConstants.P_SETTING_TABLE_FORMAT, "* Settings"); 61 | store.setDefault(PreferenceConstants.P_TESTCASE_TABLE_FORMAT, "* Test Cases"); 62 | store.setDefault(PreferenceConstants.P_KEYWORD_TABLE_FORMAT, "* Keywords"); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /plugin/robot-indices/SeleniumLibrary-2.8/SeleniumLibrary.index: -------------------------------------------------------------------------------- 1 | Add Location Strategy 2 | Alert Should Be Present 3 | Assign Id To Element 4 | Call Selenium Api 5 | Capture Page Screenshot 6 | Capture Screenshot 7 | Checkbox Should Be Selected 8 | Checkbox Should Not Be Selected 9 | Choose Cancel On Next Confirmation 10 | Choose File 11 | Click Button 12 | Click Element 13 | Click Flex Element 14 | Click Image 15 | Click Link 16 | Close All Browsers 17 | Close Browser 18 | Close Window 19 | Confirm Action 20 | Current Frame Contains 21 | Current Frame Should Contain 22 | Delete All Cookies 23 | Delete Cookie 24 | Double Click Element 25 | Double Click Flex Element 26 | Drag And Drop 27 | Element Should Be Disabled 28 | Element Should Be Enabled 29 | Element Should Be Visible 30 | Element Should Contain 31 | Element Should Not Be Visible 32 | Element Text Should Be 33 | Execute Javascript 34 | Flex Element Property Should Be 35 | Flex Element Should Exist 36 | Flex Element Should Not Exist 37 | Flex Element Text Should Be 38 | Focus 39 | Frame Should Contain 40 | Frame Should Contain Text 41 | Get Alert Message 42 | Get All Links 43 | Get Cookie Value 44 | Get Cookies 45 | Get Element Attribute 46 | Get Horizontal Position 47 | Get List Items 48 | Get Location 49 | Get Matching Xpath Count 50 | Get Selected List Label 51 | Get Selected List Labels 52 | Get Selected List Value 53 | Get Selected List Values 54 | Get Source 55 | Get Table Cell 56 | Get Text 57 | Get Title 58 | Get Value 59 | Get Vertical Position 60 | Get Window Identifiers 61 | Get Window Names 62 | Get Window Titles 63 | Go Back 64 | Go To 65 | Input Password 66 | Input Text 67 | Input Text Into Flex Element 68 | List Selection Should Be 69 | List Should Have No Selections 70 | Location Should Be 71 | Location Should Contain 72 | Log Source 73 | Maximize Browser Window 74 | Mouse Down 75 | Mouse Down On Image 76 | Mouse Down On Link 77 | Mouse Out 78 | Mouse Over 79 | Mouse Up 80 | Open Browser 81 | Open Context Menu 82 | Page Should Contain 83 | Page Should Contain Button 84 | Page Should Contain Checkbox 85 | Page Should Contain Element 86 | Page Should Contain Image 87 | Page Should Contain Link 88 | Page Should Contain List 89 | Page Should Contain Radio Button 90 | Page Should Contain Textfield 91 | Page Should Not Contain 92 | Page Should Not Contain Button 93 | Page Should Not Contain Checkbox 94 | Page Should Not Contain Element 95 | Page Should Not Contain Image 96 | Page Should Not Contain Link 97 | Page Should Not Contain List 98 | Page Should Not Contain Radio Button 99 | Page Should Not Contain Textfield 100 | Press Key 101 | Press Key Native 102 | Radio Button Should Be Set To 103 | Radio Button Should Not Be Selected 104 | Register Keyword To Run On Failure 105 | Reload Page 106 | Select All From List 107 | Select Checkbox 108 | Select Flex Application 109 | Select Frame 110 | Select From Flex Element 111 | Select From List 112 | Select Radio Button 113 | Select Window 114 | Set Selenium Speed 115 | Set Selenium Timeout 116 | Simulate 117 | Start Selenium Server 118 | Stop Selenium Server 119 | Submit Form 120 | Switch Browser 121 | Table Cell Should Contain 122 | Table Column Should Contain 123 | Table Footer Should Contain 124 | Table Header Should Contain 125 | Table Row Should Contain 126 | Table Should Contain 127 | Textfield Should Contain 128 | Textfield Value Should Be 129 | Title Should Be 130 | Unselect Checkbox 131 | Unselect Frame 132 | Unselect From List 133 | Wait For Condition 134 | Wait For Flex Element 135 | Wait Until Page Contains 136 | Wait Until Page Contains Element 137 | Wait Until Page Loaded 138 | Xpath Should Match X Times 139 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/assistant/proposalgenerator/RelevantProposalsFilter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.assistant.proposalgenerator; 17 | 18 | import java.util.ArrayList; 19 | import java.util.Collection; 20 | import java.util.Iterator; 21 | import java.util.List; 22 | 23 | import org.eclipse.jface.text.contentassist.ICompletionProposal; 24 | 25 | import com.nitorcreations.robotframework.eclipseide.internal.util.ArrayPriorityDeque; 26 | import com.nitorcreations.robotframework.eclipseide.internal.util.Prioritizer; 27 | import com.nitorcreations.robotframework.eclipseide.internal.util.PriorityDeque; 28 | 29 | public class RelevantProposalsFilter implements IRelevantProposalsFilter { 30 | 31 | private static final int NOT_PRIORITY_PROPOSAL_MASK = 1 << 0; 32 | private static final int NOT_BASED_ON_INPUT_MASK = 1 << 1; 33 | 34 | @Override 35 | public ICompletionProposal[] extractMostRelevantProposals(List proposalSets2) { 36 | PriorityDeque proposalSets = removeEmptyProposalSets(proposalSets2); 37 | 38 | int lowestPriority = proposalSets.peekLowestPriority(); 39 | boolean isEmpty = lowestPriority == -1; 40 | if (isEmpty) { 41 | return null; 42 | } 43 | if (lowestPriority < NOT_BASED_ON_INPUT_MASK) { 44 | // we have got proposals based on input, so remove proposals not based on input 45 | proposalSets.clear(NOT_BASED_ON_INPUT_MASK, proposalSets.getNumberOfPriorityLevels() - 1); 46 | } 47 | 48 | List proposals = new ArrayList(); 49 | for (RobotCompletionProposalSet proposalSet : proposalSets) { 50 | proposals.addAll(proposalSet.getProposals()); 51 | } 52 | return proposals.toArray(new ICompletionProposal[proposals.size()]); 53 | } 54 | 55 | private PriorityDeque removeEmptyProposalSets(Collection proposalSets) { 56 | PriorityDeque proposalSets2 = createProposalSets(); 57 | for (Iterator proposalSetIt = proposalSets.iterator(); proposalSetIt.hasNext();) { 58 | RobotCompletionProposalSet proposalSet = proposalSetIt.next(); 59 | if (!proposalSet.getProposals().isEmpty()) { 60 | proposalSets2.add(proposalSet); 61 | } 62 | } 63 | return proposalSets2; 64 | } 65 | 66 | private PriorityDeque createProposalSets() { 67 | return new ArrayPriorityDeque(4, new Prioritizer() { 68 | @Override 69 | public int prioritize(RobotCompletionProposalSet t) { 70 | return (t.isPriorityProposal() ? 0 : NOT_PRIORITY_PROPOSAL_MASK) + (t.isBasedOnInput() ? 0 : NOT_BASED_ON_INPUT_MASK); 71 | } 72 | }); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/builder/ToggleNatureAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.builder; 17 | 18 | import java.util.Iterator; 19 | 20 | import org.eclipse.core.resources.IProject; 21 | import org.eclipse.core.resources.IProjectDescription; 22 | import org.eclipse.core.runtime.CoreException; 23 | import org.eclipse.core.runtime.IAdaptable; 24 | import org.eclipse.jface.action.IAction; 25 | import org.eclipse.jface.viewers.ISelection; 26 | import org.eclipse.jface.viewers.IStructuredSelection; 27 | import org.eclipse.ui.IObjectActionDelegate; 28 | import org.eclipse.ui.IWorkbenchPart; 29 | 30 | public class ToggleNatureAction implements IObjectActionDelegate { 31 | 32 | private ISelection selection; 33 | 34 | @Override 35 | public void run(IAction action) { 36 | if (selection instanceof IStructuredSelection) { 37 | for (Iterator it = ((IStructuredSelection) selection).iterator(); it.hasNext();) { 38 | Object element = it.next(); 39 | IProject project = null; 40 | if (element instanceof IProject) { 41 | project = (IProject) element; 42 | } else if (element instanceof IAdaptable) { 43 | project = (IProject) ((IAdaptable) element).getAdapter(IProject.class); 44 | } 45 | if (project != null) { 46 | toggleNature(project); 47 | } 48 | } 49 | } 50 | } 51 | 52 | @Override 53 | public void selectionChanged(IAction action, ISelection selection) { 54 | this.selection = selection; 55 | } 56 | 57 | @Override 58 | public void setActivePart(IAction action, IWorkbenchPart targetPart) { 59 | } 60 | 61 | private void toggleNature(IProject project) { 62 | try { 63 | IProjectDescription description = project.getDescription(); 64 | String[] natures = description.getNatureIds(); 65 | 66 | for (int i = 0; i < natures.length; ++i) { 67 | if (RobotNature.NATURE_ID.equals(natures[i])) { 68 | // Remove the nature 69 | String[] newNatures = new String[natures.length - 1]; 70 | System.arraycopy(natures, 0, newNatures, 0, i); 71 | System.arraycopy(natures, i + 1, newNatures, i, natures.length - i - 1); 72 | description.setNatureIds(newNatures); 73 | project.setDescription(description, null); 74 | return; 75 | } 76 | } 77 | 78 | // Add the nature 79 | String[] newNatures = new String[natures.length + 1]; 80 | System.arraycopy(natures, 0, newNatures, 0, natures.length); 81 | newNatures[natures.length] = RobotNature.NATURE_ID; 82 | description.setNatureIds(newNatures); 83 | project.setDescription(description, null); 84 | } catch (CoreException e) { 85 | e.printStackTrace(); 86 | } 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /plugin/src/test/java/com/nitorcreations/robotframework/eclipseide/internal/assistant/Content.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.internal.assistant; 17 | 18 | import java.util.LinkedHashMap; 19 | import java.util.Map; 20 | import java.util.NoSuchElementException; 21 | import java.util.regex.Matcher; 22 | import java.util.regex.Pattern; 23 | 24 | import org.eclipse.jface.text.IRegion; 25 | import org.eclipse.jface.text.Region; 26 | 27 | import com.nitorcreations.robotframework.eclipseide.structure.ParsedString; 28 | import com.nitorcreations.robotframework.eclipseide.structure.ParsedString.ArgumentType; 29 | 30 | /** 31 | * This class accepts text annotated with <text> which results in a pointer with the name "text" to be remembered 32 | * at the specfieid point. 33 | */ 34 | public class Content { 35 | private static final Pattern POINTER_RE = Pattern.compile("<([^>]+)>"); 36 | private final Map pointers = new LinkedHashMap(); 37 | private final String content; 38 | 39 | public Content(String contentWithPointers) { 40 | Matcher m = POINTER_RE.matcher(contentWithPointers); 41 | StringBuffer sb = new StringBuffer(); 42 | pointers.put("start", 0); 43 | while (m.find()) { 44 | m.appendReplacement(sb, ""); 45 | String pointerName = m.group(1); 46 | int pointerTarget = sb.length(); 47 | Integer old = pointers.put(pointerName, pointerTarget); 48 | if (old != null) { 49 | throw new IllegalStateException("Duplicate pointer " + pointerName); 50 | } 51 | } 52 | pointers.put("end", sb.length()); 53 | m.appendTail(sb); 54 | content = sb.toString(); 55 | } 56 | 57 | public int o(String pointerName) { 58 | if (!pointers.containsKey(pointerName)) { 59 | throw new NoSuchElementException(pointerName); 60 | } 61 | return pointers.get(pointerName); 62 | } 63 | 64 | public int l(String pointerRange) { 65 | String[] pointers = pointerRange.split("-", 2); 66 | return o(pointers[1]) - o(pointers[0]); 67 | } 68 | 69 | public IRegion r(String pointerRange) { 70 | String[] pointers = pointerRange.split("-", 2); 71 | int p0 = o(pointers[0]); 72 | int p1 = o(pointers[1]); 73 | return new Region(p0, p1 - p0); 74 | } 75 | 76 | public ParsedString ps(String pointerRange, int argIndex, ArgumentType argType) { 77 | return ps(r(pointerRange), argIndex, argType); 78 | } 79 | 80 | public ParsedString ps(IRegion region, int argIndex, ArgumentType argType) { 81 | return new ParsedString(s(region), region.getOffset(), argIndex).setType(argType); 82 | } 83 | 84 | public String s(String pointerRange) { 85 | return s(r(pointerRange)); 86 | } 87 | 88 | public String s(IRegion region) { 89 | return content.substring(region.getOffset(), region.getOffset() + region.getLength()); 90 | } 91 | 92 | public String c() { 93 | return content; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/builder/parser/TxtArgumentSplitter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012-2013 Nitor Creations Oy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.nitorcreations.robotframework.eclipseide.builder.parser; 17 | 18 | import java.util.ArrayList; 19 | import java.util.Collections; 20 | import java.util.List; 21 | import java.util.regex.Matcher; 22 | import java.util.regex.Pattern; 23 | 24 | import com.nitorcreations.robotframework.eclipseide.structure.ParsedString; 25 | 26 | public class TxtArgumentSplitter { 27 | 28 | private static final Pattern SEPARATOR_RE = Pattern.compile("(?:\t| [ \t])[ \t]*"); 29 | 30 | /** 31 | * Splits a line from a robot TXT file into arguments. Only supports the tab-or-multiple-whitespace separator right 32 | * now. 33 | * 34 | * @param line 35 | * @param charPos 36 | * the file character position of the first character of the line 37 | * @return 38 | */ 39 | static List splitLineIntoArguments(String line, int charPos) { 40 | String origLine = line; 41 | // remove trailing empty cells and whitespace 42 | line = rtrim(line); 43 | if (line == null) { 44 | return Collections.emptyList(); 45 | } 46 | 47 | // split line by tab-or-multiwhitespace 48 | Matcher m = SEPARATOR_RE.matcher(line); 49 | List arguments = new ArrayList(); 50 | int lastEnd = 0; 51 | for (int argumentIndex = 0;; ++argumentIndex) { 52 | // if next cell starts with #, the rest of the line is a comment 53 | boolean isComment = lastEnd < line.length() && line.charAt(lastEnd) == '#'; 54 | boolean isLastArgument = isComment || !m.find(); 55 | int nextStart = !isLastArgument ? m.start() : line.length(); 56 | if (lastEnd == 0 && nextStart > 0 && line.charAt(0) == ' ') { 57 | /* 58 | * spec says all arguments are trimmed - this is the only case when additional trimming is needed. 59 | */ 60 | ++lastEnd; 61 | } 62 | ParsedString parsedString = new ParsedString(line.substring(lastEnd, nextStart), charPos + lastEnd, argumentIndex); 63 | int nextLen = (!isLastArgument ? m.end() : origLine.length()) - nextStart; 64 | if (nextLen >= 1 && origLine.charAt(nextStart) == ' ') { 65 | parsedString.setHasSpaceAfter(true); 66 | } 67 | arguments.add(parsedString); 68 | if (isLastArgument) { 69 | // last argument 70 | break; 71 | } 72 | lastEnd = m.end(); 73 | } 74 | return arguments; 75 | } 76 | 77 | static String rtrim(String line) { 78 | int epos = line.length() - 1; 79 | while (epos >= 0) { 80 | switch (line.charAt(epos)) { 81 | case ' ': 82 | case '\t': 83 | break; 84 | default: 85 | return line.substring(0, epos + 1); 86 | } 87 | --epos; 88 | } 89 | return null; // empty line 90 | } 91 | 92 | } 93 | --------------------------------------------------------------------------------