Skip to content

Commits on Source 5

......@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.core.contenttype; singleton:=true
Bundle-Version: 3.7.300.qualifier
Bundle-Version: 3.7.400.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Require-Bundle: org.eclipse.equinox.preferences;bundle-version="[3.2.0,4.0.0)",
......
......@@ -14,11 +14,11 @@
<parent>
<artifactId>eclipse.platform.runtime</artifactId>
<groupId>eclipse.platform.runtime</groupId>
<version>4.12.0-SNAPSHOT</version>
<version>4.13.0-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>
<groupId>org.eclipse.core</groupId>
<artifactId>org.eclipse.core.contenttype</artifactId>
<version>3.7.300-SNAPSHOT</version>
<version>3.7.400-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
......@@ -44,9 +44,7 @@ public final class ContentTypeCatalog {
* A sorting policy where the more generic content type wins. Lexicographical comparison is done
* as a last resort when all other criteria fail.
*/
private final Comparator<IContentType> policyConstantGeneralIsBetter = new Comparator<IContentType>() {
@Override
public int compare(IContentType o1, IContentType o2) {
private final Comparator<IContentType> policyConstantGeneralIsBetter = (IContentType o1, IContentType o2) -> {
ContentType type1 = (ContentType) o1;
ContentType type2 = (ContentType) o2;
// first criteria: depth - the lower, the better
......@@ -59,16 +57,13 @@ public final class ContentTypeCatalog {
return -priorityCriteria;
// they have same depth and priority - choose one arbitrarily (stability is important)
return type1.getId().compareTo(type2.getId());
}
};
/**
* A sorting policy where the more specific content type wins. Lexicographical comparison is done
* as a last resort when all other criteria fail.
*/
private Comparator<IContentType> policyConstantSpecificIsBetter = new Comparator<IContentType>() {
@Override
public int compare(IContentType o1, IContentType o2) {
private Comparator<IContentType> policyConstantSpecificIsBetter = (IContentType o1, IContentType o2) -> {
ContentType type1 = (ContentType) o1;
ContentType type2 = (ContentType) o2;
// first criteria: depth - the higher, the better
......@@ -81,15 +76,12 @@ public final class ContentTypeCatalog {
return -priorityCriteria;
// they have same depth and priority - choose one arbitrarily (stability is important)
return type1.getId().compareTo(type2.getId());
}
};
/**
* A sorting policy where the more general content type wins.
*/
private Comparator<IContentType> policyGeneralIsBetter = new Comparator<IContentType>() {
@Override
public int compare(IContentType o1, IContentType o2) {
private Comparator<IContentType> policyGeneralIsBetter = (IContentType o1, IContentType o2) -> {
ContentType type1 = (ContentType) o1;
ContentType type2 = (ContentType) o2;
// first criteria: depth - the lower, the better
......@@ -101,26 +93,20 @@ public final class ContentTypeCatalog {
if (priorityCriteria != 0)
return -priorityCriteria;
return 0;
}
};
/**
* A sorting policy where content types are sorted by id.
*/
private Comparator<IContentType> policyLexicographical = new Comparator<IContentType>() {
@Override
public int compare(IContentType o1, IContentType o2) {
private Comparator<IContentType> policyLexicographical = (IContentType o1, IContentType o2) -> {
ContentType type1 = (ContentType) o1;
ContentType type2 = (ContentType) o2;
return type1.getId().compareTo(type2.getId());
}
};
/**
* A sorting policy where the more specific content type wins.
*/
private Comparator<IContentType> policySpecificIsBetter = new Comparator<IContentType>() {
@Override
public int compare(IContentType o1, IContentType o2) {
private Comparator<IContentType> policySpecificIsBetter = (IContentType o1, IContentType o2) -> {
ContentType type1 = (ContentType) o1;
ContentType type2 = (ContentType) o2;
// first criteria: depth - the higher, the better
......@@ -132,7 +118,6 @@ public final class ContentTypeCatalog {
if (priorityCriteria != 0)
return -priorityCriteria;
return 0;
}
};
private static IContentType[] concat(IContentType[][] types) {
......@@ -440,10 +425,12 @@ public final class ContentTypeCatalog {
if (children == null)
// this content type has no sub-types - keep traversing the tree
return true;
for (int i = 0; i < children.length; i++)
if (!internalAccept(visitor, children[i]))
for (ContentType c : children) {
if (!internalAccept(visitor, c)) {
// stop the traversal
return false;
}
}
return true;
}
......
......@@ -272,7 +272,7 @@ public class ContentTypeManager extends ContentTypeMatcher implements IContentTy
// Add preferences for this content type.
String currentUserDefined = getContext().getNode(ContentType.PREF_USER_DEFINED)
.get(ContentType.PREF_USER_DEFINED, ContentType.EMPTY_STRING);
if (currentUserDefined.length() > 0) {
if (!currentUserDefined.isEmpty()) {
currentUserDefined += ContentType.PREF_USER_DEFINED__SEPARATOR;
}
getContext().getNode(ContentType.PREF_USER_DEFINED).put(ContentType.PREF_USER_DEFINED, currentUserDefined + id);
......
......@@ -120,19 +120,25 @@ public class Util {
*/
public static byte[] getByteOrderMark(InputStream input) throws IOException {
int first = input.read();
if (first == 0xEF) {
switch (first) {
case 0xEF:
//look for the UTF-8 Byte Order Mark (BOM)
int second = input.read();
int third = input.read();
if (second == 0xBB && third == 0xBF)
return IContentDescription.BOM_UTF_8;
} else if (first == 0xFE) {
break;
case 0xFE:
//look for the UTF-16 BOM
if (input.read() == 0xFF)
return IContentDescription.BOM_UTF_16BE;
} else if (first == 0xFF) {
break;
case 0xFF:
if (input.read() == 0xFE)
return IContentDescription.BOM_UTF_16LE;
break;
default:
break;
}
return null;
}
......
......@@ -111,9 +111,7 @@ public final class XMLRootHandler extends DefaultHandler implements LexicalHandl
// be sure validation is "off" or the feature to ignore DTD's will not apply
reader.setFeature("http://xml.org/sax/features/validation", false); //$NON-NLS-1$
reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); //$NON-NLS-1$
} catch (SAXNotRecognizedException e) {
// not a big deal if the parser does not recognize the features
} catch (SAXNotSupportedException e) {
} catch (SAXNotRecognizedException | SAXNotSupportedException e) {
// not a big deal if the parser does not support the features
}
return parser;
......
......@@ -179,7 +179,7 @@ public class XMLContentDescriber extends TextContentDescriber implements ITextCo
StringBuilder stringBuilder = new StringBuilder(100);
while (stringBuilder.length() < 100 && ((line = reader.readLine()) != null)) {
stringBuilder.append(line);
if (line.indexOf(XML_DECL_END) != -1) {
if (line.contains(XML_DECL_END)) {
String resultString = stringBuilder.toString();
return resultString.substring(0, resultString.indexOf(XML_DECL_END) + XML_DECL_END.length());
}
......@@ -231,7 +231,7 @@ public class XMLContentDescriber extends TextContentDescriber implements ITextCo
}
private boolean isCharsetValid(String charset) {
if (charset.length() == 0)
if (charset.isEmpty())
return false;
char c = charset.charAt(0);
......
......@@ -254,9 +254,7 @@ public final class XMLRootElementContentDescriber2 extends XMLContentDescriber i
// create list of qualified elements
if (elements != null) {
for (QualifiedElement qualifiedElement : elements) {
qualifiedElements.add(qualifiedElement);
}
qualifiedElements.addAll(elements);
}
elementsToFind = qualifiedElements.toArray(new QualifiedElement[qualifiedElements.size()]);
}
......
......@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.core.expressions; singleton:=true
Bundle-Version: 3.6.400.qualifier
Bundle-Version: 3.6.500.qualifier
Bundle-ClassPath: .
Bundle-Activator: org.eclipse.core.internal.expressions.ExpressionPlugin
Bundle-Vendor: %providerName
......
......@@ -20,4 +20,3 @@ bin.includes = plugin.xml,\
src.includes = about.html,\
schema/
source.. = src/
jre.compilation.profile = JavaSE-1.8
......@@ -14,11 +14,11 @@
<parent>
<artifactId>eclipse.platform.runtime</artifactId>
<groupId>eclipse.platform.runtime</groupId>
<version>4.12.0-SNAPSHOT</version>
<version>4.13.0-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>
<groupId>org.eclipse.core</groupId>
<artifactId>org.eclipse.core.expressions</artifactId>
<version>3.6.400-SNAPSHOT</version>
<version>3.6.500-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
......@@ -100,7 +100,7 @@ public abstract class PropertyTester implements IPropertyTester {
@Override
public final boolean handles(String namespace, String property) {
return fNamespace.equals(namespace) && fProperties.indexOf("," + property + ",") != -1; //$NON-NLS-1$//$NON-NLS-2$
return fNamespace.equals(namespace) && fProperties.contains("," + property + ","); //$NON-NLS-1$//$NON-NLS-2$
}
@Override
......
......@@ -48,7 +48,7 @@ public class AdaptExpression extends CompositeExpression {
public AdaptExpression(Element element) throws CoreException {
fTypeName= element.getAttribute(ATT_TYPE);
Expressions.checkAttribute(ATT_TYPE, fTypeName.length() > 0 ? fTypeName : null);
Expressions.checkAttribute(ATT_TYPE, fTypeName.isEmpty() ? null : fTypeName);
}
public AdaptExpression(String typeName) {
......
......@@ -54,7 +54,7 @@ public class CountExpression extends Expression {
public CountExpression(Element element) {
String size = element.getAttribute(ATT_VALUE);
initializeSize(size.length() > 0 ? size : null);
initializeSize(size.isEmpty() ? null : size);
}
public CountExpression(String size) {
......
......@@ -45,7 +45,7 @@ public class EqualsExpression extends Expression {
public EqualsExpression(Element element) throws CoreException {
String value= element.getAttribute(ATT_VALUE);
Expressions.checkAttribute(ATT_VALUE, value.length() > 0 ? value : null);
Expressions.checkAttribute(ATT_VALUE, value.isEmpty() ? null : value);
fExpectedValue= Expressions.convertArgument(value);
}
......
......@@ -271,7 +271,7 @@ public class Expressions {
public static boolean getOptionalBooleanAttribute(Element element, String attributeName) {
String value= element.getAttribute(attributeName);
if (value.length() == 0)
if (value.isEmpty())
return false;
return Boolean.valueOf(value).booleanValue();
}
......@@ -291,7 +291,7 @@ public class Expressions {
public static Object[] getArguments(Element element, String attributeName) throws CoreException {
String args= element.getAttribute(attributeName);
if (args.length() > 0) {
if (!args.isEmpty()) {
return parseArguments(args);
} else {
return EMPTY_ARGS;
......@@ -341,7 +341,7 @@ public class Expressions {
public static Object convertArgument(String arg) throws CoreException {
if (arg == null) {
return null;
} else if (arg.length() == 0) {
} else if (arg.isEmpty()) {
return arg;
} else if (arg.charAt(0) == '\'' && arg.charAt(arg.length() - 1) == '\'') {
return unEscapeString(arg.substring(1, arg.length() - 1));
......
......@@ -39,7 +39,7 @@ public class InstanceofExpression extends Expression {
public InstanceofExpression(Element element) throws CoreException {
fTypeName= element.getAttribute(ATT_VALUE);
Expressions.checkAttribute(ATT_VALUE, fTypeName.length() > 0 ? fTypeName : null);
Expressions.checkAttribute(ATT_VALUE, fTypeName.isEmpty() ? null : fTypeName);
}
public InstanceofExpression(String typeName) {
......
......@@ -110,9 +110,9 @@ public class IterateExpression extends CompositeExpression {
public IterateExpression(Element element) throws CoreException {
String opValue= element.getAttribute(ATT_OPERATOR);
initializeOperatorValue(opValue.length() > 0 ? opValue : null);
initializeOperatorValue(opValue.isEmpty() ? null : opValue);
String ifEmpty= element.getAttribute(ATT_IF_EMPTY);
initializeEmptyResultValue(ifEmpty.length() > 0 ? ifEmpty : null);
initializeEmptyResultValue(ifEmpty.isEmpty() ? null : ifEmpty);
}
public IterateExpression(String opValue) throws CoreException {
......
......@@ -80,7 +80,7 @@ public class PropertyTesterDescriptor implements IPropertyTester {
@Override
public boolean handles(String namespace, String property) {
return fNamespace.equals(namespace) && fProperties.indexOf("," + property + ",") != -1; //$NON-NLS-1$//$NON-NLS-2$
return fNamespace.equals(namespace) && fProperties.contains("," + property + ","); //$NON-NLS-1$//$NON-NLS-2$
}
@Override
......
......@@ -65,7 +65,7 @@ public class ReferenceExpression extends Expression {
public ReferenceExpression(Element element) throws CoreException {
fDefinitionId= element.getAttribute(ATT_DEFINITION_ID);
Expressions.checkAttribute(ATT_DEFINITION_ID, fDefinitionId.length() > 0 ? fDefinitionId : null);
Expressions.checkAttribute(ATT_DEFINITION_ID, fDefinitionId.isEmpty() ? null : fDefinitionId);
}
@Override
......