diff --git a/src/org/ice1000/tt/psi/agda/parser.kt b/src/org/ice1000/tt/psi/agda/parser.kt index 5e7c84f..85f3416 100644 --- a/src/org/ice1000/tt/psi/agda/parser.kt +++ b/src/org/ice1000/tt/psi/agda/parser.kt @@ -36,7 +36,8 @@ class AgdaTokenType(debugName: String) : IElementType(debugName, AgdaLanguage.IN @JvmField val IDENTIFIERS = TokenSet.create(AgdaTypes.IDENTIFIER) fun fromText(text: String, project: Project) = PsiFileFactory.getInstance(project).createFileFromText(AgdaLanguage.INSTANCE, text)?.firstChild - fun createSignature(text: String, project: Project) = fromText(text, project) as? AgdaSignature + fun createLayout(text: String, project: Project) = fromText(text, project) as? AgdaLayout + fun createSignature(text: String, project: Project) = createLayout(text, project)?.firstChild as? AgdaSignature fun createExp(text: String, project: Project) = createSignature("f : $text", project)?.exp fun createStr(text: String, project: Project) = createExp(text, project) as? AgdaString } diff --git a/src/org/ice1000/tt/psi/layout.kt b/src/org/ice1000/tt/psi/layout.kt index f247392..2d7671a 100644 --- a/src/org/ice1000/tt/psi/layout.kt +++ b/src/org/ice1000/tt/psi/layout.kt @@ -113,7 +113,7 @@ class LayoutLexer( when (state) { WaitingForLayout -> { if (token.isCode && token.column > indentStack.peek()) { - tokens.add(i, virtualToken(layoutStart, tokens[i - 1])) + tokens.add(i, virtualToken(layoutStart, tokens[(i - 1).coerceAtLeast(0)])) i++ indentStack.push(token.column) if (token.elementType !in layoutCreatingTokens) state = Normal