mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1,9 +1,16 @@
|
||||
package org.jetbrains.jps.javac;
|
||||
|
||||
import com.sun.source.tree.*;
|
||||
import com.sun.source.util.TreeScanner;
|
||||
import com.sun.source.util.Trees;
|
||||
|
||||
import javax.annotation.processing.AbstractProcessor;
|
||||
import javax.annotation.processing.ProcessingEnvironment;
|
||||
import javax.annotation.processing.RoundEnvironment;
|
||||
import javax.annotation.processing.SupportedAnnotationTypes;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.Modifier;
|
||||
import javax.lang.model.element.Name;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -15,12 +22,80 @@ import java.util.Set;
|
||||
//@SupportedSourceVersion(SourceVersion.RELEASE_7)
|
||||
@SupportedAnnotationTypes("*")
|
||||
public class JavacASTAnalyser extends AbstractProcessor{
|
||||
private Trees myTrees;
|
||||
private final boolean mySuppressOtherProcessors;
|
||||
|
||||
public JavacASTAnalyser(boolean suppressOtherProcessors) {
|
||||
mySuppressOtherProcessors = suppressOtherProcessors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(ProcessingEnvironment processingEnv) {
|
||||
super.init(processingEnv);
|
||||
myTrees = Trees.instance(processingEnv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||
MyAnalyzer scaner = new MyAnalyzer();
|
||||
for (Element element : roundEnv.getRootElements()) {
|
||||
System.out.println("Element: " + element.getSimpleName());
|
||||
final Tree tree = myTrees.getTree(element);
|
||||
scaner.scan(tree, myTrees);
|
||||
}
|
||||
return false;
|
||||
|
||||
return mySuppressOtherProcessors;
|
||||
}
|
||||
|
||||
|
||||
private static class MyAnalyzer extends TreeScanner<Object, Trees> {
|
||||
@Override
|
||||
public Object visitImport(ImportTree node, Trees trees) {
|
||||
return null/*super.visitImport(node, trees)*/;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitClass(ClassTree node, Trees trees) {
|
||||
return scan(node.getMembers(), trees);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitVariable(VariableTree node, Trees trees) {
|
||||
final ModifiersTree modifiers = node.getModifiers();
|
||||
final Set<Modifier> flags = modifiers.getFlags();
|
||||
if (flags.contains(Modifier.STATIC) && flags.contains(Modifier.FINAL)) {
|
||||
final Name variableName = node.getName();
|
||||
// todo register constant
|
||||
final ConstantRefsFinder finder = new ConstantRefsFinder();
|
||||
finder.scan(node.getInitializer(), trees);
|
||||
// todo: process found refs
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitMethod(MethodTree node, Trees trees) {
|
||||
final ConstantRefsFinder finder = new ConstantRefsFinder();
|
||||
finder.scan(node.getBody(), trees);
|
||||
// todo: process found refs
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConstantRefsFinder extends TreeScanner<Object, Trees> {
|
||||
@Override
|
||||
public Object visitMethodInvocation(MethodInvocationTree node, Trees trees) {
|
||||
return scan(node.getArguments(), trees);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitMemberSelect(MemberSelectTree node, Trees trees) {
|
||||
return super.visitMemberSelect(node, trees);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitIdentifier(IdentifierTree node, Trees trees) {
|
||||
return super.visitIdentifier(node, trees);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,10 @@ import java.util.*;
|
||||
*/
|
||||
public class JavacMain {
|
||||
private static final Set<String> FILTERED_OPTIONS = new HashSet<String>(Arrays.<String>asList(
|
||||
"-verbose", "-d", "-classpath", "-cp", "-bootclasspath"/*, "-proc:none"*/
|
||||
"-d", "-classpath", "-cp", "-bootclasspath"
|
||||
));
|
||||
private static final Set<String> FILTERED_SINGLE_OPTIONS = new HashSet<String>(Arrays.<String>asList(
|
||||
"-verbose", "-proc:none"
|
||||
));
|
||||
|
||||
public static boolean compile(Collection<String> options,
|
||||
@@ -65,7 +68,7 @@ public class JavacMain {
|
||||
final JavaCompiler.CompilationTask task = compiler.getTask(
|
||||
out, fileManager, outConsumer, filterOptionList(options), null, fileManager.toJavaFileObjects(sources)
|
||||
);
|
||||
//final JavacASTAnalyser analyzer = new JavacASTAnalyser();
|
||||
//final JavacASTAnalyser analyzer = new JavacASTAnalyser(shouldSuppressAnnotationProcessing(options));
|
||||
//task.setProcessors(Collections.singleton(analyzer));
|
||||
return task.call();
|
||||
}
|
||||
@@ -74,6 +77,15 @@ public class JavacMain {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean shouldSuppressAnnotationProcessing(final Collection<String> options) {
|
||||
for (String option : options) {
|
||||
if ("-proc:none".equals(option)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Collection<String> filterOptionList(final Collection<String> options) {
|
||||
if (options.isEmpty()) {
|
||||
return options;
|
||||
@@ -86,7 +98,9 @@ public class JavacMain {
|
||||
continue;
|
||||
}
|
||||
if (!skip) {
|
||||
result.add(option);
|
||||
if (!FILTERED_SINGLE_OPTIONS.contains(option)) {
|
||||
result.add(option);
|
||||
}
|
||||
}
|
||||
skip = false;
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ public class VMOptions {
|
||||
}
|
||||
|
||||
final String productName = ApplicationNamesInfo.getInstance().getProductName().toLowerCase();
|
||||
final String platformSuffix = SystemInfo.is64Bit ? "64" : "";
|
||||
final String platformSuffix = (SystemInfo.is64Bit && !SystemInfo.isLinux) ? "64" : "";
|
||||
final String osSuffix = SystemInfo.isWindows ? ".exe" : "";
|
||||
return PathManager.getBinPath() + File.separatorChar + productName + platformSuffix + osSuffix + ".vmoptions";
|
||||
}
|
||||
|
||||
@@ -142,6 +142,12 @@ public class PluginRunConfiguration extends RunConfigurationBase implements Modu
|
||||
vm.defineProperty("apple.laf.useScreenMenuBar", "true");
|
||||
}
|
||||
|
||||
if (SystemInfo.isLinux) {
|
||||
if (VM_PARAMETERS == null || !VM_PARAMETERS.contains("-Dsun.awt.disablegrab")) {
|
||||
vm.defineProperty("sun.awt.disablegrab", "true"); // See http://devnet.jetbrains.net/docs/DOC-1142
|
||||
}
|
||||
}
|
||||
|
||||
String buildNumber = IdeaJdk.getBuildNumber(usedIdeaJdk.getHomePath());
|
||||
if (buildNumber != null) {
|
||||
if (buildNumber.startsWith("IC")) {
|
||||
@@ -205,11 +211,12 @@ public class PluginRunConfiguration extends RunConfigurationBase implements Modu
|
||||
this.ALTERNATIVE_JRE_PATH_ENABLED = ALTERNATIVE_JRE_PATH_ENABLED;
|
||||
}
|
||||
|
||||
private static void fillParameterList(ParametersList list, String value) {
|
||||
final String[] parameters = value != null ? value.split(" ") : null;
|
||||
for (int i = 0; parameters != null && i < parameters.length; i++) {
|
||||
if (parameters[i] != null && parameters[i].length() > 0){
|
||||
list.add(parameters[i]);
|
||||
private static void fillParameterList(ParametersList list, @Nullable String value) {
|
||||
if (value == null) return;
|
||||
|
||||
for (String parameter : value.split(" ")) {
|
||||
if (parameter != null && parameter.length() > 0) {
|
||||
list.add(parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user