mirror of
https://github.com/ilyakooo0/intellij-haskell.git
synced 2024-10-26 15:13:25 +03:00
Added rename refactoring.
This commit is contained in:
parent
2f3fc95085
commit
d5a83df8d1
@ -55,6 +55,10 @@
|
||||
<fileBasedIndex implementation="com.powertuple.intellij.haskell.util.HaskellFileIndex"/>
|
||||
|
||||
<lang.findUsagesProvider language="Haskell" implementationClass="com.powertuple.intellij.haskell.HaskellFindUsagesProvider"/>
|
||||
|
||||
<lang.namesValidator language="Haskell" implementationClass="com.powertuple.intellij.haskell.HaskellNamesValidator"/>
|
||||
<lang.refactoringSupport language="Haskell" implementationClass="com.powertuple.intellij.haskell.HaskellRefactoringSupportProvider"/>
|
||||
<renamePsiElementProcessor implementation="com.powertuple.intellij.haskell.HaskellRenameVariableProcessor"/>
|
||||
</extensions>
|
||||
|
||||
<application-components>
|
||||
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2014 Rik van der Kleij
|
||||
|
||||
* 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.powertuple.intellij.haskell
|
||||
|
||||
import com.intellij.lang.refactoring.NamesValidator
|
||||
import com.intellij.openapi.project.Project
|
||||
|
||||
class HaskellNamesValidator extends NamesValidator {
|
||||
|
||||
override def isKeyword(name: String, project: Project): Boolean = {
|
||||
val lexer = new HaskellLexer
|
||||
lexer.start(name.toCharArray)
|
||||
HaskellParserDefinition.RESERVED_IDS.contains(lexer.getTokenType)
|
||||
}
|
||||
|
||||
override def isIdentifier(name: String, project: Project): Boolean = {
|
||||
// TODO: Except reservedop and dashes
|
||||
!isKeyword(name, project)
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2014 Rik van der Kleij
|
||||
|
||||
* 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.powertuple.intellij.haskell
|
||||
|
||||
import com.intellij.lang.refactoring.RefactoringSupportProvider
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.powertuple.intellij.haskell.psi.HaskellVar
|
||||
|
||||
class HaskellRefactoringSupportProvider extends RefactoringSupportProvider {
|
||||
|
||||
override def isMemberInplaceRenameAvailable(element: PsiElement, context: PsiElement): Boolean = {
|
||||
element.isInstanceOf[HaskellVar]
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2014 Rik van der Kleij
|
||||
|
||||
* 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.powertuple.intellij.haskell
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.refactoring.rename.RenamePsiElementProcessor
|
||||
import com.powertuple.intellij.haskell.psi.HaskellVar
|
||||
|
||||
class HaskellRenameVariableProcessor extends RenamePsiElementProcessor{
|
||||
override def canProcessElement(element: PsiElement): Boolean = element.isInstanceOf[HaskellVar]
|
||||
|
||||
override def forcesShowPreview(): Boolean = true
|
||||
}
|
Loading…
Reference in New Issue
Block a user