Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
28,900
File () { return myDescriptor.getRootFile(); }
getRootFile
28,901
Set<File> () { return myDescriptor.getExcludedRoots(); }
getExcludedRoots
28,902
void (@NotNull JpsProject project, @NotNull Element componentTag) { JpsGroovySettings configuration = XmlSerializer.deserialize(componentTag, JpsGroovySettings.class); configuration.initExcludes(); project.getContainer().setChild(JpsGroovySettings.ROLE, configuration); }
loadExtension
28,903
void (@NotNull JpsProject project, @NotNull Element componentTag) { GreclipseSettings settings = XmlSerializer.deserialize(componentTag, GreclipseSettings.class); GreclipseJpsCompilerSettings component = new GreclipseJpsCompilerSettings(settings); project.getContainer().setChild(GreclipseJpsCompilerSettings.ROLE, component); }
loadExtension
28,904
void (@NotNull JpsProject project) { GreclipseJpsCompilerSettings component = new GreclipseJpsCompilerSettings(new GreclipseSettings()); project.getContainer().setChild(GreclipseJpsCompilerSettings.ROLE, component); }
loadExtensionWithDefaultSettings
28,905
String () { return myModule.getName(); }
getId
28,906
GroovyResourceRootDescriptor (@NotNull String rootId, @NotNull BuildRootIndex rootIndex) { List<GroovyResourceRootDescriptor> descriptors = rootIndex.getRootDescriptors(new File(rootId), Collections.singletonList((Type)getTargetType()), null); return ContainerUtil.getFirstItem(descriptors); }
findRootDescriptor
28,907
String () { return "Check Groovy Resources for '" + myModule.getName() + "' " + (isTests() ? "tests" : "production"); }
getPresentableName
28,908
List<GroovyResourceRootDescriptor> (@NotNull JpsModel model, @NotNull ModuleExcludeIndex index, @NotNull IgnoredFileIndex ignoredFileIndex, @NotNull BuildDataPaths dataPaths) { ResourcesTarget target = new ResourcesTarget(myModule, ResourcesTargetType.getInstance(isTests())); List<ResourceRootDescriptor> resources = target.computeRootDescriptors(model, index, ignoredFileIndex, dataPaths); return ContainerUtil.map(resources, descriptor -> new GroovyResourceRootDescriptor(descriptor, this)); }
computeRootDescriptors
28,909
Collection<File> (@NotNull CompileContext context) { return Collections.singletonList(getOutputRoot(context)); }
getOutputRoots
28,910
JpsModule () { return myModule; }
getModule
28,911
boolean (Object o) { if (this == o) return true; if (!(o instanceof CheckResourcesTarget)) return false; CheckResourcesTarget target = (CheckResourcesTarget)o; if (!myModule.equals(target.myModule)) return false; if (!getTargetType().equals(target.getTargetType())) return false; return true; }
equals
28,912
int () { return myModule.hashCode() + 31 * getTargetType().hashCode(); }
hashCode
28,913
List<CheckResourcesTarget> (@NotNull JpsModel model) { return ContainerUtil.map(model.getProject().getModules(), module -> new CheckResourcesTarget(module, this)); }
computeAllTargets
28,914
BuildTargetLoader<CheckResourcesTarget> (@NotNull JpsModel model) { final Map<String, JpsModule> modules = new HashMap<>(); for (JpsModule module : model.getProject().getModules()) { modules.put(module.getName(), module); } return new BuildTargetLoader<CheckResourcesTarget>() { @Nullable @Override public CheckResourcesTarget createTarget(@NotNull String targetId) { JpsModule module = modules.get(targetId); return module != null ? new CheckResourcesTarget(module, Type.this) : null; } }; }
createLoader
28,915
CheckResourcesTarget (@NotNull String targetId) { JpsModule module = modules.get(targetId); return module != null ? new CheckResourcesTarget(module, Type.this) : null; }
createTarget
28,916
void (int version, int access, String name, String signature, String superName, String[] interfaces) { nameRef.set(name.replace('/', '.')); }
visit
28,917
void (final List<CompilerMessage> parsedMessages, final StringBuilder sb) { if (sb.length() > 0) { ContainerUtil.addIfNotNull(parsedMessages, parseMessage(sb.toString())); } }
handleCurrentMessage
28,918
CompilerMessage (@NlsSafe String msgText) { // message should look like this: // 1. WARNING in /Users/andrew/git-repos/foo/src/main/java/packAction.java (at line 47) // public abstract class AbstractScmTagAction extends TaskAction implements BuildBadgeAction { // ^^^^^^^^^^^^^^^^^^^^ // But there will also be messages contributed from annotation processors that will look non-normal int dotIndex = msgText.indexOf('.'); BuildMessage.Kind kind; boolean isNormal = false; if (msgText.startsWith("Error")) { // since we are now also launching greclipse in a separate process, we may also face the errors from java kind = BuildMessage.Kind.ERROR; } else if (dotIndex > 0) { if (msgText.substring(dotIndex).startsWith(". WARNING")) { kind = BuildMessage.Kind.WARNING; isNormal = true; dotIndex += ". WARNING in ".length(); } else if (msgText.substring(dotIndex).startsWith(". ERROR")) { kind = BuildMessage.Kind.ERROR; isNormal = true; dotIndex += ". ERROR in ".length(); } else { kind = BuildMessage.Kind.INFO; } } else { kind = BuildMessage.Kind.INFO; } int firstNewline = msgText.indexOf('\n'); String firstLine = firstNewline > 0 ? msgText.substring(0, firstNewline) : msgText; String rest = firstNewline > 0 ? msgText.substring(firstNewline+1).trim() : ""; if (isNormal) { try { int parenIndex = firstLine.indexOf(" ("); String file = firstLine.substring(dotIndex, parenIndex); int line = Integer.parseInt(firstLine.substring(parenIndex + " (at line ".length(), firstLine.indexOf(')'))); int lastLineIndex = rest.lastIndexOf("\n"); return new CompilerMessage(myBuilderName, kind, rest.substring(lastLineIndex + 1), file, -1, -1, -1, line, -1); } catch (RuntimeException ignore) { } } if (msgText.trim().matches("(\\d)+ problem(s)? \\((\\d)+ (error|warning)(s)?\\)")) { return null; } return new CompilerMessage(myBuilderName, kind, msgText); } }
parseMessage
28,919
boolean (String path) { return super.acceptsFileType(path) || path.endsWith(".java"); }
acceptsFileType
28,920
ClassLoader (@Nullable String jar) { if (StringUtil.isEmpty(jar)) return null; if (jar.equals(myGreclipseJar)) { return myGreclipseLoader; } try { URL[] urls = { new File(jar).toURI().toURL(), Objects.requireNonNull(PathManager.getJarForClass(GreclipseMain.class)).toUri().toURL() }; ClassLoader loader = new URLClassLoader(urls, StandardJavaFileManager.class.getClassLoader()); Class.forName("org.eclipse.jdt.internal.compiler.batch.Main", false, loader); myGreclipseJar = jar; myGreclipseLoader = loader; return loader; } catch (Exception e) { LOG.error(e); return null; } }
createGreclipseLoader
28,921
List<String> () { return Arrays.asList("groovy", "java"); }
getCompilableFileExtensions
28,922
boolean (CompileContext context) { JpsProject project = context.getProjectDescriptor().getProject(); return ID.equals(JpsJavaExtensionService.getInstance().getCompilerConfiguration(project).getJavaCompilerId()); }
useGreclipse
28,923
boolean (List<String> vmOptions, List<String> args, StringWriter out, StringWriter err, Map<String, List<String>> outputs, CompileContext context, ModuleChunk chunk) { String bytecodeTarget = JpsGroovycRunner.getBytecodeTarget(context, chunk); if (bytecodeTarget != null && System.getProperty(GroovyRtConstants.GROOVY_TARGET_BYTECODE) == null) { synchronized (ourGlobalEnvironmentLock) { try { System.setProperty(GroovyRtConstants.GROOVY_TARGET_BYTECODE, bytecodeTarget); return performCompilationInner(vmOptions, args, out, err, outputs, context, chunk); } finally { System.clearProperty(GroovyRtConstants.GROOVY_TARGET_BYTECODE); } } } return performCompilationInner(vmOptions, args, out, err, outputs, context, chunk); }
performCompilation
28,924
boolean (List<String> vmOptions, List<String> args, StringWriter out, StringWriter err, Map<String, List<String>> outputs, CompileContext context, ModuleChunk chunk) { final ClassLoader jpsLoader = Thread.currentThread().getContextClassLoader(); try { // We have to set context class loader in order because greclipse will create child GroovyClassLoader, // and will use context class loader as parent. // // Here's what happens if we leave jpsLoader: // 1. org.codehaus.groovy.transform.ASTTransformationCollectorCodeVisitor // is loaded with GreclipseMain's class loader, i.e. myGreclipseLoader; // 2. org.codehaus.groovy.transform.ASTTransformation inside ASTTransformationCollectorCodeVisitor.verifyClass // is loaded with ASTTransformationCollectorCodeVisitor' loader, i.e. myGreclipseLoader; // 3. transformation GroovyClassLoader is created with context class loader (jpsLoader) as a parent; // 4. some CoolTransform implements ASTTransformation is loaded with GroovyClassLoader; // 5. ASTTransformation supertype of CoolTransform is loaded with GroovyClassLoader too; // 6. GroovyClassLoader asks its parent, which is jpsLoader, it doesn't know about ASTTransformation // => GroovyClassLoader loads ASTTransformation by itself; // 7. there are two different ASTTransformation class instances // => we get ASTTransformation.class.isAssignableFrom(klass) = false // => compilation fails with error. // // If we set context classloader here, then in the 6th step parent loader will be myGreclipseLoader, // and ASTTransformation class will be returned from myGreclipseLoader, and the compilation won't fail. Thread.currentThread().setContextClassLoader(myGreclipseLoader); if (vmOptions.isEmpty()) { Class<?> mainClass = Class.forName(GreclipseMain.class.getName(), true, myGreclipseLoader); Constructor<?> constructor = mainClass.getConstructor(PrintWriter.class, PrintWriter.class, Map.class); Method compileMethod = mainClass.getMethod("compile", String[].class); Object main = constructor.newInstance(new PrintWriter(out), new PrintWriter(err), outputs); return (Boolean)compileMethod.invoke(main, new Object[]{ArrayUtilRt.toStringArray(args)}); } else { final List<String> cmd = ExternalProcessUtil.buildJavaCommandLine( ForkedGroovyc.getJavaExecutable(chunk), "org.jetbrains.jps.incremental.groovy.GreclipseMain", Collections.emptyList(), Arrays.asList(myGreclipseJar, Objects.requireNonNull(PathManager.getJarForClass(GreclipseMain.class)).toAbsolutePath() .toString()), vmOptions, args ); final Process process = Runtime.getRuntime().exec(ArrayUtilRt.toStringArray(cmd)); ProcessHandler handler = new BaseOSProcessHandler(process, StringUtil.join(cmd, " "), null) { @NotNull @Override public Future<?> executeTask(@NotNull Runnable task) { return SharedThreadPool.getInstance().submit(task); } @Override public void notifyTextAvailable(@NotNull String text, @NotNull Key outputType) { if (outputType == ProcessOutputType.STDERR) { err.append(text); } if (outputType == ProcessOutputType.STDOUT) { out.append(text); } } }; handler.startNotify(); handler.waitFor(); return true; } } catch (Exception e) { context.processMessage(CompilerMessage.createInternalBuilderError(getPresentableName(), e)); return false; } finally { Thread.currentThread().setContextClassLoader(jpsLoader); } }
performCompilationInner
28,925
void (@NotNull String text, @NotNull Key outputType) { if (outputType == ProcessOutputType.STDERR) { err.append(text); } if (outputType == ProcessOutputType.STDOUT) { out.append(text); } }
notifyTextAvailable
28,926
List<String> (CompileContext context, ModuleChunk chunk, List<File> srcFiles, String mainOutputDir, @Nullable ProcessorConfigProfile profile, GreclipseSettings settings) { final List<String> args = new ArrayList<>(); args.add("-cp"); args.add(getClasspathString(chunk)); JavaBuilder.addCompilationOptions(args, context, chunk, profile); args.add("-d"); args.add(mainOutputDir); //todo AjCompilerSettings exact duplicate, JavaBuilder.loadCommonJavacOptions inexact duplicate List<String> params = ParametersListUtil.parse(settings.cmdLineParams); for (Iterator<String> iterator = params.iterator(); iterator.hasNext(); ) { String option = iterator.next(); if ("-javaAgentClass".equals(option)) { iterator.next(); continue; } if ("-target".equals(option)) { iterator.next(); continue; } else if (option.isEmpty() || "-g".equals(option) || "-verbose".equals(option)) { continue; } args.add(option); } if (settings.debugInfo) { args.add("-g"); } for (File file : srcFiles) { args.add(file.getPath()); } return args; }
createCommandLine
28,927
List<String> (ModuleChunk chunk, String args, String rawVmOptions) { List<String> params = ParametersListUtil.parse(args); List<String> vmOptions = new ArrayList<>(ParametersListUtil.parse(rawVmOptions)); for (Iterator<String> iterator = params.iterator(); iterator.hasNext(); ) { String option = iterator.next(); if ("-javaAgentClass".equals(option)) { String agentClass = iterator.next(); vmOptions.add("-javaagent:" + locateAgentJar(chunk, agentClass)); } } return vmOptions; }
discoverVmOptions
28,928
String (ModuleChunk chunk, String agentClassName) { Collection<File> files = ProjectPaths.getCompilationClasspathFiles(chunk, chunk.containsTests(), false, false); URL[] urls = new URL[files.size()]; int i = 0; for (File file : files) { try { urls[i] = file.toURI().toURL(); ++i; } catch (MalformedURLException e) { LOG.warn("Malformed dependency: " + file); } } try (URLClassLoader dependenciesLoader = new URLClassLoader(urls, StandardJavaFileManager.class.getClassLoader())) { Class<?> agentClass = Class.forName(agentClassName, false, dependenciesLoader); URL agentUrl = agentClass.getProtectionDomain().getCodeSource().getLocation(); File agentClassFile = new File(URLDecoder.decode(agentUrl.getPath(), StandardCharsets.UTF_8)); return agentClassFile.getAbsolutePath(); } catch (IOException | ClassNotFoundException e) { throw new RuntimeException(e); } }
locateAgentJar
28,929
String (ModuleChunk chunk) { final Set<String> cp = new LinkedHashSet<>(); for (File file : ProjectPaths.getCompilationClasspathFiles(chunk, chunk.containsTests(), false, false)) { if (file.exists()) { cp.add(FileUtil.toCanonicalPath(file.getPath())); } } return StringUtil.join(cp, File.pathSeparator); }
getClasspathString
28,930
String () { return GroovyJpsBundle.message("compiler.name.greclipse"); }
getPresentableName
28,931
long () { return 100; }
getExpectedBuildTime
28,932
JpsGroovySettings () { return new JpsGroovySettings(this); }
createCopy
28,933
void (@NotNull JpsGroovySettings modified) { }
applyChanges
28,934
JpsGroovySettings (@NotNull JpsProject project) { JpsGroovySettings settings = project.getContainer().getChild(ROLE); return settings == null ? new JpsGroovySettings() : settings; }
getSettings
28,935
boolean (File file) { return myExcludeFromStubGeneration != null && myExcludeFromStubGeneration.isExcluded(file); }
isExcludedFromStubGeneration
28,936
Set<ModuleBuildTarget> (ModuleChunk chunk) { return chunk.getTargets(); }
getTargets
28,937
JavaSourceRootDescriptor (CompileContext context, File srcFile) { return context.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(context, srcFile); }
findRoot
28,938
void (CompileContext context, Map<ModuleBuildTarget, String> generationOutputs, MultiMap<ModuleBuildTarget, OutputItem> compiled) { addStubRootsToJavacSourcePath(context, generationOutputs); rememberStubSources(context, compiled); }
stubsGenerated
28,939
void (CompileContext context, Map<ModuleBuildTarget, String> generationOutputs) { final BuildRootIndex rootsIndex = context.getProjectDescriptor().getBuildRootIndex(); for (ModuleBuildTarget target : generationOutputs.keySet()) { File root = new File(generationOutputs.get(target)); rootsIndex.associateTempRoot(context, target, new JavaSourceRootDescriptor(root, target, true, true, "", Collections.emptySet(), FileFilters.EVERYTHING)); } }
addStubRootsToJavacSourcePath
28,940
void (CompileContext context, MultiMap<ModuleBuildTarget, OutputItem> compiled) { Map<String, String> stubToSrc = GroovyBuilder.STUB_TO_SRC.get(context); if (stubToSrc == null) { GroovyBuilder.STUB_TO_SRC.set(context, stubToSrc = new HashMap<>()); } for (OutputItem item : compiled.values()) { stubToSrc.put(FileUtil.toSystemIndependentName(item.outputPath), item.sourcePath); } }
rememberStubSources
28,941
boolean () { for (CompilerMessage message : myCompilerMessages) { String text = message.getMessageText(); if (text.contains("java.lang.NoClassDefFoundError") || text.contains("java.lang.TypeNotPresentException") || text.contains("unable to resolve class")) { JpsGroovycRunner.LOG.debug("Resolve issue: " + message); return true; } } return false; }
shouldRetry
28,942
GreclipseJpsCompilerSettings () { return new GreclipseJpsCompilerSettings(mySettings); }
createCopy
28,943
void (@NotNull GreclipseJpsCompilerSettings modified) { mySettings = modified.mySettings; }
applyChanges
28,944
GreclipseSettings (@NotNull JpsProject project) { GreclipseJpsCompilerSettings extension = project.getContainer().getChild(ROLE); return extension != null ? extension.mySettings : null; }
getSettings
28,945
void (final String text, final Key outputType) { if (LOG.isDebugEnabled()) { LOG.debug("Received from groovyc " + outputType + ": " + text); } if (outputType == ProcessOutputTypes.SYSTEM) { return; } if (outputType == ProcessOutputTypes.STDERR && !isSafeStderr(text)) { stdErr.append(StringUtil.convertLineSeparators(text)); return; } parseOutput(text); }
notifyTextAvailable
28,946
boolean (String line) { return line.startsWith("SLF4J:") || line.startsWith("Picked up JAVA_TOOL_OPTIONS"); }
isSafeStderr
28,947
void (@Nls @NotNull String status) { myContext.processMessage(new ProgressMessage( GroovyJpsBundle.message("status.0.chunk.name.1", status, myChunk.getPresentableShortName()) )); }
updateStatus
28,948
void (String text) { final String trimmed = text.trim(); if (trimmed.startsWith(GroovyRtConstants.PRESENTABLE_MESSAGE)) { String message = trimmed.substring(GroovyRtConstants.PRESENTABLE_MESSAGE.length()); updateStatus(message); return; } if (GroovyRtConstants.CLEAR_PRESENTABLE.equals(trimmed)) { updateStatus(GroovyJpsBundle.message("groovy.compiler.in.operation")); return; } if (StringUtil.isNotEmpty(text)) { outputBuffer.append(text); //compiled start marker have to be in the beginning on each string if (outputBuffer.indexOf(GroovyRtConstants.COMPILED_START) != -1) { if (outputBuffer.indexOf(GroovyRtConstants.COMPILED_END) == -1) { return; } final String compiled = handleOutputBuffer(GroovyRtConstants.COMPILED_START, GroovyRtConstants.COMPILED_END); final List<String> list = splitAndTrim(compiled); String outputPath = list.get(0); String sourceFile = list.get(1); OutputItem item = new OutputItem(outputPath, sourceFile); if (LOG.isDebugEnabled()) { LOG.debug("Output: " + item); } myCompiledItems.add(item); } else if (outputBuffer.indexOf(GroovyRtConstants.MESSAGES_START) != -1) { if (outputBuffer.indexOf(GroovyRtConstants.MESSAGES_END) == -1) { return; } text = handleOutputBuffer(GroovyRtConstants.MESSAGES_START, GroovyRtConstants.MESSAGES_END); List<String> tokens = splitAndTrim(text); LOG.assertTrue(tokens.size() > 4, "Wrong number of output params"); String category = tokens.get(0); String message = tokens.get(1); String url = tokens.get(2); String lineNum = tokens.get(3); String columnNum = tokens.get(4); int lineInt; int columnInt; try { lineInt = Integer.parseInt(lineNum); columnInt = Integer.parseInt(columnNum); } catch (NumberFormatException e) { LOG.error(e); lineInt = 0; columnInt = 0; } BuildMessage.Kind kind = category.equals(GroovyCompilerMessageCategories.ERROR) ? BuildMessage.Kind.ERROR : category.equals(GroovyCompilerMessageCategories.WARNING) ? BuildMessage.Kind.WARNING : BuildMessage.Kind.INFO; if (StringUtil.isEmpty(url) || "null".equals(url)) { url = null; message = GroovyJpsBundle.message("while.compiling.chunk.0.message.1", myChunk.getPresentableShortName(), message); } CompilerMessage compilerMessage = new CompilerMessage( GroovyJpsBundle.message("compiler.name.groovyc"), kind, message, url, -1, -1, -1, lineInt, columnInt ); if (LOG.isDebugEnabled()) { LOG.debug("Message: " + compilerMessage); } addCompilerMessage(compilerMessage); } } }
parseOutput
28,949
String (String startMarker, String endMarker) { final int start = outputBuffer.indexOf(startMarker); final int end = outputBuffer.indexOf(endMarker); if (start > end) { throw new AssertionError("Malformed Groovyc output: " + outputBuffer); } String text = outputBuffer.substring(start + startMarker.length(), end); outputBuffer.delete(start, end + endMarker.length()); return text.trim(); }
handleOutputBuffer
28,950
List<String> (String compiled) { return ContainerUtil.map(StringUtil.split(compiled, GroovyRtConstants.SEPARATOR), s -> s.trim()); }
splitAndTrim
28,951
List<CompilerMessage> () { ArrayList<CompilerMessage> messages = new ArrayList<>(compilerMessages); final StringBuffer unparsedBuffer = getStdErr(); if (unparsedBuffer.length() != 0) { String msg = unparsedBuffer.toString(); if (msg.contains(GroovyRtConstants.NO_GROOVY)) { messages.add(reportNoGroovy(msg)); } else { messages.add(new CompilerMessage( GroovyJpsBundle.message("compiler.name.groovyc"), BuildMessage.Kind.INFO, GroovyJpsBundle.message("while.compiling.chunk.0.message.1", myChunk.getPresentableShortName(), msg) )); } } if (myExitCode != 0) { for (CompilerMessage message : messages) { if (message.getKind() == BuildMessage.Kind.ERROR) { return messages; } } messages.add(new CompilerMessage( GroovyJpsBundle.message("compiler.name.groovyc"), BuildMessage.Kind.ERROR, GroovyJpsBundle.message("internal.groovyc.error.code.0", myExitCode) )); } return messages; }
getCompilerMessages
28,952
StringBuffer () { return stdErr; }
getStdErr
28,953
void () { myCompiledItems.clear(); compilerMessages.clear(); stdErr.setLength(0); outputBuffer.setLength(0); }
onContinuation
28,954
GroovyCompilerResult () { return new GroovyCompilerResult(myCompiledItems, getCompilerMessages()); }
result
28,955
boolean (@NotNull File file) { return GroovyBuilder.isGroovyFile(file.getAbsolutePath()); }
shouldHonorFileEncodingForCompilation
28,956
String () { return myCategory; }
getCategory
28,957
String () { return myMessage; }
getMessage
28,958
String () { return myUrl; }
getUrl
28,959
int () { return myLineNum; }
getLineNum
28,960
int () { return myColumnNum; }
getColumnNum
28,961
String () { return "OutputItem{" + "outputPath='" + outputPath + '\'' + ", sourcePath='" + sourcePath + '\'' + '}'; }
toString
28,962
List<String> (File jpsPluginRoot, boolean addClassLoaderJar) { List<String> result = new ArrayList<>(); addGroovyRtJarPath(jpsPluginRoot, "groovy-rt.jar", Collections.singletonList("intellij.groovy.rt"), "groovy-rt", result); addGroovyRtJarPath(jpsPluginRoot, "groovy-constants-rt.jar", Collections.singletonList("intellij.groovy.constants.rt"), "groovy-constants-rt", result); if (addClassLoaderJar) { addGroovyRtJarPath(jpsPluginRoot, "groovy-rt-class-loader.jar", Collections.singletonList("intellij.groovy.rt.classLoader"), "groovy-rt-class-loader", result); } return result; }
getGroovyRtRoots
28,963
void (File jpsPluginClassesRoot, String jarNameInDistribution, List<String> moduleNames, String mavenArtifactNamePrefix, List<String> to) { File parentDir = jpsPluginClassesRoot.getParentFile(); if (jpsPluginClassesRoot.isFile()) { String fileName; if (jpsPluginClassesRoot.getName().equals("groovy-jps.jar")) { fileName = jarNameInDistribution; } else { String name = jpsPluginClassesRoot.getName(); int dotIndex = name.lastIndexOf('.'); name = dotIndex < 0 ? name : name.substring(0, dotIndex); int dashIndex = name.lastIndexOf('-'); String version = dashIndex < 0 ? null : name.substring(dashIndex + 1); fileName = mavenArtifactNamePrefix + "-" + version + ".jar"; if (parentDir.getName().equals(version)) { parentDir = new File(parentDir.getParentFile().getParentFile(), mavenArtifactNamePrefix + "/" + version); } } to.add(new File(parentDir, fileName).getPath()); } else { for (String moduleName : moduleNames) { to.add(new File(parentDir, moduleName).getPath()); } } }
addGroovyRtJarPath
28,964
void (String options, Instrumentation inst) { // Handle duplicate agents if (initialized) { return; } initialized = true; inst.addTransformer(new ClassFileTransformer() { public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { try { if (className == null || className.indexOf('$') >= 0) { // non-toplevel Groovy classes don't have timestamp fields, so don't Java classes and lambdas // let's not care about presumably rare dollar-named Groovy classes return null; } if (classBeingRedefined != null) { Field callSiteArrayField = classBeingRedefined.getDeclaredField("$callSiteArray"); callSiteArrayField.setAccessible(true); callSiteArrayField.set(null, null); } return removeTimestampField(classfileBuffer); } catch (Throwable ignored) { return null; } } }); }
premain
28,965
boolean (byte[] array, byte[] subArray, int start) { for (int i = 1; i < subArray.length; i++) { if (array[start + i] != subArray[i]) { return false; } } return true; }
matches
28,966
boolean (byte[] array, byte[] subArray) { int maxLength = array.length - subArray.length; for (int i = 0; i < maxLength; i++) { if (array[i] == subArray[0] && matches(array, subArray, i)) { return true; } } return false; }
containsSubArray
28,967
byte[] (byte[] newBytes) { if (!containsSubArray(newBytes, timeStampFieldStartBytes)) { return null; } final boolean[] changed = new boolean[]{false}; final ClassWriter writer = new ClassWriter(0); new ClassReader(newBytes).accept(new TimestampFieldRemover(writer, changed), 0); if (changed[0]) { return writer.toByteArray(); } return null; }
removeTimestampField
28,968
FieldVisitor (int i, String name, String s1, String s2, Object o) { if (name.startsWith(timeStampFieldStart)) { //remove the field changed[0] = true; return null; } return super.visitField(i, name, s1, s2, o); }
visitField
28,969
MethodVisitor (int i, String name, String s1, String s2, String[] strings) { final MethodVisitor mw = super.visitMethod(i, name, s1, s2, strings); if ("<clinit>".equals(name)) { //remove field's static initialization return new MethodAdapter(mw) { @Override public void visitFieldInsn(int opCode, String s, String name, String desc) { if (name.startsWith(timeStampFieldStart) && opCode == Opcodes.PUTSTATIC) { visitInsn(Type.LONG_TYPE.getDescriptor().equals(desc) ? Opcodes.POP2 : Opcodes.POP); } else { super.visitFieldInsn(opCode, s, name, desc); } } }; } return mw; }
visitMethod
28,970
void (int opCode, String s, String name, String desc) { if (name.startsWith(timeStampFieldStart) && opCode == Opcodes.PUTSTATIC) { visitInsn(Type.LONG_TYPE.getDescriptor().equals(desc) ? Opcodes.POP2 : Opcodes.POP); } else { super.visitFieldInsn(opCode, s, name, desc); } }
visitFieldInsn
28,971
boolean (@NotNull String newName, @NotNull PsiElement element, @NotNull ProcessingContext context) { return GroovyRefactoringUtil.isCorrectReferenceName(newName, element.getProject()); }
isInputValid
28,972
String () { return GroovyFileType.DEFAULT_EXTENSION; }
getFileExtension
28,973
String (CharSequence text) { Lexer lexer = new GroovyLexer(); lexer.start(text); skipWhitespacesAndComments(lexer); final IElementType firstToken = lexer.getTokenType(); if (firstToken != GroovyTokenTypes.kPACKAGE) { return ""; } lexer.advance(); skipWhitespacesAndComments(lexer); final StringBuilder buffer = new StringBuilder(); while(true){ if (lexer.getTokenType() != GroovyTokenTypes.mIDENT) break; buffer.append(text, lexer.getTokenStart(), lexer.getTokenEnd()); lexer.advance(); skipWhitespacesAndComments(lexer); if (lexer.getTokenType() != GroovyTokenTypes.mDOT) break; buffer.append('.'); lexer.advance(); skipWhitespacesAndComments(lexer); } String packageName = buffer.toString(); if (packageName.isEmpty() || StringUtil.endsWithChar(packageName, '.')) return null; return packageName; }
getPackageName
28,974
void (Lexer lexer) { while(TokenSets.ALL_COMMENT_TOKENS.contains(lexer.getTokenType()) || TokenSets.WHITE_SPACES_SET.contains(lexer.getTokenType())) { lexer.advance(); } }
skipWhitespacesAndComments
28,975
boolean (@NotNull PsiReference reference, @NotNull JavaCallHierarchyData data) { PsiClass originalClass = data.getOriginalClass(); PsiMethod method = data.getMethod(); Set<? extends PsiMethod> methodsToFind = data.getMethodsToFind(); PsiMethod methodToFind = data.getMethodToFind(); PsiClassType originalType = data.getOriginalType(); Map<PsiMember, NodeDescriptor<?>> methodToDescriptorMap = data.getResultMap(); Project project = data.getProject(); if (reference instanceof GrReferenceExpression) { GrExpression qualifier = ((GrReferenceExpression)reference).getQualifierExpression(); if (org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.isSuperReference(qualifier)) { // filter super.foo() call inside foo() and similar cases (bug 8411) PsiClass superClass = PsiUtil.resolveClassInType(qualifier.getType()); if (superClass == null || originalClass.isInheritor(superClass, true)) { return false; } } if (qualifier != null && !methodToFind.hasModifierProperty(PsiModifier.STATIC)) { PsiType qualifierType = qualifier.getType(); if (qualifierType instanceof PsiClassType && !TypeConversionUtil.isAssignable(qualifierType, originalType) && methodToFind != method) { PsiClass psiClass = ((PsiClassType)qualifierType).resolve(); if (psiClass != null) { PsiMethod callee = psiClass.findMethodBySignature(methodToFind, true); if (callee != null && !methodsToFind.contains(callee)) { // skip sibling methods return false; } } } } } else { if (!(reference instanceof PsiElement)) { return true; } PsiElement parent = ((PsiElement)reference).getParent(); if (parent instanceof PsiNewExpression) { if (((PsiNewExpression)parent).getClassReference() != reference) { return true; } } else if (parent instanceof GrAnonymousClassDefinition) { if (((GrAnonymousClassDefinition)parent).getBaseClassReferenceGroovy() != reference) { return true; } } else { return true; } } PsiElement element = reference.getElement(); PsiMember key = CallHierarchyNodeDescriptor.getEnclosingElement(element); synchronized (methodToDescriptorMap) { CallHierarchyNodeDescriptor d = (CallHierarchyNodeDescriptor)methodToDescriptorMap.get(key); if (d == null) { d = new CallHierarchyNodeDescriptor(project, (CallHierarchyNodeDescriptor)data.getNodeDescriptor(), element, false, true); methodToDescriptorMap.put(key, d); } else if (!d.hasReference(reference)) { d.incrementUsageCount(); } d.addReference(reference); } return true; }
process
28,976
JComponent () { myPanel = new JPanel(new BorderLayout(10, 5)); final JPanel contentPanel = new JPanel(new BorderLayout(4, 0)); myPanel.add(contentPanel, BorderLayout.NORTH); contentPanel.add(new JLabel(GroovyBundle.message("framework.0.home.label", myFrameworkName)), BorderLayout.WEST); myPathField = new TextFieldWithBrowseButton(); contentPanel.add(myPathField); myPathField .addBrowseFolderListener(GroovyBundle.message("select.framework.0.home.title", myFrameworkName), "", myProject, new FileChooserDescriptor(false, true, false, false, false, false) { @Override public boolean isFileSelectable(@Nullable VirtualFile file) { return file != null && isSdkHome(file); } }); return myPanel; }
createComponent
28,977
boolean (@Nullable VirtualFile file) { return file != null && isSdkHome(file); }
isFileSelectable
28,978
boolean () { return !(myPathField.getText().equals(StringUtil.notNullize(getStateText()))); }
isModified
28,979
void () { myPathField.setText(getStateText()); }
reset
28,980
void () { myPathField = null; myPanel = null; }
disposeUIResources
28,981
String () { return getHelpTopic(); }
getId
28,982
int (Editor editor, int tailOffset) { CommonCodeStyleSettings styleSettings = CodeStyle.getLocalLanguageSettings(editor, tailOffset); Document document = editor.getDocument(); CharSequence chars = document.getCharsSequence(); int textLength = chars.length(); if (tailOffset < textLength - 1 && chars.charAt(tailOffset) == ' ' && chars.charAt(tailOffset + 1) == '='){ return moveCaret(editor, tailOffset, 2); } if (tailOffset < textLength && chars.charAt(tailOffset) == '='){ return moveCaret(editor, tailOffset, 1); } if (styleSettings.SPACE_AROUND_ASSIGNMENT_OPERATORS){ document.insertString(tailOffset, " ="); tailOffset = moveCaret(editor, tailOffset, 2); } else{ document.insertString(tailOffset, "="); tailOffset = moveCaret(editor, tailOffset, 1); } if (styleSettings.SPACE_AROUND_ASSIGNMENT_OPERATORS){ tailOffset = insertChar(editor, tailOffset, ' '); } document.insertString(tailOffset, myText); return moveCaret(editor, tailOffset, myPosition); }
processTail
28,983
String (final SourcePosition position) { PsiElement element = findElementAt(position); while (true) { element = PsiTreeUtil.getParentOfType(element, GrTypeDefinition.class, PsiClassImpl.class); if (element == null || (element instanceof GrTypeDefinition && !((GrTypeDefinition)element).isAnonymous()) || (element instanceof PsiClassImpl && ((PsiClassImpl)element).getName() != null) ) { break; } } if (element != null) { return getClassNameForJvm((PsiClass)element); } return null; }
findEnclosingName
28,984
String (final PsiClass aClass) { final PsiClass psiClass = aClass.getContainingClass(); if (psiClass != null) { return getClassNameForJvm(psiClass) + "$" + aClass.getName(); } return aClass.getQualifiedName(); }
getClassNameForJvm
28,985
String (final SourcePosition position) { return ReadAction.compute(()->{ PsiElement element = findElementAt(position); if (element == null) return null; PsiElement sourceImage = PsiTreeUtil.getParentOfType(element, GrClosableBlock.class, GrTypeDefinition.class, PsiClassImpl.class); if (sourceImage instanceof PsiClass) { return getClassNameForJvm((PsiClass)sourceImage); } return null; }); }
getOuterClassName
28,986
PsiElement (SourcePosition position) { PsiFile file = position.getFile(); if (!(file instanceof GroovyFileBase) && !(file instanceof PsiJavaFile)) return null; return file.findElementAt(position.getOffset()); }
findElementAt
28,987
boolean (ReferenceType ownerClass, ReferenceType aClass) { String name = aClass.name(); String ownerClassName = ownerClass.name(); // return name == ownerClassName + "$$" + /[A-Za-z0-9]{8}/ return name.length() == ownerClassName.length() + 2 + 8 && name.startsWith(ownerClassName) && GENERATED_CLASS_NAME.matcher(name.substring(ownerClassName.length())).matches(); }
isSpringLoadedGeneratedClass
28,988
void (Set<ReferenceType> res, ReferenceType fromClass, int line) { if (!fromClass.isPrepared()) return; List<ReferenceType> nestedTypes = fromClass.nestedTypes(); ReferenceType springLoadedGeneratedClass = null; for (ReferenceType nested : nestedTypes) { if (!nested.isPrepared()) continue; if (isSpringLoadedGeneratedClass(fromClass, nested)) { if (springLoadedGeneratedClass == null || !springLoadedGeneratedClass.name().equals(nested.name())) { springLoadedGeneratedClass = nested; // Only latest generated classes should be used. } } else { findNested(res, nested, line); } } try { final int lineNumber = line + 1; ReferenceType effectiveRef = springLoadedGeneratedClass == null ? fromClass : springLoadedGeneratedClass; if (!DebuggerUtilsAsync.locationsOfLineSync(effectiveRef, lineNumber).isEmpty()) { res.add(effectiveRef); } } catch (ObjectCollectedException | AbsentInformationException ignored) { } }
findNested
28,989
PositionManager (@NotNull final DebugProcess process) { return usesSpringLoaded(process) ? new SpringLoadedPositionManager(process) : null; }
createPositionManager
28,990
boolean (@NotNull final DebugProcess process) { Boolean force = process.getProcessHandler().getUserData(FORCE_SPRINGLOADED); if (force == Boolean.TRUE) return true; if (ReadAction.compute(()->{ JavaPsiFacade facade = JavaPsiFacade.getInstance(process.getProject()); if (facade.findPackage("com.springsource.loaded") != null || facade.findPackage("org.springsource.loaded") != null) { return true; } return false; })) { return true; } // Check spring loaded for remote process VirtualMachineProxy proxy = process.getVirtualMachineProxy(); return !proxy.classesByName("com.springsource.loaded.agent.SpringLoadedAgent").isEmpty() || !proxy.classesByName("org.springsource.loaded.agent.SpringLoadedAgent").isEmpty(); }
usesSpringLoaded
28,991
List<TargetTypeBuildScope> (@NotNull CompileScope baseScope, @NotNull Project project, boolean forceBuild) { Boolean checkResourcesRebuild = baseScope.getUserData(GroovyResourceChecker.CHECKING_RESOURCES_REBUILD); if (checkResourcesRebuild == null) return Collections.emptyList(); forceBuild |= checkResourcesRebuild; return JBIterable.of(createTargets(project, forceBuild, JavaResourceRootType.RESOURCE, CheckResourcesTarget.PRODUCTION), createTargets(project, forceBuild, JavaResourceRootType.TEST_RESOURCE, CheckResourcesTarget.TESTS)). filter(Conditions.notNull()).toList(); }
getBuildTargetScopes
28,992
TargetTypeBuildScope (@NotNull Project project, boolean forceBuild, final JavaResourceRootType rootType, final CheckResourcesTarget.Type targetType) { List<Module> withResources = getModulesWithGroovyResources(project, rootType); return withResources.isEmpty() ? null : CmdlineProtoUtil.createTargetsScope(targetType.getTypeId(), ContainerUtil.map(withResources, Module::getName), forceBuild); }
createTargets
28,993
List<Module> (@NotNull Project project, @NotNull JpsModuleSourceRootType<?> rootType) { return ContainerUtil.filter(ModuleManager.getInstance(project).getModules(), module -> containsGroovyResources(rootType, module, false)); }
getModulesWithGroovyResources
28,994
boolean (@NotNull JpsModuleSourceRootType<?> rootType, Module module, boolean isSmartMode) { return ContainerUtil .exists(ModuleRootManager.getInstance(module).getSourceRoots(rootType), root -> containsGroovyResources(module, root, isSmartMode)); }
containsGroovyResources
28,995
boolean (Module module, VirtualFile root, boolean isSmartMode) { if (isSmartMode) { Collection<?> files = FileTypeIndex.getFiles(GroovyFileType.GROOVY_FILE_TYPE, GlobalSearchScopes.directoryScope(module.getProject(), root, true)); return !files.isEmpty(); } else { return !ModuleRootManager.getInstance(module).getFileIndex().iterateContentUnderDirectory(root, file -> { if (!file.isDirectory() && FileTypeRegistry.getInstance().isFileOfType(file, GroovyFileType.GROOVY_FILE_TYPE)) { return false; // found } return true; }); } }
containsGroovyResources
28,996
JpsGroovySettings () { final JpsGroovySettings bean = new JpsGroovySettings(); bean.configScript = myConfigScript; bean.invokeDynamic = myInvokeDynamic; bean.transformsOk = transformsOk; myExcludeFromStubGeneration.writeExternal(bean.excludes); return bean; }
getState
28,997
ExcludesConfiguration (Project project) { return getInstance(project).myExcludeFromStubGeneration; }
getExcludeConfiguration
28,998
ExcludesConfiguration () { return myExcludeFromStubGeneration; }
getExcludeFromStubGeneration
28,999
void (@NotNull JpsGroovySettings state) { myConfigScript = state.configScript; myInvokeDynamic = state.invokeDynamic; transformsOk = state.transformsOk; myExcludeFromStubGeneration.readExternal(state.excludes); }
loadState