diff --git a/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/assistant/proposalgenerator/CompletionMatchVisitor.java b/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/assistant/proposalgenerator/CompletionMatchVisitor.java index 5d95ed0..4b6a28d 100644 --- a/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/assistant/proposalgenerator/CompletionMatchVisitor.java +++ b/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/assistant/proposalgenerator/CompletionMatchVisitor.java @@ -1,5 +1,5 @@ /** - * Copyright 2012-2013 Nitor Creations Oy + * Copyright 2012-2014 Nitor Creations Oy, Dreamhunters-net * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,12 +39,17 @@ public CompletionMatchVisitor(IFile file, String userInput, List maxVariableCharPos) { diff --git a/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/hyperlinks/KeywordCallHyperlinkDetector.java b/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/hyperlinks/KeywordCallHyperlinkDetector.java index 9ffd348..78c0172 100644 --- a/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/hyperlinks/KeywordCallHyperlinkDetector.java +++ b/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/hyperlinks/KeywordCallHyperlinkDetector.java @@ -1,5 +1,5 @@ /** - * Copyright 2012-2013 Nitor Creations Oy + * Copyright 2012-2014 Nitor Creations Oy, Dreamhunters-net * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -71,6 +71,11 @@ public VisitorInterest visitMatch(ParsedString match, FileWithType location) { return VisitorInterest.CONTINUE; } + @Override + public VisitorInterest visitMatch(ParsedString match, FileWithType location, String context) { + return visitMatch(match, location); + } + private String getMatchStringInFile(FileWithType location, String linkString) { String filePrefix = location.getName() + "."; if (linkString.startsWith(filePrefix)) { diff --git a/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/hyperlinks/VariableAccessHyperlinkDetector.java b/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/hyperlinks/VariableAccessHyperlinkDetector.java index 285b4d6..e69ba11 100644 --- a/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/hyperlinks/VariableAccessHyperlinkDetector.java +++ b/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/hyperlinks/VariableAccessHyperlinkDetector.java @@ -1,5 +1,5 @@ /** - * Copyright 2012-2013 Nitor Creations Oy + * Copyright 2012-2014 Nitor Creations Oy, Dreamhunters-net * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,6 +66,11 @@ public VisitorInterest visitMatch(ParsedString match, FileWithType location) { return VisitorInterest.CONTINUE; } + @Override + public VisitorInterest visitMatch(ParsedString match, FileWithType location, String context) { + return visitMatch(match, location); + } + @Override public LineType getWantedLineType() { return LineType.VARIABLE_TABLE_LINE; diff --git a/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/DefinitionFinder.java b/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/DefinitionFinder.java index 26bda62..34d04d2 100644 --- a/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/DefinitionFinder.java +++ b/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/DefinitionFinder.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Nitor Creations Oy + * Copyright 2012, 2014 Nitor Creations Oy, Dreamhunters-net * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,9 +33,14 @@ private static class LineMatchVisitorAdapter implements LineMatchVisitor { this.delegate = delegate; } + @Override + public VisitorInterest visitMatch(RobotLine line, FileWithType lineLocation, String context) { + return delegate.visitMatch(line.arguments.get(0), lineLocation, context); + } + @Override public VisitorInterest visitMatch(RobotLine line, FileWithType lineLocation) { - return delegate.visitMatch(line.arguments.get(0), lineLocation); + return delegate.visitMatch(line.arguments.get(0), lineLocation, ""); } @Override diff --git a/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/DefinitionMatchVisitor.java b/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/DefinitionMatchVisitor.java index 16c82f9..90fb52e 100644 --- a/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/DefinitionMatchVisitor.java +++ b/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/DefinitionMatchVisitor.java @@ -1,5 +1,5 @@ /** - * Copyright 2012-2013 Nitor Creations Oy + * Copyright 2012-2014 Nitor Creations Oy, Dreamhunters-net * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,8 +28,9 @@ public interface DefinitionMatchVisitor { * the match * @param matchLocation * where match is located - null if the match is located in a variable file or a library + * @param context */ - VisitorInterest visitMatch(ParsedString match, FileWithType matchLocation); + VisitorInterest visitMatch(ParsedString match, FileWithType matchLocation, String context); LineType getWantedLineType(); @@ -37,4 +38,6 @@ public interface DefinitionMatchVisitor { * @return true if {@link DefinitionFinder} should descend into the given import, false if not */ boolean visitImport(IFile currentFile, RobotLine line); + + VisitorInterest visitMatch(ParsedString match, FileWithType matchLocation); } \ No newline at end of file diff --git a/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/LineFinder.java b/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/LineFinder.java index 83fb218..f17c96f 100644 --- a/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/LineFinder.java +++ b/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/LineFinder.java @@ -1,5 +1,5 @@ /** - * Copyright 2012-2013 Nitor Creations Oy + * Copyright 2012-2014 Nitor Creations Oy, Dreamhunters-net * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.List; +import java.util.ListIterator; import java.util.Set; import org.eclipse.core.resources.IFile; @@ -108,7 +109,77 @@ private static VisitorInterest acceptResourceFile(FileWithType currentFileWithTy VisitorInterest interest = CONTINUE; for (RobotLine line : lines) { if (visitor.getWantedLineTypes().contains(line.type)) { - interest = visitor.visitMatch(line, currentFileWithType); + // Visit the next few lines to build the context of the keyword + String keywordContext = ""; + // Flag for continuing 0 is no context, 1 is Arguments, 2 is Documentation + int contextCont = 0; + // If the Arguments are part of the line + if (line.arguments.size() > 1) { + if (line.arguments.get(1).getValue().equals("[Arguments]")) { + keywordContext = keywordContext + "
"; + for (int i = 1; i < line.arguments.size(); i++) { + keywordContext = keywordContext + " " + line.arguments.get(i).getValue(); + } + } + } + for (ListIterator iter = lines.listIterator(lines.indexOf(line) + 1); iter.hasNext();) { + RobotLine contextLine = iter.next(); + if (contextLine.arguments.size() <= 1) { + break; + } + if (contextCont == 0) { + if ((contextLine.arguments.get(1).getValue().equals("[Arguments]")) || (contextLine.arguments.get(1).getValue().equals("[Documentation]"))) { + keywordContext = keywordContext + "
"; + for (int i = 1; i < contextLine.arguments.size(); i++) { + keywordContext = keywordContext + " " + contextLine.arguments.get(i).getValue(); + } + if (contextLine.arguments.get(0).getValue().equals("[Arguments]")) { + contextCont = 1; + } else { + contextCont = 2; + } + } else if (contextLine.arguments.get(1).getType().name().equals("COMMENT")) { + // Do nothing if it's a comment + } else { + break; + } + } else if (contextCont == 1) { + if (contextLine.arguments.get(1).getValue().equals("[Documentation]")) { + keywordContext = keywordContext + "
"; + for (int i = 1; i < contextLine.arguments.size(); i++) { + keywordContext = keywordContext + " " + contextLine.arguments.get(i).getValue(); + } + contextCont = 0; + break; + } else if (contextLine.arguments.get(1).getValue().equals("...")) { + for (int i = 2; i < contextLine.arguments.size(); i++) { + keywordContext = keywordContext + " " + contextLine.arguments.get(i).getValue(); + } + } else if (contextLine.arguments.get(1).getType().equals("COMMENT")) { + // Do nothing if it's a comment + } else { + contextCont = 0; + } + } else if (contextCont == 2) { + if (contextLine.arguments.get(1).getValue().equals("[Arguments]")) { + keywordContext = keywordContext + "
"; + for (int i = 1; i < contextLine.arguments.size(); i++) { + keywordContext = keywordContext + " " + contextLine.arguments.get(i).getValue(); + } + contextCont = 0; + break; + } else if (contextLine.arguments.get(1).getValue().equals("...")) { + for (int i = 2; i < contextLine.arguments.size(); i++) { + keywordContext = keywordContext + " " + contextLine.arguments.get(i).getValue(); + } + } else if (contextLine.arguments.get(1).getType().equals("COMMENT")) { + // Do nothing if it's a comment + } else { + contextCont = 0; + } + } + } + interest = visitor.visitMatch(line, currentFileWithType, keywordContext); if (interest == STOP) { return STOP; } diff --git a/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/LineMatchVisitor.java b/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/LineMatchVisitor.java index 8abfb5c..947429d 100644 --- a/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/LineMatchVisitor.java +++ b/plugin/src/main/java/com/nitorcreations/robotframework/eclipseide/internal/util/LineMatchVisitor.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Nitor Creations Oy + * Copyright 2012, 2014 Nitor Creations Oy, Dreamhunters-net * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,8 +29,11 @@ public interface LineMatchVisitor { * the line * @param lineLocation * where line is located - null if the proposal is located in a variable file or a library + * @param keywordContext */ - VisitorInterest visitMatch(RobotLine line, FileWithType lineLocation); + VisitorInterest visitMatch(RobotLine line, FileWithType lineLocation, String keywordContext); + + VisitorInterest visitMatch(RobotLine line, FileWithType fileWithType); Set getWantedLineTypes(); @@ -42,4 +45,5 @@ public interface LineMatchVisitor { * @return true if {@link DefinitionFinder} should descend into the given import, false if not */ boolean visitImport(IFile currentFile, RobotLine line); + }