Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public interface RobotTokenTypes {
final IElementType KeywordsHeader = new RobotIElementType("KeywordsHeader");
final IElementType VariablesHeader = new RobotIElementType("VariablesHeader");
final IElementType TasksHeader = new RobotIElementType("TasksHeader");
final IElementType CommentsHeader = new RobotIElementType("CommentsHeader");

final IElementType Ellipsis = new RobotIElementType("Ellipsis");
final IElementType ScalarVariable = new RobotIElementType("ScalarVariable");
Expand All @@ -35,5 +36,5 @@ public interface RobotTokenTypes {
final TokenSet WhitespacesTokens = TokenSet.create(IrrelevantSpaces, BlankLine);
final TokenSet CommentsTokens = TokenSet.create(Comment);
final TokenSet StringLiteralElements = TokenSet.EMPTY;
final TokenSet HeaderTokens = TokenSet.create(SettingsHeader, TestCasesHeader, KeywordsHeader, VariablesHeader, TasksHeader);
final TokenSet HeaderTokens = TokenSet.create(SettingsHeader, TestCasesHeader, KeywordsHeader, VariablesHeader, TasksHeader, CommentsHeader);
}
2 changes: 2 additions & 0 deletions src/main/resources/amailp/intellij/robot/lexer/Robot.flex
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ TestCasesHeader = "*** Test Cases ***" | "*** Test Case ***"
KeywordsHeader = "*** Keywords ***" | "*** Keyword ***"
VariablesHeader = "*** Variables ***" | "*** Variable ***"
TasksHeader = "*** Tasks ***" | "*** Task ***"
CommentsHeader = "*** Comments ***"


WordChar = [^$@&%\ \t\f\r\n]
Expand Down Expand Up @@ -68,6 +69,7 @@ EnvironmentVariable = "%{" ~"}"
{KeywordsHeader} { yybegin(LINE); return RobotTokenTypes.KeywordsHeader; }
{VariablesHeader} { yybegin(LINE); return RobotTokenTypes.VariablesHeader; }
{TasksHeader} { yybegin(LINE); return RobotTokenTypes.TasksHeader; }
{CommentsHeader} { yybegin(LINE); return RobotTokenTypes.CommentsHeader;}

{Ellipsis} { yybegin(LINE); return RobotTokenTypes.Ellipsis; }
{ScalarVariable} { yybegin(LINE); return RobotTokenTypes.ScalarVariable; }
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/amailp/intellij/robot/ast/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.intellij.psi.tree.TokenSet
package object ast {
object Tables extends RobotIElementType("Tables")

object CommentsTable extends RobotIElementType("CommentsTable")
object SettingsTable extends RobotIElementType("SettingsTable")
object Setting extends RobotIElementType("Setting")
object SettingName extends RobotIElementType("SettingName")
Expand All @@ -31,6 +32,5 @@ package object ast {
object TableRow extends RobotIElementType("TableRow")
object NonEmptyCell extends RobotIElementType("NonEmptyCell")

val tableElementTypes = TokenSet.create(SettingsTable, TestCasesTable, KeywordsTable, VariablesTable)

val tableElementTypes = TokenSet.create(SettingsTable, TestCasesTable, KeywordsTable, VariablesTable, CommentsTable)
}
9 changes: 9 additions & 0 deletions src/main/scala/amailp/intellij/robot/parser/RobotParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.intellij.psi.tree.IElementType
import amailp.intellij.robot.elements.RobotTokenTypes._
import amailp.intellij.robot.ast


object RobotParser extends PsiParser {
def parse(root: IElementType, builder: PsiBuilder): ASTNode = {
val robotBuilder = new RobotPsiBuilder(builder)
Expand All @@ -17,6 +18,7 @@ object RobotParser extends PsiParser {
case TestCasesHeader | TasksHeader => parseTableItemsWith(parseTestCaseDefinition); Some(ast.TestCasesTable)
case KeywordsHeader => parseTableItemsWith(parseKeywordDefinition); Some(ast.KeywordsTable)
case VariablesHeader => parseTableItemsWith(parseVariableDefinition); Some(ast.VariablesTable)
case CommentsHeader => parseTableItemsWith(parseCommentsTable); Some(ast.CommentsTable)
case _ => None
}
tableType match {
Expand All @@ -25,6 +27,13 @@ object RobotParser extends PsiParser {
}
}

def parseCommentsTable(): Unit = {
while (!isHeader(currentType)) {
//val comments_line = currentText
advanceLexer()
}
}

def parseHeaderRow(): IElementType = {
val headerMark = mark
val headerType = currentType
Expand Down
6 changes: 6 additions & 0 deletions src/main/scala/amailp/intellij/robot/parser/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ package object parser {
def currentType = getTokenType
def currentText = getTokenText

def parserCommentLine(includingTerminator: Boolean = true): Unit = {
while (currentType != SettingsHeader) {
parseRowContent()
}
}

def parseRowContent(includingTerminator: Boolean = true) {
if (!currentIsSeparator) parseCellOfType(ast.NonEmptyCell)
parseRemainingCells()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*** Comments ***
Hello World
*** Keywords ***
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*** Comments ***
Hello World
*** Settings ***
3 changes: 3 additions & 0 deletions src/test/resources/CommentsTableTest/CommentsTableTasks.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*** Comments ***
Hello World
*** Tasks ***
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*** Comments ***
Hello World
*** Test Cases ***
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*** Comments ***
Hello World
*** Variables ***
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package amailp.intellij.robot.psi.tables

import amailp.intellij.robot.psi.RobotPsiFile
import amailp.intellij.robot.structureView.RobotTreeBasedStructureViewBuilder
import amailp.intellij.robot.testFramework.RobotCodeInsightFixtureTestCase

class RobotCommentsTableTest extends RobotCodeInsightFixtureTestCase {

def testCommentsSetting(): Unit = {
val files = myFixture
.configureByFiles(
"CommentsTableTest/CommentsTableSettings.robot"
)
.map(_.asInstanceOf[RobotPsiFile])

val oneComments = files.head

val structureViewModel =
new RobotTreeBasedStructureViewBuilder(oneComments).createStructureViewModel(myFixture.getEditor)

val root = structureViewModel.getRoot
root.getChildren should have size 1


val comments = root.getChildren()(0)
val settings = root.getChildren()(1)

comments.getPresentation.getPresentableText should equal("Comments")
settings.getPresentation.getPresentableText should equal("Settings")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ import org.scalatest.matchers.should.Matchers
import org.scalatestplus.junit.AssertionsForJUnit

@Ignore
class RobotCodeInsightFixtureTestCase
extends BasePlatformTestCase
with Matchers
with AssertionsForJUnit {
class RobotCodeInsightFixtureTestCase extends BasePlatformTestCase with Matchers with AssertionsForJUnit {
override def getTestDataPath =
new File(this.getClass.getClassLoader.getResource("complete.robot").toURI).getParent

Expand Down