本文整理汇总了Java中com.intellij.codeInsight.template.TemplateContextType类的典型用法代码示例。如果您正苦于以下问题:Java TemplateContextType类的具体用法?Java TemplateContextType怎么用?Java TemplateContextType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TemplateContextType类属于com.intellij.codeInsight.template包,在下文中一共展示了TemplateContextType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addContextNode
import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
private static void addContextNode(MultiMap<TemplateContextType, TemplateContextType> hierarchy,
CheckedTreeNode parent,
TemplateContextType type, TemplateContext context) {
final Collection<TemplateContextType> children = hierarchy.get(type);
final String name = UIUtil.removeMnemonic(type.getPresentableName());
final CheckedTreeNode node = new CheckedTreeNode(Pair.create(children.isEmpty() ? type : null, name));
parent.add(node);
if (children.isEmpty()) {
node.setChecked(context.isExplicitlyEnabled(type));
}
else {
for (TemplateContextType child : children) {
addContextNode(hierarchy, node, child, context);
}
final CheckedTreeNode other = new CheckedTreeNode(Pair.create(type, "Other"));
other.setChecked(context.isExplicitlyEnabled(type));
node.add(other);
}
}
示例2: getDifference
import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
Map<TemplateContextType, Boolean> getDifference(@Nullable TemplateContext defaultContext) {
Map<TemplateContextType, Boolean> result = ContainerUtil.newLinkedHashMap();
synchronized (myContextStates) {
//noinspection NestedSynchronizedStatement
synchronized (defaultContext == null ? myContextStates : defaultContext.myContextStates) {
for (TemplateContextType contextType : TemplateManagerImpl.getAllContextTypes()) {
Boolean ownValue = getOwnValue(contextType);
if (ownValue != null) {
if (defaultContext == null || isEnabled(contextType) != defaultContext.isEnabled(contextType)) {
result.put(contextType, ownValue);
}
}
}
}
}
return result;
}
示例3: performCopy
import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
@Override
public void performCopy(@NotNull DataContext dataContext) {
final Set<TemplateImpl> templates = myConfigurable.getSelectedTemplates().keySet();
CopyPasteManager.getInstance().setContents(new StringSelection(StringUtil.join(templates, new Function<TemplateImpl, String>() {
@Override
public String fun(TemplateImpl template) {
TemplateContext zeroContext = new TemplateContext();
for (TemplateContextType type : TemplateContextType.EP_NAME.getExtensions()) {
zeroContext.setEnabled(type, false);
}
return JDOMUtil.writeElement(TemplateSettings.serializeTemplate(template, zeroContext));
}
}, SystemProperties.getLineSeparator())));
}
示例4: addContextNode
import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
private void addContextNode(MultiMap<TemplateContextType, TemplateContextType> hierarchy,
CheckedTreeNode parent,
TemplateContextType type) {
final Collection<TemplateContextType> children = hierarchy.get(type);
final String name = UIUtil.removeMnemonic(type.getPresentableName());
final CheckedTreeNode node = new CheckedTreeNode(Pair.create(children.isEmpty() ? type : null, name));
parent.add(node);
if (children.isEmpty()) {
node.setChecked(myContext.get(type));
}
else {
for (TemplateContextType child : children) {
addContextNode(hierarchy, node, child);
}
final CheckedTreeNode other = new CheckedTreeNode(Pair.create(type, "Other"));
other.setChecked(myContext.get(type));
node.add(other);
}
}
示例5: createTemplateEditor
import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
private void createTemplateEditor(final TemplateImpl template,
String shortcut,
Map<TemplateOptionalProcessor, Boolean> options,
Map<TemplateContextType, Boolean> context) {
myCurrentTemplateEditor = new LiveTemplateSettingsEditor(template, shortcut, options, context, new Runnable() {
@Override
public void run() {
DefaultMutableTreeNode node = getNode(getSingleSelectedIndex());
if (node != null) {
((DefaultTreeModel)myTree.getModel()).nodeChanged(node);
TemplateSettings.getInstance().setLastSelectedTemplate(template.getGroupName(), template.getKey());
}
}
}, TemplateSettings.getInstance().getTemplate(template.getKey(), template.getGroupName()) != null);
for (Component component : myDetailsPanel.getComponents()) {
if (component instanceof LiveTemplateSettingsEditor) {
myDetailsPanel.remove(component);
}
}
myDetailsPanel.add(myCurrentTemplateEditor, TEMPLATE_SETTINGS);
}
示例6: getDifference
import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
Map<TemplateContextType, Boolean> getDifference(@Nullable TemplateContext defaultContext) {
Map<TemplateContextType, Boolean> result = ContainerUtil.newLinkedHashMap();
synchronized (myContextStates) {
//noinspection NestedSynchronizedStatement
synchronized (defaultContext == null ? myContextStates : defaultContext.myContextStates) {
for (TemplateContextType contextType : TemplateManagerImpl.getAllContextTypes()) {
String context = contextType.getContextId();
Boolean myStateInContext = myContextStates.get(context);
if (myStateInContext != null && differsFromDefault(defaultContext, context, myStateInContext)) {
result.put(contextType, myStateInContext);
}
}
}
}
return result;
}
示例7: getDifference
import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
Map<TemplateContextType, Boolean> getDifference(@Nullable TemplateContext defaultContext) {
Map<TemplateContextType, Boolean> result = ContainerUtil.newLinkedHashMap();
synchronized (myContextStates) {
//noinspection NestedSynchronizedStatement
synchronized (defaultContext == null ? myContextStates : defaultContext.myContextStates) {
for (TemplateContextType contextType : TemplateContextType.EP_NAME.getExtensions()) {
String context = contextType.getContextId();
Boolean myStateInContext = myContextStates.get(context);
if (myStateInContext != null && differsFromDefault(defaultContext, context, myStateInContext)) {
result.put(contextType, myStateInContext);
}
}
}
}
return result;
}
示例8: testLiveTemplate
import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
public void testLiveTemplate() throws Throwable {
final Template template = TemplateManager.getInstance(getProject()).createTemplate("foo", "zzz");
template.addTextSegment("FooFactory.createFoo()");
final SmartCompletionContextType completionContextType =
ContainerUtil.findInstance(TemplateContextType.EP_NAME.getExtensions(), SmartCompletionContextType.class);
((TemplateImpl)template).getTemplateContext().setEnabled(completionContextType, true);
CodeInsightTestUtil.addTemplate(template, myTestRootDisposable);
doTest();
}
示例9: getApplicableContexts
import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
private List<TemplateContextType> getApplicableContexts() {
ArrayList<TemplateContextType> result = new ArrayList<TemplateContextType>();
for (TemplateContextType type : TemplateManagerImpl.getAllContextTypes()) {
if (myContext.isExplicitlyEnabled(type)) {
result.add(type);
}
}
return result;
}
示例10: isExpandableFromEditor
import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
private boolean isExpandableFromEditor() {
boolean hasNonExpandable = false;
for (TemplateContextType type : getApplicableContexts()) {
if (type.isExpandableFromEditor()) {
return true;
}
hasNonExpandable = true;
}
return !hasNonExpandable;
}
示例11: isEnabled
import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
public boolean isEnabled(TemplateContextType contextType) {
synchronized (myContextStates) {
Boolean storedValue = getOwnValue(contextType);
if (storedValue == null) {
TemplateContextType baseContextType = contextType.getBaseContextType();
if (baseContextType != null && !(baseContextType instanceof EverywhereContextType)) {
return isEnabled(baseContextType);
}
return false;
}
return storedValue.booleanValue();
}
}
示例12: writeTemplateContext
import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
void writeTemplateContext(Element element, @Nullable TemplateContext defaultContext) throws WriteExternalException {
Map<TemplateContextType, Boolean> diff = getDifference(defaultContext);
for (TemplateContextType type : diff.keySet()) {
Element optionElement = new Element("option");
optionElement.setAttribute("name", type.getContextId());
optionElement.setAttribute("value", diff.get(type).toString());
element.addContent(optionElement);
}
}
示例13: createDocument
import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
private static Document createDocument(CharSequence text, @Nullable TemplateContext context, Project project) {
if (context != null) {
for (TemplateContextType type : TemplateManagerImpl.getAllContextTypes()) {
if (context.isExplicitlyEnabled(type)) {
return type.createDocument(text, project);
}
}
}
return EditorFactory.getInstance().createDocument(text);
}
示例14: setHighlighter
import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
public static void setHighlighter(Editor editor, @Nullable TemplateContext templateContext) {
SyntaxHighlighter highlighter = null;
if (templateContext != null) {
for(TemplateContextType type: TemplateManagerImpl.getAllContextTypes()) {
if (templateContext.isEnabled(type)) {
highlighter = type.createHighlighter();
if (highlighter != null) break;
}
}
}
setHighlighter((EditorEx)editor, highlighter);
}
示例15: EditVariableDialog
import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
public EditVariableDialog(Editor editor, Component parent, ArrayList<Variable> variables, List<TemplateContextType> contextTypes) {
super(parent, true);
myContextTypes = contextTypes;
setButtonsMargin(null);
myVariables = variables;
myEditor = editor;
init();
setTitle(CodeInsightBundle.message("templates.dialog.edit.variables.title"));
setOKButtonText(CommonBundle.getOkButtonText());
}