Cleanup (formatting; typos; dead code)

This commit is contained in:
Roman Shevchenko
2016-02-16 17:09:46 +01:00
parent 69ff8d60a9
commit 44b436c9f0
12 changed files with 99 additions and 201 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -85,7 +85,7 @@ public class PatternPackageSetParserExtension implements PackageSetParserExtensi
wasIdentifier = false;
}
else if (lexer.getTokenType() == ScopeTokenTypes.IDENTIFIER) {
if (wasIdentifier) error(AnalysisScopeBundle.message("error.packageset.token.expectations", getTokenText(lexer)), lexer);
if (wasIdentifier) error(AnalysisScopeBundle.message("error.package.set.token.expectations", getTokenText(lexer)), lexer);
wasIdentifier = true;
pattern.append(getTokenText(lexer));
}
@@ -96,7 +96,7 @@ public class PatternPackageSetParserExtension implements PackageSetParserExtensi
}
if (pattern.length() == 0) {
error(AnalysisScopeBundle.message("error.packageset.pattern.expectations"), lexer);
error(AnalysisScopeBundle.message("error.package.set.pattern.expectations"), lexer);
}
return pattern.toString();
@@ -111,6 +111,6 @@ public class PatternPackageSetParserExtension implements PackageSetParserExtensi
private static void error(String message, Lexer lexer) throws ParsingException {
throw new ParsingException(
AnalysisScopeBundle.message("error.packageset.position.parsing.error", message, (lexer.getTokenStart() + 1)));
AnalysisScopeBundle.message("error.package.set.position.parsing.error", message, (lexer.getTokenStart() + 1)));
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,25 +45,16 @@ class ClsPackageStatementImpl extends ClsElementImpl implements PsiPackageStatem
return myFile;
}
/**
* @not_implemented
*/
@Override
public PsiJavaCodeReferenceElement getPackageReference() {
throw new UnsupportedOperationException("Method not implemented");
}
/**
* @not_implemented
*/
@Override
public PsiModifierList getAnnotationList() {
throw new UnsupportedOperationException("Method not implemented");
}
/**
* @not_implemented
*/
@Override
@NotNull
public PsiElement[] getChildren() {
@@ -101,4 +92,4 @@ class ClsPackageStatementImpl extends ClsElementImpl implements PsiPackageStatem
public String toString() {
return "PsiPackageStatement:" + getPackageName();
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -123,24 +123,6 @@ public class PsiExpressionListImpl extends CompositePsiElement implements PsiExp
TreeElement firstAdded = super.addInternal(first, last, anchor, before);
if (ElementType.EXPRESSION_BIT_SET.contains(first.getElementType())) {
JavaSourceUtil.addSeparatingComma(this, first, ElementType.EXPRESSION_BIT_SET);
/*ASTNode element = first;
for (ASTNode child = element.getTreeNext(); child != null; child = child.getTreeNext()) {
if (child.getElementType() == JavaTokenType.COMMA) break;
if (ElementType.EXPRESSION_BIT_SET.contains(child.getElementType())) {
TreeElement comma = Factory.createSingleLeafElement(JavaTokenType.COMMA, ",", 0, 1, treeCharTab, getManager());
super.addInternal(comma, comma, element, Boolean.FALSE);
break;
}
}
for (ASTNode child = element.getTreePrev(); child != null; child = child.getTreePrev()) {
final IElementType t = child.getElementType();
if (t == JavaTokenType.COMMA) break;
if (ElementType.EXPRESSION_BIT_SET.contains(t) || ElementType.JAVA_COMMENT_BIT_SET.contains(t)) {
TreeElement comma = Factory.createSingleLeafElement(JavaTokenType.COMMA, ",", 0, 1, treeCharTab, getManager());
super.addInternal(comma, comma, child, Boolean.FALSE);
break;
}
}*/
}
return firstAdded;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,15 +24,15 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Locale;
/**
* @author ven
* @noinspection HardCodedStringLiteral
* @noinspection UseOfSystemOutOrSystemErr
*/
public class AppMain {
private static final String PROPERTY_PORT_NUMBER = "idea.launcher.port";
private static final String PROPERTY_BINPATH = "idea.launcher.bin.path";
private static final String PROPERTY_BIN_PATH = "idea.launcher.bin.path";
private static final String JAVAFX_LAUNCHER = "com.sun.javafx.application.LauncherImpl";
private static final String LAUNCH_APPLICATION_METHOD_NAME = "launchApplication";
@@ -41,31 +41,19 @@ public class AppMain {
private static boolean ourHasSecurityProblem = false;
static {
try {
String binPath = System.getProperty(PROPERTY_BINPATH) + File.separator;
final String osName = System.getProperty("os.name").toLowerCase();
String arch = System.getProperty("os.arch").toLowerCase();
String binPath = System.getProperty(PROPERTY_BIN_PATH) + File.separator;
String osName = System.getProperty("os.name").toLowerCase(Locale.US);
String arch = System.getProperty("os.arch").toLowerCase(Locale.US);
String libPath = null;
if (osName.startsWith("windows")) {
if (arch.equals("amd64")) {
libPath = binPath + "breakgen64.dll";
}
else {
libPath = binPath + "breakgen.dll";
}
} else if (osName.startsWith("linux")) {
if (arch.equals("amd64")) {
libPath = binPath + "libbreakgen64.so";
} else {
libPath = binPath + "libbreakgen.so";
}
} else if (osName.startsWith("mac")) {
if (arch.endsWith("64")) {
libPath = binPath + "libbreakgen64.jnilib";
} else {
libPath = binPath + "libbreakgen.jnilib";
}
libPath = binPath + (arch.equals("amd64") ? "breakgen64.dll" : "breakgen.dll");
}
else if (osName.startsWith("linux")) {
libPath = binPath + (arch.equals("amd64") ? "libbreakgen64.so" : "libbreakgen.so");
}
else if (osName.startsWith("mac")) {
libPath = binPath + (arch.endsWith("64") ? "libbreakgen64.jnilib" : "libbreakgen.jnilib");
}
if (libPath != null) {
System.load(libPath);
}
@@ -87,45 +75,58 @@ public class AppMain {
public void run() {
try {
ServerSocket socket = new ServerSocket(portNumber);
Socket client = socket.accept();
BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream()));
while (true) {
String msg = reader.readLine();
if ("TERM".equals(msg)){
return;
try {
Socket client = socket.accept();
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream()));
try {
while (true) {
String msg = reader.readLine();
if ("TERM".equals(msg)) {
return;
}
else if ("BREAK".equals(msg)) {
triggerControlBreak();
}
else if ("STOP".equals(msg)) {
System.exit(1);
}
}
}
finally {
reader.close();
}
}
else if ("BREAK".equals(msg)) {
triggerControlBreak();
}
else if ("STOP".equals(msg)) {
System.exit(1);
finally {
client.close();
}
}
} catch (IOException ignored) {
} catch (IllegalArgumentException ignored) {
} catch (SecurityException ignored) {
finally {
socket.close();
}
}
catch (IOException ignored) { }
catch (IllegalArgumentException ignored) { }
catch (SecurityException ignored) { }
}
}, "Monitor Ctrl-Break");
try {
t.setDaemon(true);
t.start();
} catch (Exception ignored) {}
} catch (Exception ignored) { }
}
String mainClass = args[0];
String[] parms = new String[args.length - 1];
for (int j = 1; j < args.length; j++) {
parms[j - 1] = args[j];
}
final Class appClass = Class.forName(mainClass);
String[] params = new String[args.length - 1];
System.arraycopy(args, 1, params, 0, args.length - 1);
Class appClass = Class.forName(mainClass);
Method m;
try {
m = appClass.getMethod("main", new Class[]{parms.getClass()});
m = appClass.getMethod("main", new Class[]{params.getClass()});
}
catch (NoSuchMethodException e) {
if (!startJavaFXApplication(parms, appClass)) {
if (!startJavaFXApplication(params, appClass)) {
throw e;
}
return;
@@ -135,41 +136,31 @@ public class AppMain {
System.err.println("main method should be static");
return;
}
if (!void.class.isAssignableFrom(m.getReturnType())) {
System.err.println("main method must return a value of type void");
return;
}
try {
ensureAccess(m);
m.invoke(null, new Object[]{parms});
} catch (InvocationTargetException ite) {
m.setAccessible(true);
m.invoke(null, new Object[]{params});
}
catch (InvocationTargetException ite) {
throw ite.getTargetException();
}
}
private static boolean startJavaFXApplication(String[] parms, Class appClass) throws NoSuchMethodException {
private static boolean startJavaFXApplication(String[] params, Class appClass) throws NoSuchMethodException {
try {
//check in launch method for application class in the stack trace leads to this hack here
final Method launchApplication = Class.forName(JAVAFX_LAUNCHER).getMethod(LAUNCH_APPLICATION_METHOD_NAME,
new Class[]{appClass.getClass(), parms.getClass()});
launchApplication.invoke(null, new Object[] {appClass, parms});
Class[] types = {appClass.getClass(), params.getClass()};
Method launchApplication = Class.forName(JAVAFX_LAUNCHER).getMethod(LAUNCH_APPLICATION_METHOD_NAME, types);
launchApplication.invoke(null, new Object[] {appClass, params});
return true;
}
catch (Throwable e) {
return false;
}
}
private static void ensureAccess(Object reflectionObject) {
// need to call setAccessible here in order to be able to launch package-local classes
// calling setAccessible() via reflection because the method is missing from java version 1.1.x
final Class aClass = reflectionObject.getClass();
try {
final Method setAccessibleMethod = aClass.getMethod("setAccessible", new Class[] {boolean.class});
setAccessibleMethod.invoke(reflectionObject, new Object[] {Boolean.TRUE});
}
catch (Exception e) {
// the method not found
}
}
}
}
@@ -1,62 +0,0 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.rt.execution.application;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
/**
* @author ven
*/
public class MainAppClassLoader extends URLClassLoader {
/**
* @noinspection HardCodedStringLiteral
*/
private static final String USER_CLASSPATH = "idea.user.classpath";
private final Class myAppMainClass;
private static URL[] makeUrls() {
List classpath = new ArrayList();
try {
String userClassPath = System.getProperty(USER_CLASSPATH, "");
StringTokenizer tokenizer = new StringTokenizer(userClassPath, File.pathSeparator, false);
while (tokenizer.hasMoreTokens()) {
String pathItem = tokenizer.nextToken();
classpath.add(new File(pathItem).toURL());
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
return (URL[]) classpath.toArray(new URL[classpath.size()]);
}
public MainAppClassLoader(ClassLoader loader) {
super(makeUrls(), null);
myAppMainClass = AppMain.class;
}
protected synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException {
if (name.equals(myAppMainClass.getName())) {
return myAppMainClass;
}
return super.loadClass(name, resolve);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.psi.impl;
import com.intellij.openapi.fileTypes.FileTypeRegistry;
@@ -33,15 +32,15 @@ public class CheckUtil {
public static void checkWritable(@NotNull final PsiElement element) throws IncorrectOperationException {
if (!element.isWritable()) {
if (element instanceof PsiDirectory) {
throw new IncorrectOperationException(
PsiBundle.message("cannot.modify.a.read.only.directory", ((PsiDirectory)element).getVirtualFile().getPresentableUrl()));
String url = ((PsiDirectory)element).getVirtualFile().getPresentableUrl();
throw new IncorrectOperationException(PsiBundle.message("cannot.modify.a.read.only.directory", url));
}
else {
PsiFile file = element.getContainingFile();
if (file == null) {
throw new IncorrectOperationException();
}
final VirtualFile virtualFile = file.getVirtualFile();
VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) {
throw new IncorrectOperationException();
}
@@ -64,4 +63,4 @@ public class CheckUtil {
}
});
}
}
}
@@ -29,7 +29,7 @@
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/AnalysisScopeBundle" key="scope.option.uncommited.files"/>
<text resource-bundle="messages/AnalysisScopeBundle" key="scope.option.uncommitted.files"/>
</properties>
</component>
<component id="179bb" class="javax.swing.JRadioButton" binding="myFileButton">
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -72,7 +72,7 @@ public class BaseAnalysisActionDialog extends DialogWrapper {
private final String myAnalysisNoon;
private ButtonGroup myGroup;
private static final String ALL = AnalysisScopeBundle.message("scope.option.uncommited.files.all.changelists.choice");
private static final String ALL = AnalysisScopeBundle.message("scope.option.uncommitted.files.all.changelists.choice");
private final AnalysisUIOptions myAnalysisOptions;
@Nullable private final PsiElement myContext;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -66,7 +66,7 @@ public class FilePackageSetParserExtension implements PackageSetParserExtension
pattern.append("/");
}
else if (lexer.getTokenType() == ScopeTokenTypes.IDENTIFIER || lexer.getTokenType() == ScopeTokenTypes.INTEGER_LITERAL) {
if (wasIdentifier) error(lexer, AnalysisScopeBundle.message("error.packageset.token.expectations", getTokenText(lexer)));
if (wasIdentifier) error(lexer, AnalysisScopeBundle.message("error.package.set.token.expectations", getTokenText(lexer)));
wasIdentifier = lexer.getTokenType() == ScopeTokenTypes.IDENTIFIER;
pattern.append(getTokenText(lexer));
}
@@ -101,7 +101,7 @@ public class FilePackageSetParserExtension implements PackageSetParserExtension
}
if (pattern.length() == 0) {
error(lexer, AnalysisScopeBundle.message("error.packageset.pattern.expectations"));
error(lexer, AnalysisScopeBundle.message("error.package.set.pattern.expectations"));
}
return pattern.toString();
@@ -115,6 +115,6 @@ public class FilePackageSetParserExtension implements PackageSetParserExtension
private static void error(Lexer lexer, String message) throws ParsingException {
throw new ParsingException(
AnalysisScopeBundle.message("error.packageset.position.parsing.error", message, (lexer.getTokenStart() + 1)));
AnalysisScopeBundle.message("error.package.set.position.parsing.error", message, (lexer.getTokenStart() + 1)));
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@ public class PackageSetFactoryImpl extends PackageSetFactory {
public PackageSet parse() throws ParsingException {
PackageSet set = parseUnion();
if (myLexer.getTokenType() != null) error(AnalysisScopeBundle.message("error.packageset.token.expectations", getTokenText()));
if (myLexer.getTokenType() != null) error(AnalysisScopeBundle.message("error.package.set.token.expectations", getTokenText()));
return set;
}
@@ -142,7 +142,7 @@ public class PackageSetFactoryImpl extends PackageSetFactory {
myLexer.advance();
}
if (pattern.length() == 0) {
error(AnalysisScopeBundle.message("error.packageset.pattern.expectations"));
error(AnalysisScopeBundle.message("error.package.set.pattern.expectations"));
}
return pattern.toString();
}
@@ -152,7 +152,7 @@ public class PackageSetFactoryImpl extends PackageSetFactory {
myLexer.advance();
PackageSet result = parseUnion();
if (myLexer.getTokenType() != ScopeTokenTypes.RPARENTH) error(AnalysisScopeBundle.message("error.packageset.rparen.expected"));
if (myLexer.getTokenType() != ScopeTokenTypes.RPARENTH) error(AnalysisScopeBundle.message("error.package.set.rparen.expected"));
myLexer.advance();
return result;
@@ -160,7 +160,7 @@ public class PackageSetFactoryImpl extends PackageSetFactory {
private void error(String message) throws ParsingException {
throw new ParsingException(
AnalysisScopeBundle.message("error.packageset.position.parsing.error", message, (myLexer.getTokenStart() + 1)));
AnalysisScopeBundle.message("error.package.set.position.parsing.error", message, (myLexer.getTokenStart() + 1)));
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,6 @@ import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.util.io.HttpRequests;
import org.jetbrains.annotations.NotNull;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.Collection;
import java.util.LinkedList;
@@ -27,21 +26,18 @@ import java.util.List;
class DevelopersLoader {
private static final String DEVELOPERS_LIST_URL = "http://ea-engine.labs.intellij.net/data?category=developers";
public static final int TIMEOUT = 1000;
private DevelopersLoader() {
}
private DevelopersLoader() { }
public static Collection<Developer> fetchDevelopers(@NotNull final ProgressIndicator indicator) throws IOException {
public static Collection<Developer> fetchDevelopers(@NotNull ProgressIndicator indicator) throws IOException {
return HttpRequests.request(DEVELOPERS_LIST_URL).connect(new HttpRequests.RequestProcessor<Collection<Developer>>() {
@Override
public Collection<Developer> process(@NotNull HttpRequests.Request request) throws IOException {
List<Developer> developers = new LinkedList<Developer>();
developers.add(Developer.NULL);
BufferedReader reader = request.getReader();
while (true) {
String line = reader.readLine();
if (line == null) break;
String line;
while ((line = request.getReader().readLine()) != null) {
int i = line.indexOf('\t');
if (i == -1) throw new IOException("Protocol error");
int id = Integer.parseInt(line.substring(0, i));
@@ -49,8 +45,9 @@ class DevelopersLoader {
developers.add(new Developer(id, name));
indicator.checkCanceled();
}
return developers;
}
});
}
}
}
@@ -84,10 +84,10 @@ dependencies.tree.node.default.package.abbreviation=<default package>
#scope selector
dependencies.libraries.node.text=Libraries
error.packageset.token.expectations=Unexpected ''{0}''
error.packageset.pattern.expectations=Package pattern expected
error.packageset.rparen.expected=')' expected
error.packageset.position.parsing.error={0} at position {1}
error.package.set.token.expectations=Unexpected ''{0}''
error.package.set.pattern.expectations=Package pattern expected
error.package.set.rparen.expected=')' expected
error.package.set.position.parsing.error={0} at position {1}
#dependencies configurations
status.bar.no.rule.violation.message=No rules are violated
@@ -100,8 +100,8 @@ dependency.configurable.allow.table.column2=only in
scope.display.name.deny.scope=Deny usages of scope ''{0}'' in scope ''{1}''
scope.display.name.allow.scope=Allow usages of scope ''{0}'' in scope ''{1}''
scope.option.uncommited.files=&Uncommitted files
scope.option.uncommited.files.all.changelists.choice=All
scope.option.uncommitted.files=&Uncommitted files
scope.option.uncommitted.files.all.changelists.choice=All
scanning.scope.progress.title=Scanning scope ...
analyzing.project=Analyzing Project
checking.class.files=Checking Class Files