Skip to content

Commit d7e7b53

Browse files
committed
Implement todo index pattern builder
1 parent 0a6d8be commit d7e7b53

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

src/META-INF/plugin.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<depends optional="true" config-file="java-deps.xml">com.intellij.modules.java</depends>
4444
<depends optional="true" config-file="coverage.xml">Coverage</depends>
4545
<depends optional="true" config-file="coverage.xml">com.intellij.modules.coverage</depends>
46-
<!-- todo[IDEA 15] replace with real dependency -->
46+
<!-- todo[IDEA 16] replace with real dependency -->
4747
<depends optional="true" config-file="app-engine.xml">com.intellij.modules.lang</depends>
4848

4949
<module-components>
@@ -61,6 +61,7 @@
6161
<stubIndex implementation="com.goide.stubs.index.GoMethodIndex"/>
6262
<stubIndex implementation="com.goide.stubs.index.GoMethodFingerprintIndex"/>
6363
<stubElementTypeHolder class="com.goide.GoTypes"/>
64+
<indexPatternBuilder implementation="com.goide.GoIndexPatternBuilder"/>
6465

6566
<internalFileTemplate name="Go Application"/>
6667
<internalFileTemplate name="Go File"/>
@@ -294,7 +295,7 @@
294295
<!-- GAE -->
295296

296297
<!-- START plugin.xml of future GAE module -->
297-
<!-- todo[IDEA 15] It's supposed that GAE-core module will be moved to IDEA source and bundled in IDEA 15 -->
298+
<!-- todo[IDEA 16] It's supposed that GAE-core module will be moved to IDEA source and bundled in IDEA 16 -->
298299
<!--<id>com.intellij.appengine</id>-->
299300
<depends optional="true" config-file="google-app-engine-core-yaml.xml">org.jetbrains.plugins.yaml</depends>
300301
<extensionPoints>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright 2013-2015 Sergey Ignatov, Alexander Zolotov, Florin Patan
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+
17+
package com.goide;
18+
19+
import com.goide.psi.GoFile;
20+
import com.intellij.lexer.Lexer;
21+
import com.intellij.psi.PsiFile;
22+
import com.intellij.psi.impl.search.IndexPatternBuilder;
23+
import com.intellij.psi.tree.IElementType;
24+
import com.intellij.psi.tree.TokenSet;
25+
import org.jetbrains.annotations.NotNull;
26+
import org.jetbrains.annotations.Nullable;
27+
28+
public class GoIndexPatternBuilder implements IndexPatternBuilder {
29+
@Nullable
30+
@Override
31+
public Lexer getIndexingLexer(@NotNull PsiFile file) {
32+
return file instanceof GoFile ? ((GoFile)file).getParserDefinition().createLexer(file.getProject()) : null;
33+
}
34+
35+
@Nullable
36+
@Override
37+
public TokenSet getCommentTokenSet(@NotNull PsiFile file) {
38+
return GoParserDefinition.COMMENTS;
39+
}
40+
41+
@Override
42+
public int getCommentStartDelta(IElementType tokenType) {
43+
return 0;
44+
}
45+
46+
@Override
47+
public int getCommentEndDelta(IElementType tokenType) {
48+
return tokenType == GoParserDefinition.MULTILINE_COMMENT ? 2 : 0;
49+
}
50+
}

0 commit comments

Comments
 (0)