本文将分享为什么我们需要两次在tomcatlogging.properties中编写处理程序?的详细内容,并且还将对为什么要用两次getchar进行详尽解释,此外,我们还将为大家带来关于CODING2
本文将分享为什么我们需要两次在tomcat logging.properties中编写处理程序?的详细内容,并且还将对为什么要用两次getchar进行详尽解释,此外,我们还将为大家带来关于CODING 2.0:为什么我们需要 DevOps、com.intellij.lang.properties.parsing.PropertiesTokenTypes的实例源码、com.intellij.lang.properties.PropertiesUtil的实例源码、com.intellij.uiDesigner.propertyInspector.properties.BindingProperty的实例源码的相关知识,希望对你有所帮助。
本文目录一览:- 为什么我们需要两次在tomcat logging.properties中编写处理程序?(为什么要用两次getchar)
- CODING 2.0:为什么我们需要 DevOps
- com.intellij.lang.properties.parsing.PropertiesTokenTypes的实例源码
- com.intellij.lang.properties.PropertiesUtil的实例源码
- com.intellij.uiDesigner.propertyInspector.properties.BindingProperty的实例源码
为什么我们需要两次在tomcat logging.properties中编写处理程序?(为什么要用两次getchar)
从文档:
handlers = 1catalina.org.apache.juli.FileHandler, \ 2localhost.org.apache.juli.FileHandler, \ 3manager.org.apache.juli.FileHandler, \ java.util.logging.ConsoleHandler.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
我没有找到任何解释为什么为什么需要写处理程序以及.handlers之后?类似属性文件是否有通用规则?
答案1
小编典典第一行声明可以/将要使用的处理程序集,第二行将处理程序分配给特定的记录器(在这种情况下,根记录器.handlers
没有任何前缀)。
稍后在logging.properties
每个处理程序中进行配置。
CODING 2.0:为什么我们需要 DevOps
CODING 在前两天的 Kubecon 2019 大会上发布了 CODING 2.0。这背后是 CODING 对研发管理和研发团队组建的思考。从 CODING 成立以来,我们一直在探索“让开发更简单”的方式。把“让开发更简单”这个大愿景进行拆分,具体到可量化的产品目标上去,实际上是希望通过工具的形式,可以减轻开发过程中的重复劳动,提高软件交付的速度与质量。
云端开发的初心
最开始做 CODING 的时候,脑海中的蓝图是开发者在这里讨论需求、布置任务、写代码,改代码,演示代码,完成相关任务,整套的开发操作都在这里。
所以当时的产品结构是:轻量级的任务管理 - 讨论 - 代码版本管理 - 演示平台 在这套产品体系下,产品经理会把任务指派给设计师,设计师完成设计后,产品经理验收后再把任务指派给研发人员,研发人员推送代码后,可以在演示平台做演示给产品经理验收。这是一套非常适合小团队的工作模型,流程简单,反应快速,CODING 自己团队也在使用,并且支撑了 CODING 产品前期的快速起步,快速上线,快速响应反馈的开发节奏。
企业在成长过程中碰到的实际问题
很快,随着 CODING 业务的发展,CODING 的产品线越来越多,团队也越来越大,当团队到达 100 人的时候(其中 60% 都是研发),我们发现团队开始"管不动"了,最终的上线质量非常依赖部门 Leader 的管理能力和开发者的自我修养。为了保证产品达到预期,我们制定了大量流程和规范,但这让我们的进度越变越慢了。我们一度非常苦恼,创业公司的优势在于极高的效率与极快的产品迭代,但如果我们在发展的过程中丢失了这样的优势,将会很轻易的被别人超过。
所幸我们并不是第一个碰到这个问题的人。《人月神话》中有个很著名的观点:
Adding manpower to a late software project makes it later. -- Fred Brooks, (1975)
“如果希望用增加人力的方式解决软件的进度问题,只会让进度变得更慢。”因为:
沟通成本= n(n-1)/2 n=团队人数
举例而言 10 个人的团队将有 45 个沟通管道,当人数到达 50 人时,这个数字将上升为 1225 个。随着人数的增多,团队内的沟通成本将指数级上升。了解到问题出现的原因,也就知道了解决方案:“我们需要更多更小的团队”——通过将团队分成若干个内部闭环的小团队来降低沟通成本。于是我们有了一个稍微敏捷一点的组织架构:
这个工作方式敏捷的很不彻底,问题在于运维。考虑到线上稳定性及系统的耦合程度,无法将运维拆到各个团队中去,各个产品线虽然有独立的产品经理、设计师和开发者,但需要运维协助上线测试环境,再由测试进行 testing 和 staging 两个环境进行测试验收。大量的时间被无用的等待浪费掉了。
同时,由于工作目的的不同,开发与运维的矛盾也日益加深,都觉得对方基础的工作没有完成。 团队陷入了困境。
我们需要 DevOps
困境中酝酿着机会,我们在与用户的交流中发现这也是大多数团队的共同苦恼:**团队如何组织才能最大化的进行软件产出?**各个角色之间天然的目标不同,使得”又快又好的上线“变得困难重重。
DevOps 的理念就是希望能打破这种屏障,让研发(Development)和运维(Operations)一体化,让团队从业务需求出发,向着同一个目标前进。DevOps 不只是通过工具辅助开发完成运维的部分工作,更是一种软件研发管理的思想、方法论,所追求的是一种没有隔阂的理想的研发协作状态。
实践 DevOps 的首要任务是需要对 DevOps 的目标和精神达成共识,并以此指导工作。据此,我们制定了从新的产品线开始逐步拆分微服务、优化白名单验收机制等改进措施,并制定了明确的时间表。长期来看,希望在更好的保证软件质量的同时,开发更少的依赖运维工作。
之后,团队开始尝试放大工具带来的效能提升。虽然之前也使用了不少工具,比如用 Jenkins 在本地构建持续集成,自建 Docker Registry 做构建物管理,使用 Excel 进行测试管理等。但相对零散,培训成本高,同时需要有人力进行选型搭建和维护,哪怕只放半个开发半个运维,一年也是小几十万的投入。
我们迫切的需要一套工具,上手即用,辅助我们提升研发团队的产出效能,而不是花费人力时间在进行基础设施的搭建上,但市面上完全没有这样的产品,我们的用户也存在类似的苦恼,只能用好几种开源产品进行搭建。
那 CODING 为什么不做一套这样的系统,让有同样困难的 DevOps 转型企业可以快速完成工具建设?“让开发更简单”作为 CODING 一直以来的使命和愿景,督促 CODING 团队为开发者提供更优质的工具与服务。加之 CODING 的核心业务——代码托管是 DevOps 工具的基础与支点,故从 2018 年年初起,CODING 就将产品目标调整至为企业提供一整套的研发管理工具。在一年多的努力下,目前 CODING 已经全面开放持续集成功能及制品库的 SaaS 版本的服务,支持所有主流语言以及多种目标环境。
DevOps 开发工具链:代码即应用
我们认为,在不远的将来,随着工具的成熟,我们将进入**“代码即应用”(Code as a Product)**的时代,开发者无需进行繁杂的其他工作,仅需完成代码编写,应用就自动运行,企业因此降低了运维成本,提升了软件研发部门的效率。
"代码即应用”对工具的要求分三个阶段:
- 持续集成阶段:通过持续集成工具,运行设置好的执行命令,避免重复劳动。
- 自动化部署阶段:构建的创建过程本身变得简单,无需学习额外的运维开发知识即可创建应用的发布方式。
- Serverless 阶段:真正做到发布无感知,代码写下即发布。
CODING 2.0 上线了持续集成及制品库的功能,标志着 CODING 正式进入持续集成阶段。用户仅需推送代码或合并请求,即可出发持续集成进行构建、单元测试、安全扫描等工作,并生成制品存储在制品库。提升软件交付的质量与速度,同时减少因为构建过程中引入“人”而带来的不确定性。
除工具外,CODING 还为企业提供研发流程实施的指导培训、敏捷训练等额外服务。目前已有几十家企业将 CODING 的 DevOps 工具应用到内部生产中,大大提升了团队 DevOps 转型的效率。
还有点想说的
中国软件行业发展时间短,发展速度快,人才储备时间短,地位也比较尴尬,哪怕是软件服务起家的互联网公司,随着公司的壮大,业务部门的地位也逐渐高于软件研发部门。除了在少量领域,中国企业在这一过程中,研发部门的内驱力往往被消磨殆尽。加之软件行业人力成本不断增加,作为支持和成本部门,管理者也容易将软件研发部门视为成本部门,思路往往是“能否降低成本”。
但如今,瞬息万变的市场环境对软件研发部门提出了很高的挑战,这是困难但也是机会。一支高效的研发团队,不光可以减少系统间的摩擦和浪费,让研发部门快速响应市场需求,还可以持续交付高标准的产品,让产品验证进入正循环,引领整个团队的价值实现。
但组建一支这样的团队,需要的远不止是工具,更重要的是团队领导者的经验,知识,和变化的决心。许多有先锋精神的团队走在改革的前面,CODING 在协助他们转型的过程中,也看到了他们因为改革所碰到的困难、权衡和进步之后团队爆发出的生产力。
我们希望可以看到更多的中国软件企业了解 DevOps 的精神,并应用到自己的团队管理中去,向中国和世界交付一流的软件产品。这个过程很难,但真的很值得。
点击使用 CODING 2.0 体验 DevOps 全工具链敏捷研发
com.intellij.lang.properties.parsing.PropertiesTokenTypes的实例源码
@Override @Nullable public LeafElement createLeaf(@NotNull final IElementType type,@NotNull CharSequence text) { if (type == PropertiesTokenTypes.KEY_CHaraCTERS) { return new PropertyKeyImpl(type,text); } if (type == PropertiesTokenTypes.VALUE_CHaraCTERS) { return new PropertyValueImpl(type,text); } if (type == PropertiesTokenTypes.END_OF_LINE_COMMENT) { return new PsiCommentImpl(type,text); } return new LeafPsiElement(type,text); }
@Nullable public Character getkeyvalueDelimiter() { final PsiElement delimiter = findChildByType(PropertiesTokenTypes.KEY_VALUE_SEParaTOR); if (delimiter == null) { return null; } String separatorText = delimiter.getText(); if (separatorText.isEmpty()) { return null; } separatorText = separatorText.trim(); if (separatorText.isEmpty()) { separatorText = " "; } LOG.assertTrue(separatorText.length() == 1,"\"" + separatorText + "\""); return separatorText.charat(0); }
public void advance() { final IElementType tokenType = getDelegate().getTokenType(); if (tokenType == PropertiesTokenTypes.KEY_CHaraCTERS) { scanWordsInToken(UsageSearchContext.IN_CODE | UsageSearchContext.IN_FOREIGN_LANGUAGES | UsageSearchContext.IN_PLAIN_TEXT,false,false); } else if (PropertiesTokenTypes.COMMENTS.contains(tokenType)) { scanWordsInToken(UsageSearchContext.IN_COMMENTS | UsageSearchContext.IN_PLAIN_TEXT,false); advancetodoItemCountsInToken(); } else { scanWordsInToken(UsageSearchContext.IN_CODE | UsageSearchContext.IN_FOREIGN_LANGUAGES | UsageSearchContext.IN_PLAIN_TEXT,false); } getDelegate().advance(); }
public void advance() { final IElementType tokenType = getDelegate().getTokenType(); if (tokenType == PropertiesTokenTypes.KEY_CHaraCTERS) { scanWordsInToken(UsageSearchContext.IN_CODE | UsageSearchContext.IN_FOREIGN_LANGUAGES | UsageSearchContext.IN_PLAIN_TEXT,false); } getDelegate().advance(); }
private static void handleEnterInPropertiesFile(final Editor editor,final Document document,final PsiElement psiAtOffset,int caretoffset) { String text = document.getText(); String line = text.substring(0,caretoffset); int i = line.lastIndexOf('\n'); if (i > 0) { line = line.substring(i); } final String toInsert; if (PropertiesUtil.isUnescapedBackSlashAtTheEnd(line)) { toInsert = "\n "; } else { final IElementType elementType = psiAtOffset == null ? null : psiAtOffset.getNode().getElementType(); if (elementType == PropertiesTokenTypes.VALUE_CHaraCTERS) { toInsert = "\\\n "; } else if (elementType == PropertiesTokenTypes.END_OF_LINE_COMMENT && "#!".indexOf(document.getText().charat(caretoffset)) == -1) { toInsert = "\n#"; } else { toInsert = "\n"; } } document.insertString(caretoffset,toInsert); caretoffset+=toInsert.length(); editor.getCaretModel().movetoOffset(caretoffset); editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); editor.getSelectionModel().removeSelection(); }
public void replacekeyvalueDelimiterWithDefault() { PropertyImpl property = (PropertyImpl)PropertiesElementFactory.createProperty(getProject(),"yyy","xxx"); final ASTNode oldDelimiter = getNode().findChildByType(PropertiesTokenTypes.KEY_VALUE_SEParaTOR); LOG.assertTrue(oldDelimiter != null); final ASTNode newDelimiter = property.getNode().findChildByType(PropertiesTokenTypes.KEY_VALUE_SEParaTOR); LOG.assertTrue(newDelimiter != null); getNode().replaceChild(oldDelimiter,newDelimiter); }
public PropertiesHighlightingLexer() { super(new PropertiesLexer()); registerSelfStoppingLayer(new StringLiteralLexer(StringLiteralLexer.NO_QUOTE_CHAR,PropertiesTokenTypes.VALUE_CHaraCTERS,true,"#!=:"),new IElementType[]{PropertiesTokenTypes.VALUE_CHaraCTERS},IElementType.EMPTY_ARRAY); registerSelfStoppingLayer(new StringLiteralLexer(StringLiteralLexer.NO_QUOTE_CHAR,PropertiesTokenTypes.KEY_CHaraCTERS,"#!=: "),new IElementType[]{PropertiesTokenTypes.KEY_CHaraCTERS},IElementType.EMPTY_ARRAY); }
@Override public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) { registrar.registerReferenceProvider(PlatformPatterns.psiElement(PropertiesTokenTypes.VALUE_CHaraCTERS),new PsiReferenceProvider() { @NotNull @Override public PsiReference[] getReferencesByElement(@NotNull PsiElement element,@NotNull ProcessingContext context) { if (!DGMUtil.isInDGMFile(element)) return PsiReference.EMPTY_ARRAY; IProperty parent = (IProperty)element.getParent(); if (!"extensionClasses".equals(parent.getName())) { return PsiReference.EMPTY_ARRAY; } ArrayList<PsiReference> result = new ArrayList<PsiReference>(); String text = element.getText(); int i = 0; while ((i = skipwhiteSpace(i,text)) < text.length()) { int end = findWhiteSpaceOrComma(i,text); if (end <= text.length()) { JavaClassReferenceSet set = new JavaClassReferenceSet(text.substring(i,end),element,i,myProvider); ContainerUtil.addAll(result,set.getAllReferences()); } i = end; i = skipwhiteSpace(i,text); if (i == text.length()) break; if (text.charat(i) == ',') i++; i = skipwhiteSpace(i,text); } return result.toArray(new PsiReference[result.size()]); } }); }
@Override public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) { CndReferenceProvider cndReferenceProvider = new CndReferenceProvider(); registrar.registerReferenceProvider(PlatformPatterns.psiElement(PsiLiteralExpression.class),cndReferenceProvider); //Java registrar.registerReferenceProvider(PlatformPatterns.psiElement(CndTypes.SUPER_TYPE),cndReferenceProvider); //Cnd super types registrar.registerReferenceProvider(PlatformPatterns.psiElement(CndTypes.EXTENSION),cndReferenceProvider); //Cnd extends types registrar.registerReferenceProvider(PlatformPatterns.psiElement(CndTypes.SUB_NODE_TYPE),cndReferenceProvider); //Cnd subnode types registrar.registerReferenceProvider(PlatformPatterns.psiElement(CndTypes.SUB_NODE_DEFAULT_TYPE),cndReferenceProvider); //Cnd subnode default type registrar.registerReferenceProvider(PlatformPatterns.psiElement(XmlElementType.XML_ATTRIBUTE_VALUE),cndReferenceProvider); //XML registrar.registerReferenceProvider(PlatformPatterns.psiElement(PropertiesTokenTypes.KEY_CHaraCTERS),cndReferenceProvider); //Properties }
private static void handleEnterInPropertiesFile(final Editor editor,toInsert); caretoffset+=toInsert.length(); editor.getCaretModel().movetoOffset(caretoffset); editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); editor.getSelectionModel().removeSelection(); }
public PropertiesHighlightingLexer() { super(new PropertiesLexer()); registerSelfStoppingLayer(new StringLiteralLexer(StringLiteralLexer.NO_QUOTE_CHAR,IElementType.EMPTY_ARRAY); }
@Nullable public LeafElement createLeaf(final IElementType type,CharSequence text) { if (type == PropertiesTokenTypes.VALUE_CHaraCTERS) { return new PropertyValueImpl(type,text); }
@Override public void registerReferenceProviders(PsiReferenceRegistrar registrar) { registrar.registerReferenceProvider(PlatformPatterns.psiElement(PropertiesTokenTypes.VALUE_CHaraCTERS),text); } return result.toArray(new PsiReference[result.size()]); } }); }
@Nullable public ASTNode getKeyNode() { return getNode().findChildByType(PropertiesTokenTypes.KEY_CHaraCTERS); }
@Nullable public ASTNode getValueNode() { return getNode().findChildByType(PropertiesTokenTypes.VALUE_CHaraCTERS); }
public PropertiesValueHighlightingLexer() { super(new DummyLexer(PropertiesTokenTypes.VALUE_CHaraCTERS)); registerSelfStoppingLayer(new StringLiteralLexer(StringLiteralLexer.NO_QUOTE_CHAR,IElementType.EMPTY_ARRAY); }
@Nullable public ASTNode getKeyNode() { return getNode().findChildByType(PropertiesTokenTypes.KEY_CHaraCTERS); }
@Nullable public ASTNode getValueNode() { return getNode().findChildByType(PropertiesTokenTypes.VALUE_CHaraCTERS); }
public PropertiesValueHighlightingLexer() { super(new DummyLexer(PropertiesTokenTypes.VALUE_CHaraCTERS)); registerSelfStoppingLayer(new StringLiteralLexer(StringLiteralLexer.NO_QUOTE_CHAR,IElementType.EMPTY_ARRAY); }
com.intellij.lang.properties.PropertiesUtil的实例源码
public List<PropertiesFile> getPropertiesFilesWithoutTranslation(final ResourceBundle resourceBundle,final Set<String> keys) { final PropertiesFile defaultPropertiesFile = resourceBundle.getDefaultPropertiesFile(); return ContainerUtil.filter(resourceBundle.getPropertiesFiles(),new Condition<PropertiesFile>() { @Override public boolean value(PropertiesFile propertiesFile) { if (defaultPropertiesFile.equals(propertiesFile)) { return false; } for (String key : keys) { if (propertiesFile.findPropertyByKey(key) == null && !myState.getIgnoredSuffixes().contains(PropertiesUtil.getSuffix(propertiesFile))) { return true; } } return false; } }); }
public PsiElement resolve() { final Project project = myFile.getProject(); final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); final VirtualFile formVirtualFile = myFile.getVirtualFile(); if (formVirtualFile == null) { return null; } final Module module = fileIndex.getModuleForFile(formVirtualFile); if (module == null) { return null; } final PropertiesFile propertiesFile = PropertiesUtil.getPropertiesFile(myBundleName,module,null); if (propertiesFile == null) { return null; } IProperty property = propertiesFile.findPropertyByKey(getRangeText()); return property == null ? null : property.getPsiElement(); }
public IProperty resolvetoProperty(@NotNull StringDescriptor descriptor,@Nullable Locale locale) { String propFileName = descriptor.getDottedBundleName(); Pair<Locale,String> cacheKey = new Pair<Locale,String>(locale,propFileName); SoftReference<PropertiesFile> propertiesFileRef; synchronized (myPropertiesFileCache) { propertiesFileRef = myPropertiesFileCache.get(cacheKey); } PropertiesFile propertiesFile = (propertiesFileRef == null) ? null : propertiesFileRef.get(); if (propertiesFile == null || !propertiesFile.getContainingFile().isValid()) { propertiesFile = PropertiesUtil.getPropertiesFile(propFileName,myModule,locale); synchronized (myPropertiesFileCache) { myPropertiesFileCache.put(cacheKey,new SoftReference<PropertiesFile>(propertiesFile)); } } if (propertiesFile != null) { final IProperty propertyByKey = propertiesFile.findPropertyByKey(descriptor.getKey()); if (propertyByKey != null) { return propertyByKey; } } return null; }
public ItemPresentation getPresentation() { return new ColoredItemPresentation() { public String getPresentableText() { return myPresentableName == null ? myPropertyName : myPresentableName; } public String getLocationString() { return null; } public Icon getIcon(boolean open) { return PlatformIcons.PROPERTY_ICON; } @Override public TextAttributesKey getTextAttributesKey() { boolean isComplete = PropertiesUtil.isPropertyComplete(myProject,myResourceBundle,myPropertyName); if (isComplete) { return Properties@R_301_2701@.PROPERTY_KEY; } return INCOMPLETE_PROPERTY_KEY; } }; }
@NotNull public FileEditor createEditor(@NotNull Project project,@NotNull final VirtualFile file){ ResourceBundle resourceBundle; if (file instanceof ResourceBundleAsVirtualFile) { resourceBundle = ((ResourceBundleAsVirtualFile)file).getResourceBundle(); } else { PsiFile psiFile = PsiManager.getInstance(project).findFile(file); if (psiFile == null) { throw new IllegalArgumentException("psifile cannot be null"); } resourceBundle = PropertiesUtil.getPropertiesFile(psiFile).getResourceBundle(); } return new ResourceBundleEditor(project,resourceBundle); }
private void updatePropertyValueFromDocument(final String propertyName,final PropertiesFile propertiesFile,final String text) { if (PropertiesUtil.isUnescapedBackSlashAtTheEnd(text)) { myBackSlashpressed.add(propertiesFile); } else { myBackSlashpressed.remove(propertiesFile); } IProperty property = propertiesFile.findPropertyByKey(propertyName); try { if (property == null) { propertiesFile.addProperty(propertyName,text); } else { property.setValue(text); } } catch (IncorrectOperationException e) { LOG.error(e); } }
public static Set<String> getConfiguredBindableTypes(Project project) { final Set<String> bindableTypes = new HashSet<String>(); for (PsiFile file : Util.getAllErraiAppProperties(project)) { for (IProperty property : PropertiesUtil.findAllProperties(project,PropertiesUtil.getResourceBundle(file),"errai.ui.bindableTypes")) { final String value = property.getValue(); if (value != null) { for (String s : value.split("\\s+")) { bindableTypes.add(s.trim()); } } } } return bindableTypes; }
public static Set<String> getConfiguredPortableTypes(Project project) { final Set<String> bindableTypes = new HashSet<String>(); for (PsiFile file : Util.getAllErraiAppProperties(project)) { for (IProperty property : PropertiesUtil.findAllProperties(project,"errai.marshalling.serializableTypes")) { final String value = property.getValue(); if (value != null) { for (String s : value.split("\\s+")) { bindableTypes.add(s.trim()); } } } } return bindableTypes; }
public PsiElement resolve() { final Project project = myFile.getProject(); final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); final VirtualFile formVirtualFile = myFile.getVirtualFile(); if (formVirtualFile == null) { return null; } final Module module = fileIndex.getModuleForFile(formVirtualFile); if (module == null) { return null; } final PropertiesFile propertiesFile = PropertiesUtil.getPropertiesFile(myBundleName,null); if (propertiesFile == null) { return null; } IProperty property = propertiesFile.findPropertyByKey(getRangeText()); return property == null ? null : property.getPsiElement(); }
public IProperty resolvetoProperty(@NotNull StringDescriptor descriptor,new SoftReference<PropertiesFile>(propertiesFile)); } } if (propertiesFile != null) { final IProperty propertyByKey = propertiesFile.findPropertyByKey(descriptor.getKey()); if (propertyByKey != null) { return propertyByKey; } } return null; }
@NotNull public ResolveResult[] multiResolve(boolean incompleteCode){ final String text = element.getText(); final String strippedText = text.substring(1,text.length() - 1); // Todo[yole] figure out what was meant here. this never works and never Could have worked. final List<IProperty> properties = PropertiesUtil.findAllProperties(element.getProject(),null,strippedText); final Set<IProperty> propertySet = new HashSet<IProperty>(properties); final ResolveResult[] out = new ResolveResult[propertySet.size()]; int i = 0; for(IProperty property : propertySet){ out[i] = new CandidateInfo(property.getPsiElement(),null); i++; } return out; }
private static void handleEnterInPropertiesFile(final Editor editor,final Document document,final PsiElement psiAtOffset,int caretoffset) { String text = document.getText(); String line = text.substring(0,caretoffset); int i = line.lastIndexOf('\n'); if (i > 0) { line = line.substring(i); } final String toInsert; if (PropertiesUtil.isUnescapedBackSlashAtTheEnd(line)) { toInsert = "\n "; } else { final IElementType elementType = psiAtOffset == null ? null : psiAtOffset.getNode().getElementType(); if (elementType == PropertiesTokenTypes.VALUE_CHaraCTERS) { toInsert = "\\\n "; } else if (elementType == PropertiesTokenTypes.END_OF_LINE_COMMENT && "#!".indexOf(document.getText().charat(caretoffset)) == -1) { toInsert = "\n#"; } else { toInsert = "\n"; } } document.insertString(caretoffset,toInsert); caretoffset+=toInsert.length(); editor.getCaretModel().movetoOffset(caretoffset); editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); editor.getSelectionModel().removeSelection(); }
@Nullable private BaseNameError checkBaseName(final String baseNameCandidate) { for (PropertiesFile propertiesFile : myPropertiesFiles) { final String name = propertiesFile.getVirtualFile().getName(); if (!name.startsWith(baseNameCandidate) || !PropertiesUtil.BASE_NAME_BORDER_CHAR.contains(name.charat(baseNameCandidate.length()))) { return new BaseNameError(name); } } return null; }
public void prepareRenaming(final PsiElement element,final String newName,final Map<PsiElement,String> allRenames) { ResourceBundle resourceBundle = PropertiesImplUtil.getProperty(element).getPropertiesFile().getResourceBundle(); final Map<PsiElement,String> allRenamescopy = new LinkedHashMap<PsiElement,String>(allRenames); allRenames.clear(); for (final Map.Entry<PsiElement,String> e : allRenamescopy.entrySet()) { final IProperty property = PropertiesImplUtil.getProperty(e.getKey()); final List<IProperty> properties = PropertiesUtil.findAllProperties(resourceBundle,property.getUnescapedKey()); for (final IProperty toRename : properties) { allRenames.put(toRename.getPsiElement(),e.getValue()); } } }
public boolean isPropertyComplete(final ResourceBundle resourceBundle,final String key) { List<PropertiesFile> propertiesFiles = resourceBundle.getPropertiesFiles(); for (PropertiesFile propertiesFile : propertiesFiles) { if (propertiesFile.findPropertyByKey(key) == null && !myState.getIgnoredSuffixes().contains(PropertiesUtil.getSuffix(propertiesFile))) { return false; } } return true; }
public boolean isReferenceto(final PsiElement element) { if (!(element instanceof IProperty)) { return false; } IProperty property = (IProperty) element; String baseName = PropertiesUtil.getFullName(property.getPropertiesFile()); return baseName != null && myBundleName.equals(baseName.replace('.','/')) && getRangeText().equals(property.getUnescapedKey()); }
public PsiElement resolve() { final Project project = myFile.getProject(); final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); final VirtualFile formVirtualFile = myFile.getVirtualFile(); if (formVirtualFile == null) { return null; } final Module module = fileIndex.getModuleForFile(formVirtualFile); if (module == null) { return null; } PropertiesFile propertiesFile = PropertiesUtil.getPropertiesFile(getRangeText(),null); return propertiesFile == null ? null : propertiesFile.getContainingFile(); }
@Override public boolean isReferenceto(final PsiElement element) { if (!(element instanceof PropertiesFile)) return false; String baseName = PropertiesUtil.getFullName((PropertiesFile) element); if (baseName == null) return false; baseName = baseName.replace('.','/'); final String rangeText = getRangeText(); return rangeText.equals(baseName); }
private static void handleEnterInPropertiesFile(final Editor editor,toInsert); caretoffset+=toInsert.length(); editor.getCaretModel().movetoOffset(caretoffset); editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); editor.getSelectionModel().removeSelection(); }
@Override public void registerReferenceProviders(PsiReferenceRegistrar registrar) { registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withLocalName("key"),new PsiReferenceProvider() { @NotNull @Override public PsiReference[] getReferencesByElement(@NotNull PsiElement element,@NotNull ProcessingContext context) { PropertiesFile propertiesFile = PropertiesUtil.getPropertiesFile(element.getContainingFile()); if (propertiesFile == null) return PsiReference.EMPTY_ARRAY; XmlProperty property = new XmlProperty(PsiTreeUtil.getParentOfType(element,XmlTag.class),(XmlPropertiesFile)propertiesFile); return new PsiReference[] { new PsiReferenceBase.Immediate<PsiElement>(element,PomService.convertToPsi(property))}; } }); }
public void prepareRenaming(final PsiElement element,String> allRenames) { IProperty property = (IProperty) element; ResourceBundle resourceBundle = property.getPropertiesFile().getResourceBundle(); List<IProperty> properties = PropertiesUtil.findAllProperties(element.getProject(),resourceBundle,property.getUnescapedKey()); allRenames.clear(); for (IProperty otherProperty : properties) { allRenames.put(otherProperty.getPsiElement(),newName); } }
public void testXmlProperties() throws Exception { myFixture.configureByFile("foo.xml"); List<PropertiesFile> files = PropertiesReferenceManager.getInstance(getProject()).findPropertiesFiles(myModule,"foo"); assertEquals(1,files.size()); PropertiesFile file = files.get(0); assertEquals(1,file.findPropertiesByKey("foo").size()); List<IProperty> properties = PropertiesUtil.findPropertiesByKey(getProject(),properties.size()); }
public static boolean isPropertyRef(final PsiLiteralExpression expression,final String key,final String resourceBundleName) { if (resourceBundleName == null) { return !PropertiesUtil.findPropertiesByKey(expression.getProject(),key).isEmpty(); } else { final List<PropertiesFile> propertiesFiles = propertiesFilesByBundleName(resourceBundleName,expression); boolean containedInPropertiesFile = false; for (PropertiesFile propertiesFile : propertiesFiles) { containedInPropertiesFile |= propertiesFile.findPropertyByKey(key) != null; } return containedInPropertiesFile; } }
public boolean isReferenceto(final PsiElement element) { if (!(element instanceof IProperty)) { return false; } IProperty property = (IProperty) element; String baseName = PropertiesUtil.getFullName(property.getPropertiesFile()); return baseName != null && myBundleName.equals(baseName.replace('.','/')) && getRangeText().equals(property.getUnescapedKey()); }
public PsiElement resolve() { final Project project = myFile.getProject(); final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); final VirtualFile formVirtualFile = myFile.getVirtualFile(); if (formVirtualFile == null) { return null; } final Module module = fileIndex.getModuleForFile(formVirtualFile); if (module == null) { return null; } PropertiesFile propertiesFile = PropertiesUtil.getPropertiesFile(getRangeText(),null); return propertiesFile == null ? null : propertiesFile.getContainingFile(); }
@Override public boolean isReferenceto(final PsiElement element) { if (!(element instanceof PropertiesFile)) return false; String baseName = PropertiesUtil.getFullName((PropertiesFile) element); if (baseName == null) return false; baseName = baseName.replace('.','/'); final String rangeText = getRangeText(); return rangeText.equals(baseName); }
public Object[] getvariants(){ // Todo[yole] figure out what was meant here. this never works and never Could have worked. final List<IProperty> properties = PropertiesUtil.findAllProperties(element.getProject(),null); final List<Object> out = new ArrayList<Object>(); for(IProperty property : properties){ out.add(property.getName()); } return out.toArray(new Object[out.size()]); }
public static boolean isPropertyRef(final PsiLiteralExpression expression,expression); boolean containedInPropertiesFile = false; for (PropertiesFile propertiesFile : propertiesFiles) { containedInPropertiesFile |= propertiesFile.findPropertyByKey(key) != null; } return containedInPropertiesFile; } }
@Override public void actionPerformed(AnActionEvent e) { final ResourceBundleEditor resourceBundleEditor = (ResourceBundleEditor)PlatformDataKeys.FILE_EDITOR.getData(e.getDataContext()); LOG.assertTrue(resourceBundleEditor != null); final Project project = getEventProject(e); LOG.assertTrue(project != null); final Set<String> properties = new HashSet<String>(); processSelectedIncompleteProperties(new Processor<IProperty>() { @Override public boolean process(IProperty property) { properties.add(property.getKey()); return true; } },resourceBundleEditor,project); final IgnoredPropertiesFilesSuffixesManager suffixesManager = IgnoredPropertiesFilesSuffixesManager.getInstance(project); final List<PropertiesFile> allFilesWithoutTranslation = suffixesManager.getPropertiesFilesWithoutTranslation(resourceBundleEditor.getResourceBundle(),properties); if (allFilesWithoutTranslation.isEmpty()) { return; } Collections.sort(allFilesWithoutTranslation,new Comparator<PropertiesFile>() { @Override public int compare(PropertiesFile p1,PropertiesFile p2) { return p1.getName().compareto(p2.getName()); } }); final List<PropertiesFile> suffixRepresentatives = new IgnoredSuffixesDialog(allFilesWithoutTranslation,project).showAndGetSuffixesRepresentatives(); if (suffixRepresentatives == null) { return; } final List<String> suffixesToIgnore = ContainerUtil.map(suffixRepresentatives,new NotNullFunction<PropertiesFile,String>() { @NotNull @Override public String fun(PropertiesFile propertiesFile) { return PropertiesUtil.getSuffix(propertiesFile); } }); if (!suffixesToIgnore.isEmpty()) { suffixesManager.addSuffixes(suffixesToIgnore); UIUtil.invokelaterIfNeeded(new Runnable() { @Override public void run() { resourceBundleEditor.queueUpdateTree(); } }); } }
@NotNull @Override public Locale getLocale() { return PropertiesUtil.getLocale(this); }
@NotNull @Override public ResourceBundle getResourceBundle() { return PropertiesUtil.getResourceBundle(getContainingFile()); }
@NotNull @Override public Locale getLocale() { return PropertiesUtil.getLocale(getVirtualFile()); }
public boolean contains(@NotNull VirtualFile file) { if (!file.isValid()) return false; PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(file); PropertiesFile propertiesFile = PropertiesUtil.getPropertiesFile(psiFile); return propertiesFile != null && getValue().getPropertiesFiles(myProject).contains(propertiesFile); }
@Override @NotNull public ResourceBundle getResourceBundle() { return PropertiesUtil.getResourceBundle(getContainingFile()); }
@Override @NotNull public Locale getLocale() { return PropertiesUtil.getLocale(getVirtualFile()); }
public boolean accept(@NotNull Project project,@NotNull VirtualFile file){ if (file instanceof ResourceBundleAsVirtualFile) return true; PsiFile psiFile = PsiManager.getInstance(project).findFile(file); PropertiesFile propertiesFile = PropertiesUtil.getPropertiesFile(psiFile); return propertiesFile != null && propertiesFile.getResourceBundle().getPropertiesFiles(project).size() > 1; }
public void testWrongFile() throws Exception { PsiFile psiFile = myFixture.configureByFile("wrong.xml"); PropertiesFile file = PropertiesUtil.getPropertiesFile(psiFile); assertNull(file); }
com.intellij.uiDesigner.propertyInspector.properties.BindingProperty的实例源码
private static void adjustDuplicates(final Map<RadComponent,RadComponent> duplicates) { for(RadComponent c: duplicates.keySet()) { RadComponent copy = duplicates.get(c); if (c.getBinding() != null) { String binding = BindingProperty.getDefaultBinding(copy); new BindingProperty(c.getProject()).setValueEx(copy,binding); copy.setDefaultBinding(true); } for(IProperty prop: copy.getModifiedProperties()) { if (prop instanceof IntroComponentProperty) { final IntroComponentProperty componentProperty = (IntroComponentProperty)prop; String copyValue = componentProperty.getValue(copy); for(RadComponent original: duplicates.keySet()) { if (original.getId().equals(copyValue)) { componentProperty.setValueEx(copy,duplicates.get(original).getId()); } } } } } }
private static void adjustDuplicates(final Map<RadComponent,duplicates.get(original).getId()); } } } } } }
private static void adjustDuplicates(final Map<RadComponent,duplicates.get(original).getId()); } } } } } }
private static boolean canCreateListener(final ArrayList<RadComponent> selection) { if (selection.size() == 0) return false; final RadRootContainer root = (RadRootContainer)FormEditingUtil.getRoot(selection.get(0)); if (root.getClasstoBind() == null) return false; String componentClass = selection.get(0).getComponentClassName(); for(RadComponent c: selection) { if (!c.getComponentClassName().equals(componentClass) || c.getBinding() == null) return false; if (BindingProperty.findBoundField(root,c.getBinding()) == null) return false; } return true; }
private static void updateBoundFieldType(final GuiEditor editor,final RadComponent oldComponent,final ComponentItem targetItem) { PsiField oldBoundField = BindingProperty.findBoundField(editor.getRootContainer(),oldComponent.getBinding()); if (oldBoundField != null) { final PsiElementFactory factory = JavaPsiFacade.getInstance(editor.getProject()).getElementFactory(); try { PsiType componentType = factory.createTypeFromText(targetItem.getClassName().replace('$','.'),null); new ChangeFieldTypeFix(editor,oldBoundField,componentType).run(); } catch (IncorrectOperationException e) { LOG.error(e); } } }
private void saveButtonGroupIsBound() { if (myGroup.isBound() != myBindToFieldCheckBox.isSelected()) { myGroup.setBound(myBindToFieldCheckBox.isSelected()); notifyListeners(new ChangeEvent(myGroup)); if (myGroup.isBound()) { BindingProperty.updateBoundFieldName(myRootContainer,null,myGroup.getName(),ButtonGroup.class.getName()); } else { BindingProperty.checkRemoveUnusedField(myRootContainer,FormEditingUtil.getNextSaveUndoGroupId(myRootContainer.getProject())); } } }
private void saveButtonGroupName() { String oldName = myGroup.getName(); String newName = myNameTextField.getText(); if (!oldName.equals(newName)) { myGroup.setName(newName); notifyListeners(new ChangeEvent(myGroup)); if (myGroup.isBound()) { BindingProperty.updateBoundFieldName(myRootContainer,oldName,newName,ButtonGroup.class.getName()); } } }
private static boolean canCreateListener(final ArrayList<RadComponent> selection) { if (selection.size() == 0) return false; final RadRootContainer root = (RadRootContainer)FormEditingUtil.getRoot(selection.get(0)); if (root.getClasstoBind() == null) return false; String componentClass = selection.get(0).getComponentClassName(); for(RadComponent c: selection) { if (!c.getComponentClassName().equals(componentClass) || c.getBinding() == null) return false; if (BindingProperty.findBoundField(root,c.getBinding()) == null) return false; } return true; }
private static void updateBoundFieldType(final GuiEditor editor,componentType).run(); } catch (IncorrectOperationException e) { LOG.error(e); } } }
private void saveButtonGroupIsBound() { if (myGroup.isBound() != myBindToFieldCheckBox.isSelected()) { myGroup.setBound(myBindToFieldCheckBox.isSelected()); notifyListeners(new ChangeEvent(myGroup)); if (myGroup.isBound()) { BindingProperty.updateBoundFieldName(myRootContainer,FormEditingUtil.getNextSaveUndoGroupId(myRootContainer.getProject())); } } }
private void saveButtonGroupName() { String oldName = myGroup.getName(); String newName = myNameTextField.getText(); if (!oldName.equals(newName)) { myGroup.setName(newName); notifyListeners(new ChangeEvent(myGroup)); if (myGroup.isBound()) { BindingProperty.updateBoundFieldName(myRootContainer,ButtonGroup.class.getName()); } } }
private static boolean canCreateListener(final ArrayList<RadComponent> selection) { if (selection.size() == 0) return false; final RadRootContainer root = (RadRootContainer)FormEditingUtil.getRoot(selection.get(0)); if (root.getClasstoBind() == null) return false; String componentClass = selection.get(0).getComponentClassName(); for(RadComponent c: selection) { if (!c.getComponentClassName().equals(componentClass) || c.getBinding() == null) return false; if (BindingProperty.findBoundField(root,c.getBinding()) == null) return false; } return true; }
private static void updateBoundFieldType(final GuiEditor editor,componentType).run(); } catch (IncorrectOperationException e) { LOG.error(e); } } }
private void saveButtonGroupIsBound() { if (myGroup.isBound() != myBindToFieldCheckBox.isSelected()) { myGroup.setBound(myBindToFieldCheckBox.isSelected()); notifyListeners(new ChangeEvent(myGroup)); if (myGroup.isBound()) { BindingProperty.updateBoundFieldName(myRootContainer,FormEditingUtil.getNextSaveUndoGroupId(myRootContainer.getProject())); } } }
private void saveButtonGroupName() { String oldName = myGroup.getName(); String newName = myNameTextField.getText(); if (!oldName.equals(newName)) { myGroup.setName(newName); notifyListeners(new ChangeEvent(myGroup)); if (myGroup.isBound()) { BindingProperty.updateBoundFieldName(myRootContainer,ButtonGroup.class.getName()); } } }
private static String[] getFieldNames(final RadComponent component,final String currentName) { final ArrayList<String> result = new ArrayList<String>(); if (currentName != null){ result.add(currentName); } final IRootContainer root = FormEditingUtil.getRoot(component); final String className = root.getClasstoBind(); if (className == null) { return ArrayUtil.toStringArray(result); } final PsiClass aClass = FormEditingUtil.findClasstoBind(component.getModule(),className); if (aClass == null) { return ArrayUtil.toStringArray(result); } final PsiField[] fields = aClass.getFields(); for (final PsiField field : fields) { if (field.hasModifierProperty(PsiModifier.STATIC)) { continue; } final String fieldName = field.getName(); if (Comparing.equal(currentName,fieldName)) { continue; } if (!FormEditingUtil.isBindingUnique(component,fieldName,root)) { continue; } final String componentClassName; if (component instanceof RadErrorComponent) { componentClassName = component.getComponentClassName(); } else if (component instanceof RadHSpacer || component instanceof RadVSpacer) { componentClassName = Spacer.class.getName(); } else { componentClassName = component.getComponentClass().getName(); } final PsiType componentType; try { componentType = JavaPsiFacade.getInstance(component.getProject()).getElementFactory().createTypeFromText(componentClassName,null); } catch (IncorrectOperationException e) { continue; } final PsiType fieldType = field.getType(); if (!fieldType.isAssignableFrom(componentType)) { continue; } result.add(fieldName); } String text = ForminspectionUtil.getText(component.getModule(),component); if (text != null) { String binding = BindingProperty.suggestBindingFromText(component,text); if (binding != null && !result.contains(binding)) { result.add(binding); } } final String[] names = ArrayUtil.toStringArray(result); Arrays.sort(names); return names; }
private static boolean morphComponent(final GuiEditor editor,ComponentItem targetItem) { targetItem = InsertComponentProcessor.replaceAnyComponentItem(editor,targetItem,"Morph to Non-Palette Component"); if (targetItem == null) { return false; } final RadComponent newComponent = InsertComponentProcessor.createInsertedComponent(editor,targetItem); if (newComponent == null) return false; newComponent.setBinding(oldComponent.getBinding()); newComponent.setCustomLayoutConstraints(oldComponent.getCustomLayoutConstraints()); newComponent.getConstraints().restore(oldComponent.getConstraints()); updateBoundFieldType(editor,oldComponent,targetItem); final IProperty[] oldProperties = oldComponent.getModifiedProperties(); final Palette palette = Palette.getInstance(editor.getProject()); for(IProperty prop: oldProperties) { IntrospectedProperty newProp = palette.getIntrospectedProperty(newComponent,prop.getName()); if (newProp == null || !prop.getClass().equals(newProp.getClass())) continue; Object oldValue = prop.getPropertyValue(oldComponent); try { //noinspection unchecked newProp.setValue(newComponent,oldValue); } catch (Exception e) { // ignore } } retargetComponentProperties(editor,newComponent); final RadContainer parent = oldComponent.getParent(); int index = parent.indexOfComponent(oldComponent); parent.removeComponent(oldComponent); parent.addComponent(newComponent,index); newComponent.setSelected(true); if (oldComponent.isDefaultBinding()) { final String text = ForminspectionUtil.getText(newComponent.getModule(),newComponent); if (text != null) { String binding = BindingProperty.suggestBindingFromText(newComponent,text); if (binding != null) { new BindingProperty(newComponent.getProject()).setValueEx(newComponent,binding); } } newComponent.setDefaultBinding(true); } return true; }
private static String[] getFieldNames(final RadComponent component,text); if (binding != null && !result.contains(binding)) { result.add(binding); } } final String[] names = ArrayUtil.toStringArray(result); Arrays.sort(names); return names; }
private static boolean morphComponent(final GuiEditor editor,binding); } } newComponent.setDefaultBinding(true); } return true; }
private static boolean morphComponent(final GuiEditor editor,binding); } } newComponent.setDefaultBinding(true); } return true; }
关于为什么我们需要两次在tomcat logging.properties中编写处理程序?和为什么要用两次getchar的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于CODING 2.0:为什么我们需要 DevOps、com.intellij.lang.properties.parsing.PropertiesTokenTypes的实例源码、com.intellij.lang.properties.PropertiesUtil的实例源码、com.intellij.uiDesigner.propertyInspector.properties.BindingProperty的实例源码等相关知识的信息别忘了在本站进行查找喔。
本文标签: