/*
 * Copyright 2000-2014 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.jetbrains.python.findUsages;

import com.intellij.lang.cacheBuilder.DefaultWordsScanner;
import com.intellij.psi.tree.TokenSet;
import com.jetbrains.python.PyTokenTypes;
import com.jetbrains.python.lexer.PythonLexer;

/**
 * @author yole
 */
public class PyWordsScanner extends DefaultWordsScanner {
    public PyWordsScanner() {
        super(new PythonLexer(),
                TokenSet.create(PyTokenTypes.IDENTIFIER),
                TokenSet.create(PyTokenTypes.END_OF_LINE_COMMENT),
                PyTokenTypes.STRING_NODES);
    }
}

@@ -719,25 +719,176 @@
 lij.
-psi.tree.TokenSet
+lang.cacheBuilder.VersionedWordsScanner;%0Aimport com.intellij.lang.cacheBuilder.WordOccurrence;%0Aimport com.intellij.psi.tree.TokenSet;%0Aimport com.intellij.util.Processor
 ;%0Aim
@@ -999,23 +999,16 @@
 ole%0A */%0A
-public 
 class Py
@@ -1032,71 +1032,311 @@
 nds 
-DefaultWordsScanner %7B%0A    public PyWordsScanner() %7B%0A        sup
+VersionedWordsScanner %7B%0A  private volatile DefaultWordsScanner myDelegate;%0A%0A  @Override%0A  public void processWords(CharSequence fileText, Processor%3CWordOccurrence%3E processor) %7B%0A    DefaultWordsScanner delegate = myDelegate;%0A    if (delegate == null) %7B%0A      myDelegate = delegate = new DefaultWordsScann
 er(n
@@ -1353,16 +1353,41 @@
 exer(),%0A
+                         
         
@@ -1444,32 +1444,57 @@
                 
+           
+              
 TokenSet.create(
@@ -1528,16 +1528,41 @@
 MMENT),%0A
+                         
         
@@ -1603,10 +1603,143 @@
 ;%0A    %7D%0A
+    delegate.processWords(fileText, processor);%0A  %7D%0A%0A  @Override%0A  public int getVersion() %7B%0A    return super.getVersion() + 1;%0A  %7D%0A%0A
 %7D%0A

allow to get PyWordsScanner's version on startup without initializing a lot of stuff needed only for actual indexing