Operation mode.
This commit is contained in:
@@ -36,6 +36,8 @@ import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.impl.compiled.ClsCustomNavigationPolicy;
|
||||
import com.intellij.psi.impl.file.impl.JavaFileManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.CompilerModeProvider;
|
||||
import org.jetbrains.jet.OperationModeProvider;
|
||||
import org.jetbrains.jet.asJava.JavaElementFinder;
|
||||
import org.jetbrains.jet.asJava.LightClassGenerationSupport;
|
||||
import org.jetbrains.jet.cli.common.CLIConfigurationKeys;
|
||||
@@ -89,6 +91,8 @@ public class JetCoreEnvironment {
|
||||
applicationEnvironment.registerParserDefinition(new JavaParserDefinition());
|
||||
applicationEnvironment.registerParserDefinition(new JetParserDefinition());
|
||||
|
||||
applicationEnvironment.getApplication().registerService(OperationModeProvider.class, new CompilerModeProvider());
|
||||
|
||||
projectEnvironment = new JavaCoreProjectEnvironment(parentDisposable, applicationEnvironment);
|
||||
|
||||
MockProject project = projectEnvironment.getProject();
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet;
|
||||
|
||||
public class CompilerModeProvider implements OperationModeProvider {
|
||||
public static final OperationMode COMPILER_MODE = new OperationMode("compiler mode");
|
||||
|
||||
@Override
|
||||
public OperationMode getMode() {
|
||||
return COMPILER_MODE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class OperationMode {
|
||||
private final String id;
|
||||
|
||||
public OperationMode(@NotNull String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
|
||||
public interface OperationModeProvider {
|
||||
class SERVICE {
|
||||
private SERVICE() {
|
||||
}
|
||||
|
||||
public static OperationMode getMode() {
|
||||
return ServiceManager.getService(OperationModeProvider.class).getMode();
|
||||
}
|
||||
}
|
||||
|
||||
OperationMode getMode();
|
||||
}
|
||||
@@ -74,6 +74,9 @@
|
||||
<applicationService serviceInterface="org.jetbrains.jet.lang.psi.stubs.elements.StubIndexService"
|
||||
serviceImplementation="org.jetbrains.jet.plugin.stubindex.StubIndexServiceImpl" />
|
||||
|
||||
<applicationService serviceInterface="org.jetbrains.jet.OperationModeProvider"
|
||||
serviceImplementation="org.jetbrains.jet.plugin.IdeModeProvider" />
|
||||
|
||||
<projectService serviceInterface="org.jetbrains.jet.lang.resolve.java.JetFilesProvider"
|
||||
serviceImplementation="org.jetbrains.jet.plugin.project.PluginJetFilesProvider"/>
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.plugin;
|
||||
|
||||
import org.jetbrains.jet.OperationMode;
|
||||
import org.jetbrains.jet.OperationModeProvider;
|
||||
|
||||
public class IdeModeProvider implements OperationModeProvider {
|
||||
public static final OperationMode IDE_MODE = new OperationMode("IDE mode");
|
||||
|
||||
@Override
|
||||
public OperationMode getMode() {
|
||||
return IDE_MODE;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user