Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
33,600
PsiMethod (PsiField field) { final PsiClass containingClass = field.getContainingClass(); final String propertyName = field.getName(); final boolean isStatic = field.hasModifierProperty(PsiModifier.STATIC); return findPropertySetter(containingClass, propertyName, isStatic, true); }
findSetterForField
33,601
PsiMethod (PsiField field) { final PsiClass containingClass = field.getContainingClass(); final String propertyName = field.getName(); final boolean isStatic = field.hasModifierProperty(PsiModifier.STATIC); return findPropertyGetter(containingClass, propertyName, isStatic, true); }
findGetterForField
33,602
PsiMethod (@Nullable PsiType type, String propertyName, @NotNull GroovyPsiElement context) { final String setterName = getSetterName(propertyName); if (type == null) { final GrExpression fromText = GroovyPsiElementFactory.getInstance(context.getProject()).createExpressionFromText("this", context); return findPropertySe...
findPropertySetter
33,603
PsiMethod (PsiClass aClass, String propertyName, boolean isStatic, boolean checkSuperClasses) { if (aClass == null) return null; PsiMethod[] methods; if (checkSuperClasses) { methods = aClass.getAllMethods(); } else { methods = aClass.getMethods(); } for (PsiMethod method : methods) { if (method.hasModifierProperty(Psi...
findPropertySetter
33,604
PsiMethod (@Nullable PsiClass aClass, String propertyName, @Nullable Boolean isStatic, boolean checkSuperClasses) { if (aClass == null) return null; PsiMethod[] methods; if (checkSuperClasses) { methods = aClass.getAllMethods(); } else { methods = aClass.getMethods(); } for (PsiMethod method : methods) { if (isStatic !...
findPropertyGetter
33,605
boolean (PsiMethod method) { return isSimplePropertyGetter(method) || isSimplePropertySetter(method); }
isSimplePropertyAccessor
33,606
boolean (PsiMethod method) { return isSimplePropertyGetter(method, null); }
isSimplePropertyGetter
33,607
boolean (PsiMethod method, @Nullable String propertyName) { if (method == null || method.isConstructor()) return false; if (!method.getParameterList().isEmpty()) return false; if (!isGetterName(method.getName())) return false; boolean booleanReturnType = isBooleanOrBoxed(method.getReturnType()); if (method.getName().st...
isSimplePropertyGetter
33,608
boolean (PsiMethod method) { return isSimplePropertySetter(method, null); }
isSimplePropertySetter
33,609
boolean (PsiMethod method, @Nullable String propertyName) { if (method == null || method.isConstructor()) return false; if (method.getParameterList().getParametersCount() != 1) return false; if (!isSetterName(method.getName())) return false; if (propertyName==null) return true; final String bySetter = getPropertyNameBy...
isSimplePropertySetter
33,610
boolean (@NotNull PsiMethod method, @NotNull String prefix) { if (method.isConstructor()) return false; if (method.getParameterList().getParametersCount() != 1) return false; return isPropertyName(method.getName(), prefix); }
isSetterLike
33,611
String (PsiMethod getterMethod) { if (getterMethod instanceof GrAccessorMethod) { return ((GrAccessorMethod)getterMethod).getProperty().getName(); } @NonNls String methodName = getterMethod.getName(); final boolean isPropertyBoolean = isBooleanOrBoxed(getterMethod.getReturnType()); return getPropertyNameByGetterName(me...
getPropertyNameByGetter
33,612
String (@NotNull String methodName, boolean canBeBoolean) { if (methodName.startsWith(GET_PREFIX) && methodName.length() > 3) { return decapitalize(methodName.substring(3)); } if (canBeBoolean && methodName.startsWith(IS_PREFIX) && methodName.length() > 2) { return decapitalize(methodName.substring(2)); } return null; ...
getPropertyNameByGetterName
33,613
String (PsiMethod setterMethod) { if (setterMethod instanceof GrAccessorMethod) { return ((GrAccessorMethod)setterMethod).getProperty().getName(); } @NonNls String methodName = setterMethod.getName(); return getPropertyNameBySetterName(methodName); }
getPropertyNameBySetter
33,614
String (@NotNull String methodName) { if (methodName.startsWith(SET_PREFIX) && methodName.length() > 3) { return StringUtil.decapitalize(methodName.substring(3)); } else { return null; } }
getPropertyNameBySetterName
33,615
String (String accessorName) { if (isGetterName(accessorName)) { return getPropertyNameByGetterName(accessorName, true); } else if (isSetterName(accessorName)) { return getPropertyNameBySetterName(accessorName); } return null; }
getPropertyNameByAccessorName
33,616
String (PsiMethod accessor) { if (isSimplePropertyGetter(accessor)) return getPropertyNameByGetter(accessor); if (isSimplePropertySetter(accessor)) return getPropertyNameBySetter(accessor); return null; }
getPropertyName
33,617
boolean (@NotNull String name) { int prefixLength; if (name.startsWith(GET_PREFIX)) { prefixLength = 3; } else if (name.startsWith(IS_PREFIX)) { prefixLength = 2; } else { return false; } if (name.length() == prefixLength) return false; if (isUpperCase(name.charAt(prefixLength))) return true; return name.length() > pre...
isGetterName
33,618
String (@NotNull String name) { return getAccessorName(GET_PREFIX, name); }
getGetterNameNonBoolean
33,619
String (@NotNull String name) { return name; }
getGetterNameForRecordField
33,620
String (@NotNull String name) { return getAccessorName(IS_PREFIX, name); }
getGetterNameBoolean
33,621
String (@NotNull String name) { return getAccessorName("set", name); }
getSetterName
33,622
String (String prefix, String name) { if (name.isEmpty()) return prefix; StringBuilder sb = new StringBuilder(); sb.append(prefix); if (name.length() > 1 && Character.isUpperCase(name.charAt(1))) { sb.append(name); } else { sb.append(Character.toUpperCase(name.charAt(0))); sb.append(name, 1, name.length()); } return sb...
getAccessorName
33,623
String[] (@NotNull String name) { return new String[]{getGetterNameBoolean(name), getGetterNameNonBoolean(name)}; }
suggestGettersName
33,624
boolean (@Nullable String name) { if (name == null || name.isEmpty()) return false; if (Character.isUpperCase(name.charAt(0)) && (name.length() == 1 || !Character.isUpperCase(name.charAt(1)))) return false; return true; }
isPropertyName
33,625
String[] (@NotNull String name) { return new String[]{getSetterName(name)}; }
suggestSettersName
33,626
boolean (@Nullable String name) { return isPropertyName(name, SET_PREFIX); }
isSetterName
33,627
boolean (@Nullable String name, @NotNull String prefix) { return name != null && name.startsWith(prefix) && name.length() > prefix.length() && isUpperCase(name.charAt(prefix.length())); }
isPropertyName
33,628
boolean (@Nullable PsiClass aClass, @Nullable String propertyName, boolean isStatic) { if (aClass == null || propertyName == null) return false; final PsiField field = aClass.findFieldByName(propertyName, true); if (field instanceof GrField && ((GrField)field).isProperty() && field.hasModifierProperty(PsiModifier.STATI...
isProperty
33,629
boolean (GrField field) { final PsiClass clazz = field.getContainingClass(); return isProperty(clazz, field.getName(), field.hasModifierProperty(PsiModifier.STATIC)); }
isProperty
33,630
boolean (char c) { return Character.toUpperCase(c) == c; }
isUpperCase
33,631
String (String s) { if (s.isEmpty()) return s; if (s.length() == 1) return StringUtil.toUpperCase(s); if (Character.isUpperCase(s.charAt(1))) return s; final char[] chars = s.toCharArray(); chars[0] = Character.toUpperCase(chars[0]); return new String(chars); }
capitalize
33,632
String (String s) { return Introspector.decapitalize(s); }
decapitalize
33,633
PsiField (PsiMethod accessor, boolean checkSuperClasses) { final PsiClass psiClass = accessor.getContainingClass(); if (psiClass == null) return null; PsiField field = null; if (!checkSuperClasses) { field = psiClass.findFieldByName(getPropertyNameByAccessorName(accessor.getName()), true); } else { final String name = ...
findFieldForAccessor
33,634
String (PsiMethod getter) { final String name = getter.getName(); if (name.startsWith(GET_PREFIX)) return GET_PREFIX; if (name.startsWith(IS_PREFIX)) return IS_PREFIX; return null; }
getGetterPrefix
33,635
String (PsiMethod setter) { if (setter.getName().startsWith(SET_PREFIX)) return SET_PREFIX; return null; }
getSetterPrefix
33,636
String (PsiMethod method) { final String prefix = getGetterPrefix(method); if (prefix != null) return prefix; return getSetterPrefix(method); }
getAccessorPrefix
33,637
boolean (PsiMethod accessor, PsiField field) { final String accessorName = accessor.getName(); final String fieldName = field.getName(); if (!ArrayUtil.contains(accessorName, suggestGettersName(fieldName)) && !ArrayUtil.contains(accessorName, suggestSettersName(fieldName))) { return false; } final PsiClass accessorClas...
isAccessorFor
33,638
List<GrAccessorMethod> (GrField field) { List<GrAccessorMethod> accessors = new ArrayList<>(); final GrAccessorMethod[] getters = field.getGetters(); Collections.addAll(accessors, getters); final GrAccessorMethod setter = field.getSetter(); if (setter != null) accessors.add(setter); return accessors; }
getFieldAccessors
33,639
GrMethod (PsiField field) { GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(field.getProject()); String name = field.getName(); String getName = getGetterNameNonBoolean(field.getName()); try { PsiType type = field instanceof GrField ? ((GrField)field).getDeclaredType() : field.getType(); GrMethod ...
generateGetterPrototype
33,640
GrMethod (PsiField field) { Project project = field.getProject(); JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(project); GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(project); String name = field.getName(); boolean isStatic = field.hasModifierProperty(PsiModifier.STA...
generateSetterPrototype
33,641
boolean (PsiType type) { return PsiTypes.booleanType().equals(type) || PsiTypes.booleanType().equals(PsiPrimitiveType.getUnboxedType(type)); }
isBooleanOrBoxed
33,642
PsiClass (@Nullable PsiElement element) { if (element == null) return null; if (DumbService.isDumb(element.getProject())) return null; final PsiFile file = element.getContainingFile(); if (!(file instanceof GroovyFile)) return null; for (PsiClass clazz = PsiTreeUtil.getParentOfType(element, PsiClass.class); clazz != nu...
getRunningClass
33,643
boolean (@Nullable final PsiClass psiClass) { if (psiClass == null) return false; final PsiClass runnable = JavaPsiFacade.getInstance(psiClass.getProject()).findClass(CommonClassNames.JAVA_LANG_RUNNABLE, psiClass.getResolveScope()); if (runnable == null) return false; return psiClass instanceof GrTypeDefinition && !(ps...
isRunnable
33,644
boolean (final PsiClass psiClass) { return psiClass instanceof GroovyScriptClass || isRunnable(psiClass) || psiClass instanceof GrTypeDefinition && PsiMethodUtil.hasMainMethod(psiClass); }
canBeRunByGroovy
33,645
boolean (@NotNull PsiMethod method, PsiElement place) { if (method instanceof GrMethod && method.isConstructor()) { PsiClass aClass = method.getContainingClass(); if (aClass != null && !aClass.hasModifierProperty(PsiModifier.STATIC)) { PsiClass containingClass = aClass.getContainingClass(); if (containingClass != null ...
isInnerClassConstructorUsedOutsideOfItParent
33,646
PsiClass (@NotNull PsiElement place, @NotNull PsiClass aClass) { if (!aClass.hasModifierProperty(PsiModifier.STATIC)) { PsiClass containingClass = aClass.getContainingClass(); if (containingClass != null) { if (PsiUtil.hasEnclosingInstanceInScope(containingClass, place, true)) { return containingClass; } } } return nul...
enclosingClass
33,647
PsiClass (GrTypeDefinition grType, String name, boolean checkBases) { if (!checkBases) { for (PsiClass inner : grType.getInnerClasses()) { if (name.equals(inner.getName())) return inner; } return null; } else { Map<String, CandidateInfo> innerClasses = CollectClassMembersUtil.getAllInnerClasses(grType, true); final Can...
findInnerClassByName
33,648
PsiClass (@NotNull GrTypeDefinition grType) { return getSuperClass(grType, grType.getExtendsListTypes()); }
getSuperClass
33,649
PsiClass (@NotNull GrTypeDefinition grType, PsiClassType @NotNull [] extendsListTypes) { if (extendsListTypes.length == 0) return getBaseClass(grType); final PsiClass superClass = extendsListTypes[0].resolve(); return superClass != null ? superClass : getBaseClass(grType); }
getSuperClass
33,650
PsiClass (GrTypeDefinition grType) { if (grType.isEnum()) { return JavaPsiFacade.getInstance(grType.getProject()).findClass(CommonClassNames.JAVA_LANG_ENUM, grType.getResolveScope()); } else { return JavaPsiFacade.getInstance(grType.getProject()).findClass(CommonClassNames.JAVA_LANG_OBJECT, grType.getResolveScope()); }...
getBaseClass
33,651
PsiClassType (GrTypeDefinition grType) { if (grType.isEnum()) { return TypesUtil.createTypeByFQClassName(CommonClassNames.JAVA_LANG_ENUM, grType); } return TypesUtil.getJavaLangObject(grType); }
createBaseClassType
33,652
List<PsiMethod> (Collection<? extends PsiClass> classes) { List<PsiMethod> allMethods = new ArrayList<>(); HashSet<PsiClass> visited = new HashSet<>(); for (PsiClass psiClass : classes) { getAllMethodsInner(psiClass, allMethods, visited); } return allMethods; }
getAllMethods
33,653
void (PsiClass clazz, List<? super PsiMethod> allMethods, HashSet<? super PsiClass> visited) { if (visited.contains(clazz)) return; visited.add(clazz); ContainerUtil.addAll(allMethods, clazz.getMethods()); final PsiClass[] supers = clazz.getSupers(); for (PsiClass aSuper : supers) { getAllMethodsInner(aSuper, allMethod...
getAllMethodsInner
33,654
PsiClassType[] (@Nullable GrReferenceList list) { if (list == null) return PsiClassType.EMPTY_ARRAY; return list.getReferencedTypes(); }
getReferenceListTypes
33,655
boolean (@NotNull GrTypeDefinition grType, @NotNull PsiScopeProcessor processor, @NotNull ResolveState state, @Nullable PsiElement lastParent, @NotNull PsiElement place) { if (isAnnotationResolve(processor)) return true; //don't process class members while resolving annotation if (processor.getHint(CompilationPhaseHint...
processDeclarations
33,656
boolean (@NotNull GrTypeDefinition grType, @NotNull PsiScopeProcessor processor, @NotNull ResolveState state, @NotNull PsiElement place, boolean processInstanceMethods, @NotNull PsiSubstitutor substitutor, @NotNull PsiElementFactory factory, @NotNull LanguageLevel level, CandidateInfo fieldInfo) { final PsiField field ...
processField
33,657
boolean (@NotNull GrTypeDefinition grType, @NotNull PsiScopeProcessor processor, @NotNull ResolveState state, @NotNull PsiElement place, boolean processInstanceMethods, @NotNull PsiSubstitutor substitutor, @NotNull PsiElementFactory factory, @NotNull LanguageLevel level, boolean placeGroovy, @NotNull CandidateInfo info...
processMethod
33,658
boolean (@NotNull GrTypeDefinition grType, @NotNull PsiMember element, @NotNull PsiElement place) { return !grType.isTrait() || !element.hasModifierProperty(PsiModifier.STATIC) || grType.equals(element.getContainingClass()) && PsiTreeUtil.isAncestor(grType, place, true); }
shouldProcessTraitMember
33,659
boolean (@NotNull GrTypeDefinition grType, @Nullable PsiElement lastParent) { if (lastParent != null) { final GrModifierList modifierList = grType.getModifierList(); if (modifierList != null && modifierList.hasAnnotation(GroovyCommonClassNames.GROOVY_LANG_CATEGORY)) { return false; } } return true; }
shouldProcessInstanceMembers
33,660
boolean (boolean shouldProcessInstance, @NotNull PsiMember member) { if (shouldProcessInstance) return true; if (member instanceof GrReflectedMethod) { return ((GrReflectedMethod)member).getBaseMethod().hasModifierProperty(PsiModifier.STATIC); } else { return member.hasModifierProperty(PsiModifier.STATIC); } }
processInstanceMember
33,661
boolean (PsiElement place, PsiElement element) { if (element instanceof GrAccessorMethod) element = ((GrAccessorMethod)element).getProperty(); if (!(element instanceof GrField)) return false; if (element instanceof GrScriptField) element = ((GrScriptField)element).getOriginalVariable(); while (place != null) { if (plac...
isSameDeclaration
33,662
boolean (boolean isPlaceGroovy, PsiMethod method) { return isPlaceGroovy || !(method instanceof GrGdkMethod); }
isMethodVisible
33,663
PsiMethod (GrTypeDefinition grType, PsiMethod patternMethod, boolean checkBases) { final MethodSignature patternSignature = patternMethod.getSignature(PsiSubstitutor.EMPTY); for (PsiMethod method : findMethodsByName(grType, patternMethod.getName(), checkBases, false)) { MethodSignature signature = getSignatureForInheri...
findMethodBySignature
33,664
PsiMethod[] (GrTypeDefinition grType, String name, boolean checkBases, boolean includeSyntheticAccessors) { if (!checkBases) { List<PsiMethod> result = new ArrayList<>(); for (PsiMethod method : CollectClassMembersUtil.getMethods(grType, includeSyntheticAccessors)) { if (name.equals(method.getName())) result.add(method...
findMethodsByName
33,665
PsiMethod[] (GrTypeDefinition grType, PsiMethod patternMethod, boolean checkBases, boolean includeSynthetic) { ArrayList<PsiMethod> result = new ArrayList<>(); final MethodSignature patternSignature = patternMethod.getSignature(PsiSubstitutor.EMPTY); for (PsiMethod method : findMethodsByName(grType, patternMethod.getNa...
findMethodsBySignature
33,666
MethodSignature (@NotNull PsiMethod methodFromSuperClass, @NotNull GrTypeDefinition inheritor) { final PsiClass clazz = methodFromSuperClass.getContainingClass(); if (clazz == null) return null; PsiSubstitutor superSubstitutor = TypeConversionUtil.getClassSubstitutor(clazz, inheritor, PsiSubstitutor.EMPTY); if (superSu...
getSignatureForInheritor
33,667
PsiField (GrTypeDefinition grType, String name, boolean checkBases, boolean includeSynthetic) { if (!checkBases) { for (PsiField field : CollectClassMembersUtil.getFields(grType, includeSynthetic)) { if (name.equals(field.getName())) return field; } return null; } Map<String, CandidateInfo> fieldsMap = CollectClassMemb...
findFieldByName
33,668
PsiField[] (GrTypeDefinition grType) { return getAllFields(grType, true); }
getAllFields
33,669
PsiField[] (GrTypeDefinition grType, boolean includeSynthetic) { Map<String, CandidateInfo> fieldsMap = CollectClassMembersUtil.getAllFields(grType, includeSynthetic); return ContainerUtil.map2Array(fieldsMap.values(), PsiField.class, entry -> (PsiField)entry.getElement()); }
getAllFields
33,670
boolean (GrTypeDefinitionImpl definition, PsiElement another) { return PsiClassImplUtil.isClassEquivalentTo(definition, another); }
isClassEquivalentTo
33,671
Set<MethodSignature> (@NotNull PsiClass clazz) { return CachedValuesManager.getCachedValue(clazz, () -> { PsiElementFactory factory = JavaPsiFacade.getInstance(clazz.getProject()).getElementFactory(); MostlySingularMultiMap<MethodSignature, PsiMethod> signatures = new MostlySingularMultiMap<>(); for (PsiMethod method :...
getDuplicatedSignatures
33,672
GrAccessorMethod (GrField field) { return CachedValuesManager.getCachedValue(field, () -> CachedValueProvider.Result.create( doGetSetter(field), PsiModificationTracker.MODIFICATION_COUNT )); }
findSetter
33,673
GrAccessorMethod (GrField field) { PsiClass containingClass = field.getContainingClass(); if (containingClass == null) return null; PsiMethod[] setters = containingClass.findMethodsByName(GroovyPropertyUtils.getSetterName(field.getName()), false); for (PsiMethod setter : setters) { if (setter instanceof GrAccessorMetho...
doGetSetter
33,674
GrAccessorMethod[] (GrField field) { return CachedValuesManager.getCachedValue(field, () -> CachedValueProvider.Result.create( doGetGetters(field), PsiModificationTracker.MODIFICATION_COUNT )); }
findGetters
33,675
String (String s) { return unescapeRegex(s, true); }
unescapeSlashyString
33,676
String (String s) { return unescapeRegex(s, false); }
unescapeDollarSlashyString
33,677
String (String str) { final StringBuilder buffer = new StringBuilder(str.length()); escapeSymbolsForSlashyStrings(buffer, str); return buffer.toString(); }
escapeSymbolsForSlashyStrings
33,678
void (StringBuilder buffer, String str) { final int length = str.length(); for (int idx = 0; idx < length; idx++) { char ch = str.charAt(idx); if (ch == '/') { buffer.append("\\/"); } else if (Character.isISOControl(ch) && ch != '\n' || ch == '$') { appendUnicode(buffer, ch); } else { buffer.append(ch); } } }
escapeSymbolsForSlashyStrings
33,679
String (String str) { final StringBuilder buffer = new StringBuilder(str.length()); escapeSymbolsForDollarSlashyStrings(buffer, str); return buffer.toString(); }
escapeSymbolsForDollarSlashyStrings
33,680
void (StringBuilder buffer, String str) { final int length = str.length(); int idx = 0; while (idx < length) { final char ch = str.charAt(idx); if (ch == '/') { if (idx + 1 < length) { char nextCh = str.charAt(idx + 1); if (nextCh == '$') { // /$ -> $/$ buffer.append("$/"); idx++; continue; } } } else if (ch == '$') { ...
escapeSymbolsForDollarSlashyStrings
33,681
void (@NlsSafe StringBuilder buffer, char ch) { String hexCode = StringUtil.toUpperCase(Integer.toHexString(ch)); buffer.append("\\u"); int paddingCount = 4 - hexCode.length(); while (paddingCount-- > 0) { buffer.append(0); } buffer.append(hexCode); }
appendUnicode
33,682
String (CharSequence s, boolean isSingleLine, boolean unescapeSymbols) { StringBuilder b = new StringBuilder(); escapeSymbolsForGString(s, isSingleLine, unescapeSymbols, b); return b.toString(); }
escapeSymbolsForGString
33,683
void (CharSequence s, boolean isSingleLine, boolean unescapeSymbols, StringBuilder b) { escapeStringCharacters(s.length(), s, isSingleLine ? "$\"" : "$", isSingleLine, true, b); if (unescapeSymbols) { unescapeCharacters(b, isSingleLine ? "'" : "'\"", true); } if (!isSingleLine) escapeLastSymbols(b, '\"'); }
escapeSymbolsForGString
33,684
String (String s, boolean isSingleLine, boolean forInjection) { final StringBuilder builder = new StringBuilder(); escapeStringCharacters(s.length(), s, isSingleLine ? "'" : "", isSingleLine, true, builder); if (!forInjection) { unescapeCharacters(builder, isSingleLine ? "$\"" : "$'\"", !isSingleLine); } if (!isSingleL...
escapeSymbolsForString
33,685
void (StringBuilder builder, char toEscape) { for (int i = builder.length() - 1; i >= 0 && builder.charAt(i) == toEscape; i--) { builder.insert(i, '\\'); } }
escapeLastSymbols
33,686
StringBuilder (int length, @NotNull CharSequence str, @Nullable String additionalChars, boolean escapeLineFeeds, boolean escapeBackSlash, @NotNull @NonNls StringBuilder buffer) { for (int idx = 0; idx < length; idx++) { char ch = str.charAt(idx); switch (ch) { case '\b' -> buffer.append("\\b"); case '\t' -> buffer.appe...
escapeStringCharacters
33,687
void (StringBuilder builder, String toUnescape, boolean isMultiLine) { for (int i = 0; i < builder.length(); i++) { if (builder.charAt(i) != '\\') continue; if (i + 1 == builder.length()) break; char next = builder.charAt(i + 1); if (next == 'n') { if (isMultiLine) { builder.replace(i, i + 2, "\n"); } } else if (next =...
unescapeCharacters
33,688
String (String s, String toEscape, String toUnescape, StringBuilder builder) { boolean escaped = false; for (int i = 0; i < s.length(); i++) { char ch = s.charAt(i); if (escaped) { if (toUnescape.indexOf(ch) < 0) { builder.append('\\'); builder.append(ch); } else { if (ch=='n') builder.append('\n'); else if (ch=='r') b...
escapeAndUnescapeSymbols
33,689
String (@NotNull String s) { String quote = getStartQuote(s); int sL = s.length(); int qL = quote.length(); if (sL >= qL * 2 && DOLLAR_SLASH.equals(quote)) { if (s.endsWith(SLASH_DOLLAR)) { return s.substring(qL, sL - qL); } else { return s.substring(qL); } } if (sL >= qL * 2 && s.endsWith(quote)) { return s.substring(...
removeQuotes
33,690
String (String s, boolean forGString) { if (forGString) { if (s.contains("\n") || s.contains("\r")) { return TRIPLE_DOUBLE_QUOTES + s + TRIPLE_DOUBLE_QUOTES; } else { return DOUBLE_QUOTES + s + DOUBLE_QUOTES; } } else { if (s.contains("\n") || s.contains("\r")) { return TRIPLE_QUOTES + s + TRIPLE_QUOTES; } else { retur...
addQuotes
33,691
GrString (GrStringInjection injection, GrLiteral literal) { GrString grString = (GrString)injection.getParent(); final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(grString.getProject()); String literalText; //wrap last injection in inserted literal if it needed // e.g.: "bla bla ${foo}bla bla"...
replaceStringInjectionByLiteral
33,692
void (GrString grString, String quotes) { GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(grString.getProject()); final PsiElement firstChild = grString.getFirstChild(); final PsiElement lastChild = grString.getLastChild(); final GrExpression template = factory.createExpressionFromText(quotes + "$...
wrapGStringInto
33,693
void (GrStringInjection injection) { final GrExpression expression = injection.getExpression(); LOG.assertTrue(expression != null); final GroovyPsiElementFactory instance = GroovyPsiElementFactory.getInstance(injection.getProject()); final GrClosableBlock closure = instance.createClosureFromText("{foo}"); closure.getNo...
wrapInjection
33,694
boolean (GrStringInjection injection) { final GrClosableBlock block = injection.getClosableBlock(); if (block == null) return false; final GrStatement[] statements = block.getStatements(); if (statements.length != 1) return false; if (!(statements[0] instanceof GrReferenceExpression)) return false; return checkBraceIsU...
checkGStringInjectionForUnnecessaryBraces
33,695
boolean (GrStatement injected, PsiElement next) { if (next.getTextLength() == 0) next = next.getNextSibling(); char nextChar = next.getText().charAt(0); if (nextChar == '"' || nextChar == '$') { return true; } final GroovyPsiElementFactory elementFactory = GroovyPsiElementFactory.getInstance(injected.getProject()); fin...
checkBraceIsUnnecessary
33,696
void (GrString grString) { for (GrStringInjection child : grString.getInjections()) { if (checkGStringInjectionForUnnecessaryBraces(child)) { final GrClosableBlock closableBlock = child.getClosableBlock(); final GrReferenceExpression refExpr = (GrReferenceExpression)closableBlock.getStatements()[0]; final GrReferenceEx...
removeUnnecessaryBracesInGString
33,697
String (String text) { if (text.startsWith(TRIPLE_QUOTES)) return TRIPLE_QUOTES; if (text.startsWith(QUOTE)) return QUOTE; if (text.startsWith(TRIPLE_DOUBLE_QUOTES)) return TRIPLE_DOUBLE_QUOTES; if (text.startsWith(DOUBLE_QUOTES)) return DOUBLE_QUOTES; if (text.startsWith(SLASH)) return SLASH; if (text.startsWith(DOLLA...
getStartQuote
33,698
String (String text) { if (text.endsWith(TRIPLE_QUOTES)) return TRIPLE_QUOTES; if (text.endsWith(QUOTE)) return QUOTE; if (text.endsWith(TRIPLE_DOUBLE_QUOTES)) return TRIPLE_DOUBLE_QUOTES; if (text.endsWith(DOUBLE_QUOTES)) return DOUBLE_QUOTES; if (text.endsWith(SLASH)) return SLASH; if (text.endsWith(SLASH_DOLLAR)) re...
getEndQuote
33,699
TextRange (@Nullable PsiElement element) { if (element == null) return null; IElementType elementType = element.getNode().getElementType(); if (!GroovyTokenSets.STRING_LITERALS.contains(elementType)) return null; String text = element.getText(); String startQuote = getStartQuote(text); String endQuote = getEndQuote(tex...
getStringContentRange