├── testdata ├── parser │ ├── empty_list.test │ ├── empty_map.test │ ├── float.test │ ├── integer.test │ ├── sexp.test │ ├── symbol.test │ ├── symbol2.test │ ├── empty_vector.test │ ├── quote.test │ ├── sexp2.test │ ├── string.test │ ├── vector.test │ ├── meta.test │ ├── sexp45.test │ ├── str1.test │ ├── map.test │ ├── nameApostrophe.test │ ├── symbols │ │ ├── sym1.test │ │ ├── sym2.test │ │ ├── sym4.test │ │ ├── sym3.test │ │ ├── sym2-tree.txt │ │ ├── sym1-tree.txt │ │ ├── sym5.test │ │ ├── sym4-tree.txt │ │ └── sym3-tree.txt │ ├── unicode_symbol.test │ ├── sexp3.test │ ├── uncompl.test │ ├── sexp4.test │ ├── let.test │ ├── str4.test │ ├── multiline_string.test │ ├── symbol-tree.txt │ ├── symbol2-tree.txt │ ├── float-tree.txt │ ├── integer-tree.txt │ ├── string-tree.txt │ ├── empty_list-tree.txt │ ├── empty_map-tree.txt │ ├── str1-tree.txt │ ├── empty_vector-tree.txt │ ├── fn.test │ ├── multiline_string-tree.txt │ ├── uncompl-tree.txt │ ├── sexp-tree.txt │ ├── sexp45-tree.txt │ ├── nameApostrophe-tree.txt │ ├── unicode_symbol-tree.txt │ ├── meta-tree.txt │ ├── defn.test │ ├── sexp2-tree.txt │ ├── vector-tree.txt │ ├── sexp4-tree.txt │ ├── quote-tree.txt │ ├── str4-tree.txt │ ├── map-tree.txt │ ├── sexp3-tree.txt │ ├── defn2.test │ ├── defn3.test │ └── defn-tree.txt ├── intention │ ├── Import1.test │ ├── Import3.test │ ├── Import1.clj │ ├── Import2.test │ ├── Import3.clj │ ├── Import2.clj │ ├── Import4.clj │ └── Import5.clj ├── refactoring │ ├── Caret.clj │ ├── SimpleSelection.clj │ ├── FuzzySelection.clj │ ├── FuzzySelection.test │ ├── JavaNames.clj │ ├── SimpleSelection.test │ ├── ContainerChooser.clj │ ├── ContainerChooser.test │ ├── Caret.test │ ├── JavaNames.test │ ├── ClojureNames.clj │ ├── LetAddition.clj │ ├── LetAddition.test │ ├── ClojureNames.test │ ├── Guard.clj │ ├── Guard.test │ ├── Occurences.clj │ ├── Occurences.test │ ├── LetInLet.test │ ├── LetInLet.clj │ ├── MultiBody.clj │ └── MultiBody.test ├── resolve │ ├── base │ │ └── definitionInsideLet.clj │ ├── use │ │ ├── use1.clj │ │ ├── use2.clj │ │ ├── use7.clj │ │ ├── use8.clj │ │ ├── useFailed1.clj │ │ ├── use9.clj │ │ ├── use3.clj │ │ ├── use4.clj │ │ ├── useFailed2.clj │ │ ├── use10.clj │ │ ├── use5.clj │ │ ├── use6.clj │ │ ├── use11.clj │ │ ├── use13.clj │ │ ├── useFailed4.clj │ │ ├── use12.clj │ │ ├── use14.clj │ │ ├── use15.clj │ │ ├── use16.clj │ │ └── useFailed5.clj │ ├── javaClass │ │ ├── import1.clj │ │ ├── import3.clj │ │ ├── import4.clj │ │ ├── import5.clj │ │ ├── import7.clj │ │ ├── importFails3.clj │ │ ├── importFails1.clj │ │ ├── import6.clj │ │ ├── importFails2.clj │ │ ├── import2.clj │ │ └── my_namespace.clj │ ├── useNs │ │ ├── deftest1.clj │ │ ├── deftest3.clj │ │ ├── deftest4.clj │ │ ├── deftest5.clj │ │ ├── deftest6.clj │ │ ├── deftest2.clj │ │ └── my_namespace.clj │ ├── useNsResolve │ │ └── my_namespace.clj │ ├── requireNs │ │ ├── require1.clj │ │ ├── require2.clj │ │ ├── require3.clj │ │ ├── require4.clj │ │ ├── require5.clj │ │ ├── requireFails1.clj │ │ ├── require6.clj │ │ ├── requireFails2.clj │ │ └── my_namespace.clj │ ├── useNsMany │ │ └── my_namespace.clj │ └── requireSymbol │ │ └── my_namespace.clj ├── formatter │ ├── keywordBeforeBrace.test │ ├── keywordBeforeBrace.clj │ ├── nameApostrophe.clj │ ├── nameApostrophe.test │ ├── clj_98.clj │ └── clj_98.test ├── mockJDK │ ├── src.zip │ ├── bin │ │ └── java.exe │ └── jre │ │ └── lib │ │ ├── rt.jar │ │ └── annotations.jar └── mockClojureLib │ ├── clojure-1.5.jar │ └── clojure-contrib.jar ├── .gitignore ├── lib ├── boot │ └── boot.jar ├── clojure-1.8.0.jar └── tools.nrepl-0.2.12.jar ├── resources ├── intentionDescriptions │ └── ConvertImportIntention │ │ ├── after.clj.template │ │ ├── before.clj.template │ │ └── description.html ├── fileTemplates │ └── j2ee │ │ ├── ClojureFile.clj.ft │ │ └── ClojureFile.clj.html └── org │ └── jetbrains │ └── plugins │ └── clojure │ └── icons │ ├── field.png │ ├── method.png │ ├── symbol.png │ ├── def_tmp.png │ ├── meth_tmp.png │ ├── repl_add.png │ ├── repl_go.png │ ├── repl_run.png │ ├── clojure_sdk.png │ ├── namespace.png │ ├── repl_close.png │ ├── repl_eval.png │ ├── repl_console.png │ ├── clojure_icon_16x16.png │ └── clojure_sdk_missed.png ├── .idea ├── copyright │ └── profiles_settings.xml ├── scopes │ └── scope_settings.xml ├── encodings.xml ├── vcs.xml ├── libraries │ ├── nrepl.xml │ └── clojure_sdk.xml ├── clojure_compiler.xml ├── inspectionProfiles │ └── profiles_settings.xml ├── highlighting.xml ├── ant.xml ├── misc.xml ├── artifacts │ ├── Production.xml │ └── ClojurePlugin.xml ├── modules.xml └── compiler.xml ├── jps-plugin ├── src │ ├── META-INF │ │ └── services │ │ │ ├── org.jetbrains.jps.incremental.BuilderService │ │ │ └── org.jetbrains.jps.model.serialization.JpsModelSerializerExtension │ └── org │ │ └── jetbrains │ │ └── jps │ │ └── clojure │ │ ├── model │ │ ├── impl │ │ │ ├── JpsClojureCompilerSettingsState.java │ │ │ ├── JpsClojureCompilerSettingsExtensionImpl.java │ │ │ └── JpsClojureModelSerializerExtension.java │ │ ├── JpsClojureCompilerSettingsExtension.java │ │ └── JpsClojureExtensionService.java │ │ └── build │ │ └── ClojureBuilderService.java └── clojure-jps-plugin.iml ├── src ├── java │ └── org │ │ └── jetbrains │ │ └── plugins │ │ └── clojure │ │ ├── psi │ │ ├── api │ │ │ ├── ClSet.java │ │ │ ├── ClFn.java │ │ │ ├── ClLiteral.java │ │ │ ├── synthetic │ │ │ │ ├── ClSyntheticClass.java │ │ │ │ └── ClSyntheticMethod.java │ │ │ ├── defs │ │ │ │ ├── ClDefMethod.java │ │ │ │ └── ClDef.java │ │ │ ├── ClVector.java │ │ │ ├── ClQuotedForm.java │ │ │ ├── ClKeyword.java │ │ │ ├── ClListLike.java │ │ │ ├── ClBraced.java │ │ │ ├── ClList.java │ │ │ ├── ClMap.java │ │ │ ├── ClMetadata.java │ │ │ ├── ns │ │ │ │ └── ClNs.java │ │ │ ├── symbols │ │ │ │ └── ClSymbol.java │ │ │ └── ClojureFile.java │ │ ├── stubs │ │ │ ├── index │ │ │ │ ├── ClojureIndexVersion.java │ │ │ │ ├── ClDefNameIndex.java │ │ │ │ ├── ClojureNsNameIndex.java │ │ │ │ ├── ClojureKeywordIndex.java │ │ │ │ ├── ClojureClassNameIndex.java │ │ │ │ └── ClojureFullScriptNameIndex.java │ │ │ ├── api │ │ │ │ ├── ClKeywordStub.java │ │ │ │ ├── ClFileStub.java │ │ │ │ ├── ClNsStub.java │ │ │ │ └── ClDefStub.java │ │ │ ├── ClojureFileStubBuilder.java │ │ │ ├── impl │ │ │ │ ├── ClKeywordStubImpl.java │ │ │ │ └── ClFileStubImpl.java │ │ │ └── elements │ │ │ │ ├── ns │ │ │ │ ├── ClNsElementType.java │ │ │ │ ├── ClInNsElementType.java │ │ │ │ └── ClCreateNsElementType.java │ │ │ │ └── ClListElementType.java │ │ ├── impl │ │ │ ├── ClAt.java │ │ │ ├── ClVar.java │ │ │ ├── ClSharp.java │ │ │ ├── ClTilda.java │ │ │ ├── ClTildaAt.java │ │ │ ├── ClBindings.java │ │ │ ├── synthetic │ │ │ │ └── SynteticUtil.java │ │ │ ├── ClBackQuotedExpression.java │ │ │ ├── ClFnImpl.java │ │ │ ├── ClMetaForm.java │ │ │ ├── ClLiteralImpl.java │ │ │ ├── ClMapEntry.java │ │ │ ├── symbols │ │ │ │ ├── ClImplicitArgumentImpl.java │ │ │ │ └── SymbolUtils.java │ │ │ ├── ns │ │ │ │ ├── ClCreateNsImpl.java │ │ │ │ └── ClInNsImpl.java │ │ │ ├── ClQuotedFormImpl.java │ │ │ ├── ClSetImpl.java │ │ │ ├── list │ │ │ │ └── ClListImpl.java │ │ │ ├── ClMapEntryImpl.java │ │ │ ├── search │ │ │ │ └── ClojureSourceFilterScope.java │ │ │ ├── ClojurePsiManager.java │ │ │ └── ClMetadataImpl.java │ │ ├── resolve │ │ │ ├── ClojureResolveResult.java │ │ │ ├── processors │ │ │ │ └── ResolveKind.java │ │ │ ├── completion │ │ │ │ ├── CompletionProcessor.java │ │ │ │ └── ClojureCompletionConfidence.java │ │ │ └── ClojureResolveResultImpl.java │ │ ├── ClojurePsiElement.java │ │ ├── util │ │ │ ├── ClojureKeywords.java │ │ │ ├── ClojureTextUtil.java │ │ │ ├── ClojurePsiFactory.java │ │ │ └── ClojurePsiCheckers.java │ │ └── ClStubElementType.java │ │ ├── ClojureActions.java │ │ ├── repl │ │ ├── actions │ │ │ ├── ClojureReplActionGroup.java │ │ │ ├── ExecuteStatementAction.java │ │ │ ├── SwitchNamespaceClojureFileInConsoleAction.java │ │ │ ├── RunLastSExprAction.java │ │ │ ├── RunTopSExprAction.java │ │ │ └── RunSelectedTextAction.java │ │ ├── ClojureConsoleEnterAction.java │ │ ├── ClojureExecuteImmediatelyAction.java │ │ └── ClojureConsoleProcessHandler.java │ │ ├── refactoring │ │ └── rename │ │ │ ├── ClojureSymbolPattern.java │ │ │ ├── RenameClojureFileProcessor.java │ │ │ ├── ClojureRenameInputValidator.java │ │ │ └── ClojureNameValidator.java │ │ ├── highlighter │ │ ├── ClojureEditorHighlighter.java │ │ └── ClojureCommenter.java │ │ ├── lexer │ │ ├── TokenSets.java │ │ └── ClojureFlexLexer.java │ │ ├── compiler │ │ └── ClojureCompilerSettingsFactory.java │ │ ├── formatter │ │ ├── codeStyle │ │ │ ├── ClojureCodeStyleSettings.java │ │ │ └── ClojureCodeStyleSettingsProvider.java │ │ ├── processors │ │ │ └── ClojureIndentProcessor.java │ │ └── ClojureFormattingModelBuilder.java │ │ ├── debugger │ │ ├── ClojurePositionManagerFactory.java │ │ └── filters │ │ │ ├── ClojureDebuggerSettings.java │ │ │ ├── ClojureDebugClassesFilterProvider.java │ │ │ └── ClojureDebuggerSettingsConfigurable.form │ │ ├── config │ │ ├── ClojureModuleSettings.java │ │ ├── ClojureFacetLoader.java │ │ ├── util │ │ │ └── ClojureMavenLibraryUtil.java │ │ └── ClojureFacetListener.java │ │ ├── runner │ │ ├── console │ │ │ └── ClojureConsoleFilterProvider.java │ │ └── ClojureScriptConfigurationFactory.java │ │ ├── utils │ │ └── ClojureNamesUtil.java │ │ ├── parser │ │ ├── ClojureElementType.java │ │ ├── ClojureSpecialFormTokens.java │ │ └── Expression.java │ │ ├── editor │ │ ├── ClojureEditorActionGroup.java │ │ ├── todo │ │ │ └── ClojureIndexPatternBuilder.java │ │ ├── braceHighlighter │ │ │ └── ClojureBraceAttributes.java │ │ ├── ClojureQuoteHandler.java │ │ ├── ClojureCopyrightProvider.java │ │ └── selection │ │ │ └── ClojureLiteralSelectioner.java │ │ ├── ClojureLanguage.java │ │ ├── file │ │ └── ClojureFileTypeLoader.java │ │ ├── ClojureBundle.java │ │ ├── structure │ │ ├── ClojureStructureViewBuilderFactory.java │ │ └── ClojureStructureViewModel.java │ │ ├── settings │ │ ├── ClojureApplicationSettings.java │ │ └── ClojureProjectSettingsForm.java │ │ ├── gotoclass │ │ └── ClojureGoToSymbolContributor.java │ │ ├── annotator │ │ └── intentions │ │ │ └── imports │ │ │ └── ClojureImportClassFix.java │ │ └── actions │ │ └── editor │ │ └── ClojureEditorAction.java └── clojure │ └── org │ └── jetbrains │ └── plugins │ └── clojure │ ├── init_clojure.clj │ └── refactoring │ └── clojure_refactoring_support_provider.clj ├── META-INF └── copyright.xml ├── clojure-runner └── clojure-runner.iml ├── test └── org │ └── jetbrains │ └── plugins │ └── clojure │ ├── refactoring │ ├── RenameTest.java │ ├── ClojureRefactoringTestBase.java │ └── IntroduceVariableTest.java │ ├── completion │ └── ClojureBasicCompletionTest.java │ ├── intentions │ ├── ConvertImportIntentionTest.java │ └── ClojureIntentionTestBase.java │ ├── actions │ └── editor │ │ ├── SpliceTest.java │ │ ├── BarfForwardsTest.java │ │ ├── BarfBackwardsTest.java │ │ ├── SlurpBackwardsTest.java │ │ ├── SlurpForwardsTest.java │ │ └── ClojureEditingTest.java │ └── resolve │ └── psi │ └── StubTest.java └── clojure-plugin.iml /testdata/parser/empty_list.test: -------------------------------------------------------------------------------- 1 | () -------------------------------------------------------------------------------- /testdata/parser/empty_map.test: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /testdata/parser/float.test: -------------------------------------------------------------------------------- 1 | 123.123 -------------------------------------------------------------------------------- /testdata/parser/integer.test: -------------------------------------------------------------------------------- 1 | 123 -------------------------------------------------------------------------------- /testdata/parser/sexp.test: -------------------------------------------------------------------------------- 1 | (a b) -------------------------------------------------------------------------------- /testdata/parser/symbol.test: -------------------------------------------------------------------------------- 1 | foo -------------------------------------------------------------------------------- /testdata/parser/symbol2.test: -------------------------------------------------------------------------------- 1 | .foo* -------------------------------------------------------------------------------- /testdata/parser/empty_vector.test: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /testdata/parser/quote.test: -------------------------------------------------------------------------------- 1 | '(a b (c d)) -------------------------------------------------------------------------------- /testdata/parser/sexp2.test: -------------------------------------------------------------------------------- 1 | (a b (c d)) -------------------------------------------------------------------------------- /testdata/parser/string.test: -------------------------------------------------------------------------------- 1 | "123.456" -------------------------------------------------------------------------------- /testdata/parser/vector.test: -------------------------------------------------------------------------------- 1 | [a b (c d)] -------------------------------------------------------------------------------- /testdata/parser/meta.test: -------------------------------------------------------------------------------- 1 | #^{:foo "bah"} -------------------------------------------------------------------------------- /testdata/parser/sexp45.test: -------------------------------------------------------------------------------- 1 | (:static ^foo) -------------------------------------------------------------------------------- /testdata/parser/str1.test: -------------------------------------------------------------------------------- 1 | "asdasd \" cdfg" -------------------------------------------------------------------------------- /testdata/parser/map.test: -------------------------------------------------------------------------------- 1 | { :a a :b b :cd (c d)} -------------------------------------------------------------------------------- /testdata/parser/nameApostrophe.test: -------------------------------------------------------------------------------- 1 | (def f' 2) -------------------------------------------------------------------------------- /testdata/parser/symbols/sym1.test: -------------------------------------------------------------------------------- 1 | aaa/bbb/CCC -------------------------------------------------------------------------------- /testdata/parser/symbols/sym2.test: -------------------------------------------------------------------------------- 1 | .abc.cdef.Fff -------------------------------------------------------------------------------- /testdata/parser/unicode_symbol.test: -------------------------------------------------------------------------------- 1 | (def π 2) -------------------------------------------------------------------------------- /testdata/parser/sexp3.test: -------------------------------------------------------------------------------- 1 | (fn [[m p]] {(str m) [p]}) -------------------------------------------------------------------------------- /testdata/parser/uncompl.test: -------------------------------------------------------------------------------- 1 | " sdfsdfsdf \" fgbnfgn -------------------------------------------------------------------------------- /testdata/intention/Import1.test: -------------------------------------------------------------------------------- 1 | (import '(java.util.Date)) -------------------------------------------------------------------------------- /testdata/intention/Import3.test: -------------------------------------------------------------------------------- 1 | (import '(java.util.List)) -------------------------------------------------------------------------------- /testdata/parser/symbols/sym4.test: -------------------------------------------------------------------------------- 1 | Aaaa///ddd//Ccccc 2 | -------------------------------------------------------------------------------- /testdata/intention/Import1.clj: -------------------------------------------------------------------------------- 1 | (import java.util.Date) -------------------------------------------------------------------------------- /testdata/intention/Import2.test: -------------------------------------------------------------------------------- 1 | (import java.util.Date) 2 | -------------------------------------------------------------------------------- /testdata/intention/Import3.clj: -------------------------------------------------------------------------------- 1 | (import java.util.List) -------------------------------------------------------------------------------- /testdata/parser/sexp4.test: -------------------------------------------------------------------------------- 1 | (apply merge-with concat {} all-sigs) -------------------------------------------------------------------------------- /testdata/intention/Import2.clj: -------------------------------------------------------------------------------- 1 | (import '(java.util.Date)) 2 | -------------------------------------------------------------------------------- /testdata/intention/Import4.clj: -------------------------------------------------------------------------------- 1 | (import [java.util ArrayList]) -------------------------------------------------------------------------------- /testdata/intention/Import5.clj: -------------------------------------------------------------------------------- 1 | (import '(java.util List Date)) -------------------------------------------------------------------------------- /testdata/parser/let.test: -------------------------------------------------------------------------------- 1 | (let [[a b c & d :as e] [1 2 3 4 5 6 7]] [a b c d e]) -------------------------------------------------------------------------------- /testdata/parser/str4.test: -------------------------------------------------------------------------------- 1 | { 2 | \\ "\\\\" 3 | \backspace "\\b" 4 | } -------------------------------------------------------------------------------- /testdata/parser/symbols/sym3.test: -------------------------------------------------------------------------------- 1 | (. (identity Classname) instanceMember args) 2 | -------------------------------------------------------------------------------- /testdata/refactoring/Caret.clj: -------------------------------------------------------------------------------- 1 | (defn problem-ten [n] (reduce + (primes n))) -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | clojure-intellij-plugin.iws 2 | out 3 | dist 4 | jflex.log 5 | lib/*SDK 6 | *~ -------------------------------------------------------------------------------- /testdata/refactoring/SimpleSelection.clj: -------------------------------------------------------------------------------- 1 | (defn foo [a b] (+ a b)) -------------------------------------------------------------------------------- /testdata/resolve/base/definitionInsideLet.clj: -------------------------------------------------------------------------------- 1 | (let [] (def foo "string")) 2 | (foo) -------------------------------------------------------------------------------- /testdata/resolve/use/use1.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest) 2 | (use 'clojure.string) 3 | (split) -------------------------------------------------------------------------------- /testdata/resolve/use/use2.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest) 2 | (use '[clojure.string]) 3 | (split) -------------------------------------------------------------------------------- /lib/boot/boot.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/la-clojure/HEAD/lib/boot/boot.jar -------------------------------------------------------------------------------- /testdata/resolve/javaClass/import1.clj: -------------------------------------------------------------------------------- 1 | (ns im (:import java.util.Date)) 2 | 3 | (Date.) -------------------------------------------------------------------------------- /testdata/resolve/javaClass/import3.clj: -------------------------------------------------------------------------------- 1 | (ns im) 2 | (import java.util.Date) 3 | (Date.) -------------------------------------------------------------------------------- /testdata/resolve/javaClass/import4.clj: -------------------------------------------------------------------------------- 1 | (ns im) 2 | (import 'java.util.Date) 3 | (Date.) -------------------------------------------------------------------------------- /testdata/resolve/javaClass/import5.clj: -------------------------------------------------------------------------------- 1 | (ns im) 2 | (import '(java.util Date)) 3 | (Date.) -------------------------------------------------------------------------------- /testdata/resolve/javaClass/import7.clj: -------------------------------------------------------------------------------- 1 | (ns im) 2 | (import (java.util Date)) 3 | (Date.) -------------------------------------------------------------------------------- /testdata/resolve/javaClass/importFails3.clj: -------------------------------------------------------------------------------- 1 | (ns im (:import 'java.util.Date)) 2 | (Date.) -------------------------------------------------------------------------------- /testdata/resolve/use/use7.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest (:use clojure.string)) 2 | (split "text" #"x") -------------------------------------------------------------------------------- /testdata/resolve/use/use8.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest (:use clojure.string)) 2 | (split "text" #"x") -------------------------------------------------------------------------------- /testdata/resolve/use/useFailed1.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest) 2 | (use '(clojure.string)) 3 | (split) -------------------------------------------------------------------------------- /lib/clojure-1.8.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/la-clojure/HEAD/lib/clojure-1.8.0.jar -------------------------------------------------------------------------------- /testdata/parser/multiline_string.test: -------------------------------------------------------------------------------- 1 | "this is 2 | a multiline 3 | string" -------------------------------------------------------------------------------- /testdata/parser/symbol-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClSymbol 3 | PsiElement(atom)('foo') 4 | -------------------------------------------------------------------------------- /testdata/parser/symbol2-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClSymbol 3 | PsiElement(atom)('.foo*') 4 | -------------------------------------------------------------------------------- /testdata/refactoring/FuzzySelection.clj: -------------------------------------------------------------------------------- 1 | (defn func [a b] 2 | (+ a b) ) -------------------------------------------------------------------------------- /testdata/refactoring/FuzzySelection.test: -------------------------------------------------------------------------------- 1 | (defn func [a b] 2 | (let [val (+ a b)] 3 | val)) -------------------------------------------------------------------------------- /testdata/refactoring/JavaNames.clj: -------------------------------------------------------------------------------- 1 | (defn java-name 2 | [] 3 | (Collections/emptyList)) -------------------------------------------------------------------------------- /testdata/resolve/javaClass/importFails1.clj: -------------------------------------------------------------------------------- 1 | (ns im) 2 | (import '[java.util.Date]) 3 | (Date.) -------------------------------------------------------------------------------- /testdata/resolve/use/use9.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest [:use [clojure.string]]) 2 | (split "text" #"x") -------------------------------------------------------------------------------- /testdata/resolve/useNs/deftest1.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest 2 | (:use [clojure test])) 3 | (deftest) -------------------------------------------------------------------------------- /testdata/resolve/useNs/deftest3.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest 2 | (:use [clojure.test])) 3 | (deftest) -------------------------------------------------------------------------------- /testdata/resolve/useNs/deftest4.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest 2 | (:use clojure.test)) 3 | (deftest) -------------------------------------------------------------------------------- /testdata/resolve/useNs/deftest5.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest 2 | (:use (clojure.test))) 3 | (deftest) -------------------------------------------------------------------------------- /testdata/resolve/useNs/deftest6.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest 2 | (:use (clojure test))) 3 | (deftest) -------------------------------------------------------------------------------- /resources/intentionDescriptions/ConvertImportIntention/after.clj.template: -------------------------------------------------------------------------------- 1 | (import '(java.util Date)) -------------------------------------------------------------------------------- /testdata/formatter/keywordBeforeBrace.test: -------------------------------------------------------------------------------- 1 | (ns foo.bar 2 | (:require [clojure.string :refer :all])) -------------------------------------------------------------------------------- /testdata/refactoring/SimpleSelection.test: -------------------------------------------------------------------------------- 1 | (defn foo [a b] (let [val (+ a b)] 2 | val)) -------------------------------------------------------------------------------- /testdata/resolve/javaClass/import6.clj: -------------------------------------------------------------------------------- 1 | (ns im) 2 | (import '[java.util ArrayList Date]) 3 | (Date.) -------------------------------------------------------------------------------- /testdata/resolve/javaClass/importFails2.clj: -------------------------------------------------------------------------------- 1 | (ns im) 2 | 3 | (Date.) 4 | (import 'java.util.Date) -------------------------------------------------------------------------------- /testdata/resolve/use/use3.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest) 2 | (use '(clojure string)) 3 | (split "text" #"x") -------------------------------------------------------------------------------- /testdata/resolve/use/use4.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest) 2 | (use '[clojure string]) 3 | (split "text" #"x") -------------------------------------------------------------------------------- /testdata/resolve/use/useFailed2.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest [:use 'clojure.string]) 2 | (split "text" #"x") -------------------------------------------------------------------------------- /lib/tools.nrepl-0.2.12.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/la-clojure/HEAD/lib/tools.nrepl-0.2.12.jar -------------------------------------------------------------------------------- /testdata/formatter/keywordBeforeBrace.clj: -------------------------------------------------------------------------------- 1 | (ns foo.bar 2 | (:require [clojure.string :refer :all ])) -------------------------------------------------------------------------------- /testdata/mockJDK/src.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/la-clojure/HEAD/testdata/mockJDK/src.zip -------------------------------------------------------------------------------- /testdata/parser/float-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClLiteral 3 | PsiElement(double literal)('123.123') 4 | -------------------------------------------------------------------------------- /testdata/parser/integer-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClLiteral 3 | PsiElement(long literal)('123') 4 | -------------------------------------------------------------------------------- /testdata/resolve/javaClass/import2.clj: -------------------------------------------------------------------------------- 1 | (ns im (:import (java.util ArrayList Date))) 2 | 3 | (Date.) -------------------------------------------------------------------------------- /testdata/resolve/use/use10.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest [:use [clojure.string :as doo]]) 2 | (split "text" #"x") -------------------------------------------------------------------------------- /testdata/resolve/use/use5.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest) 2 | (use '[clojure core string]) 3 | (split "text" #"x") -------------------------------------------------------------------------------- /testdata/resolve/use/use6.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest) 2 | (use '(clojure core string)) 3 | (split "text" #"x") -------------------------------------------------------------------------------- /testdata/resolve/useNsResolve/my_namespace.clj: -------------------------------------------------------------------------------- 1 | (ns my-namespace 2 | (:use (clojure data inspector))) -------------------------------------------------------------------------------- /resources/intentionDescriptions/ConvertImportIntention/before.clj.template: -------------------------------------------------------------------------------- 1 | (import java.util.Date) -------------------------------------------------------------------------------- /testdata/parser/string-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClLiteral 3 | PsiElement(string literal)('"123.456"') 4 | -------------------------------------------------------------------------------- /testdata/parser/symbols/sym2-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClSymbol 3 | PsiElement(atom)('.abc.cdef.Fff') 4 | -------------------------------------------------------------------------------- /testdata/refactoring/ContainerChooser.clj: -------------------------------------------------------------------------------- 1 | (defn is-prime? [n] 2 | (empty? (divisors n))) -------------------------------------------------------------------------------- /testdata/resolve/use/use11.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest [:use [clojure.string :only (split)]]) 2 | (split "text" #"x") -------------------------------------------------------------------------------- /testdata/resolve/useNs/deftest2.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest 2 | (:use [clojure data] [clojure test])) 3 | (deftest) -------------------------------------------------------------------------------- /testdata/mockJDK/bin/java.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/la-clojure/HEAD/testdata/mockJDK/bin/java.exe -------------------------------------------------------------------------------- /testdata/mockJDK/jre/lib/rt.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/la-clojure/HEAD/testdata/mockJDK/jre/lib/rt.jar -------------------------------------------------------------------------------- /testdata/parser/empty_list-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClList 3 | PsiElement(()('(') 4 | PsiElement())(')') 5 | -------------------------------------------------------------------------------- /testdata/parser/empty_map-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClMap 3 | PsiElement({)('{') 4 | PsiElement(})('}') 5 | -------------------------------------------------------------------------------- /testdata/parser/str1-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClLiteral 3 | PsiElement(string literal)('"asdasd \" cdfg"') 4 | -------------------------------------------------------------------------------- /testdata/refactoring/ContainerChooser.test: -------------------------------------------------------------------------------- 1 | (defn is-prime? [n] 2 | (let [val (divisors n)] 3 | (empty? val))) -------------------------------------------------------------------------------- /testdata/resolve/use/use13.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest [:use [clojure.string :rename {split spl}]]) 2 | (spl "text" #"x") -------------------------------------------------------------------------------- /testdata/resolve/use/useFailed4.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest [:use [clojure.string :only (join)]]) 2 | (split "text" #"x") -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /testdata/parser/empty_vector-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClVector 3 | PsiElement([)('[') 4 | PsiElement(])(']') 5 | -------------------------------------------------------------------------------- /testdata/refactoring/Caret.test: -------------------------------------------------------------------------------- 1 | (defn problem-ten [n] (let [val (primes n)] 2 | (reduce + val))) -------------------------------------------------------------------------------- /testdata/parser/fn.test: -------------------------------------------------------------------------------- 1 | (fn [cs] (if (pos? (count cs)) 2 | (into-array (map totype cs)) 3 | (make-array Type 0))) -------------------------------------------------------------------------------- /testdata/resolve/requireNs/require1.clj: -------------------------------------------------------------------------------- 1 | (ns boo (:require [clojure [test :as testo]])) 2 | 3 | (println (testo/is "abs")) -------------------------------------------------------------------------------- /testdata/resolve/requireNs/require2.clj: -------------------------------------------------------------------------------- 1 | (ns boo (:require (clojure [test :as testo]))) 2 | 3 | (println (testo/is "abs")) -------------------------------------------------------------------------------- /testdata/resolve/requireNs/require3.clj: -------------------------------------------------------------------------------- 1 | (ns boo (:require [clojure.test :as testo])) 2 | 3 | (println (testo/is "abs")) -------------------------------------------------------------------------------- /testdata/resolve/use/use12.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest [:use [clojure.string :only (split) :rename {split spl}]]) 2 | (spl "text" #"x") -------------------------------------------------------------------------------- /testdata/resolve/use/use14.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest [:use [clojure [string :as boo :only (join split)]]]) 2 | (split "text" #"x") -------------------------------------------------------------------------------- /testdata/resolve/useNs/my_namespace.clj: -------------------------------------------------------------------------------- 1 | (ns my-namespace 2 | (use 'clojure.contrib.base64)) 3 | 4 | (encode-str "abc") -------------------------------------------------------------------------------- /jps-plugin/src/META-INF/services/org.jetbrains.jps.incremental.BuilderService: -------------------------------------------------------------------------------- 1 | org.jetbrains.jps.clojure.build.ClojureBuilderService -------------------------------------------------------------------------------- /testdata/refactoring/JavaNames.test: -------------------------------------------------------------------------------- 1 | (defn java-name 2 | [] 3 | (let [collections (Collections/emptyList)] 4 | collections)) -------------------------------------------------------------------------------- /testdata/resolve/requireNs/require4.clj: -------------------------------------------------------------------------------- 1 | (ns boo (:require (clojure core [test :as testo]))) 2 | 3 | (println (testo/is "abs")) -------------------------------------------------------------------------------- /testdata/resolve/requireNs/require5.clj: -------------------------------------------------------------------------------- 1 | (ns boo) 2 | 3 | (require '[clojure.test :as testo]) 4 | 5 | (println (testo/is "abs")) -------------------------------------------------------------------------------- /testdata/resolve/requireNs/requireFails1.clj: -------------------------------------------------------------------------------- 1 | (ns boo (:require (clojure.test :as testo))) 2 | 3 | (println (testo/is "abs")) -------------------------------------------------------------------------------- /testdata/resolve/use/use15.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest [:use [clojure core [string :as boo :only (join split)]]]) 2 | (split "text" #"x") -------------------------------------------------------------------------------- /testdata/resolve/use/use16.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest [:use [clojure core [string :rename {join joy, split spl}]]]) 2 | (spl "text" #"x") -------------------------------------------------------------------------------- /testdata/resolve/use/useFailed5.clj: -------------------------------------------------------------------------------- 1 | (ns boo.rest [:use [clojure.string :only (join) :rename {split spl}]]) 2 | (spl "text" #"x") -------------------------------------------------------------------------------- /testdata/resolve/useNsMany/my_namespace.clj: -------------------------------------------------------------------------------- 1 | (ns my-namespace 2 | (:use (clojure data inspector))) 3 | 4 | (collection-tag nil) -------------------------------------------------------------------------------- /testdata/mockClojureLib/clojure-1.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/la-clojure/HEAD/testdata/mockClojureLib/clojure-1.5.jar -------------------------------------------------------------------------------- /testdata/mockJDK/jre/lib/annotations.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/la-clojure/HEAD/testdata/mockJDK/jre/lib/annotations.jar -------------------------------------------------------------------------------- /testdata/resolve/requireNs/require6.clj: -------------------------------------------------------------------------------- 1 | (ns boo) 2 | 3 | (require '(clojure [test :as testo])) 4 | 5 | (println (testo/is "abs")) -------------------------------------------------------------------------------- /testdata/resolve/requireNs/requireFails2.clj: -------------------------------------------------------------------------------- 1 | (ns boo (:require '(clojure core [test :as testo]))) 2 | 3 | (println (testo/is "abs")) -------------------------------------------------------------------------------- /testdata/mockClojureLib/clojure-contrib.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/la-clojure/HEAD/testdata/mockClojureLib/clojure-contrib.jar -------------------------------------------------------------------------------- /testdata/refactoring/ClojureNames.clj: -------------------------------------------------------------------------------- 1 | (defn clojure-name 2 | [config] 3 | (get-divisors 4 | (+ a b) 5 | (run-config config))) -------------------------------------------------------------------------------- /resources/fileTemplates/j2ee/ClojureFile.clj.ft: -------------------------------------------------------------------------------- 1 | #if ($PACKAGE_NAME != "")(ns 2 | ^{:author ${USER}} 3 | ${PACKAGE_NAME}.${NAME.replace('_','-')}) 4 | #end -------------------------------------------------------------------------------- /resources/intentionDescriptions/ConvertImportIntention/description.html: -------------------------------------------------------------------------------- 1 | Intention to convert different possibilities to write import call -------------------------------------------------------------------------------- /testdata/refactoring/LetAddition.clj: -------------------------------------------------------------------------------- 1 | (defn test 2 | [a t] 3 | (let [a 3 4 | b (+ 4 a)] 5 | (filter 6 | odd? 7 | (range 10)))) -------------------------------------------------------------------------------- /resources/org/jetbrains/plugins/clojure/icons/field.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/la-clojure/HEAD/resources/org/jetbrains/plugins/clojure/icons/field.png -------------------------------------------------------------------------------- /resources/org/jetbrains/plugins/clojure/icons/method.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/la-clojure/HEAD/resources/org/jetbrains/plugins/clojure/icons/method.png -------------------------------------------------------------------------------- /resources/org/jetbrains/plugins/clojure/icons/symbol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/la-clojure/HEAD/resources/org/jetbrains/plugins/clojure/icons/symbol.png -------------------------------------------------------------------------------- /testdata/parser/multiline_string-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClLiteral 3 | PsiElement(string literal)('"this is\n a multiline\n string"') 4 | -------------------------------------------------------------------------------- /testdata/parser/uncompl-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | PsiErrorElement:Uncompleted string literal 3 | PsiElement(wrong string literal)('" sdfsdfsdf \" fgbnfgn') 4 | -------------------------------------------------------------------------------- /jps-plugin/src/META-INF/services/org.jetbrains.jps.model.serialization.JpsModelSerializerExtension: -------------------------------------------------------------------------------- 1 | org.jetbrains.jps.clojure.model.impl.JpsClojureModelSerializerExtension -------------------------------------------------------------------------------- /resources/org/jetbrains/plugins/clojure/icons/def_tmp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/la-clojure/HEAD/resources/org/jetbrains/plugins/clojure/icons/def_tmp.png -------------------------------------------------------------------------------- /resources/org/jetbrains/plugins/clojure/icons/meth_tmp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/la-clojure/HEAD/resources/org/jetbrains/plugins/clojure/icons/meth_tmp.png -------------------------------------------------------------------------------- /resources/org/jetbrains/plugins/clojure/icons/repl_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/la-clojure/HEAD/resources/org/jetbrains/plugins/clojure/icons/repl_add.png -------------------------------------------------------------------------------- /resources/org/jetbrains/plugins/clojure/icons/repl_go.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/la-clojure/HEAD/resources/org/jetbrains/plugins/clojure/icons/repl_go.png -------------------------------------------------------------------------------- /resources/org/jetbrains/plugins/clojure/icons/repl_run.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/la-clojure/HEAD/resources/org/jetbrains/plugins/clojure/icons/repl_run.png -------------------------------------------------------------------------------- /testdata/refactoring/LetAddition.test: -------------------------------------------------------------------------------- 1 | (defn test 2 | [a t] 3 | (let [a 3 4 | b (+ 4 a) 5 | val (range 10)] 6 | (filter 7 | odd? 8 | val))) -------------------------------------------------------------------------------- /resources/org/jetbrains/plugins/clojure/icons/clojure_sdk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/la-clojure/HEAD/resources/org/jetbrains/plugins/clojure/icons/clojure_sdk.png -------------------------------------------------------------------------------- /resources/org/jetbrains/plugins/clojure/icons/namespace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/la-clojure/HEAD/resources/org/jetbrains/plugins/clojure/icons/namespace.png -------------------------------------------------------------------------------- /resources/org/jetbrains/plugins/clojure/icons/repl_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/la-clojure/HEAD/resources/org/jetbrains/plugins/clojure/icons/repl_close.png -------------------------------------------------------------------------------- /resources/org/jetbrains/plugins/clojure/icons/repl_eval.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/la-clojure/HEAD/resources/org/jetbrains/plugins/clojure/icons/repl_eval.png -------------------------------------------------------------------------------- /resources/org/jetbrains/plugins/clojure/icons/repl_console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/la-clojure/HEAD/resources/org/jetbrains/plugins/clojure/icons/repl_console.png -------------------------------------------------------------------------------- /testdata/formatter/nameApostrophe.clj: -------------------------------------------------------------------------------- 1 | (defn dotify-graph' [{:keys [nodes edges]}] 2 | (str 3 | "graph{" 4 | (dotify-nodes nodes) 5 | (dotify-edges' edges) 6 | "}")) -------------------------------------------------------------------------------- /testdata/formatter/nameApostrophe.test: -------------------------------------------------------------------------------- 1 | (defn dotify-graph' [{:keys [nodes edges]}] 2 | (str 3 | "graph{" 4 | (dotify-nodes nodes) 5 | (dotify-edges' edges) 6 | "}")) -------------------------------------------------------------------------------- /.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /resources/org/jetbrains/plugins/clojure/icons/clojure_icon_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/la-clojure/HEAD/resources/org/jetbrains/plugins/clojure/icons/clojure_icon_16x16.png -------------------------------------------------------------------------------- /resources/org/jetbrains/plugins/clojure/icons/clojure_sdk_missed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/la-clojure/HEAD/resources/org/jetbrains/plugins/clojure/icons/clojure_sdk_missed.png -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/api/ClSet.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.api; 2 | 3 | /** 4 | * @author ilyas 5 | */ 6 | public interface ClSet extends ClBraced { 7 | } 8 | -------------------------------------------------------------------------------- /testdata/refactoring/ClojureNames.test: -------------------------------------------------------------------------------- 1 | (defn clojure-name 2 | [config] 3 | (let [divisors (get-divisors 4 | (+ a b) 5 | (run-config config))] 6 | divisors)) -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /testdata/refactoring/Guard.clj: -------------------------------------------------------------------------------- 1 | (letfn [(twice [x] 2 | (* x 2)) 3 | (six-times [y] 4 | (* (twice y) 3))] 5 | (println "Twice 15 =" (twice 15)) 6 | (println "Six times 15 =" (six-times 15))) -------------------------------------------------------------------------------- /testdata/parser/sexp-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClList 3 | PsiElement(()('(') 4 | ClSymbol 5 | PsiElement(atom)('a') 6 | PsiWhiteSpace(' ') 7 | ClSymbol 8 | PsiElement(atom)('b') 9 | PsiElement())(')') 10 | -------------------------------------------------------------------------------- /testdata/refactoring/Guard.test: -------------------------------------------------------------------------------- 1 | (letfn [(twice [x] 2 | (* x 2)) 3 | (six-times [y] 4 | (* (twice y) 3))] 5 | (let [val (println "Twice 15 =" (twice 15))] 6 | val) 7 | (println "Six times 15 =" (six-times 15))) -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/stubs/index/ClojureIndexVersion.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.stubs.index; 2 | 3 | /** 4 | * @author ilyas 5 | */ 6 | public class ClojureIndexVersion { 7 | static int VERSION = 4; 8 | } 9 | -------------------------------------------------------------------------------- /testdata/refactoring/Occurences.clj: -------------------------------------------------------------------------------- 1 | (defn func 2 | [a b] 3 | (and 4 | (> 56 5 | (+ 6 | (+ a b) 7 | (* 8 | (+ a b) 9 | (/ a 10 | (+ a b))) 11 | (+ a b))))) -------------------------------------------------------------------------------- /testdata/refactoring/Occurences.test: -------------------------------------------------------------------------------- 1 | (defn func 2 | [a b] 3 | (and 4 | (let [val (+ a b)] 5 | (> 56 6 | (+ 7 | val 8 | (* 9 | val 10 | (/ a 11 | val)) 12 | val))))) -------------------------------------------------------------------------------- /.idea/libraries/nrepl.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/libraries/clojure_sdk.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /testdata/parser/symbols/sym1-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClSymbol 3 | ClSymbol 4 | ClSymbol 5 | PsiElement(atom)('aaa') 6 | PsiElement(ns-sep)('/') 7 | PsiElement(atom)('bbb') 8 | PsiElement(ns-sep)('/') 9 | PsiElement(atom)('CCC') 10 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/api/ClFn.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.api; 2 | 3 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElement; 4 | 5 | /** 6 | * @author ilyas 7 | */ 8 | public interface ClFn extends ClojurePsiElement{ 9 | } 10 | -------------------------------------------------------------------------------- /.idea/clojure_compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/api/ClLiteral.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.api; 2 | 3 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElement; 4 | 5 | /** 6 | * @author ilyas 7 | */ 8 | public interface ClLiteral extends ClojurePsiElement{ 9 | } 10 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/api/synthetic/ClSyntheticClass.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.api.synthetic; 2 | 3 | import com.intellij.psi.PsiClass; 4 | 5 | /** 6 | * @author ilyas 7 | */ 8 | public interface ClSyntheticClass extends PsiClass { 9 | } 10 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/ClojureActions.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure; 2 | 3 | /** 4 | * @author ilyas 5 | */ 6 | public abstract class ClojureActions { 7 | 8 | public static final String CLOJURE_EXECUTE_STATEMENT = "ClojureExecuteStatementAction"; 9 | } 10 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/api/synthetic/ClSyntheticMethod.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.api.synthetic; 2 | 3 | import com.intellij.psi.PsiMethod; 4 | 5 | /** 6 | * @author ilyas 7 | */ 8 | public interface ClSyntheticMethod extends PsiMethod{ 9 | } 10 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/api/defs/ClDefMethod.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.api.defs; 2 | 3 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElement; 4 | 5 | /** 6 | * @author ilyas 7 | */ 8 | public interface ClDefMethod extends ClojurePsiElement{ 9 | } 10 | -------------------------------------------------------------------------------- /testdata/parser/sexp45-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClList 3 | PsiElement(()('(') 4 | ClKeyword 5 | PsiElement(key)(':static') 6 | PsiWhiteSpace(' ') 7 | MetaForm 8 | PsiElement(^)('^') 9 | ClSymbol 10 | PsiElement(atom)('foo') 11 | PsiElement())(')') 12 | -------------------------------------------------------------------------------- /testdata/refactoring/LetInLet.test: -------------------------------------------------------------------------------- 1 | (defn func 2 | [a b c] 3 | (let [name0 bind0 4 | val (bind2 5 | bind) 6 | name1 (bind1 7 | val) 8 | name2 (bind4 9 | val)] 10 | (op1 11 | (op2 12 | expr1 13 | expr2)))) -------------------------------------------------------------------------------- /.idea/highlighting.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/api/ClVector.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.api; 2 | 3 | import org.jetbrains.plugins.clojure.psi.api.symbols.ClSymbol; 4 | 5 | /** 6 | * @author ilyas 7 | */ 8 | public interface ClVector extends ClListLike { 9 | 10 | ClSymbol[] getOddSymbols(); 11 | } 12 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/repl/actions/ClojureReplActionGroup.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.repl.actions; 2 | 3 | import com.intellij.openapi.actionSystem.DefaultActionGroup; 4 | 5 | /** 6 | * @author ilyas 7 | */ 8 | public class ClojureReplActionGroup extends DefaultActionGroup { 9 | 10 | } -------------------------------------------------------------------------------- /testdata/refactoring/LetInLet.clj: -------------------------------------------------------------------------------- 1 | (defn func 2 | [a b c] 3 | (let [name0 bind0 4 | name1 (bind1 5 | (bind2 6 | bind)) 7 | name2 (bind4 8 | (bind2 9 | bind))] 10 | (op1 11 | (op2 12 | expr1 13 | expr2)))) -------------------------------------------------------------------------------- /META-INF/copyright.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /testdata/parser/nameApostrophe-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClDef 3 | PsiElement(()('(') 4 | ClSymbol 5 | PsiElement(atom)('def') 6 | PsiWhiteSpace(' ') 7 | ClSymbol 8 | PsiElement(atom)('f'') 9 | PsiWhiteSpace(' ') 10 | ClLiteral 11 | PsiElement(long literal)('2') 12 | PsiElement())(')') 13 | -------------------------------------------------------------------------------- /testdata/parser/unicode_symbol-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClDef 3 | PsiElement(()('(') 4 | ClSymbol 5 | PsiElement(atom)('def') 6 | PsiWhiteSpace(' ') 7 | ClSymbol 8 | PsiElement(atom)('π') 9 | PsiWhiteSpace(' ') 10 | ClLiteral 11 | PsiElement(long literal)('2') 12 | PsiElement())(')') 13 | -------------------------------------------------------------------------------- /testdata/parser/symbols/sym5.test: -------------------------------------------------------------------------------- 1 | (ns clojure.inspector 2 | (:import 3 | (java.awt BorderLayout) 4 | (java.awt.event ActionEvent ActionListener) 5 | (javax.swing.tree TreeModel) 6 | (javax.swing.table TableModel AbstractTableModel) 7 | (javax.swing JPanel JTree JTable JScrollPane JFrame JToolBar JButton SwingUtilities))) -------------------------------------------------------------------------------- /.idea/ant.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /testdata/parser/meta-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClMetadata 3 | PsiElement(#^)('#^') 4 | ClMap 5 | PsiElement({)('{') 6 | ClMapEntry 7 | ClKeyword 8 | PsiElement(key)(':foo') 9 | PsiWhiteSpace(' ') 10 | ClLiteral 11 | PsiElement(string literal)('"bah"') 12 | PsiElement(})('}') 13 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/api/ClQuotedForm.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.api; 2 | 3 | import org.jetbrains.annotations.Nullable; 4 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElement; 5 | 6 | /** 7 | * @author ilyas 8 | */ 9 | public interface ClQuotedForm { 10 | @Nullable 11 | ClojurePsiElement getQuotedElement(); 12 | } 13 | -------------------------------------------------------------------------------- /testdata/parser/defn.test: -------------------------------------------------------------------------------- 1 | (defn 2 | "#^{:doc "mymax [xs+] gets the maximum value in xs using > " 3 | :test (fn [] 4 | (assert (= 42 (max 2 42 5 4)))) 5 | :user/comment \"this is the best fn ever!\"} 6 | mymax 7 | ([x] x) 8 | ([x y] (if (> x y) x y)) 9 | ([x y & more] 10 | (reduce mymax (mymax x y) more))) 11 | -------------------------------------------------------------------------------- /testdata/resolve/javaClass/my_namespace.clj: -------------------------------------------------------------------------------- 1 | (ns examples.test 2 | (:require [clojure.contrib.jar :as jar] 3 | [clojure.contrib.classpath :as cp] 4 | [clojure.contrib.trace :as tr]) 5 | (:import [javax.swing JFrame JPanel] 6 | [java.util Arrays] 7 | [clojure.lang PersistentArrayMap])) 8 | 9 | (new Arrays) 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/impl/ClAt.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.impl; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElementImpl; 5 | 6 | /** 7 | * @author ilyas 8 | */ 9 | public class ClAt extends ClojurePsiElementImpl { 10 | public ClAt(ASTNode node) { 11 | super(node); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/impl/ClVar.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.impl; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElementImpl; 5 | 6 | /** 7 | * @author ilyas 8 | */ 9 | public class ClVar extends ClojurePsiElementImpl { 10 | public ClVar(ASTNode node) { 11 | super(node); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /jps-plugin/src/org/jetbrains/jps/clojure/model/impl/JpsClojureCompilerSettingsState.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.jps.clojure.model.impl; 2 | 3 | /** 4 | * @author nik 5 | * @since 02.11.12 6 | */ 7 | public class JpsClojureCompilerSettingsState { 8 | public boolean COMPILE_CLOJURE = false; 9 | public boolean CLOJURE_BEFORE = true; 10 | public boolean COPY_CLJ_SOURCES = false; 11 | } 12 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/impl/ClSharp.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.impl; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElementImpl; 5 | 6 | /** 7 | * @author ilyas 8 | */ 9 | public class ClSharp extends ClojurePsiElementImpl { 10 | public ClSharp(ASTNode node) { 11 | super(node); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/impl/ClTilda.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.impl; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElementImpl; 5 | 6 | /** 7 | * @author ilyas 8 | */ 9 | public class ClTilda extends ClojurePsiElementImpl { 10 | public ClTilda(ASTNode node) { 11 | super(node); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /testdata/formatter/clj_98.clj: -------------------------------------------------------------------------------- 1 | (ns timda.core 2 | (:require [timda.core] 3 | [clojure.contrib.string :as string]) 4 | (:import [javax.mail Session MessagingException Folder] 5 | [javax.mail.internet InternetAddress] 6 | [java.io File])) 7 | 8 | (defn a [a b c] 9 | (let [d a 10 | e (fn [x y] 11 | (+ b 12 | (/ x y))) 13 | f c]) 14 | ) -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/impl/ClTildaAt.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.impl; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElementImpl; 5 | 6 | /** 7 | * @author ilyas 8 | */ 9 | public class ClTildaAt extends ClojurePsiElementImpl { 10 | public ClTildaAt(ASTNode node) { 11 | super(node); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/api/ClKeyword.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.api; 2 | 3 | import com.intellij.psi.PsiNamedElement; 4 | import com.intellij.psi.PsiReference; 5 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElement; 6 | 7 | /** 8 | * @author ilyas 9 | */ 10 | public interface ClKeyword extends ClojurePsiElement, PsiNamedElement, PsiReference { 11 | } 12 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/impl/ClBindings.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.impl; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElementImpl; 5 | 6 | /** 7 | * @author ilyas 8 | */ 9 | public class ClBindings extends ClojurePsiElementImpl { 10 | public ClBindings(ASTNode node) { 11 | super(node); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/impl/synthetic/SynteticUtil.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.impl.synthetic; 2 | 3 | import org.jetbrains.plugins.clojure.psi.api.defs.ClDef; 4 | 5 | /** 6 | * @author ilyas 7 | */ 8 | public abstract class SynteticUtil { 9 | public static String getJavaMethodByDef(ClDef def) { 10 | return "public static void main"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/resolve/ClojureResolveResult.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.resolve; 2 | 3 | import com.intellij.psi.ResolveResult; 4 | 5 | /** 6 | * @author ilyas 7 | */ 8 | public interface ClojureResolveResult extends ResolveResult { 9 | 10 | public ClojureResolveResult[] EMPTY_ARRAY = new ClojureResolveResult[0]; 11 | 12 | boolean isAccessible(); 13 | } 14 | -------------------------------------------------------------------------------- /testdata/formatter/clj_98.test: -------------------------------------------------------------------------------- 1 | (ns timda.core 2 | (:require [timda.core] 3 | [clojure.contrib.string :as string]) 4 | (:import [javax.mail Session MessagingException Folder] 5 | [javax.mail.internet InternetAddress] 6 | [java.io File])) 7 | 8 | (defn a [a b c] 9 | (let [d a 10 | e (fn [x y] 11 | (+ b 12 | (/ x y))) 13 | f c]) 14 | ) -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/impl/ClBackQuotedExpression.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.impl; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElementImpl; 5 | 6 | /** 7 | * @author ilyas 8 | */ 9 | public class ClBackQuotedExpression extends ClojurePsiElementImpl { 10 | public ClBackQuotedExpression(ASTNode node) { 11 | super(node); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /testdata/refactoring/MultiBody.clj: -------------------------------------------------------------------------------- 1 | (fact 2 | "Better constructor works" 3 | (let [test-user (new-user "Mark" "Mandel" "email" "password")] 4 | (:id test-user) => truthy 5 | (:firstname test-user) => "Mark" 6 | (:lastname test-user) => "Mandel" 7 | (:password test-user) => "password" 8 | (:email test-user) => "email" 9 | (:photo test-user) => nil 10 | (:last-logged-in test-user) => nil 11 | ) 12 | ) -------------------------------------------------------------------------------- /testdata/refactoring/MultiBody.test: -------------------------------------------------------------------------------- 1 | (fact 2 | "Better constructor works" 3 | (let [test-user (new-user "Mark" "Mandel" "email" "password") 4 | val (:password test-user)] 5 | (:id test-user) => truthy 6 | (:firstname test-user) => "Mark" 7 | (:lastname test-user) => "Mandel" 8 | val => "password" 9 | (:email test-user) => "email" 10 | (:photo test-user) => nil 11 | (:last-logged-in test-user) => nil) 12 | ) -------------------------------------------------------------------------------- /jps-plugin/src/org/jetbrains/jps/clojure/model/JpsClojureCompilerSettingsExtension.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.jps.clojure.model; 2 | 3 | import org.jetbrains.jps.model.JpsElement; 4 | 5 | /** 6 | * @author nik 7 | * @since 02.11.12 8 | */ 9 | public interface JpsClojureCompilerSettingsExtension extends JpsElement { 10 | 11 | boolean isCompileClojure(); 12 | 13 | boolean isClojureBefore(); 14 | 15 | boolean isCopyCljSources(); 16 | } 17 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/impl/ClFnImpl.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.impl; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElementImpl; 5 | import org.jetbrains.plugins.clojure.psi.api.ClFn; 6 | 7 | /** 8 | * @author ilyas 9 | */ 10 | public class ClFnImpl extends ClojurePsiElementImpl implements ClFn { 11 | public ClFnImpl(ASTNode node) { 12 | super(node); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /testdata/parser/symbols/sym4-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClSymbol 3 | ClSymbol 4 | ClSymbol 5 | ClSymbol 6 | ClSymbol 7 | ClSymbol 8 | PsiElement(atom)('Aaaa') 9 | PsiElement(ns-sep)('/') 10 | PsiElement(ns-sep)('/') 11 | PsiElement(ns-sep)('/') 12 | PsiElement(atom)('ddd') 13 | PsiElement(ns-sep)('/') 14 | PsiElement(ns-sep)('/') 15 | PsiElement(atom)('Ccccc') 16 | -------------------------------------------------------------------------------- /resources/fileTemplates/j2ee/ClojureFile.clj.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 11 | 12 |
6 | 7 | This is a built-in template used by IDEA each time you create a 8 | Clojure file 9 | 10 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /testdata/parser/sexp2-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClList 3 | PsiElement(()('(') 4 | ClSymbol 5 | PsiElement(atom)('a') 6 | PsiWhiteSpace(' ') 7 | ClSymbol 8 | PsiElement(atom)('b') 9 | PsiWhiteSpace(' ') 10 | ClList 11 | PsiElement(()('(') 12 | ClSymbol 13 | PsiElement(atom)('c') 14 | PsiWhiteSpace(' ') 15 | ClSymbol 16 | PsiElement(atom)('d') 17 | PsiElement())(')') 18 | PsiElement())(')') 19 | -------------------------------------------------------------------------------- /clojure-runner/clojure-runner.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/clojure/org/jetbrains/plugins/clojure/init_clojure.clj: -------------------------------------------------------------------------------- 1 | (ns org.jetbrains.plugins.clojure.init-clojure 2 | (:require org.jetbrains.plugins.clojure.intention.convert-import-intention) 3 | (:require org.jetbrains.plugins.clojure.refactoring.clojure-refactoring-support-provider)) 4 | 5 | (defn init [] 6 | (do 7 | (org.jetbrains.plugins.clojure.intention.convert-import-intention/init) 8 | (org.jetbrains.plugins.clojure.refactoring.clojure-refactoring-support-provider/init))) 9 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/refactoring/rename/ClojureSymbolPattern.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.refactoring.rename; 2 | 3 | import com.intellij.patterns.ObjectPattern; 4 | import org.jetbrains.plugins.clojure.psi.api.symbols.ClSymbol; 5 | 6 | /** 7 | * @author ilyas 8 | */ 9 | public class ClojureSymbolPattern extends ObjectPattern{ 10 | public ClojureSymbolPattern() { 11 | super(ClSymbol.class); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /testdata/parser/vector-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClVector 3 | PsiElement([)('[') 4 | ClSymbol 5 | PsiElement(atom)('a') 6 | PsiWhiteSpace(' ') 7 | ClSymbol 8 | PsiElement(atom)('b') 9 | PsiWhiteSpace(' ') 10 | ClList 11 | PsiElement(()('(') 12 | ClSymbol 13 | PsiElement(atom)('c') 14 | PsiWhiteSpace(' ') 15 | ClSymbol 16 | PsiElement(atom)('d') 17 | PsiElement())(')') 18 | PsiElement(])(']') 19 | -------------------------------------------------------------------------------- /testdata/resolve/requireSymbol/my_namespace.clj: -------------------------------------------------------------------------------- 1 | (ns examples.test 2 | (:require [clojure.contrib.jar :as jar] 3 | [clojure.contrib.classpath :as cp] 4 | [clojure.contrib.trace :as tr]) 5 | (:import [javax.swing JFrame JPanel] 6 | [java.util Arrays] 7 | [clojure.lang PersistentArrayMap])) 8 | 9 | (new JFrame (new JPanel)) 10 | 11 | (jar/filenames-in-jar) 12 | (cp/classpath-directories) 13 | (tr/trace-fn-call) 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/stubs/api/ClKeywordStub.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.stubs.api; 2 | 3 | import com.intellij.psi.stubs.NamedStub; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.jetbrains.annotations.Nullable; 6 | import org.jetbrains.plugins.clojure.psi.api.ClKeyword; 7 | 8 | /** 9 | * @author ilyas 10 | */ 11 | public interface ClKeywordStub extends NamedStub { 12 | @NotNull 13 | String getName(); 14 | } 15 | -------------------------------------------------------------------------------- /jps-plugin/clojure-jps-plugin.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/impl/ClMetaForm.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.impl; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElementImpl; 5 | 6 | /** 7 | * @author ilyas 8 | */ 9 | public class ClMetaForm extends ClojurePsiElementImpl { 10 | public ClMetaForm(ASTNode node) { 11 | super(node); 12 | } 13 | 14 | @Override 15 | public String toString() { 16 | return "MetaForm"; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /.idea/artifacts/Production.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/out/artifacts/Production 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/impl/ClLiteralImpl.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.impl; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElementImpl; 5 | import org.jetbrains.plugins.clojure.psi.api.ClLiteral; 6 | 7 | /** 8 | * @author ilyas 9 | */ 10 | public class ClLiteralImpl extends ClojurePsiElementImpl implements ClLiteral { 11 | public ClLiteralImpl(ASTNode node) { 12 | super(node, "ClLiteral"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/ClojurePsiElement.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi; 2 | 3 | import com.intellij.psi.PsiElement; 4 | import org.jetbrains.annotations.Nullable; 5 | 6 | /** 7 | * @author ilyas 8 | */ 9 | public interface ClojurePsiElement extends PsiElement { 10 | 11 | @Nullable 12 | PsiElement getFirstNonLeafElement(); 13 | 14 | @Nullable 15 | PsiElement getLastNonLeafElement(); 16 | 17 | @Nullable 18 | PsiElement getNonLeafElement(int k); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/stubs/api/ClFileStub.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.stubs.api; 2 | 3 | import com.intellij.psi.stubs.PsiFileStub; 4 | import com.intellij.util.io.StringRef; 5 | import org.jetbrains.plugins.clojure.psi.api.ClojureFile; 6 | 7 | /** 8 | * @author ilyas 9 | */ 10 | public interface ClFileStub extends PsiFileStub { 11 | StringRef getPackageName(); 12 | 13 | StringRef getClassName(); 14 | 15 | boolean isClassDefinition(); 16 | } 17 | 18 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/api/ClListLike.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.api; 2 | 3 | import org.jetbrains.annotations.Nullable; 4 | import org.jetbrains.plugins.clojure.psi.api.symbols.ClSymbol; 5 | 6 | /** 7 | * @author ilyas 8 | */ 9 | public interface ClListLike extends ClBraced { 10 | T findFirstChildByClass(Class aClass); 11 | 12 | @Nullable 13 | String getHeadText(); 14 | 15 | ClSymbol[] getAllSymbols(); 16 | 17 | ClSymbol[] getAllQuotedSymbols(); 18 | } 19 | -------------------------------------------------------------------------------- /testdata/parser/sexp4-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClList 3 | PsiElement(()('(') 4 | ClSymbol 5 | PsiElement(atom)('apply') 6 | PsiWhiteSpace(' ') 7 | ClSymbol 8 | PsiElement(atom)('merge-with') 9 | PsiWhiteSpace(' ') 10 | ClSymbol 11 | PsiElement(atom)('concat') 12 | PsiWhiteSpace(' ') 13 | ClMap 14 | PsiElement({)('{') 15 | PsiElement(})('}') 16 | PsiWhiteSpace(' ') 17 | ClSymbol 18 | PsiElement(atom)('all-sigs') 19 | PsiElement())(')') 20 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/highlighter/ClojureEditorHighlighter.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.highlighter; 2 | 3 | import com.intellij.openapi.editor.colors.EditorColorsScheme; 4 | import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter; 5 | 6 | /** 7 | * @author ilyas 8 | */ 9 | public class ClojureEditorHighlighter extends LexerEditorHighlighter{ 10 | public ClojureEditorHighlighter(EditorColorsScheme scheme) { 11 | super(new ClojureSyntaxHighlighter(), scheme); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/api/ClBraced.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.api; 2 | 3 | import com.intellij.psi.PsiElement; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.jetbrains.annotations.Nullable; 6 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElement; 7 | 8 | /** 9 | * @author ilyas 10 | */ 11 | public interface ClBraced extends ClojurePsiElement { 12 | @NotNull 13 | PsiElement getFirstBrace(); 14 | 15 | @Nullable 16 | PsiElement getLastBrace(); 17 | } 18 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/lexer/TokenSets.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.lexer; 2 | 3 | import com.intellij.psi.tree.TokenSet; 4 | 5 | /** 6 | * @author ilyas 7 | */ 8 | public class TokenSets implements ClojureTokenTypes { 9 | 10 | public static final TokenSet REFERENCE_NAMES = TokenSet.create(symATOM); 11 | 12 | public static final TokenSet DOTS = TokenSet.create(symDOT, symNS_SEP); 13 | 14 | public static final TokenSet RIGHT_PARENTHESES = TokenSet.create(RIGHT_CURLY, RIGHT_PAREN, RIGHT_SQUARE); 15 | } 16 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/api/ClList.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.api; 2 | 3 | import org.jetbrains.plugins.clojure.psi.api.symbols.ClSymbol; 4 | import org.jetbrains.annotations.Nullable; 5 | import com.intellij.psi.PsiElement; 6 | 7 | /** 8 | * @author ilyas 9 | */ 10 | public interface ClList extends ClListLike { 11 | @Nullable 12 | String getPresentableText(); 13 | 14 | @Nullable 15 | ClSymbol getFirstSymbol(); 16 | 17 | @Nullable 18 | PsiElement getSecondNonLeafElement(); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/api/ClMap.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.api; 2 | 3 | import org.jetbrains.annotations.Nullable; 4 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElement; 5 | import org.jetbrains.plugins.clojure.psi.impl.ClMapEntry; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author ilyas 11 | */ 12 | public interface ClMap extends ClojurePsiElement, ClBraced { 13 | List getEntries(); 14 | 15 | @Nullable 16 | ClojurePsiElement getValue(final String key); 17 | } 18 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/api/ClMetadata.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.api; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.jetbrains.annotations.Nullable; 5 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElement; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author ilyas 11 | */ 12 | public interface ClMetadata extends ClojurePsiElement { 13 | 14 | @NotNull 15 | List getKeys(); 16 | 17 | @Nullable 18 | ClojurePsiElement getValue(String key); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /testdata/parser/quote-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClQuotedForm 3 | PsiElement(')(''') 4 | ClList 5 | PsiElement(()('(') 6 | ClSymbol 7 | PsiElement(atom)('a') 8 | PsiWhiteSpace(' ') 9 | ClSymbol 10 | PsiElement(atom)('b') 11 | PsiWhiteSpace(' ') 12 | ClList 13 | PsiElement(()('(') 14 | ClSymbol 15 | PsiElement(atom)('c') 16 | PsiWhiteSpace(' ') 17 | ClSymbol 18 | PsiElement(atom)('d') 19 | PsiElement())(')') 20 | PsiElement())(')') 21 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/refactoring/rename/RenameClojureFileProcessor.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.refactoring.rename; 2 | 3 | import com.intellij.psi.PsiElement; 4 | import com.intellij.refactoring.rename.RenamePsiElementProcessor; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | /** 8 | * @author ilyas 9 | */ 10 | public class RenameClojureFileProcessor extends RenamePsiElementProcessor { 11 | @Override 12 | public boolean canProcessElement(@NotNull PsiElement element) { 13 | return false; //todo: ? 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testdata/resolve/requireNs/my_namespace.clj: -------------------------------------------------------------------------------- 1 | (ns examples.test 2 | (:require [clojure.contrib.jar :as jar] 3 | [clojure.contrib.classpath :as cp] 4 | [clojure.contrib.trace :as tr]) 5 | (:import [javax.swing JFrame JPanel] 6 | [java.util Arrays] 7 | [clojure.lang PersistentArrayMap]) 8 | (:use [clojure.contrib.string :only (spli)])) 9 | 10 | (new JFrame (new JPanel)) 11 | 12 | (clojure.contrib.string/split-lines ) 13 | 14 | (jar/filenames-in-jar) 15 | (cp/classpath-directories) 16 | (tr/trace-fn-call) 17 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/impl/ClMapEntry.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.impl; 2 | 3 | import org.jetbrains.annotations.Nullable; 4 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElement; 5 | import org.jetbrains.plugins.clojure.psi.api.ClKeyword; 6 | 7 | /** 8 | * @author ilyas 9 | */ 10 | public interface ClMapEntry extends ClojurePsiElement { 11 | 12 | @Nullable 13 | ClKeyword getKeywordKey(); 14 | 15 | @Nullable 16 | ClojurePsiElement getKey(); 17 | 18 | @Nullable 19 | ClojurePsiElement getValue(); 20 | } 21 | -------------------------------------------------------------------------------- /testdata/parser/str4-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClMap 3 | PsiElement({)('{') 4 | PsiWhiteSpace('\n ') 5 | ClMapEntry 6 | ClLiteral 7 | PsiElement(character literal)('\\') 8 | PsiWhiteSpace(' ') 9 | ClLiteral 10 | PsiElement(string literal)('"\\\\"') 11 | PsiWhiteSpace('\n ') 12 | ClMapEntry 13 | ClLiteral 14 | PsiElement(character literal)('\backspace') 15 | PsiWhiteSpace(' ') 16 | ClLiteral 17 | PsiElement(string literal)('"\\b"') 18 | PsiWhiteSpace('\n') 19 | PsiElement(})('}') 20 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/compiler/ClojureCompilerSettingsFactory.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.compiler; 2 | 3 | import com.intellij.compiler.CompilerSettingsFactory; 4 | import com.intellij.openapi.options.Configurable; 5 | import com.intellij.openapi.project.Project; 6 | 7 | /** 8 | * @author ilyas 9 | */ 10 | public class ClojureCompilerSettingsFactory implements CompilerSettingsFactory { 11 | public Configurable create(Project project) { 12 | return new ClojureCompilerConfigurable(ClojureCompilerSettings.getInstance(project), project); 13 | } 14 | } -------------------------------------------------------------------------------- /testdata/parser/symbols/sym3-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClList 3 | PsiElement(()('(') 4 | ClSymbol 5 | PsiElement(dot)('.') 6 | PsiWhiteSpace(' ') 7 | ClList 8 | PsiElement(()('(') 9 | ClSymbol 10 | PsiElement(atom)('identity') 11 | PsiWhiteSpace(' ') 12 | ClSymbol 13 | PsiElement(atom)('Classname') 14 | PsiElement())(')') 15 | PsiWhiteSpace(' ') 16 | ClSymbol 17 | PsiElement(atom)('instanceMember') 18 | PsiWhiteSpace(' ') 19 | ClSymbol 20 | PsiElement(atom)('args') 21 | PsiElement())(')') 22 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/impl/symbols/ClImplicitArgumentImpl.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.impl.symbols; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | /** 7 | * @author ilyas 8 | */ 9 | public class ClImplicitArgumentImpl extends ClSymbolImpl { 10 | public ClImplicitArgumentImpl(ASTNode node) { 11 | super(node); 12 | } 13 | 14 | @Override 15 | public String toString() { 16 | return "ClImplicitArgument"; 17 | } 18 | 19 | @NotNull 20 | public String getNameString() { 21 | return getText(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/impl/ns/ClCreateNsImpl.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.impl.ns; 2 | 3 | import org.jetbrains.plugins.clojure.psi.stubs.api.ClNsStub; 4 | import org.jetbrains.annotations.NotNull; 5 | import com.intellij.psi.stubs.IStubElementType; 6 | import com.intellij.lang.ASTNode; 7 | 8 | /** 9 | * @author ilyas 10 | */ 11 | public class ClCreateNsImpl extends ClNsImpl{ 12 | public ClCreateNsImpl(ClNsStub stub, @NotNull IStubElementType nodeType) { 13 | super(stub, nodeType); 14 | } 15 | 16 | public ClCreateNsImpl(ASTNode node) { 17 | super(node); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/formatter/codeStyle/ClojureCodeStyleSettings.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.formatter.codeStyle; 2 | 3 | import com.intellij.psi.codeStyle.CustomCodeStyleSettings; 4 | import com.intellij.psi.codeStyle.CodeStyleSettings; 5 | import org.jetbrains.annotations.NonNls; 6 | 7 | /** 8 | * @author ilyas 9 | */ 10 | public class ClojureCodeStyleSettings extends CustomCodeStyleSettings{ 11 | 12 | public boolean ALIGN_CLOJURE_FORMS = false; 13 | 14 | protected ClojureCodeStyleSettings(CodeStyleSettings container) { 15 | super("ClojureCodeStyleSettings", container); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/debugger/ClojurePositionManagerFactory.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.debugger; 2 | 3 | import com.intellij.debugger.PositionManager; 4 | import com.intellij.debugger.PositionManagerFactory; 5 | import com.intellij.debugger.engine.DebugProcess; 6 | import org.jetbrains.annotations.Nullable; 7 | 8 | /** 9 | * @author ilyas 10 | */ 11 | public class ClojurePositionManagerFactory extends PositionManagerFactory { 12 | @Nullable 13 | @Override 14 | public PositionManager createPositionManager(DebugProcess process) { 15 | return new ClojurePositionManager(process); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/resolve/processors/ResolveKind.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.resolve.processors; 2 | 3 | /** 4 | * @author Alefas 5 | * @since 22.01.13 6 | */ 7 | public enum ResolveKind { 8 | NAMESPACE, JAVA_CLASS, OTHER; 9 | 10 | public static ResolveKind[] allKinds() { 11 | return new ResolveKind[] {ResolveKind.JAVA_CLASS, ResolveKind.NAMESPACE, ResolveKind.OTHER}; 12 | } 13 | 14 | public static ResolveKind[] javaClassesKinds() { 15 | return new ResolveKind[] {JAVA_CLASS}; 16 | } 17 | 18 | public static ResolveKind[] namesSpaceKinds() { 19 | return new ResolveKind[] {NAMESPACE}; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/stubs/index/ClDefNameIndex.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.stubs.index; 2 | 3 | import com.intellij.psi.stubs.StringStubIndexExtension; 4 | import com.intellij.psi.stubs.StubIndexKey; 5 | import org.jetbrains.plugins.clojure.psi.api.defs.ClDef; 6 | 7 | /** 8 | * @author ilyas 9 | */ 10 | public class ClDefNameIndex extends StringStubIndexExtension { 11 | public static final StubIndexKey KEY = StubIndexKey.createIndexKey("clj.def.name"); 12 | 13 | public StubIndexKey getKey() { 14 | return KEY; 15 | } 16 | 17 | @Override 18 | public int getVersion() { 19 | return ClojureIndexVersion.VERSION; 20 | } 21 | } -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/stubs/index/ClojureNsNameIndex.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.stubs.index; 2 | 3 | import com.intellij.psi.stubs.StringStubIndexExtension; 4 | import com.intellij.psi.stubs.StubIndexKey; 5 | import org.jetbrains.plugins.clojure.psi.api.ns.ClNs; 6 | 7 | /** 8 | * @author ilyas 9 | */ 10 | public class ClojureNsNameIndex extends StringStubIndexExtension { 11 | public static final StubIndexKey KEY = StubIndexKey.createIndexKey("clj.ns.name"); 12 | 13 | public StubIndexKey getKey() { 14 | return KEY; 15 | } 16 | 17 | @Override 18 | public int getVersion() { 19 | return ClojureIndexVersion.VERSION; 20 | } 21 | } -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/config/ClojureModuleSettings.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.config; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.jetbrains.plugins.clojure.utils.ClojureUtils; 5 | 6 | /** 7 | * @author ilyas 8 | */ 9 | public class ClojureModuleSettings { 10 | 11 | @NotNull 12 | public String myReplClass = ClojureUtils.CLOJURE_MAIN; 13 | 14 | @NotNull 15 | public String myJvmOpts = ClojureUtils.CLOJURE_DEFAULT_JVM_PARAMS; 16 | 17 | @NotNull 18 | public String myReplOpts = ""; 19 | 20 | public boolean myRunNrepl = false; 21 | 22 | @NotNull 23 | public String myNreplHost = "localhost"; 24 | 25 | @NotNull 26 | public String myReplPort = "7888"; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/stubs/index/ClojureKeywordIndex.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.stubs.index; 2 | 3 | import com.intellij.psi.stubs.StringStubIndexExtension; 4 | import com.intellij.psi.stubs.StubIndexKey; 5 | import org.jetbrains.plugins.clojure.psi.api.ClKeyword; 6 | 7 | /** 8 | * @author ilyas 9 | */ 10 | public class ClojureKeywordIndex extends StringStubIndexExtension { 11 | public static final StubIndexKey KEY = StubIndexKey.createIndexKey("clj.keywords"); 12 | 13 | public StubIndexKey getKey() { 14 | return KEY; 15 | } 16 | 17 | @Override 18 | public int getVersion() { 19 | return ClojureIndexVersion.VERSION; 20 | } 21 | } -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/runner/console/ClojureConsoleFilterProvider.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.runner.console; 2 | 3 | import com.intellij.execution.filters.ConsoleFilterProvider; 4 | import com.intellij.execution.filters.Filter; 5 | import com.intellij.execution.filters.ExceptionFilter; 6 | import com.intellij.execution.filters.YourkitFilter; 7 | import com.intellij.openapi.project.Project; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | /** 11 | * @author ilyas 12 | */ 13 | public class ClojureConsoleFilterProvider implements ConsoleFilterProvider { 14 | @NotNull 15 | public Filter[] getDefaultFilters(@NotNull Project project) { 16 | return new Filter[]{new ClojureFilter(project)}; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/org/jetbrains/plugins/clojure/refactoring/RenameTest.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.refactoring; 2 | 3 | import com.intellij.psi.PsiElement; 4 | import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; 5 | 6 | /** 7 | * @author peter 8 | */ 9 | public class RenameTest extends LightCodeInsightFixtureTestCase { 10 | 11 | public void testDash() { 12 | myFixture.configureByText("a.clj", "(let [a-b 2] a-b)"); 13 | PsiElement parameter = myFixture.getFile().findReferenceAt(myFixture.getEditor().getCaretModel().getOffset()).resolve(); 14 | myFixture.renameElement(parameter, "newName-c", true, true); 15 | myFixture.checkResult("(let [newName-c 2] newName-c)"); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/stubs/index/ClojureClassNameIndex.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.stubs.index; 2 | 3 | import com.intellij.psi.stubs.StringStubIndexExtension; 4 | import com.intellij.psi.stubs.StubIndexKey; 5 | import org.jetbrains.plugins.clojure.psi.api.ClojureFile; 6 | 7 | /** 8 | * @author ilyas 9 | */ 10 | public class ClojureClassNameIndex extends StringStubIndexExtension { 11 | public static final StubIndexKey KEY = StubIndexKey.createIndexKey("clj.class"); 12 | 13 | public StubIndexKey getKey() { 14 | return KEY; 15 | } 16 | 17 | @Override 18 | public int getVersion() { 19 | return ClojureIndexVersion.VERSION; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/util/ClojureKeywords.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.util; 2 | 3 | /** 4 | * @author ilyas 5 | */ 6 | public abstract class ClojureKeywords { 7 | public static final String GEN_CLASS = ":gen-class"; 8 | public static final String EXTENDS = ":extends"; 9 | public static final String IMPLEMENTS = ":implements"; 10 | public static final String IMPORT= ":import"; 11 | public static final String REQUIRE = ":require"; 12 | public static final String REFER = ":refer"; 13 | public static final String USE = ":use"; 14 | public static final String AS = ":as"; 15 | public static final String ONLY = ":only"; 16 | public static final String EXCLUDE = ":exclude"; 17 | public static final String RENAME = ":rename"; 18 | } 19 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/resolve/completion/CompletionProcessor.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.resolve.completion; 2 | 3 | import com.intellij.psi.PsiElement; 4 | import com.intellij.psi.ResolveState; 5 | import org.jetbrains.plugins.clojure.psi.resolve.processors.ResolveKind; 6 | import org.jetbrains.plugins.clojure.psi.resolve.processors.SymbolResolveProcessor; 7 | 8 | /** 9 | * @author ilyas 10 | */ 11 | public class CompletionProcessor extends SymbolResolveProcessor { 12 | 13 | public CompletionProcessor(PsiElement myPlace, ResolveKind[] kinds) { 14 | super(null, myPlace, true, kinds); 15 | } 16 | 17 | public boolean execute(PsiElement element, ResolveState state) { 18 | super.execute(element, state); 19 | return true; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/stubs/ClojureFileStubBuilder.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.stubs; 2 | 3 | import com.intellij.psi.stubs.DefaultStubBuilder; 4 | import com.intellij.psi.stubs.StubElement; 5 | import com.intellij.psi.PsiFile; 6 | import org.jetbrains.plugins.clojure.psi.api.ClojureFile; 7 | import org.jetbrains.plugins.clojure.psi.stubs.impl.ClFileStubImpl; 8 | 9 | /** 10 | * @author ilyas 11 | */ 12 | public class ClojureFileStubBuilder extends DefaultStubBuilder { 13 | protected StubElement createStubForFile(final PsiFile file) { 14 | if (file instanceof ClojureFile && ((ClojureFile) file).isClassDefiningFile()) { 15 | return new ClFileStubImpl((ClojureFile)file); 16 | } 17 | 18 | return super.createStubForFile(file); 19 | } 20 | } -------------------------------------------------------------------------------- /test/org/jetbrains/plugins/clojure/completion/ClojureBasicCompletionTest.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.completion; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * @author Alefas 7 | * @since 29.04.13 8 | */ 9 | public class ClojureBasicCompletionTest extends ClojureCompletionTestBase { 10 | public void testSimpleClassName() throws IOException { 11 | String fileText = 12 | "(def foo (fn [y xsxxx]))"; 13 | configureFromFileText("dummy.clj", fileText); 14 | final CompleteResult complete = complete(); 15 | assertNull(complete); 16 | } 17 | 18 | public void testNothingInLet() throws IOException { 19 | configureFromFileText("dummy.clj", "(let [xxx])"); 20 | CompleteResult result = complete(); 21 | assertNull(result); 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testdata/parser/map-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClMap 3 | PsiElement({)('{') 4 | PsiWhiteSpace(' ') 5 | ClMapEntry 6 | ClKeyword 7 | PsiElement(key)(':a') 8 | PsiWhiteSpace(' ') 9 | ClSymbol 10 | PsiElement(atom)('a') 11 | PsiWhiteSpace(' ') 12 | ClMapEntry 13 | ClKeyword 14 | PsiElement(key)(':b') 15 | PsiWhiteSpace(' ') 16 | ClSymbol 17 | PsiElement(atom)('b') 18 | PsiWhiteSpace(' ') 19 | ClMapEntry 20 | ClKeyword 21 | PsiElement(key)(':cd') 22 | PsiWhiteSpace(' ') 23 | ClList 24 | PsiElement(()('(') 25 | ClSymbol 26 | PsiElement(atom)('c') 27 | PsiWhiteSpace(' ') 28 | ClSymbol 29 | PsiElement(atom)('d') 30 | PsiElement())(')') 31 | PsiElement(})('}') 32 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/api/defs/ClDef.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.api.defs; 2 | 3 | import com.intellij.navigation.NavigationItem; 4 | import com.intellij.psi.PsiNamedElement; 5 | import org.jetbrains.annotations.Nullable; 6 | import org.jetbrains.plugins.clojure.psi.api.ClList; 7 | import org.jetbrains.plugins.clojure.psi.api.ClMetadata; 8 | import org.jetbrains.plugins.clojure.psi.api.symbols.ClSymbol; 9 | 10 | /** 11 | * @author ilyas 12 | */ 13 | public interface ClDef extends ClList, PsiNamedElement, NavigationItem { 14 | @Nullable 15 | ClSymbol getNameSymbol(); 16 | 17 | String getDefinedName(); 18 | 19 | String getPresentationText(); 20 | 21 | @Nullable 22 | String getDocString(); 23 | 24 | String getParameterString(); 25 | 26 | @Nullable 27 | ClMetadata getMeta(); 28 | } 29 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/resolve/ClojureResolveResultImpl.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.resolve; 2 | 3 | import com.intellij.psi.PsiElement; 4 | 5 | /** 6 | * @author ilyas 7 | */ 8 | public class ClojureResolveResultImpl implements ClojureResolveResult { 9 | 10 | private final PsiElement myElement; 11 | private final boolean myIsAccessible; 12 | 13 | public ClojureResolveResultImpl(PsiElement myElement, boolean myIsAccessible) { 14 | this.myElement = myElement; 15 | this.myIsAccessible = myIsAccessible; 16 | } 17 | 18 | 19 | public PsiElement getElement() { 20 | return myElement; 21 | } 22 | 23 | public boolean isValidResult() { 24 | return isAccessible(); 25 | } 26 | 27 | public boolean isAccessible() { 28 | return myIsAccessible; 29 | } 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /test/org/jetbrains/plugins/clojure/intentions/ConvertImportIntentionTest.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.intentions; 2 | 3 | /** 4 | * @author Stanislav.Osipov 5 | * @since 8/8/13 6 | */ 7 | public class ConvertImportIntentionTest extends ClojureIntentionTestBase { 8 | 9 | public void testImport1() throws Exception { 10 | doTest(); 11 | } 12 | 13 | public void testImport2() throws Exception { 14 | doTest(); 15 | } 16 | 17 | public void testImport3() throws Exception { 18 | doTest(); 19 | } 20 | 21 | public void testImport4() throws Exception { 22 | assertNotAvailable(); 23 | } 24 | 25 | public void testImport5() throws Exception { 26 | assertNotAvailable(); 27 | } 28 | 29 | @Override 30 | protected String getIntentionName() { 31 | return "(Un)Quote statement"; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/utils/ClojureNamesUtil.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.utils; 2 | 3 | import com.intellij.openapi.application.ApplicationManager; 4 | import com.intellij.lexer.Lexer; 5 | import org.jetbrains.plugins.clojure.lexer.ClojureTokenTypes; 6 | import org.jetbrains.plugins.clojure.lexer.ClojureFlexLexer; 7 | 8 | /** 9 | * @author ilyas 10 | */ 11 | public class ClojureNamesUtil { 12 | 13 | public static boolean isIdentifier(String text) { 14 | ApplicationManager.getApplication().assertReadAccessAllowed(); 15 | if (text == null) return false; 16 | Lexer lexer = new ClojureFlexLexer(); 17 | lexer.start(text, 0, text.length(), 0); 18 | if (lexer.getTokenType() != ClojureTokenTypes.symATOM) return false; 19 | lexer.advance(); 20 | return lexer.getTokenType() == null; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/impl/ClQuotedFormImpl.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.impl; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElementImpl; 5 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElement; 6 | import org.jetbrains.plugins.clojure.psi.api.ClQuotedForm; 7 | import org.jetbrains.annotations.Nullable; 8 | 9 | /** 10 | * @author ilyas 11 | */ 12 | public class ClQuotedFormImpl extends ClojurePsiElementImpl implements ClQuotedForm { 13 | public ClQuotedFormImpl(ASTNode node) { 14 | super(node); 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return "ClQuotedForm"; 20 | } 21 | 22 | @Nullable 23 | public ClojurePsiElement getQuotedElement() { 24 | return findChildByClass(ClojurePsiElement.class); 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /jps-plugin/src/org/jetbrains/jps/clojure/build/ClojureBuilderService.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.jps.clojure.build; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.jetbrains.jps.incremental.BuilderCategory; 5 | import org.jetbrains.jps.incremental.BuilderService; 6 | import org.jetbrains.jps.incremental.ModuleLevelBuilder; 7 | 8 | import java.util.ArrayList; 9 | import java.util.Collections; 10 | import java.util.List; 11 | 12 | /** 13 | * @author nik 14 | * @since 02.11.12 15 | */ 16 | public class ClojureBuilderService extends BuilderService { 17 | @NotNull 18 | @Override 19 | public List createModuleLevelBuilders() { 20 | List list = new ArrayList(); 21 | list.add(new ClojureBuilder(false)); 22 | list.add(new ClojureBuilder(true)); 23 | return list; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/stubs/impl/ClKeywordStubImpl.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.stubs.impl; 2 | 3 | import com.intellij.psi.stubs.IStubElementType; 4 | import com.intellij.psi.stubs.StubBase; 5 | import com.intellij.psi.stubs.StubElement; 6 | import com.intellij.util.io.StringRef; 7 | import org.jetbrains.plugins.clojure.psi.api.ClKeyword; 8 | import org.jetbrains.plugins.clojure.psi.stubs.api.ClKeywordStub; 9 | 10 | /** 11 | * @author ilyas 12 | */ 13 | public class ClKeywordStubImpl extends StubBase implements ClKeywordStub { 14 | 15 | private final StringRef myName; 16 | 17 | public ClKeywordStubImpl(StubElement parent, StringRef name, IStubElementType elementType) { 18 | super(parent, elementType); 19 | myName = name; 20 | } 21 | 22 | public String getName() { 23 | return StringRef.toString(myName); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/repl/ClojureConsoleEnterAction.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.repl; 2 | 3 | import com.intellij.execution.process.ProcessHandler; 4 | import com.intellij.openapi.actionSystem.AnActionEvent; 5 | 6 | /** 7 | * @author ilyas 8 | */ 9 | public class ClojureConsoleEnterAction extends ClojureExecuteActionBase { 10 | 11 | public ClojureConsoleEnterAction(ClojureConsole languageConsole, 12 | ProcessHandler processHandler, 13 | ClojureConsoleExecuteActionHandler consoleExecuteActionHandler) { 14 | super(languageConsole, processHandler, consoleExecuteActionHandler, ClojureConsoleRunner.EXECUTE_ACTION_ID); 15 | } 16 | 17 | @Override 18 | public void actionPerformed(AnActionEvent e) { 19 | getExecuteActionHandler().runExecuteAction(myLanguageConsole, false); 20 | } 21 | } -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/lexer/ClojureFlexLexer.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.lexer; 2 | 3 | import com.intellij.lexer.FlexAdapter; 4 | 5 | import java.io.Reader; 6 | 7 | /** 8 | * User: peter 9 | * Date: Dec 18, 2008 10 | * Time: 8:57:54 AM 11 | * Copyright 2007, 2008, 2009 Red Shark Technology 12 | *

13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | *

15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | public class ClojureFlexLexer extends FlexAdapter { 22 | public ClojureFlexLexer() { 23 | super(new _ClojureLexer((Reader) null)); 24 | } 25 | } -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/repl/ClojureExecuteImmediatelyAction.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.repl; 2 | 3 | import com.intellij.execution.process.ProcessHandler; 4 | import com.intellij.openapi.actionSystem.AnActionEvent; 5 | 6 | /** 7 | * @author ilyas 8 | */ 9 | public class ClojureExecuteImmediatelyAction extends ClojureExecuteActionBase { 10 | 11 | public ClojureExecuteImmediatelyAction(ClojureConsole languageConsole, 12 | ProcessHandler processHandler, 13 | ClojureConsoleExecuteActionHandler consoleExecuteActionHandler) { 14 | super(languageConsole, processHandler, consoleExecuteActionHandler, ClojureConsoleRunner.EXECUTE_ACTION_IMMEDIATELY_ID); 15 | } 16 | 17 | @Override 18 | public void actionPerformed(AnActionEvent e) { 19 | getExecuteActionHandler().runExecuteAction(myLanguageConsole, true); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/parser/ClojureElementType.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.parser; 2 | 3 | import com.intellij.psi.tree.IElementType; 4 | import org.jetbrains.plugins.clojure.file.ClojureFileType; 5 | 6 | /** 7 | * User: peter 8 | * Date: Nov 20, 2008 9 | * Time: 1:52:13 PM 10 | * Copyright 2007, 2008, 2009 Red Shark Technology 11 | *

12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | *

14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | public class ClojureElementType extends IElementType { 21 | public ClojureElementType(String debugName) { 22 | super(debugName, ClojureFileType.CLOJURE_LANGUAGE); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/util/ClojureTextUtil.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.util; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | /** 6 | * @author ilyas 7 | */ 8 | public abstract class ClojureTextUtil { 9 | 10 | public static String getLastSymbolAtom(@NotNull String sym, @NotNull String sep) { 11 | int index = sym.lastIndexOf(sep); 12 | return index > 0 && index < sym.length() - 1 ? sym.substring(index + 1) : sym; 13 | } 14 | 15 | public static String getSymbolPrefix(@NotNull String sym, @NotNull String sep) { 16 | int index = sym.lastIndexOf(sep); 17 | return index > 0 && index < sym.length() - 1 ? sym.substring(0, index) : ""; 18 | } 19 | 20 | public static String getLastSymbolAtom(@NotNull String sym) { 21 | return getLastSymbolAtom(sym, "."); 22 | } 23 | 24 | public static String getSymbolPrefix(@NotNull String sym) { 25 | return getSymbolPrefix(sym, "."); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/clojure/org/jetbrains/plugins/clojure/refactoring/clojure_refactoring_support_provider.clj: -------------------------------------------------------------------------------- 1 | (ns org.jetbrains.plugins.clojure.refactoring.clojure-refactoring-support-provider 2 | (:use [org.jetbrains.plugins.clojure.refactoring.introduce.introduce-variable]) 3 | (:import [com.intellij.lang LanguageRefactoringSupport LanguageExtension] 4 | [com.intellij.lang.refactoring RefactoringSupportProvider] 5 | [org.jetbrains.plugins.clojure ClojureLanguage])) 6 | 7 | (defn init 8 | [] 9 | (if (instance? LanguageExtension LanguageRefactoringSupport/INSTANCE) 10 | (.addExplicitExtension ^LanguageExtension 11 | LanguageRefactoringSupport/INSTANCE 12 | (ClojureLanguage/getInstance) 13 | (proxy 14 | [RefactoringSupportProvider] [] 15 | (getIntroduceVariableHandler 16 | ([] (introduce-variable-action-handler)) 17 | ([elem] (introduce-variable-action-handler))))))) 18 | 19 | 20 | -------------------------------------------------------------------------------- /testdata/parser/sexp3-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClList 3 | PsiElement(()('(') 4 | ClSymbol 5 | PsiElement(atom)('fn') 6 | PsiWhiteSpace(' ') 7 | ClVector 8 | PsiElement([)('[') 9 | ClVector 10 | PsiElement([)('[') 11 | ClSymbol 12 | PsiElement(atom)('m') 13 | PsiWhiteSpace(' ') 14 | ClSymbol 15 | PsiElement(atom)('p') 16 | PsiElement(])(']') 17 | PsiElement(])(']') 18 | PsiWhiteSpace(' ') 19 | ClMap 20 | PsiElement({)('{') 21 | ClMapEntry 22 | ClList 23 | PsiElement(()('(') 24 | ClSymbol 25 | PsiElement(atom)('str') 26 | PsiWhiteSpace(' ') 27 | ClSymbol 28 | PsiElement(atom)('m') 29 | PsiElement())(')') 30 | PsiWhiteSpace(' ') 31 | ClVector 32 | PsiElement([)('[') 33 | ClSymbol 34 | PsiElement(atom)('p') 35 | PsiElement(])(']') 36 | PsiElement(})('}') 37 | PsiElement())(')') 38 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/editor/ClojureEditorActionGroup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 JetBrains s.r.o. 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 | package org.jetbrains.plugins.clojure.editor; 17 | 18 | import com.intellij.openapi.actionSystem.DefaultActionGroup; 19 | 20 | /** 21 | * A group for editor actions. 22 | * 23 | * @author Ian Phillips 24 | */ 25 | public class ClojureEditorActionGroup extends DefaultActionGroup { 26 | } 27 | -------------------------------------------------------------------------------- /test/org/jetbrains/plugins/clojure/refactoring/ClojureRefactoringTestBase.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.refactoring; 2 | 3 | import com.intellij.refactoring.RefactoringActionHandler; 4 | import org.jetbrains.plugins.clojure.base.ClojureBaseTestCase; 5 | 6 | /** 7 | * @author Stanislav.Osipov 8 | * @since 8/23/13 9 | */ 10 | public abstract class ClojureRefactoringTestBase extends ClojureBaseTestCase { 11 | 12 | private static final String DATA_PATH = System.getProperty("user.dir") + "/testdata/refactoring"; 13 | 14 | @Override 15 | public String getDataPath() { 16 | return DATA_PATH; 17 | } 18 | 19 | protected void doTest() { 20 | String testName = getTestName(false); 21 | myFixture.configureByFile(testName + SOURCE_FILE_EXT); 22 | getRefactoringActionHandler().invoke(myFixture.getProject(), myFixture.getEditor(), myFixture.getFile(), null); 23 | myFixture.checkResultByFile(testName + TEST_FILE_EXT); 24 | } 25 | 26 | protected abstract RefactoringActionHandler getRefactoringActionHandler(); 27 | } 28 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/ClStubElementType.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi; 2 | 3 | import com.intellij.psi.stubs.StubElement; 4 | import com.intellij.psi.stubs.IStubElementType; 5 | import com.intellij.psi.stubs.IndexSink; 6 | import com.intellij.psi.PsiElement; 7 | import com.intellij.lang.ASTNode; 8 | import org.jetbrains.annotations.NonNls; 9 | import org.jetbrains.annotations.NotNull; 10 | import org.jetbrains.plugins.clojure.file.ClojureFileType; 11 | 12 | /** 13 | * @author ilyas 14 | */ 15 | public abstract class ClStubElementType extends IStubElementType { 16 | 17 | public ClStubElementType(@NonNls @NotNull String debugName) { 18 | super(debugName, ClojureFileType.CLOJURE_LANGUAGE); 19 | } 20 | 21 | public abstract PsiElement createElement(final ASTNode node); 22 | 23 | public void indexStub(final S stub, final IndexSink sink) { 24 | } 25 | 26 | public String getExternalId() { 27 | return "clj." + super.toString(); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/stubs/api/ClNsStub.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.stubs.api; 2 | 3 | import com.intellij.psi.stubs.IStubElementType; 4 | import com.intellij.psi.stubs.NamedStub; 5 | import com.intellij.psi.stubs.StubBase; 6 | import com.intellij.psi.stubs.StubElement; 7 | import com.intellij.util.io.StringRef; 8 | import org.jetbrains.plugins.clojure.psi.api.ns.ClNs; 9 | import org.jetbrains.plugins.clojure.psi.stubs.api.ClNsStub; 10 | 11 | /** 12 | * @author ilyas 13 | */ 14 | public class ClNsStub extends StubBase implements NamedStub { 15 | private final StringRef myName; 16 | private final int myTextOffset; 17 | 18 | public ClNsStub(StubElement parent, StringRef name, final IStubElementType elementType, int textOffset) { 19 | super(parent, elementType); 20 | myName = name; 21 | myTextOffset = textOffset; 22 | } 23 | 24 | public int getTextOffset() { 25 | return myTextOffset; 26 | } 27 | 28 | public String getName() { 29 | return StringRef.toString(myName); 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 29 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/parser/ClojureSpecialFormTokens.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.parser; 2 | 3 | import java.util.Arrays; 4 | import java.util.HashSet; 5 | import java.util.Set; 6 | 7 | /** 8 | * @author ilyas 9 | */ 10 | public class ClojureSpecialFormTokens { 11 | 12 | public static final String tDEF = "def"; 13 | public static final String tDEFN = "defn"; 14 | public static final String tDEFN_DASH = "defn-"; 15 | public static final String tDEFINLINE = "defninline"; 16 | public static final String tDEFMACRO = "defmacro"; 17 | public static final String tDEFMETHOD= "defmethod"; 18 | public static final String tDEFMULTI= "defmulti"; 19 | public static final String tDEFONCE= "defonce"; 20 | public static final String tDEFSTRUCT= "defstruct"; 21 | 22 | public static final Set DEF_TOKENS = new HashSet(); 23 | 24 | static { 25 | DEF_TOKENS.addAll(Arrays.asList( 26 | tDEF, tDEFN, tDEFN_DASH, tDEFMACRO, tDEFMETHOD, tDEFMULTI, tDEFONCE, tDEFSTRUCT, tDEFINLINE 27 | )); 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/stubs/api/ClDefStub.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.stubs.api; 2 | 3 | import com.intellij.psi.stubs.IStubElementType; 4 | import com.intellij.psi.stubs.NamedStub; 5 | import com.intellij.psi.stubs.StubBase; 6 | import com.intellij.psi.stubs.StubElement; 7 | import com.intellij.util.io.StringRef; 8 | import org.jetbrains.plugins.clojure.psi.api.defs.ClDef; 9 | import org.jetbrains.plugins.clojure.psi.stubs.api.ClDefStub; 10 | 11 | /** 12 | * @author ilyas 13 | */ 14 | public class ClDefStub extends StubBase implements NamedStub { 15 | private final StringRef myName; 16 | private final int myTextOffset; 17 | 18 | public ClDefStub(StubElement parent, StringRef name, final IStubElementType elementType, int textOffset) { 19 | super(parent, elementType); 20 | myName = name; 21 | myTextOffset = textOffset; 22 | } 23 | 24 | public int getTextOffset() { 25 | return myTextOffset; 26 | } 27 | 28 | public String getName() { 29 | return StringRef.toString(myName); 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/ClojureLanguage.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure; 2 | 3 | import com.intellij.lang.Language; 4 | import org.jetbrains.plugins.clojure.file.ClojureFileType; 5 | 6 | /** 7 | * Created by IntelliJ IDEA. 8 | * User: merlyn 9 | * Date: 16-Nov-2008 10 | * Time: 11:09:48 PM 11 | * Copyright 2007, 2008, 2009 Red Shark Technology 12 | *

13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | *

15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | public class ClojureLanguage extends Language { 22 | private static final String ID = "Clojure"; 23 | 24 | public ClojureLanguage() { 25 | super(ID); 26 | } 27 | 28 | public static Language getInstance() { 29 | return ClojureFileType.CLOJURE_LANGUAGE; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/file/ClojureFileTypeLoader.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.file; 2 | 3 | import com.intellij.openapi.fileTypes.FileTypeConsumer; 4 | import com.intellij.openapi.fileTypes.FileTypeFactory; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | /** 8 | * User: peter 9 | * Date: Dec 18, 2008 10 | * Time: 8:57:54 AM 11 | * Copyright 2007, 2008, 2009 Red Shark Technology 12 | *

13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | *

15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | public class ClojureFileTypeLoader extends FileTypeFactory { 22 | public void createFileTypes(@NotNull FileTypeConsumer consumer) { 23 | consumer.consume(ClojureFileType.CLOJURE_FILE_TYPE, ClojureFileType.CLOJURE_DEFAULT_EXTENSION); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/refactoring/rename/ClojureRenameInputValidator.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.refactoring.rename; 2 | 3 | import com.intellij.patterns.ElementPattern; 4 | import com.intellij.psi.PsiElement; 5 | import com.intellij.refactoring.rename.RenameInputValidator; 6 | import com.intellij.util.ProcessingContext; 7 | import org.jetbrains.plugins.clojure.lexer.ClojureFlexLexer; 8 | import org.jetbrains.plugins.clojure.lexer.ClojureTokenTypes; 9 | 10 | /** 11 | * @author ilyas 12 | */ 13 | 14 | public class ClojureRenameInputValidator implements RenameInputValidator { 15 | public ElementPattern getPattern() { 16 | return new ClojureSymbolPattern(); 17 | } 18 | 19 | public boolean isInputValid(String newName, PsiElement element, ProcessingContext context) { 20 | final ClojureFlexLexer lexer = new ClojureFlexLexer(); 21 | lexer.start(newName, 0, newName.length(), 0); 22 | if (lexer.getTokenType() != ClojureTokenTypes.symATOM) return false; 23 | lexer.advance(); 24 | return lexer.getTokenType() == null; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/parser/Expression.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.parser; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElementImpl; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: peter 10 | * Date: Jan 1, 2009 11 | * Time: 5:43:42 PM 12 | * Copyright 2007, 2008, 2009 Red Shark Technology 13 | *

14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | *

16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | public class Expression extends ClojurePsiElementImpl { 23 | public Expression(@NotNull final ASTNode node) { 24 | super(node); 25 | } 26 | 27 | protected boolean isEmpty(ASTNode[] children) { 28 | return children == null || children.length < 1; 29 | } 30 | } -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/ClojureBundle.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure; 2 | 3 | import com.intellij.CommonBundle; 4 | import org.jetbrains.annotations.NonNls; 5 | import org.jetbrains.annotations.PropertyKey; 6 | 7 | import java.lang.ref.Reference; 8 | import java.lang.ref.SoftReference; 9 | import java.util.ResourceBundle; 10 | 11 | /** 12 | * @author ilyas 13 | */ 14 | public class ClojureBundle { 15 | 16 | private static Reference ourBundle; 17 | 18 | @NonNls 19 | private static final String BUNDLE = "org.jetbrains.plugins.clojure.ClojureBundle"; 20 | 21 | public static String message(@PropertyKey(resourceBundle = BUNDLE) String key, Object... params) { 22 | return CommonBundle.message(getBundle(), key, params); 23 | } 24 | 25 | private static ResourceBundle getBundle() { 26 | ResourceBundle bundle = null; 27 | 28 | if (ourBundle != null) bundle = ourBundle.get(); 29 | 30 | if (bundle == null) { 31 | bundle = ResourceBundle.getBundle(BUNDLE); 32 | ourBundle = new SoftReference(bundle); 33 | } 34 | return bundle; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/api/ns/ClNs.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.api.ns; 2 | 3 | import com.intellij.psi.PsiClass; 4 | import com.intellij.psi.PsiElement; 5 | import org.jetbrains.annotations.NotNull; 6 | import org.jetbrains.plugins.clojure.psi.api.ClList; 7 | import org.jetbrains.plugins.clojure.psi.api.ClListLike; 8 | import org.jetbrains.plugins.clojure.psi.api.ClVector; 9 | import org.jetbrains.plugins.clojure.psi.api.symbols.ClSymbol; 10 | import org.jetbrains.annotations.Nullable; 11 | import com.intellij.psi.PsiNamedElement; 12 | 13 | /** 14 | * @author ilyas 15 | */ 16 | public interface ClNs extends ClList, PsiNamedElement { 17 | @Nullable 18 | ClSymbol getNameSymbol(); 19 | 20 | String getDefinedName(); 21 | 22 | @Nullable 23 | ClList findImportClause(@Nullable PsiElement place); 24 | 25 | @Nullable 26 | ClList findImportClause(); 27 | 28 | @NotNull 29 | ClList findOrCreateImportClause(@Nullable PsiElement place); 30 | 31 | @NotNull 32 | ClList findOrCreateImportClause(); 33 | 34 | @Nullable 35 | ClListLike addImportForClass(PsiElement place, PsiClass clazz); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/structure/ClojureStructureViewBuilderFactory.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.structure; 2 | 3 | import com.intellij.lang.PsiStructureViewFactory; 4 | import com.intellij.ide.structureView.StructureViewBuilder; 5 | import com.intellij.ide.structureView.TreeBasedStructureViewBuilder; 6 | import com.intellij.ide.structureView.StructureViewModel; 7 | import com.intellij.openapi.editor.Editor; 8 | import com.intellij.psi.PsiFile; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | /** 12 | * @author ilyas 13 | */ 14 | public class ClojureStructureViewBuilderFactory implements PsiStructureViewFactory { 15 | public StructureViewBuilder getStructureViewBuilder(final PsiFile psiFile) { 16 | return new TreeBasedStructureViewBuilder() { 17 | @NotNull 18 | @Override 19 | public StructureViewModel createStructureViewModel(Editor editor) { 20 | return new ClojureStructureViewModel(psiFile); 21 | } 22 | 23 | public boolean isRootNodeShown() { 24 | return false; 25 | } 26 | }; 27 | } 28 | } -------------------------------------------------------------------------------- /testdata/parser/defn2.test: -------------------------------------------------------------------------------- 1 | (defn- non-private-methods [#^Class c] 2 | (loop [mm {} 3 | considered #{} 4 | c c] 5 | (if c 6 | (let [[mm considered] 7 | (loop [mm mm 8 | considered considered 9 | meths (concat 10 | (seq (. c (getDeclaredMethods))) 11 | (seq (. c (getMethods))))] 12 | (if meths 13 | (let [#^java.lang.reflect.Method meth (first meths) 14 | mods (. meth (getModifiers)) 15 | mk (method-sig meth)] 16 | (if (or (considered mk) 17 | (. Modifier (isPrivate mods)) 18 | (. Modifier (isStatic mods)) 19 | (. Modifier (isFinal mods)) 20 | (= \"finalize\" (.getName meth))) 21 | (recur mm (conj considered mk) (rest meths)) 22 | (recur (assoc mm mk meth) (conj considered mk) (rest meths)))) 23 | [mm considered]))] 24 | (recur mm considered (. c (getSuperclass)))) 25 | mm))) -------------------------------------------------------------------------------- /testdata/parser/defn3.test: -------------------------------------------------------------------------------- 1 | (defn- non-private-methods [#^Class c] 2 | (loop [mm {} 3 | considered #{} 4 | c c] 5 | (if c 6 | (let [[mm considered] 7 | (loop [mm mm 8 | considered considered 9 | meths (concat 10 | (seq (. c (getDeclaredMethods))) 11 | (seq (. c (getMethods))))] 12 | (if meths 13 | (let [#^java.lang.reflect.Method meth (first meths) 14 | mods (. meth (getModifiers)) 15 | mk (method-sig meth)] 16 | (if (or (considered mk) 17 | (. Modifier (isPrivate mods)) 18 | (. Modifier (isStatic mods)) 19 | (. Modifier (isFinal mods)) 20 | (= \"finalize\" (.getName meth))) 21 | (recur mm (conj considered mk) (rest meths)) 22 | (recur (assoc mm mk meth) (conj considered mk) (rest meths)))) 23 | [mm considered]))] 24 | (recur mm considered (. c (getSuperclass)))) 25 | mm))) -------------------------------------------------------------------------------- /jps-plugin/src/org/jetbrains/jps/clojure/model/JpsClojureExtensionService.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.jps.clojure.model; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.jetbrains.annotations.Nullable; 5 | import org.jetbrains.jps.clojure.model.impl.JpsClojureCompilerSettingsExtensionImpl; 6 | import org.jetbrains.jps.model.JpsElement; 7 | import org.jetbrains.jps.model.JpsProject; 8 | import org.jetbrains.jps.model.ex.JpsElementChildRoleBase; 9 | 10 | /** 11 | * @author nik 12 | * @since 02.11.12 13 | */ 14 | public class JpsClojureExtensionService { 15 | public static final JpsElementChildRoleBase COMPILER_SETTINGS_ROLE = JpsElementChildRoleBase.create("clojure compiler settings"); 16 | 17 | @Nullable 18 | public static JpsClojureCompilerSettingsExtension getExtension(@NotNull JpsProject project) { 19 | return project.getContainer().getChild(COMPILER_SETTINGS_ROLE); 20 | } 21 | 22 | 23 | public static void setExtension(@NotNull JpsProject project, JpsClojureCompilerSettingsExtension extension) { 24 | project.getContainer().setChild(COMPILER_SETTINGS_ROLE, extension); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/stubs/elements/ns/ClNsElementType.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.stubs.elements.ns; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import com.intellij.psi.PsiElement; 5 | import com.intellij.psi.stubs.StubElement; 6 | import com.intellij.util.io.StringRef; 7 | import org.jetbrains.plugins.clojure.parser.ClojureElementTypes; 8 | import org.jetbrains.plugins.clojure.psi.api.ns.ClNs; 9 | import org.jetbrains.plugins.clojure.psi.impl.ns.ClNsImpl; 10 | import org.jetbrains.plugins.clojure.psi.stubs.api.ClNsStub; 11 | 12 | /** 13 | * @author ilyas 14 | */ 15 | public class ClNsElementType extends ClNsElementTypeBase { 16 | public ClNsElementType() { 17 | super("ns"); 18 | } 19 | 20 | public PsiElement createElement(ASTNode node) { 21 | return new ClNsImpl(node); 22 | } 23 | 24 | public ClNs createPsi(ClNsStub stub) { 25 | return new ClNsImpl(stub, ClojureElementTypes.NS); 26 | } 27 | 28 | public ClNsStub createStub(ClNs psi, StubElement parentStub) { 29 | return new ClNsStub(parentStub, StringRef.fromString(psi.getDefinedName()), ClojureElementTypes.NS, psi.getTextOffset()); 30 | } 31 | 32 | 33 | 34 | } -------------------------------------------------------------------------------- /.idea/artifacts/ClojurePlugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/out/artifacts/Clojure 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/stubs/elements/ns/ClInNsElementType.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.stubs.elements.ns; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import com.intellij.psi.PsiElement; 5 | import com.intellij.psi.stubs.StubElement; 6 | import com.intellij.util.io.StringRef; 7 | import org.jetbrains.plugins.clojure.parser.ClojureElementTypes; 8 | import org.jetbrains.plugins.clojure.psi.api.ns.ClNs; 9 | import org.jetbrains.plugins.clojure.psi.impl.ns.ClInNsImpl; 10 | import org.jetbrains.plugins.clojure.psi.stubs.api.ClNsStub; 11 | 12 | /** 13 | * @author ilyas 14 | */ 15 | public class ClInNsElementType extends ClNsElementTypeBase { 16 | public ClInNsElementType() { 17 | super("in-ns"); 18 | } 19 | 20 | public PsiElement createElement(ASTNode node) { 21 | return new ClInNsImpl(node); 22 | } 23 | 24 | public ClNs createPsi(ClNsStub stub) { 25 | return new ClInNsImpl(stub, ClojureElementTypes.IN_NS); 26 | } 27 | 28 | public ClNsStub createStub(ClNs psi, StubElement parentStub) { 29 | return new ClNsStub(parentStub, StringRef.fromString(psi.getDefinedName()), ClojureElementTypes.IN_NS, psi.getTextOffset()); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/config/ClojureFacetLoader.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.config; 2 | 3 | import com.intellij.openapi.components.ApplicationComponent; 4 | import com.intellij.openapi.application.ApplicationManager; 5 | import com.intellij.facet.FacetTypeRegistry; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | /** 9 | * @author ilyas 10 | */ 11 | public class ClojureFacetLoader implements ApplicationComponent { 12 | 13 | public static final String PLUGIN_MODULE_ID = "PLUGIN_MODULE"; 14 | 15 | 16 | public static ClojureFacetLoader getInstance() { 17 | return ApplicationManager.getApplication().getComponent(ClojureFacetLoader.class); 18 | } 19 | 20 | public ClojureFacetLoader() { 21 | } 22 | 23 | public void initComponent() { 24 | FacetTypeRegistry.getInstance().registerFacetType(ClojureFacetType.INSTANCE); 25 | } 26 | 27 | public void disposeComponent() { 28 | FacetTypeRegistry instance = FacetTypeRegistry.getInstance(); 29 | instance.unregisterFacetType(instance.findFacetType(ClojureFacet.ID)); 30 | } 31 | 32 | @NotNull 33 | public String getComponentName() { 34 | return "ClojureFacetLoader"; 35 | } 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/repl/actions/ExecuteStatementAction.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.repl.actions; 2 | 3 | import com.intellij.openapi.actionSystem.DataContext; 4 | import com.intellij.openapi.actionSystem.Presentation; 5 | import com.intellij.openapi.editor.Editor; 6 | import com.intellij.openapi.editor.actionSystem.EditorAction; 7 | import com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler; 8 | 9 | /** 10 | * @author ilyas 11 | */ 12 | public class ExecuteStatementAction extends EditorAction { 13 | 14 | public static String ID = "ClojureExecuteStatementAction"; 15 | 16 | protected ExecuteStatementAction() { 17 | super(new MyHandler()); 18 | } 19 | 20 | private static class MyHandler extends EditorWriteActionHandler { 21 | public boolean isEnabled(Editor editor, DataContext dataContext) { 22 | return false; 23 | } 24 | 25 | public void executeWriteAction(Editor editor, DataContext dataContext) { 26 | // do nothing 27 | } 28 | } 29 | 30 | @Override 31 | public void update(Editor editor, Presentation presentation, DataContext dataContext) { 32 | super.update(editor, presentation, dataContext); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/settings/ClojureApplicationSettings.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.settings; 2 | 3 | import com.intellij.openapi.components.State; 4 | import com.intellij.openapi.components.Storage; 5 | import com.intellij.openapi.components.PersistentStateComponent; 6 | import com.intellij.openapi.components.ServiceManager; 7 | import com.intellij.util.xmlb.XmlSerializerUtil; 8 | 9 | /** 10 | * @author ilyas 11 | */ 12 | @State( 13 | name = "ClojureApplicationSettings", 14 | storages = { 15 | @Storage(id = "clojure_config", file = "$APP_CONFIG$/clojure_application.xml") 16 | }) 17 | public class ClojureApplicationSettings implements PersistentStateComponent { 18 | 19 | public String[] CONSOLE_HISTORY = new String[0]; 20 | 21 | public ClojureApplicationSettings getState() { 22 | return this; 23 | } 24 | 25 | public void loadState(ClojureApplicationSettings clojureApplicationSettings) { 26 | XmlSerializerUtil.copyBean(clojureApplicationSettings, this); 27 | } 28 | 29 | public static ClojureApplicationSettings getInstance() { 30 | return ServiceManager.getService(ClojureApplicationSettings.class); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/impl/ClSetImpl.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.impl; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import com.intellij.psi.PsiElement; 5 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElementImpl; 6 | import org.jetbrains.plugins.clojure.psi.api.ClSet; 7 | import org.jetbrains.plugins.clojure.lexer.ClojureTokenTypes; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | /** 11 | * @author ilyas 12 | */ 13 | public class ClSetImpl extends ClojurePsiElementImpl implements ClSet { 14 | 15 | public ClSetImpl(ASTNode node) { 16 | super(node, "ClSet"); 17 | } 18 | 19 | @NotNull 20 | public PsiElement getFirstBrace() { 21 | // XXX: there must be a cleaner way of doing this... 22 | ASTNode sharp; 23 | while ((sharp = getNode().findChildByType(ClojureTokenTypes.SHARP)) != null) { 24 | ASTNode next = sharp.getTreeNext(); 25 | if (ClojureTokenTypes.LEFT_CURLY.equals(next.getElementType())) { 26 | return sharp.getPsi(); 27 | } 28 | } 29 | throw new AssertionError(); 30 | } 31 | 32 | public PsiElement getLastBrace() { 33 | return findChildByType(ClojureTokenTypes.RIGHT_CURLY); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/impl/list/ClListImpl.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.impl.list; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import com.intellij.psi.stubs.EmptyStub; 5 | import com.intellij.psi.stubs.IStubElementType; 6 | import com.intellij.psi.stubs.NamedStub; 7 | import com.intellij.psi.scope.PsiScopeProcessor; 8 | import com.intellij.psi.ResolveState; 9 | import com.intellij.psi.PsiElement; 10 | import org.jetbrains.plugins.clojure.psi.api.ClList; 11 | import org.jetbrains.annotations.NotNull; 12 | 13 | /** 14 | * @author ilyas 15 | */ 16 | public class ClListImpl extends ClListBaseImpl { 17 | 18 | public ClListImpl(ASTNode node) { 19 | super(node); 20 | } 21 | 22 | public ClListImpl(EmptyStub stub, @NotNull IStubElementType nodeType) { 23 | super(stub, nodeType); 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return "ClList"; 29 | } 30 | 31 | @Override 32 | public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) { 33 | return ListDeclarations.get(processor, state, lastParent, place, this, getHeadText()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/stubs/elements/ns/ClCreateNsElementType.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.stubs.elements.ns; 2 | 3 | import com.intellij.psi.PsiElement; 4 | import com.intellij.psi.stubs.StubElement; 5 | import com.intellij.lang.ASTNode; 6 | import com.intellij.util.io.StringRef; 7 | import org.jetbrains.plugins.clojure.psi.impl.ns.ClInNsImpl; 8 | import org.jetbrains.plugins.clojure.psi.api.ns.ClNs; 9 | import org.jetbrains.plugins.clojure.psi.stubs.api.ClNsStub; 10 | import org.jetbrains.plugins.clojure.parser.ClojureElementTypes; 11 | 12 | /** 13 | * @author ilyas 14 | */ 15 | public class ClCreateNsElementType extends ClNsElementTypeBase { 16 | public ClCreateNsElementType() { 17 | super("create-ns"); 18 | } 19 | 20 | public PsiElement createElement(ASTNode node) { 21 | return new ClInNsImpl(node); 22 | } 23 | 24 | public ClNs createPsi(ClNsStub stub) { 25 | return new ClInNsImpl(stub, ClojureElementTypes.CREATE_NS); 26 | } 27 | 28 | public ClNsStub createStub(ClNs psi, StubElement parentStub) { 29 | return new ClNsStub(parentStub, StringRef.fromString(psi.getDefinedName()), ClojureElementTypes.CREATE_NS, psi.getTextOffset()); 30 | } 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/editor/todo/ClojureIndexPatternBuilder.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.editor.todo; 2 | 3 | import com.intellij.lexer.Lexer; 4 | import com.intellij.psi.PsiFile; 5 | import com.intellij.psi.impl.search.IndexPatternBuilder; 6 | import com.intellij.psi.tree.IElementType; 7 | import com.intellij.psi.tree.TokenSet; 8 | import org.jetbrains.plugins.clojure.lexer.ClojureFlexLexer; 9 | import org.jetbrains.plugins.clojure.lexer.ClojureTokenTypes; 10 | import org.jetbrains.plugins.clojure.psi.api.ClojureFile; 11 | 12 | /** 13 | * @author ilyas 14 | */ 15 | public class ClojureIndexPatternBuilder implements IndexPatternBuilder { 16 | public Lexer getIndexingLexer(PsiFile file) { 17 | if (file instanceof ClojureFile) { 18 | return new ClojureFlexLexer(); 19 | } 20 | return null; 21 | } 22 | 23 | public TokenSet getCommentTokenSet(PsiFile file) { 24 | if (file instanceof ClojureFile) { 25 | return ClojureTokenTypes.COMMENTS; 26 | } 27 | return null; 28 | } 29 | 30 | public int getCommentStartDelta(IElementType tokenType) { 31 | return 0; 32 | } 33 | 34 | public int getCommentEndDelta(IElementType tokenType) { 35 | return 0; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/editor/braceHighlighter/ClojureBraceAttributes.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.editor.braceHighlighter; 2 | 3 | import com.intellij.openapi.editor.markup.TextAttributes; 4 | 5 | import java.awt.*; 6 | 7 | /** 8 | * @author ilyas 9 | */ 10 | public abstract class ClojureBraceAttributes { 11 | private static final Color[] CLOJURE_BRACE_COLORS = 12 | { 13 | new Color(160, 160, 160), // gray 14 | new Color(255, 160, 0), // orange 15 | new Color(255, 255, 0), // yellow 16 | new Color(160, 255, 62), // green 17 | new Color( 32, 255, 224), // cyan 18 | new Color( 64, 160, 255), // blue 19 | new Color(160, 128, 255), // magenta 20 | new Color(224, 128, 192), // pink 21 | }; 22 | 23 | public static TextAttributes getBraceAttributes(int level, Color background) { 24 | Color braceColor = CLOJURE_BRACE_COLORS[level % CLOJURE_BRACE_COLORS.length]; 25 | Color adjustedBraceColor = braceColor; // TODO make it preserve the original colors for Darcula: new Color(braceColor.getRGB() ^ background.getRGB() ^ 0xFFFFFF); 26 | return new TextAttributes(adjustedBraceColor, null, null, null, 1); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/impl/ClMapEntryImpl.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.impl; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import com.intellij.psi.PsiElement; 5 | import org.jetbrains.annotations.NotNull; 6 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElement; 7 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElementImpl; 8 | import org.jetbrains.plugins.clojure.psi.api.ClKeyword; 9 | 10 | /** 11 | * @author ilyas 12 | */ 13 | public class ClMapEntryImpl extends ClojurePsiElementImpl implements ClMapEntry { 14 | public ClMapEntryImpl(@NotNull ASTNode astNode) { 15 | super(astNode, "ClMapEntry"); 16 | } 17 | 18 | 19 | public ClKeyword getKeywordKey() { 20 | return findChildByClass(ClKeyword.class); 21 | } 22 | 23 | public ClojurePsiElement getKey() { 24 | final PsiElement child = getFirstChild(); 25 | if (child instanceof ClojurePsiElement) { 26 | return (ClojurePsiElement) child; 27 | } 28 | return null; 29 | } 30 | 31 | public ClojurePsiElement getValue() { 32 | final PsiElement child = getLastChild(); 33 | if (child instanceof ClojurePsiElement) { 34 | return (ClojurePsiElement) child; 35 | } 36 | return null; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test/org/jetbrains/plugins/clojure/actions/editor/SpliceTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 JetBrains s.r.o. 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 | package org.jetbrains.plugins.clojure.actions.editor; 17 | 18 | import com.intellij.testFramework.EditorActionTestCase; 19 | import org.junit.Test; 20 | 21 | /** 22 | * @author Ian Phillips 23 | */ 24 | public class SpliceTest extends EditorActionTestCase { 25 | 26 | @Override 27 | protected String getActionId() { 28 | return SpliceAction.class.getName(); 29 | } 30 | 31 | @Test 32 | public void testAction() throws Exception { 33 | doTextTest("Splice.clj", "(a (b c d) e)", "(a b c d e)", true); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /clojure-plugin.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /test/org/jetbrains/plugins/clojure/actions/editor/BarfForwardsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 JetBrains s.r.o. 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 | package org.jetbrains.plugins.clojure.actions.editor; 17 | 18 | import com.intellij.testFramework.EditorActionTestCase; 19 | import org.junit.Test; 20 | 21 | /** 22 | * @author Ian Phillips 23 | */ 24 | public class BarfForwardsTest extends EditorActionTestCase { 25 | 26 | @Override 27 | protected String getActionId() { 28 | return BarfForwardsAction.class.getName(); 29 | } 30 | 31 | @Test 32 | public void testAction() throws Exception { 33 | doTextTest("BarfForwards.clj", "(a (b c) d e)", "(a (b) c d e)", true); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /test/org/jetbrains/plugins/clojure/actions/editor/BarfBackwardsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 JetBrains s.r.o. 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 | package org.jetbrains.plugins.clojure.actions.editor; 17 | 18 | import com.intellij.testFramework.EditorActionTestCase; 19 | import org.junit.Test; 20 | 21 | /** 22 | * @author Ian Phillips 23 | */ 24 | public class BarfBackwardsTest extends EditorActionTestCase { 25 | 26 | @Override 27 | protected String getActionId() { 28 | return BarfBackwardsAction.class.getName(); 29 | } 30 | 31 | @Test 32 | public void testAction() throws Exception { 33 | doTextTest("BarfBackwards.clj", "(a (b c) d e)", "(a b (c) d e)", true); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /test/org/jetbrains/plugins/clojure/actions/editor/SlurpBackwardsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 JetBrains s.r.o. 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 | package org.jetbrains.plugins.clojure.actions.editor; 17 | 18 | import com.intellij.testFramework.EditorActionTestCase; 19 | import org.junit.Test; 20 | 21 | /** 22 | * @author Ian Phillips 23 | */ 24 | public class SlurpBackwardsTest extends EditorActionTestCase { 25 | 26 | @Override 27 | protected String getActionId() { 28 | return SlurpBackwardsAction.class.getName(); 29 | } 30 | 31 | @Test 32 | public void testAction() throws Exception { 33 | doTextTest("SlurpBackwards.clj", "(a b (c d) e)", "(a (b c d) e)", true); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /test/org/jetbrains/plugins/clojure/actions/editor/SlurpForwardsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 JetBrains s.r.o. 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 | package org.jetbrains.plugins.clojure.actions.editor; 17 | 18 | import com.intellij.testFramework.EditorActionTestCase; 19 | import org.junit.Test; 20 | 21 | /** 22 | * @author Ian Phillips 23 | */ 24 | public class SlurpForwardsTest extends EditorActionTestCase { 25 | 26 | @Override 27 | protected String getActionId() { 28 | return SlurpForwardsAction.class.getName(); 29 | } 30 | 31 | @Test 32 | public void testAction() throws Exception { 33 | doTextTest("SlurpForwards.clj", "(a (b c) d e)", "(a (b c d) e)", true); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/api/symbols/ClSymbol.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.api.symbols; 2 | 3 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElement; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.jetbrains.annotations.Nullable; 6 | import com.intellij.psi.PsiPolyVariantReference; 7 | import com.intellij.psi.PsiElement; 8 | import com.intellij.psi.PsiNamedElement; 9 | import org.jetbrains.plugins.clojure.psi.resolve.processors.ResolveKind; 10 | 11 | /** 12 | * @author ilyas 13 | */ 14 | public interface ClSymbol extends ClojurePsiElement, PsiPolyVariantReference, PsiNamedElement { 15 | 16 | final ClSymbol[] EMPTY_ARRAY = new ClSymbol[0]; 17 | 18 | @NotNull 19 | String getNameString(); 20 | 21 | @Nullable 22 | PsiElement getReferenceNameElement(); 23 | 24 | @Nullable 25 | String getReferenceName(); 26 | 27 | @Nullable 28 | ClSymbol getRawQualifierSymbol(); 29 | 30 | /** 31 | * Raw qualifier or in case of it's empty it can be symbol from import list 32 | * (import '(java.util Date)) 33 | * @return real qualifier of the symbol 34 | */ 35 | @Nullable 36 | ClSymbol getQualifierSymbol(); 37 | 38 | boolean isQualified(); 39 | 40 | @Nullable 41 | PsiElement getSeparatorToken(); 42 | 43 | public ResolveKind[] getKinds(); 44 | } 45 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/stubs/elements/ClListElementType.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.stubs.elements; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import com.intellij.psi.PsiElement; 5 | import com.intellij.psi.stubs.*; 6 | import org.jetbrains.plugins.clojure.psi.ClStubElementType; 7 | import org.jetbrains.plugins.clojure.psi.impl.list.ClListImpl; 8 | import org.jetbrains.plugins.clojure.psi.stubs.api.ClDefStub; 9 | 10 | import java.io.IOException; 11 | 12 | /** 13 | * @author peter 14 | */ 15 | public class ClListElementType extends ClStubElementType { 16 | 17 | public ClListElementType() { 18 | super("list"); 19 | } 20 | 21 | public void serialize(EmptyStub stub, StubOutputStream dataStream) throws IOException { 22 | } 23 | 24 | public EmptyStub deserialize(StubInputStream dataStream, StubElement parentStub) throws IOException { 25 | return new EmptyStub(parentStub, this); 26 | } 27 | 28 | public PsiElement createElement(ASTNode node) { 29 | return new ClListImpl(node); 30 | } 31 | 32 | public ClListImpl createPsi(EmptyStub stub) { 33 | return new ClListImpl(stub, this); 34 | } 35 | 36 | public EmptyStub createStub(ClListImpl psi, StubElement parentStub) { 37 | return new EmptyStub(parentStub, this); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/impl/symbols/SymbolUtils.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.impl.symbols; 2 | 3 | import com.intellij.psi.PsiElement; 4 | import com.intellij.psi.util.PsiTreeUtil; 5 | import org.jetbrains.plugins.clojure.ClojureIcons; 6 | import org.jetbrains.plugins.clojure.psi.api.ClList; 7 | import org.jetbrains.plugins.clojure.psi.api.symbols.ClSymbol; 8 | import org.jetbrains.plugins.clojure.psi.impl.list.ListDeclarations; 9 | 10 | import javax.swing.*; 11 | 12 | /** 13 | * @author nik 14 | * @since 02.11.12 15 | */ 16 | public class SymbolUtils { 17 | public static Icon getIcon(ClSymbol symbol, int flags) { 18 | ClList list = PsiTreeUtil.getParentOfType(symbol, ClList.class); 19 | if (list == null) return null; 20 | if (!symbol.equals(list.getSecondNonLeafElement())) return null; 21 | PsiElement firstNonLeafElement = list.getFirstNonLeafElement(); 22 | if (firstNonLeafElement instanceof ClSymbol) { 23 | String nameString = ((ClSymbol) firstNonLeafElement).getNameString(); 24 | if (nameString.equals(ListDeclarations.FN)) return ClojureIcons.FUNCTION; 25 | else if (nameString.equals(ListDeclarations.DEFN) || nameString.equals(ListDeclarations.DEFN_)) return ClojureIcons.FUNCTION; 26 | else return null; 27 | } else return null; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/runner/ClojureScriptConfigurationFactory.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.runner; 2 | 3 | import com.intellij.execution.configurations.ConfigurationFactory; 4 | import com.intellij.execution.configurations.RunConfiguration; 5 | import com.intellij.openapi.project.Project; 6 | 7 | /** 8 | * Created by IntelliJ IDEA. 9 | * User: peter 10 | * Date: Jan 7, 2009 11 | * Time: 6:02:01 PM 12 | * Copyright 2007, 2008, 2009 Red Shark Technology 13 | *

14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | *

16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | public class ClojureScriptConfigurationFactory extends ConfigurationFactory { 23 | public ClojureScriptConfigurationFactory(ClojureScriptRunConfigurationType scriptRunConfigurationType) { 24 | super(scriptRunConfigurationType); 25 | } 26 | 27 | public RunConfiguration createTemplateConfiguration(Project project) { 28 | return new ClojureScriptRunConfiguration(this, project, "Clojure Script"); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/refactoring/rename/ClojureNameValidator.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.refactoring.rename; 2 | 3 | import com.intellij.codeInsight.completion.CompletionContributor; 4 | import com.intellij.lang.LanguageExtensionPoint; 5 | import com.intellij.lang.refactoring.NamesValidator; 6 | import com.intellij.openapi.project.Project; 7 | import org.jetbrains.plugins.clojure.lexer.ClojureFlexLexer; 8 | import org.jetbrains.plugins.clojure.lexer.ClojureTokenTypes; 9 | 10 | /** 11 | * @author ilyas 12 | */ 13 | public class ClojureNameValidator extends LanguageExtensionPoint implements NamesValidator { 14 | 15 | public boolean isKeyword(String name, Project project) { 16 | final ClojureFlexLexer lexer = new ClojureFlexLexer(); 17 | lexer.start(name, 0, name.length(), 0); 18 | if (!ClojureTokenTypes.KEYWORDS.contains(lexer.getTokenType())) return false; 19 | lexer.advance(); 20 | return lexer.getTokenType() == null; 21 | } 22 | 23 | public boolean isIdentifier(String name, Project project) { 24 | final ClojureFlexLexer lexer = new ClojureFlexLexer(); 25 | lexer.start(name, 0, name.length(), 0); 26 | if (!ClojureTokenTypes.IDENTIFIERS.contains(lexer.getTokenType())) return false; 27 | lexer.advance(); 28 | return lexer.getTokenType() == null; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/formatter/processors/ClojureIndentProcessor.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.formatter.processors; 2 | 3 | import com.intellij.formatting.Indent; 4 | import com.intellij.lang.ASTNode; 5 | import com.intellij.psi.PsiElement; 6 | import com.intellij.psi.tree.TokenSet; 7 | import org.jetbrains.plugins.clojure.formatter.ClojureBlock; 8 | import org.jetbrains.plugins.clojure.parser.ClojureElementTypes; 9 | import org.jetbrains.plugins.clojure.psi.api.ClojureFile; 10 | 11 | /** 12 | * @author ilyas 13 | */ 14 | public class ClojureIndentProcessor implements ClojureElementTypes{ 15 | public static Indent getChildIndent(ClojureBlock parent, ASTNode prevChildNode, ASTNode child) { 16 | ASTNode astNode = parent.getNode(); 17 | final PsiElement psiParent = astNode.getPsi(); 18 | 19 | // For Groovy file 20 | if (psiParent instanceof ClojureFile) { 21 | return Indent.getNoneIndent(); 22 | } 23 | 24 | ASTNode node = parent.getNode(); 25 | final TokenSet L_BRACES = TokenSet.create(LEFT_CURLY, LEFT_PAREN, LEFT_SQUARE); 26 | if (LIST_LIKE_FORMS.contains(node.getElementType())) { 27 | if (L_BRACES.contains(child.getElementType())) { 28 | return Indent.getNoneIndent(); 29 | } else { 30 | return Indent.getNormalIndent(true); 31 | } 32 | } 33 | return Indent.getNoneIndent(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/stubs/index/ClojureFullScriptNameIndex.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.stubs.index; 2 | 3 | import com.intellij.psi.stubs.IntStubIndexExtension; 4 | import com.intellij.psi.stubs.StubIndexKey; 5 | import com.intellij.psi.search.GlobalSearchScope; 6 | import com.intellij.openapi.project.Project; 7 | 8 | import java.util.Collection; 9 | 10 | import org.jetbrains.plugins.clojure.psi.api.ClojureFile; 11 | import org.jetbrains.plugins.clojure.psi.impl.search.ClojureSourceFilterScope; 12 | 13 | /** 14 | * @author ilyas 15 | */ 16 | public class ClojureFullScriptNameIndex extends IntStubIndexExtension { 17 | public static final StubIndexKey KEY = StubIndexKey.createIndexKey("clj.script.fqn"); 18 | 19 | private static final ClojureFullScriptNameIndex ourInstance = new ClojureFullScriptNameIndex(); 20 | public static ClojureFullScriptNameIndex getInstance() { 21 | return ourInstance; 22 | } 23 | 24 | public StubIndexKey getKey() { 25 | return KEY; 26 | } 27 | 28 | public Collection get(final Integer integer, final Project project, final GlobalSearchScope scope) { 29 | return super.get(integer, project, new ClojureSourceFilterScope(scope, project)); 30 | } 31 | 32 | @Override 33 | public int getVersion() { 34 | return ClojureIndexVersion.VERSION; 35 | } 36 | } -------------------------------------------------------------------------------- /jps-plugin/src/org/jetbrains/jps/clojure/model/impl/JpsClojureCompilerSettingsExtensionImpl.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.jps.clojure.model.impl; 2 | 3 | import com.intellij.util.xmlb.XmlSerializerUtil; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.jetbrains.jps.clojure.model.JpsClojureCompilerSettingsExtension; 6 | import org.jetbrains.jps.model.ex.JpsElementBase; 7 | 8 | /** 9 | * @author nik 10 | * @since 02.11.12 11 | */ 12 | public class JpsClojureCompilerSettingsExtensionImpl extends JpsElementBase implements JpsClojureCompilerSettingsExtension { 13 | private final JpsClojureCompilerSettingsState myState; 14 | 15 | public JpsClojureCompilerSettingsExtensionImpl(JpsClojureCompilerSettingsState state) { 16 | myState = state; 17 | } 18 | 19 | @NotNull 20 | @Override 21 | public JpsClojureCompilerSettingsExtensionImpl createCopy() { 22 | return new JpsClojureCompilerSettingsExtensionImpl(XmlSerializerUtil.createCopy(myState)); 23 | } 24 | 25 | @Override 26 | public void applyChanges(@NotNull JpsClojureCompilerSettingsExtensionImpl modified) { 27 | } 28 | 29 | public boolean isCompileClojure() { 30 | return myState.COMPILE_CLOJURE; 31 | } 32 | 33 | public boolean isClojureBefore() { 34 | return myState.CLOJURE_BEFORE; 35 | } 36 | 37 | public boolean isCopyCljSources() { 38 | return myState.COPY_CLJ_SOURCES; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/impl/ns/ClInNsImpl.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.impl.ns; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import com.intellij.psi.stubs.IStubElementType; 5 | import com.intellij.psi.PsiElement; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.jetbrains.annotations.Nullable; 8 | import org.jetbrains.plugins.clojure.psi.api.symbols.ClSymbol; 9 | import org.jetbrains.plugins.clojure.psi.api.ClQuotedForm; 10 | import org.jetbrains.plugins.clojure.psi.stubs.api.ClNsStub; 11 | import org.jetbrains.plugins.clojure.psi.util.ClojurePsiUtil; 12 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElement; 13 | 14 | /** 15 | * @author ilyas 16 | */ 17 | public class ClInNsImpl extends ClNsImpl{ 18 | 19 | public ClInNsImpl(ClNsStub stub, @NotNull IStubElementType nodeType) { 20 | super(stub, nodeType); 21 | } 22 | 23 | public ClInNsImpl(ASTNode node) { 24 | super(node); 25 | } 26 | 27 | @Override 28 | @Nullable 29 | public ClSymbol getNameSymbol() { 30 | final PsiElement element = getSecondNonLeafElement(); 31 | if (element instanceof ClQuotedForm) { 32 | final ClQuotedForm form = (ClQuotedForm) element; 33 | final ClojurePsiElement elt = form.getQuotedElement(); 34 | if (elt instanceof ClSymbol) { 35 | return (ClSymbol) elt; 36 | } 37 | return null; 38 | } 39 | return null; 40 | } 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/resolve/completion/ClojureCompletionConfidence.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.resolve.completion; 2 | 3 | import com.intellij.codeInsight.CodeInsightSettings; 4 | import com.intellij.codeInsight.completion.CompletionConfidence; 5 | import com.intellij.codeInsight.completion.CompletionParameters; 6 | import com.intellij.openapi.editor.Document; 7 | import com.intellij.psi.PsiElement; 8 | import com.intellij.psi.PsiFile; 9 | import com.intellij.util.ThreeState; 10 | import org.jetbrains.annotations.NotNull; 11 | import org.jetbrains.plugins.clojure.repl.ClojureConsole; 12 | 13 | /** 14 | * @author peter 15 | */ 16 | public class ClojureCompletionConfidence extends CompletionConfidence { 17 | @NotNull 18 | @Override 19 | public ThreeState shouldFocusLookup(@NotNull CompletionParameters completionParameters) { 20 | return ThreeState.UNSURE; 21 | } 22 | 23 | @NotNull 24 | @Override 25 | public ThreeState shouldSkipAutopopup(@NotNull PsiElement contextElement, @NotNull PsiFile psiFile, int offset) { 26 | Document document = psiFile.getViewProvider().getDocument(); 27 | if (document != null && 28 | CodeInsightSettings.getInstance().SELECT_AUTOPOPUP_SUGGESTIONS_BY_CHARS && 29 | document.getUserData(ClojureConsole.CLOJURE_CONSOLE_EDITOR) == Boolean.TRUE) { 30 | return ThreeState.YES; 31 | } 32 | return ThreeState.UNSURE; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/debugger/filters/ClojureDebuggerSettings.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.debugger.filters; 2 | 3 | import com.intellij.openapi.components.State; 4 | import com.intellij.openapi.components.Storage; 5 | import com.intellij.openapi.options.Configurable; 6 | import com.intellij.util.xmlb.XmlSerializerUtil; 7 | import com.intellij.xdebugger.settings.XDebuggerSettings; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | /** 11 | * @author ilyas 12 | */ 13 | @State( 14 | name = "ClojureDebuggerSettings", 15 | storages = { 16 | @Storage( 17 | id = "clojure_debugger", 18 | file = "$APP_CONFIG$/clojure_debug.xml" 19 | )} 20 | ) 21 | public class ClojureDebuggerSettings extends XDebuggerSettings { 22 | 23 | public Boolean DEBUG_DISABLE_SPECIFIC_CLOJURE_METHODS = true; 24 | 25 | public ClojureDebuggerSettings() { 26 | super("clojure_debugger"); 27 | } 28 | 29 | @NotNull 30 | public Configurable createConfigurable() { 31 | return new ClojureDebuggerSettingsConfigurable(this); 32 | } 33 | 34 | public ClojureDebuggerSettings getState() { 35 | return this; 36 | } 37 | 38 | public void loadState(final ClojureDebuggerSettings state) { 39 | XmlSerializerUtil.copyBean(state, this); 40 | } 41 | 42 | public static ClojureDebuggerSettings getInstance() { 43 | return getInstance(ClojureDebuggerSettings.class); 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/debugger/filters/ClojureDebugClassesFilterProvider.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.debugger.filters; 2 | 3 | import com.intellij.ui.classFilter.ClassFilter; 4 | import com.intellij.ui.classFilter.DebuggerClassFilterProvider; 5 | import com.intellij.util.Function; 6 | import com.intellij.util.containers.ContainerUtil; 7 | import org.jetbrains.annotations.NonNls; 8 | 9 | import java.util.ArrayList; 10 | import java.util.Arrays; 11 | import java.util.List; 12 | 13 | /** 14 | * @author ilyas 15 | */ 16 | public class ClojureDebugClassesFilterProvider implements DebuggerClassFilterProvider { 17 | 18 | @NonNls 19 | private static final String[] PROHIBITED_CLASS_PATTERNS = 20 | {"clojure.*"}; 21 | 22 | private static ClassFilter[] FILTERS = ContainerUtil.map(PROHIBITED_CLASS_PATTERNS, new Function() { 23 | public ClassFilter fun(final String s) { 24 | return new ClassFilter(s); 25 | } 26 | }, new ClassFilter[0]); 27 | 28 | public List getFilters() { 29 | 30 | final ClojureDebuggerSettings settings = ClojureDebuggerSettings.getInstance(); 31 | final Boolean flag = settings.DEBUG_DISABLE_SPECIFIC_CLOJURE_METHODS; 32 | final ArrayList list = new ArrayList(); 33 | if (flag == null || flag.booleanValue()) { 34 | list.addAll(Arrays.asList(FILTERS)); 35 | return list; 36 | } 37 | return list; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/formatter/ClojureFormattingModelBuilder.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.formatter; 2 | 3 | import com.intellij.formatting.FormattingModel; 4 | import com.intellij.formatting.FormattingModelBuilder; 5 | import com.intellij.formatting.FormattingModelProvider; 6 | import com.intellij.formatting.Indent; 7 | import com.intellij.lang.ASTNode; 8 | import com.intellij.openapi.util.TextRange; 9 | import com.intellij.psi.PsiElement; 10 | import com.intellij.psi.PsiFile; 11 | import com.intellij.psi.codeStyle.CodeStyleSettings; 12 | import org.jetbrains.annotations.NotNull; 13 | import org.jetbrains.annotations.Nullable; 14 | 15 | /** 16 | * @author ilyas 17 | */ 18 | public class ClojureFormattingModelBuilder implements FormattingModelBuilder { 19 | @NotNull 20 | public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) { 21 | ASTNode node = element.getNode(); 22 | assert node != null; 23 | PsiFile containingFile = element.getContainingFile(); 24 | ASTNode astNode = containingFile.getNode(); 25 | assert astNode != null; 26 | return FormattingModelProvider.createFormattingModelForPsiFile(containingFile, 27 | new ClojureBlock(astNode, null, Indent.getAbsoluteNoneIndent(), null, settings), settings); 28 | } 29 | 30 | @Nullable 31 | public TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) { 32 | return null; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /test/org/jetbrains/plugins/clojure/actions/editor/ClojureEditingTest.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.actions.editor; 2 | 3 | import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; 4 | 5 | /** 6 | * @author peter 7 | */ 8 | public class ClojureEditingTest extends LightCodeInsightFixtureTestCase { 9 | 10 | public void testEnterInMultipleSemicolonComment() { 11 | myFixture.configureByText("a.clj", " ;;; helloworld"); 12 | myFixture.type('\n'); 13 | myFixture.checkResult(" ;;; hello\n ;;; world"); 14 | } 15 | 16 | public void testEnterInLet() { 17 | myFixture.configureByText("a.clj", "(let [foo bar]\n\n)"); 18 | myFixture.type('\n'); 19 | myFixture.checkResult("(let [foo bar]\n \n\n)"); 20 | } 21 | 22 | public void testEnterAfterDoc() { 23 | myFixture.configureByText("a.clj", "(defn foo\n" + 24 | " \"Doc section\""); 25 | myFixture.type('\n'); 26 | myFixture.checkResult("(defn foo\n" + 27 | " \"Doc section\"\n" + 28 | " "); 29 | } 30 | 31 | public void testEnterInVector() { 32 | myFixture.configureByText("a.clj", 33 | "(for [[x y] [[:foo1 bar1]\n" + 34 | " ]])\n"); 35 | myFixture.type('\n'); 36 | myFixture.checkResult( 37 | "(for [[x y] [[:foo1 bar1]\n" + 38 | " \n" + 39 | " ]])\n"); 40 | 41 | 42 | } 43 | 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/util/ClojurePsiFactory.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.util; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import com.intellij.openapi.components.ServiceManager; 5 | import com.intellij.openapi.project.Project; 6 | import com.intellij.psi.PsiClass; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.annotations.Nullable; 9 | import org.jetbrains.plugins.clojure.psi.api.ClList; 10 | import org.jetbrains.plugins.clojure.psi.api.ClListLike; 11 | import org.jetbrains.plugins.clojure.psi.api.ClVector; 12 | import org.jetbrains.plugins.clojure.psi.api.ClojureFile; 13 | 14 | /** 15 | * @author ilyas 16 | */ 17 | public abstract class ClojurePsiFactory { 18 | 19 | public static ClojurePsiFactory getInstance(Project project) { 20 | return ServiceManager.getService(project, ClojurePsiFactory.class); 21 | } 22 | 23 | public abstract ASTNode createSymbolNodeFromText(@NotNull String newName); 24 | 25 | public abstract boolean hasSyntacticalErrors(@NotNull String text); 26 | 27 | public abstract String getErrorMessage(@NotNull String text); 28 | 29 | public abstract ClojureFile createClojureFileFromText(@NotNull String text); 30 | 31 | public abstract ClList createListFromText(@NotNull String text); 32 | 33 | public abstract ClVector createVectorFromText(@NotNull String text); 34 | 35 | @Nullable 36 | public abstract ClListLike findOrCreateJavaImportForClass(PsiClass clazz, ClList importClause); 37 | } 38 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/gotoclass/ClojureGoToSymbolContributor.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.gotoclass; 2 | 3 | import com.intellij.navigation.ChooseByNameContributor; 4 | import com.intellij.navigation.NavigationItem; 5 | import com.intellij.openapi.project.Project; 6 | import com.intellij.psi.stubs.StubIndex; 7 | import com.intellij.psi.search.GlobalSearchScope; 8 | 9 | import java.util.Set; 10 | import java.util.HashSet; 11 | import java.util.List; 12 | import java.util.ArrayList; 13 | 14 | import org.jetbrains.plugins.clojure.psi.stubs.index.ClDefNameIndex; 15 | 16 | /** 17 | * @author ilyas 18 | */ 19 | public class ClojureGoToSymbolContributor implements ChooseByNameContributor { 20 | public String[] getNames(Project project, boolean includeNonProjectItems) { 21 | Set symbols = new HashSet(); 22 | symbols.addAll(StubIndex.getInstance().getAllKeys(ClDefNameIndex.KEY, project)); 23 | return symbols.toArray(new String[symbols.size()]); 24 | 25 | } 26 | 27 | public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) { 28 | final GlobalSearchScope scope = includeNonProjectItems ? null : GlobalSearchScope.projectScope(project); 29 | 30 | List symbols = new ArrayList(); 31 | symbols.addAll(StubIndex.getInstance().get(ClDefNameIndex.KEY, name, project, scope)); 32 | return symbols.toArray(new NavigationItem[symbols.size()]); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /testdata/parser/defn-tree.txt: -------------------------------------------------------------------------------- 1 | ClojureFile 2 | ClDef 3 | PsiElement(()('(') 4 | ClSymbol 5 | PsiElement(atom)('defn') 6 | PsiWhiteSpace('\n ') 7 | ClLiteral 8 | PsiElement(string literal)('"#^{:doc "') 9 | ClSymbol 10 | PsiElement(atom)('mymax') 11 | PsiWhiteSpace(' ') 12 | ClVector 13 | PsiElement([)('[') 14 | ClSymbol 15 | PsiElement(atom)('xs+') 16 | PsiElement(])(']') 17 | PsiWhiteSpace(' ') 18 | ClSymbol 19 | PsiElement(atom)('gets') 20 | PsiWhiteSpace(' ') 21 | ClSymbol 22 | PsiElement(atom)('the') 23 | PsiWhiteSpace(' ') 24 | ClSymbol 25 | PsiElement(atom)('maximum') 26 | PsiWhiteSpace(' ') 27 | ClSymbol 28 | PsiElement(atom)('value') 29 | PsiWhiteSpace(' ') 30 | ClSymbol 31 | PsiElement(atom)('in') 32 | PsiWhiteSpace(' ') 33 | ClSymbol 34 | PsiElement(atom)('xs') 35 | PsiWhiteSpace(' ') 36 | ClSymbol 37 | PsiElement(atom)('using') 38 | PsiWhiteSpace(' ') 39 | ClSymbol 40 | PsiElement(atom)('>') 41 | PsiWhiteSpace(' ') 42 | PsiErrorElement:Uncompleted string literal 43 | PsiElement(wrong string literal)('"\n :test (fn []\n (assert (= 42 (max 2 42 5 4))))\n :user/comment \"this is the best fn ever!\"}\n mymax\n ([x] x)\n ([x y] (if (> x y) x y))\n ([x y & more]\n (reduce mymax (mymax x y) more)))') 44 | PsiErrorElement:Expected ')' 45 | 46 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/annotator/intentions/imports/ClojureImportClassFix.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.annotator.intentions.imports; 2 | 3 | import com.intellij.codeInspection.HintAction; 4 | import com.intellij.openapi.editor.Editor; 5 | import com.intellij.openapi.project.Project; 6 | import com.intellij.psi.PsiFile; 7 | import com.intellij.psi.PsiNamedElement; 8 | import com.intellij.util.IncorrectOperationException; 9 | import org.jetbrains.annotations.NotNull; 10 | import org.jetbrains.plugins.clojure.ClojureBundle; 11 | 12 | /** 13 | * @author ilyas 14 | */ 15 | public class ClojureImportClassFix implements HintAction { 16 | private final PsiNamedElement[] myElements; 17 | 18 | public ClojureImportClassFix(PsiNamedElement[] elements) { 19 | myElements = elements; 20 | } 21 | 22 | public boolean showHint(Editor editor) { 23 | return false; 24 | } 25 | 26 | @NotNull 27 | public String getText() { 28 | return ClojureBundle.message("import.named", myElements[0].getName()); 29 | } 30 | 31 | @NotNull 32 | public String getFamilyName() { 33 | return ClojureBundle.message("import.symbol"); 34 | } 35 | 36 | public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { 37 | return false; 38 | } 39 | 40 | public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { 41 | 42 | } 43 | 44 | public boolean startInWriteAction() { 45 | return false; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/debugger/filters/ClojureDebuggerSettingsConfigurable.form: -------------------------------------------------------------------------------- 1 | 2 |

3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/api/ClojureFile.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.api; 2 | 3 | import com.intellij.psi.PsiClass; 4 | import com.intellij.psi.PsiElement; 5 | import com.intellij.psi.PsiFile; 6 | import com.intellij.psi.impl.source.PsiFileWithStubSupport; 7 | import com.intellij.util.IncorrectOperationException; 8 | import org.jetbrains.annotations.NonNls; 9 | import org.jetbrains.annotations.NotNull; 10 | import org.jetbrains.annotations.Nullable; 11 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElement; 12 | import org.jetbrains.plugins.clojure.psi.api.defs.ClDef; 13 | import org.jetbrains.plugins.clojure.psi.api.ns.ClNs; 14 | 15 | import java.util.List; 16 | 17 | /** 18 | * @author ilyas 19 | */ 20 | public interface ClojureFile extends PsiFile, ClojurePsiElement, PsiFileWithStubSupport { 21 | 22 | List getFileDefinitions(); 23 | 24 | boolean isClassDefiningFile(); 25 | 26 | @Nullable 27 | String getNamespace(); 28 | 29 | @Nullable 30 | ClNs getNamespaceElement(); 31 | 32 | @NotNull 33 | ClNs findOrCreateNamespaceElement() throws IncorrectOperationException; 34 | 35 | @NotNull 36 | String getPackageName(); 37 | 38 | @Nullable 39 | String getClassName(); 40 | 41 | PsiElement setClassName(@NonNls String s); 42 | 43 | @Nullable 44 | PsiClass getDefinedClass(); 45 | 46 | void setNamespace(String newNs); 47 | 48 | @Nullable 49 | String getNamespacePrefix(); 50 | 51 | @Nullable 52 | String getNamespaceSuffix(); 53 | } 54 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/config/util/ClojureMavenLibraryUtil.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.config.util; 2 | 3 | import com.intellij.facet.ui.libraries.LibraryInfo; 4 | import org.jetbrains.annotations.NonNls; 5 | 6 | /** 7 | * @author ilyas 8 | */ 9 | public class ClojureMavenLibraryUtil { 10 | 11 | @NonNls 12 | private static final String DOWNLOAD_JETBRAINS_COM = "http://download.jetbrains.com"; 13 | @NonNls 14 | private static final String DOWNLOADING_URL = DOWNLOAD_JETBRAINS_COM + "/idea/clojure/"; 15 | 16 | @NonNls 17 | private static final String DOWNLOAD_MAVEN_ORG = "http://repo1.maven.org"; 18 | @NonNls 19 | private static final String MAVEN_DOWNLOADING_URL = DOWNLOAD_MAVEN_ORG + "/maven2/org/clojure/clojure/"; 20 | 21 | private ClojureMavenLibraryUtil() { 22 | } 23 | 24 | public static LibraryInfo createJarDownloadInfo(final boolean useBrainsUrl, final String jarName, final String version, 25 | final String... requiredClasses) { 26 | final String v = version == null || version.length() == 0 ? "" : "/" + version + "/"; 27 | if (useBrainsUrl) 28 | return new LibraryInfo(jarName, DOWNLOADING_URL + v + jarName, DOWNLOAD_JETBRAINS_COM, null, 29 | requiredClasses); 30 | else 31 | return new LibraryInfo(jarName, MAVEN_DOWNLOADING_URL + v 32 | + jarName.substring(0, jarName.lastIndexOf('.')) + "-" + version + ".jar", DOWNLOAD_MAVEN_ORG, null, 33 | requiredClasses); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/util/ClojurePsiCheckers.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.util; 2 | 3 | import com.intellij.psi.PsiElement; 4 | import org.jetbrains.plugins.clojure.psi.api.ClList; 5 | import org.jetbrains.plugins.clojure.psi.api.ClQuotedForm; 6 | import org.jetbrains.plugins.clojure.psi.api.ns.ClNs; 7 | 8 | /** 9 | * @author ilyas 10 | */ 11 | public abstract class ClojurePsiCheckers { 12 | 13 | public static boolean isImportList(PsiElement elem) { 14 | return specificHeadText(elem, ClojureKeywords.IMPORT); 15 | } 16 | 17 | public static boolean isRequireList(PsiElement elem) { 18 | return specificHeadText(elem, ClojureKeywords.REQUIRE); 19 | } 20 | 21 | public static boolean isUseList(PsiElement elem) { 22 | return specificHeadText(elem, ClojureKeywords.USE); 23 | } 24 | 25 | public static boolean isNs(PsiElement elem) { 26 | return (elem instanceof ClNs); 27 | } 28 | 29 | private static boolean specificHeadText(PsiElement elem, String head) { 30 | return (elem instanceof ClList) && 31 | head.equals(((ClList) elem).getHeadText()); 32 | } 33 | 34 | public static boolean isImportingClause(PsiElement elem) { 35 | return isImportList(elem) || 36 | isRequireList(elem) || 37 | isUseList(elem); 38 | } 39 | 40 | public static boolean isImportMember(ClList list) { 41 | return isImportingClause(list.getParent()) || 42 | (list.getParent() instanceof ClQuotedForm && 43 | isImportingClause(list.getParent().getParent())); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /test/org/jetbrains/plugins/clojure/intentions/ClojureIntentionTestBase.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.intentions; 2 | 3 | import com.intellij.testFramework.fixtures.CodeInsightTestUtil; 4 | import org.jetbrains.plugins.clojure.base.ClojureBaseTestCase; 5 | 6 | /** 7 | * @author Stanislav.Osipov 8 | * @since 8/8/13 9 | */ 10 | public abstract class ClojureIntentionTestBase extends ClojureBaseTestCase { 11 | 12 | private static final String DATA_PATH = System.getProperty("user.dir") + "/testdata/intention"; 13 | 14 | @Override 15 | public String getDataPath() { 16 | return DATA_PATH; 17 | } 18 | 19 | protected abstract String getIntentionName(); 20 | 21 | private void doTest(String intentionName) { 22 | final String testName = getTestName(false); 23 | CodeInsightTestUtil.doIntentionTest(myFixture, intentionName, testName + SOURCE_FILE_EXT, testName + TEST_FILE_EXT); 24 | } 25 | 26 | protected void doTest() { 27 | doTest(getIntentionName()); 28 | } 29 | 30 | protected void assertNotAvailable() { 31 | assertNotAvailable(getIntentionName()); 32 | } 33 | 34 | private void assertNotAvailable(String intentionName) { 35 | final String testName = getTestName(false); 36 | myFixture.configureByFile(testName + SOURCE_FILE_EXT); 37 | assertEmpty("Intention \'" + intentionName + "\' is available but should not", 38 | myFixture.filterAvailableIntentions(intentionName)); 39 | } 40 | 41 | @Override 42 | protected boolean isWriteActionRequired() { 43 | return false; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/repl/actions/SwitchNamespaceClojureFileInConsoleAction.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.repl.actions; 2 | 3 | import com.intellij.openapi.actionSystem.AnActionEvent; 4 | import com.intellij.openapi.actionSystem.DataKeys; 5 | import com.intellij.openapi.editor.Editor; 6 | import com.intellij.openapi.fileEditor.FileDocumentManager; 7 | import com.intellij.openapi.project.Project; 8 | import com.intellij.openapi.vfs.VirtualFile; 9 | import com.intellij.psi.PsiFile; 10 | import com.intellij.psi.PsiManager; 11 | import org.jetbrains.plugins.clojure.psi.api.ClojureFile; 12 | 13 | /** 14 | * @author Alefas 15 | * @since 18.03.14 16 | */ 17 | public class SwitchNamespaceClojureFileInConsoleAction extends ClojureConsoleActionBase { 18 | @Override 19 | public void actionPerformed(AnActionEvent event) { 20 | Editor editor = event.getData(DataKeys.EDITOR); 21 | if (editor == null) { return; } 22 | 23 | Project project = editor.getProject(); 24 | if (project == null) { return; } 25 | 26 | VirtualFile vfile = FileDocumentManager.getInstance().getFile(editor.getDocument()); 27 | 28 | if (vfile == null) return; 29 | 30 | PsiFile psiFile = PsiManager.getInstance(project).findFile(vfile); 31 | if (psiFile == null || !(psiFile instanceof ClojureFile)) { return; } 32 | 33 | final String namespace = ((ClojureFile) psiFile).getNamespace(); 34 | if (namespace == null) return; 35 | final String command = "(ns " + namespace + ")"; 36 | executeCommand(project, command); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test/org/jetbrains/plugins/clojure/resolve/psi/StubTest.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.resolve.psi; 2 | 3 | import com.intellij.psi.PsiReference; 4 | import com.intellij.psi.impl.source.PsiFileImpl; 5 | import com.intellij.psi.stubs.StubIndex; 6 | import com.intellij.psi.stubs.StubUpdatingIndex; 7 | import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; 8 | import com.intellij.util.indexing.FileBasedIndex; 9 | import org.jetbrains.plugins.clojure.psi.api.defs.ClDef; 10 | 11 | /** 12 | * @author peter 13 | */ 14 | public class StubTest extends LightCodeInsightFixtureTestCase { 15 | 16 | public void testDontParseUnrelatedNamespacesDuringResolve() { 17 | PsiFileImpl ns1 = (PsiFileImpl) myFixture.addFileToProject("ns1.clj", "(ns ns1)"); 18 | PsiFileImpl ns2 = (PsiFileImpl) myFixture.addFileToProject("ns2.clj", "(ns ns2)"); 19 | myFixture.configureByText("ns3.clj", "(require ns2)\n(ns2/foo)"); 20 | 21 | myFixture.doHighlighting(); 22 | assert !ns1.isContentsLoaded(); 23 | } 24 | 25 | public void testDontParseTargetFileDuringDefnResolve() { 26 | PsiFileImpl used = (PsiFileImpl) myFixture.addFileToProject("used.clj", "(ns used)\n(defn foo [] (println \"hello\"))"); 27 | myFixture.configureByText("main.clj", "(require used)\n(used/foo)"); 28 | 29 | PsiReference ref = myFixture.getFile().findReferenceAt(myFixture.getEditor().getCaretModel().getOffset()); 30 | assertNotNull(ref); 31 | assertInstanceOf(ref.resolve(), ClDef.class); 32 | assert !used.isContentsLoaded(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/stubs/impl/ClFileStubImpl.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.stubs.impl; 2 | 3 | import com.intellij.psi.stubs.PsiFileStubImpl; 4 | import com.intellij.psi.tree.IStubFileElementType; 5 | import com.intellij.util.io.StringRef; 6 | import org.jetbrains.plugins.clojure.parser.ClojureElementTypes; 7 | import org.jetbrains.plugins.clojure.psi.api.ClojureFile; 8 | import org.jetbrains.plugins.clojure.psi.stubs.api.ClFileStub; 9 | 10 | /** 11 | * @author ilyas 12 | */ 13 | public class ClFileStubImpl extends PsiFileStubImpl implements ClFileStub { 14 | private final StringRef myPackageName; 15 | private final StringRef myClassName; 16 | private final boolean isClassDefinition; 17 | 18 | public ClFileStubImpl(ClojureFile file) { 19 | super(file); 20 | myPackageName = StringRef.fromString(file.getPackageName()); 21 | isClassDefinition = file.isClassDefiningFile(); 22 | myClassName = StringRef.fromString(file.getClassName()); 23 | } 24 | 25 | public ClFileStubImpl(StringRef packName, StringRef name, boolean isScript) { 26 | super(null); 27 | myPackageName = packName; 28 | myClassName = name; 29 | this.isClassDefinition = isScript; 30 | } 31 | 32 | public IStubFileElementType getType() { 33 | return ClojureElementTypes.FILE; 34 | } 35 | 36 | public StringRef getPackageName() { 37 | return myPackageName; 38 | } 39 | 40 | public StringRef getClassName() { 41 | return myClassName; 42 | } 43 | 44 | public boolean isClassDefinition() { 45 | return isClassDefinition; 46 | } 47 | } -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/structure/ClojureStructureViewModel.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.structure; 2 | 3 | import com.intellij.ide.structureView.TextEditorBasedStructureViewModel; 4 | import com.intellij.ide.structureView.StructureViewTreeElement; 5 | import com.intellij.ide.util.treeView.smartTree.Grouper; 6 | import com.intellij.ide.util.treeView.smartTree.Sorter; 7 | import com.intellij.ide.util.treeView.smartTree.Filter; 8 | import com.intellij.psi.PsiFile; 9 | import org.jetbrains.annotations.NotNull; 10 | import org.jetbrains.plugins.clojure.psi.api.defs.ClDef; 11 | 12 | /** 13 | * @author ilyas 14 | */ 15 | public class ClojureStructureViewModel extends TextEditorBasedStructureViewModel { 16 | private PsiFile myFile; 17 | 18 | public ClojureStructureViewModel(final PsiFile file) { 19 | super(file); 20 | myFile = file; 21 | } 22 | 23 | @NotNull 24 | public StructureViewTreeElement getRoot() { 25 | return new ClojureStructureViewElement(myFile); 26 | } 27 | 28 | @NotNull 29 | public Grouper[] getGroupers() { 30 | return Grouper.EMPTY_ARRAY; 31 | } 32 | 33 | @NotNull 34 | public Sorter[] getSorters() { 35 | return new Sorter[]{Sorter.ALPHA_SORTER}; 36 | } 37 | 38 | @NotNull 39 | public Filter[] getFilters() { 40 | return Filter.EMPTY_ARRAY; 41 | } 42 | 43 | protected PsiFile getPsiFile() { 44 | return myFile; 45 | } 46 | 47 | @NotNull 48 | protected Class[] getSuitableClasses() { 49 | return new Class[]{ClDef.class}; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /test/org/jetbrains/plugins/clojure/refactoring/IntroduceVariableTest.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.refactoring; 2 | 3 | import com.intellij.lang.LanguageRefactoringSupport; 4 | import com.intellij.refactoring.RefactoringActionHandler; 5 | import org.jetbrains.plugins.clojure.ClojureLanguage; 6 | 7 | /** 8 | * @author Stanislav.Osipov 9 | * @since 8/23/13 10 | */ 11 | public class IntroduceVariableTest extends ClojureRefactoringTestBase { 12 | 13 | @Override 14 | protected RefactoringActionHandler getRefactoringActionHandler() { 15 | return LanguageRefactoringSupport.INSTANCE.findSingle(ClojureLanguage.getInstance()).getIntroduceVariableHandler(); 16 | } 17 | 18 | public void testSimpleSelection() throws Exception { 19 | doTest(); 20 | } 21 | 22 | public void testContainerChooser() throws Exception { 23 | doTest(); 24 | } 25 | 26 | public void testGuard() throws Exception { 27 | doTest(); 28 | } 29 | 30 | public void testFuzzySelection() throws Exception { 31 | doTest(); 32 | } 33 | 34 | public void testCaret() throws Exception { 35 | doTest(); 36 | } 37 | 38 | public void testLetAddition() throws Exception { 39 | doTest(); 40 | } 41 | 42 | public void testOccurences() throws Exception { 43 | doTest(); 44 | } 45 | 46 | public void testJavaNames() throws Exception { 47 | doTest(); 48 | } 49 | 50 | public void testClojureNames() throws Exception { 51 | doTest(); 52 | } 53 | 54 | public void testLetInLet() throws Exception { 55 | doTest(); 56 | } 57 | 58 | public void testMultiBody() throws Exception { 59 | doTest(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/impl/search/ClojureSourceFilterScope.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.impl.search; 2 | 3 | import com.intellij.psi.search.GlobalSearchScope; 4 | import com.intellij.openapi.roots.ProjectFileIndex; 5 | import com.intellij.openapi.roots.ProjectRootManager; 6 | import com.intellij.openapi.project.Project; 7 | import com.intellij.openapi.vfs.VirtualFile; 8 | import com.intellij.openapi.module.Module; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | /** 12 | * @author ilyas 13 | */ 14 | public class ClojureSourceFilterScope extends GlobalSearchScope { 15 | private final GlobalSearchScope myDelegate; 16 | private final ProjectFileIndex myIndex; 17 | 18 | public ClojureSourceFilterScope(final GlobalSearchScope delegate, final Project project) { 19 | myDelegate = delegate; 20 | myIndex = ProjectRootManager.getInstance(project).getFileIndex(); 21 | } 22 | 23 | public boolean contains(final VirtualFile file) { 24 | if (myDelegate != null && !myDelegate.contains(file)) { 25 | return false; 26 | } 27 | 28 | return myIndex.isInSourceContent(file) || myIndex.isInLibraryClasses(file); 29 | } 30 | 31 | public int compare(final VirtualFile file1, final VirtualFile file2) { 32 | return myDelegate != null ? myDelegate.compare(file1, file2) : 0; 33 | } 34 | 35 | public boolean isSearchInModuleContent(@NotNull final Module aModule) { 36 | return myDelegate == null || myDelegate.isSearchInModuleContent(aModule); 37 | } 38 | 39 | public boolean isSearchInLibraries() { 40 | return myDelegate == null || myDelegate.isSearchInLibraries(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/editor/ClojureQuoteHandler.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.editor; 2 | 3 | import com.intellij.codeInsight.editorActions.QuoteHandler; 4 | import com.intellij.openapi.editor.Editor; 5 | import com.intellij.openapi.editor.highlighter.HighlighterIterator; 6 | import com.intellij.psi.tree.IElementType; 7 | import org.jetbrains.plugins.clojure.lexer.ClojureTokenTypes; 8 | 9 | /** 10 | * @author ilyas 11 | */ 12 | public class ClojureQuoteHandler implements QuoteHandler { 13 | 14 | public boolean isClosingQuote(HighlighterIterator iterator, int offset) { 15 | final IElementType tokenType = iterator.getTokenType(); 16 | 17 | if (tokenType == ClojureTokenTypes.STRING_LITERAL) { 18 | int start = iterator.getStart(); 19 | int end = iterator.getEnd(); 20 | return end - start >= 1 && offset == end - 1; 21 | } 22 | return false; 23 | } 24 | 25 | public boolean isOpeningQuote(HighlighterIterator iterator, int offset) { 26 | final IElementType tokenType = iterator.getTokenType(); 27 | 28 | if (tokenType == ClojureTokenTypes.WRONG_STRING_LITERAL || 29 | tokenType == ClojureTokenTypes.STRING_LITERAL) { 30 | int start = iterator.getStart(); 31 | return offset == start; 32 | } 33 | return false; 34 | } 35 | 36 | public boolean hasNonClosedLiteral(Editor editor, HighlighterIterator iterator, int offset) { 37 | return true; 38 | } 39 | 40 | public boolean isInsideLiteral(HighlighterIterator iterator) { 41 | final IElementType tokenType = iterator.getTokenType(); 42 | return tokenType == ClojureTokenTypes.STRING_LITERAL; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/actions/editor/ClojureEditorAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 JetBrains s.r.o. 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 | package org.jetbrains.plugins.clojure.actions.editor; 17 | 18 | import com.intellij.openapi.actionSystem.DataContext; 19 | import com.intellij.openapi.actionSystem.Presentation; 20 | import com.intellij.openapi.editor.Editor; 21 | import com.intellij.openapi.editor.actionSystem.EditorAction; 22 | import com.intellij.openapi.editor.actionSystem.EditorActionHandler; 23 | import org.jetbrains.plugins.clojure.utils.ClojureUtils; 24 | 25 | /** 26 | * An editor action that operates on clojure editors. 27 | * 28 | * @author Ian Phillips 29 | */ 30 | public class ClojureEditorAction extends EditorAction { 31 | 32 | protected ClojureEditorAction(EditorActionHandler handler) { 33 | super(handler); 34 | } 35 | 36 | @Override 37 | public void update(Editor editor, Presentation presentation, DataContext dataContext) { 38 | presentation.setEnabled(ClojureUtils.isClojureEditor(editor)); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/impl/ClojurePsiManager.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.impl; 2 | 3 | import com.intellij.openapi.components.ProjectComponent; 4 | import com.intellij.openapi.project.Project; 5 | import com.intellij.openapi.application.ApplicationManager; 6 | import com.intellij.psi.PsiFileFactory; 7 | import com.intellij.psi.PsiFile; 8 | import org.jetbrains.annotations.NotNull; 9 | import org.jetbrains.plugins.clojure.file.ClojureFileType; 10 | 11 | /** 12 | * @author ilyas 13 | */ 14 | public class ClojurePsiManager implements ProjectComponent { 15 | private final Project myProject; 16 | private PsiFile myDummyFile; 17 | 18 | public ClojurePsiManager(Project project) { 19 | myProject = project; 20 | } 21 | 22 | public void projectOpened() { 23 | } 24 | 25 | public void projectClosed() { 26 | } 27 | 28 | @NotNull 29 | public String getComponentName() { 30 | return "ClojurePsiManager"; 31 | } 32 | 33 | public void initComponent() { 34 | ApplicationManager.getApplication().runReadAction(new Runnable() { 35 | public void run() { 36 | final String dummyFn = "dummy." + ClojureFileType.CLOJURE_FILE_TYPE.getDefaultExtension(); 37 | myDummyFile = PsiFileFactory.getInstance(myProject) 38 | .createFileFromText(dummyFn, ClojureFileType.CLOJURE_FILE_TYPE, ""); 39 | } 40 | }); 41 | } 42 | 43 | public void disposeComponent() { 44 | } 45 | 46 | public static ClojurePsiManager getInstance(Project project) { 47 | return project.getComponent(ClojurePsiManager.class); 48 | } 49 | 50 | public PsiFile getDummyFile() { 51 | return myDummyFile; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/repl/actions/RunLastSExprAction.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.repl.actions; 2 | 3 | import com.intellij.openapi.actionSystem.AnActionEvent; 4 | import com.intellij.openapi.actionSystem.DataKeys; 5 | import com.intellij.openapi.editor.Editor; 6 | import com.intellij.openapi.project.Project; 7 | import com.intellij.openapi.ui.Messages; 8 | import com.intellij.psi.PsiElement; 9 | import org.jetbrains.plugins.clojure.ClojureBundle; 10 | import org.jetbrains.plugins.clojure.ClojureIcons; 11 | import org.jetbrains.plugins.clojure.psi.util.ClojurePsiFactory; 12 | import org.jetbrains.plugins.clojure.psi.util.ClojurePsiUtil; 13 | 14 | /** 15 | * @author ilyas 16 | */ 17 | public class RunLastSExprAction extends ClojureConsoleActionBase{ 18 | 19 | public RunLastSExprAction() { 20 | getTemplatePresentation().setIcon(ClojureIcons.REPL_EVAL); 21 | } 22 | 23 | 24 | @Override 25 | public void actionPerformed(AnActionEvent event) { 26 | Editor editor = event.getData(DataKeys.EDITOR); 27 | if (editor == null) { return; } 28 | 29 | Project project = editor.getProject(); 30 | if (project == null) { return; } 31 | 32 | PsiElement sexp = ClojurePsiUtil.findSexpAtCaret(editor, true); 33 | if (sexp == null) { return; } 34 | 35 | String text = sexp.getText(); 36 | if (ClojurePsiFactory.getInstance(project).hasSyntacticalErrors(text)) { 37 | Messages.showErrorDialog(project, 38 | ClojureBundle.message("evaluate.incorrect.sexp"), 39 | ClojureBundle.message("evaluate.incorrect.cannot.evaluate")); 40 | return; 41 | } 42 | 43 | executeCommand(project, text); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/editor/ClojureCopyrightProvider.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.editor; 2 | 3 | import com.intellij.openapi.fileTypes.FileType; 4 | import com.intellij.openapi.module.Module; 5 | import com.intellij.openapi.project.Project; 6 | import com.intellij.openapi.vfs.VirtualFile; 7 | import com.intellij.psi.PsiComment; 8 | import com.intellij.psi.PsiElement; 9 | import com.intellij.psi.PsiWhiteSpace; 10 | import com.maddyhome.idea.copyright.CopyrightProfile; 11 | import com.maddyhome.idea.copyright.psi.UpdateCopyright; 12 | import com.maddyhome.idea.copyright.psi.UpdateCopyrightsProvider; 13 | import com.maddyhome.idea.copyright.psi.UpdatePsiFileCopyright; 14 | 15 | /** 16 | * @author peter 17 | */ 18 | public class ClojureCopyrightProvider extends UpdateCopyrightsProvider { 19 | @Override 20 | public UpdateCopyright createInstance(Project project, Module module, VirtualFile virtualFile, FileType fileType, CopyrightProfile copyrightProfile) { 21 | return new UpdatePsiFileCopyright(project, module, virtualFile, copyrightProfile) { 22 | 23 | @Override 24 | protected void scanFile() { 25 | PsiElement first = getFile().getFirstChild(); 26 | PsiElement last = first; 27 | PsiElement next = first; 28 | while (next != null) { 29 | if (next instanceof PsiComment || next instanceof PsiWhiteSpace) { 30 | next = getNextSibling(next); 31 | } 32 | else { 33 | break; 34 | } 35 | last = next; 36 | } 37 | 38 | if (first != null) { 39 | checkComments(first, last, true); 40 | } 41 | 42 | } 43 | }; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/psi/impl/ClMetadataImpl.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.psi.impl; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import com.intellij.util.Function; 5 | import com.intellij.util.containers.ContainerUtil; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElement; 8 | import org.jetbrains.plugins.clojure.psi.ClojurePsiElementImpl; 9 | import org.jetbrains.plugins.clojure.psi.api.ClKeyword; 10 | import org.jetbrains.plugins.clojure.psi.api.ClMap; 11 | import org.jetbrains.plugins.clojure.psi.api.ClMetadata; 12 | 13 | import java.util.Collections; 14 | import java.util.List; 15 | 16 | /** 17 | * @author ilyas 18 | */ 19 | public class ClMetadataImpl extends ClojurePsiElementImpl implements ClMetadata { 20 | public ClMetadataImpl(ASTNode node) { 21 | super(node); 22 | } 23 | 24 | @Override 25 | public String toString() { 26 | return "ClMetadata"; 27 | } 28 | 29 | @NotNull 30 | public List getKeys() { 31 | ClMap map = getUnderlyingMap(); 32 | if (map == null) return Collections.emptyList(); 33 | return ContainerUtil.map(map.getEntries(), new Function() { 34 | public ClKeyword fun(ClMapEntry clMapEntry) { 35 | return clMapEntry.getKeywordKey(); 36 | } 37 | }); 38 | } 39 | 40 | private ClMap getUnderlyingMap() { 41 | final ClMap map = findChildByClass(ClMap.class); 42 | if (map == null) return null; 43 | return map; 44 | } 45 | 46 | public ClojurePsiElement getValue(String key) { 47 | final ClMap map = getUnderlyingMap(); 48 | if (map == null) return null; 49 | return map.getValue(key); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/config/ClojureFacetListener.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.config; 2 | 3 | import com.intellij.facet.Facet; 4 | import com.intellij.facet.FacetManager; 5 | import com.intellij.facet.FacetManagerAdapter; 6 | import com.intellij.openapi.module.Module; 7 | import com.intellij.openapi.module.ModuleComponent; 8 | import com.intellij.util.messages.MessageBusConnection; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | /** 12 | * @author ilyas 13 | */ 14 | public class ClojureFacetListener extends FacetManagerAdapter implements ModuleComponent { 15 | private MessageBusConnection myConnection; 16 | 17 | private Module myModule; 18 | 19 | public ClojureFacetListener(Module module) { 20 | myModule = module; 21 | } 22 | 23 | public void initComponent() { 24 | myConnection = myModule.getMessageBus().connect(); 25 | myConnection.subscribe(FacetManager.FACETS_TOPIC, new FacetManagerAdapter() { 26 | public void facetAdded(@NotNull final Facet facet) { 27 | } 28 | 29 | public void facetRemoved(@NotNull Facet facet) { 30 | } 31 | }); 32 | } 33 | 34 | public void disposeComponent() { 35 | myConnection.disconnect(); 36 | } 37 | 38 | @NotNull 39 | public String getComponentName() { 40 | return "ClojureFacetListener"; 41 | } 42 | 43 | public void projectOpened() { 44 | // called when myProject is opened 45 | } 46 | 47 | public void projectClosed() { 48 | // called when myProject is being closed 49 | } 50 | 51 | public void moduleAdded() { 52 | // Invoked when the module corresponding to this component instance has been completely 53 | // loaded and added to the myProject. 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/highlighter/ClojureCommenter.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.highlighter; 2 | 3 | import com.intellij.lang.CodeDocumentationAwareCommenter; 4 | import com.intellij.psi.PsiComment; 5 | import com.intellij.psi.tree.IElementType; 6 | import org.jetbrains.annotations.Nullable; 7 | import org.jetbrains.plugins.clojure.lexer.ClojureTokenTypes; 8 | 9 | /** 10 | * @author ilyas 11 | */ 12 | public class ClojureCommenter implements CodeDocumentationAwareCommenter, ClojureTokenTypes { 13 | public String getLineCommentPrefix() { 14 | return ";"; 15 | } 16 | 17 | public String getBlockCommentPrefix() { 18 | return null; 19 | } 20 | 21 | public String getBlockCommentSuffix() { 22 | return null; 23 | } 24 | 25 | public String getCommentedBlockCommentPrefix() { 26 | return null; 27 | } 28 | 29 | public String getCommentedBlockCommentSuffix() { 30 | return null; 31 | } 32 | 33 | @Nullable 34 | public IElementType getLineCommentTokenType() { 35 | return LINE_COMMENT; 36 | } 37 | 38 | @Nullable 39 | public IElementType getBlockCommentTokenType() { 40 | return null; 41 | } 42 | 43 | @Nullable 44 | public IElementType getDocumentationCommentTokenType() { 45 | return null; 46 | } 47 | 48 | @Nullable 49 | public String getDocumentationCommentPrefix() { 50 | return null; 51 | } 52 | 53 | @Nullable 54 | public String getDocumentationCommentLinePrefix() { 55 | return null; 56 | } 57 | 58 | @Nullable 59 | public String getDocumentationCommentSuffix() { 60 | return null; 61 | } 62 | 63 | public boolean isDocumentationComment(PsiComment element) { 64 | return false; 65 | } 66 | 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/repl/actions/RunTopSExprAction.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.repl.actions; 2 | 3 | import com.intellij.openapi.actionSystem.AnActionEvent; 4 | import com.intellij.openapi.actionSystem.DataKeys; 5 | import com.intellij.openapi.editor.Editor; 6 | import com.intellij.openapi.project.Project; 7 | import com.intellij.openapi.ui.Messages; 8 | import com.intellij.psi.PsiElement; 9 | import org.jetbrains.plugins.clojure.ClojureBundle; 10 | import org.jetbrains.plugins.clojure.ClojureIcons; 11 | import org.jetbrains.plugins.clojure.psi.util.ClojurePsiFactory; 12 | import org.jetbrains.plugins.clojure.psi.util.ClojurePsiUtil; 13 | 14 | /** 15 | * @author ilyas 16 | */ 17 | public final class RunTopSExprAction extends ClojureConsoleActionBase { 18 | 19 | public RunTopSExprAction() { 20 | getTemplatePresentation().setIcon(ClojureIcons.REPL_EVAL); 21 | } 22 | 23 | public void actionPerformed(AnActionEvent event) { 24 | Editor editor = event.getData(DataKeys.EDITOR); 25 | if (editor == null) { 26 | return; 27 | } 28 | 29 | Project project = editor.getProject(); 30 | if (project == null) { 31 | return; 32 | } 33 | 34 | PsiElement sexp = ClojurePsiUtil.findTopSexpAroundCaret(editor); 35 | if (sexp == null) { 36 | return; 37 | } 38 | 39 | String text = sexp.getText(); 40 | if (ClojurePsiFactory.getInstance(project).hasSyntacticalErrors(text)) { 41 | Messages.showErrorDialog(project, 42 | ClojureBundle.message("evaluate.incorrect.sexp"), 43 | ClojureBundle.message("evaluate.incorrect.cannot.evaluate")); 44 | return; 45 | } 46 | 47 | executeCommand(project, text); 48 | 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/editor/selection/ClojureLiteralSelectioner.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.editor.selection; 2 | 3 | import com.intellij.psi.PsiElement; 4 | import com.intellij.lang.ASTNode; 5 | import com.intellij.openapi.util.TextRange; 6 | import com.intellij.openapi.editor.Editor; 7 | 8 | 9 | 10 | 11 | 12 | import java.util.List; 13 | 14 | import org.jetbrains.annotations.NotNull; 15 | import org.jetbrains.plugins.clojure.psi.api.ClLiteral; 16 | import org.jetbrains.plugins.clojure.lexer.ClojureTokenTypes; 17 | 18 | /** 19 | * @author ilyas 20 | */ 21 | public class ClojureLiteralSelectioner extends ClojureBasicSelectioner { 22 | public boolean canSelect(PsiElement e) { 23 | PsiElement parent = e.getParent(); 24 | return isStringLiteral(e) || isStringLiteral(parent); 25 | } 26 | 27 | private static boolean isStringLiteral(PsiElement element) { 28 | if (!(element instanceof ClLiteral)) return false; 29 | ASTNode node = element.getNode(); 30 | if (node == null) return false; 31 | ASTNode[] children = node.getChildren(null); 32 | return children.length == 1 && (children[0].getElementType() == ClojureTokenTypes.STRING_LITERAL); 33 | } 34 | 35 | public List select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) { 36 | List result = super.select(e, editorText, cursorOffset, editor); 37 | 38 | TextRange range = e.getTextRange(); 39 | if (range.getLength() <= 2) { 40 | result.add(range); 41 | } else { 42 | result.add(new TextRange(range.getStartOffset() + 1, range.getEndOffset() - 1)); 43 | } 44 | return result; 45 | } 46 | 47 | public int getMinimalTextRangeLength(@NotNull PsiElement element) { 48 | return 0; 49 | } 50 | } -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/repl/actions/RunSelectedTextAction.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.repl.actions; 2 | 3 | import com.intellij.openapi.actionSystem.AnActionEvent; 4 | import com.intellij.openapi.actionSystem.DataKeys; 5 | import com.intellij.openapi.editor.Editor; 6 | import com.intellij.openapi.editor.SelectionModel; 7 | import com.intellij.openapi.project.Project; 8 | import com.intellij.openapi.ui.Messages; 9 | import org.jetbrains.plugins.clojure.ClojureBundle; 10 | import org.jetbrains.plugins.clojure.ClojureIcons; 11 | import org.jetbrains.plugins.clojure.psi.util.ClojurePsiFactory; 12 | 13 | /** 14 | * @author ilyas 15 | */ 16 | public class RunSelectedTextAction extends ClojureConsoleActionBase { 17 | public RunSelectedTextAction(){ 18 | getTemplatePresentation().setIcon(ClojureIcons.REPL_EVAL); 19 | } 20 | 21 | @Override 22 | public void actionPerformed(AnActionEvent e) { 23 | final Editor editor = e.getData(DataKeys.EDITOR); 24 | if (editor == null) { 25 | return; 26 | } 27 | final SelectionModel selectionModel = editor.getSelectionModel(); 28 | String selectedText = selectionModel.getSelectedText(); 29 | if (selectedText == null || selectedText.trim().length() == 0) { 30 | return; 31 | } 32 | final String text = selectedText.trim(); 33 | final Project project = editor.getProject(); 34 | 35 | final String msg = ClojurePsiFactory.getInstance(project).getErrorMessage(text); 36 | if (msg != null) { 37 | Messages.showErrorDialog(project, 38 | ClojureBundle.message("evaluate.incorrect.form", msg), 39 | ClojureBundle.message("evaluate.incorrect.cannot.evaluate")); 40 | return; 41 | } 42 | 43 | executeCommand(project, text); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/formatter/codeStyle/ClojureCodeStyleSettingsProvider.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.formatter.codeStyle; 2 | 3 | import com.intellij.application.options.CodeStyleAbstractConfigurable; 4 | import com.intellij.application.options.CodeStyleAbstractPanel; 5 | import com.intellij.lang.Language; 6 | import com.intellij.openapi.options.Configurable; 7 | import com.intellij.psi.codeStyle.CodeStyleSettings; 8 | import com.intellij.psi.codeStyle.CodeStyleSettingsProvider; 9 | import com.intellij.psi.codeStyle.CustomCodeStyleSettings; 10 | import org.jetbrains.annotations.NotNull; 11 | import org.jetbrains.annotations.Nullable; 12 | import org.jetbrains.plugins.clojure.ClojureBundle; 13 | import org.jetbrains.plugins.clojure.file.ClojureFileType; 14 | 15 | /** 16 | * @author ilyas 17 | */ 18 | public class ClojureCodeStyleSettingsProvider extends CodeStyleSettingsProvider{ 19 | @NotNull 20 | public Configurable createSettingsPage(CodeStyleSettings settings, CodeStyleSettings originalSettings) { 21 | return new CodeStyleAbstractConfigurable(settings, originalSettings, ClojureBundle.message("title.clojure.code.style.settings")) { 22 | protected CodeStyleAbstractPanel createPanel(CodeStyleSettings settings) { 23 | return new ClojureCodeStylePanel(settings); 24 | } 25 | 26 | public String getHelpTopic() { 27 | return "reference.settingsdialog.IDE.globalcodestyle.spaces"; 28 | } 29 | }; 30 | } 31 | 32 | @Nullable 33 | @Override 34 | public Language getLanguage() { 35 | return ClojureFileType.CLOJURE_LANGUAGE; 36 | } 37 | 38 | @Override 39 | public CustomCodeStyleSettings createCustomSettings(CodeStyleSettings settings) { 40 | return new ClojureCodeStyleSettings(settings); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/repl/ClojureConsoleProcessHandler.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.plugins.clojure.repl; 2 | 3 | import com.intellij.execution.console.LanguageConsoleImpl; 4 | import com.intellij.execution.process.ColoredProcessHandler; 5 | import com.intellij.openapi.util.Key; 6 | import com.intellij.openapi.util.text.StringUtil; 7 | import com.intellij.openapi.vfs.CharsetToolkit; 8 | 9 | import java.util.regex.Matcher; 10 | 11 | /** 12 | * @author ilyas 13 | */ 14 | public class ClojureConsoleProcessHandler extends ColoredProcessHandler { 15 | 16 | private final LanguageConsoleImpl myLanguageConsole; 17 | 18 | public ClojureConsoleProcessHandler(Process process, String commandLine, LanguageConsoleImpl console) { 19 | super(process, commandLine, CharsetToolkit.UTF8_CHARSET); 20 | myLanguageConsole = console; 21 | } 22 | 23 | @Override 24 | protected void textAvailable(String text, Key attributes) { 25 | final String string = processPrompts(myLanguageConsole, StringUtil.convertLineSeparators(text)); 26 | ClojureConsoleHighlightingUtil.processOutput(myLanguageConsole, string, attributes); 27 | } 28 | 29 | private static String processPrompts(final LanguageConsoleImpl console, String text) { 30 | if (text != null && text.matches(ClojureConsoleHighlightingUtil.LINE_WITH_PROMPT)) { 31 | final Matcher matcher = ClojureConsoleHighlightingUtil.CLOJURE_PROMPT_PATTERN.matcher(text); 32 | matcher.find(); 33 | final String prefix = matcher.group(); 34 | final String trimmed = StringUtil.trimStart(text, prefix).trim(); 35 | console.setPrompt(prefix + " "); 36 | return trimmed; 37 | } 38 | return text; 39 | } 40 | 41 | public LanguageConsoleImpl getLanguageConsole() { 42 | return myLanguageConsole; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /jps-plugin/src/org/jetbrains/jps/clojure/model/impl/JpsClojureModelSerializerExtension.java: -------------------------------------------------------------------------------- 1 | package org.jetbrains.jps.clojure.model.impl; 2 | 3 | import com.intellij.util.xmlb.XmlSerializer; 4 | import org.jdom.Element; 5 | import org.jetbrains.annotations.NotNull; 6 | import org.jetbrains.jps.clojure.model.JpsClojureExtensionService; 7 | import org.jetbrains.jps.model.JpsProject; 8 | import org.jetbrains.jps.model.serialization.JpsModelSerializerExtension; 9 | import org.jetbrains.jps.model.serialization.JpsProjectExtensionSerializer; 10 | 11 | import java.util.Collections; 12 | import java.util.List; 13 | 14 | /** 15 | * @author nik 16 | * @since 02.11.12 17 | */ 18 | public class JpsClojureModelSerializerExtension extends JpsModelSerializerExtension { 19 | public static final String CLOJURE_COMPILER_SETTINGS_COMPONENT_NAME = "ClojureCompilerSettings"; 20 | public static final String CLOJURE_COMPILER_SETTINGS_FILE = "clojure_compiler.xml"; 21 | 22 | @NotNull 23 | @Override 24 | public List getProjectExtensionSerializers() { 25 | return Collections.singletonList(new JpsProjectExtensionSerializer(CLOJURE_COMPILER_SETTINGS_FILE, CLOJURE_COMPILER_SETTINGS_COMPONENT_NAME) { 26 | @Override 27 | public void loadExtension(@NotNull JpsProject jpsProject, @NotNull Element componentTag) { 28 | JpsClojureCompilerSettingsState state = XmlSerializer.deserialize(componentTag, JpsClojureCompilerSettingsState.class); 29 | if (state != null) { 30 | JpsClojureExtensionService.setExtension(jpsProject, new JpsClojureCompilerSettingsExtensionImpl(state)); 31 | } 32 | } 33 | 34 | @Override 35 | public void saveExtension(@NotNull JpsProject jpsProject, @NotNull Element componentTag) { 36 | } 37 | }); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/java/org/jetbrains/plugins/clojure/settings/ClojureProjectSettingsForm.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 JetBrains s.r.o. 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 | package org.jetbrains.plugins.clojure.settings; 17 | 18 | import com.intellij.openapi.project.Project; 19 | 20 | import javax.swing.*; 21 | 22 | /** 23 | * @author Ian Phillips 24 | */ 25 | public final class ClojureProjectSettingsForm { 26 | 27 | private final ClojureProjectSettings mySettings; 28 | 29 | private JPanel myPanel; 30 | private JCheckBox rainbowParenthesesCheckBox; 31 | private JPanel myAppearancePanel; 32 | 33 | public ClojureProjectSettingsForm(Project project) { 34 | mySettings = ClojureProjectSettings.getInstance(project); 35 | } 36 | 37 | JComponent getComponent() { 38 | return myPanel; 39 | } 40 | 41 | boolean isColoredParentheses() { 42 | return rainbowParenthesesCheckBox.isSelected(); 43 | } 44 | 45 | boolean isModified() { 46 | final boolean coloredParentheses = mySettings.coloredParentheses; 47 | return (rainbowParenthesesCheckBox.isSelected() != coloredParentheses); 48 | } 49 | 50 | void reset() { 51 | rainbowParenthesesCheckBox.setSelected(mySettings.coloredParentheses); 52 | } 53 | 54 | } 55 | --------------------------------------------------------------------------------