Skip to content

Commit

Permalink
fix: Replace org.antlr.misc.Nullable imports since they are no longer…
Browse files Browse the repository at this point in the history
… resolved by Detect
  • Loading branch information
crowleySynopsys committed May 19, 2020
1 parent b435252 commit db429cd
Show file tree
Hide file tree
Showing 18 changed files with 101 additions and 101 deletions.
Expand Up @@ -26,7 +26,7 @@
import java.util.List;

import org.antlr.v4.runtime.misc.NotNull;
import org.antlr.v4.runtime.misc.Nullable;
import org.jetbrains.annotations.Nullable;

import com.synopsys.integration.configuration.util.Category;
import com.synopsys.integration.configuration.util.Group;
Expand Down
Expand Up @@ -25,7 +25,7 @@
import java.util.Optional;

import org.antlr.v4.runtime.misc.NotNull;
import org.antlr.v4.runtime.misc.Nullable;
import org.jetbrains.annotations.Nullable;
import org.springframework.util.Assert;

import com.synopsys.integration.configuration.util.Bdo;
Expand Down
Expand Up @@ -26,7 +26,7 @@
import java.util.Optional;

import org.antlr.v4.runtime.misc.NotNull;
import org.antlr.v4.runtime.misc.Nullable;
import org.jetbrains.annotations.Nullable;
import org.springframework.util.Assert;

// An enum that can be the given ENUM or can be STRING
Expand Down
Expand Up @@ -26,7 +26,7 @@
import java.util.Set;

import org.antlr.v4.runtime.misc.NotNull;
import org.antlr.v4.runtime.misc.Nullable;
import org.jetbrains.annotations.Nullable;

import com.synopsys.integration.configuration.util.Bds;
import com.synopsys.integration.configuration.util.KeyUtils;
Expand Down
Expand Up @@ -25,7 +25,7 @@
import java.util.Set;

import org.antlr.v4.runtime.misc.NotNull;
import org.antlr.v4.runtime.misc.Nullable;
import org.jetbrains.annotations.Nullable;

// IMPORTANT
// A property source is responsible for responding with keys in the normalized form "example.key"
Expand Down
Expand Up @@ -25,7 +25,7 @@
import java.util.ArrayList;
import java.util.List;

import org.antlr.v4.runtime.misc.Nullable;
import org.jetbrains.annotations.Nullable;

class HelpJsonOption {
private String propertyName = "";
Expand Down
@@ -1,85 +1,85 @@
/**
* detectable
*
* Copyright (c) 2020 Synopsys, Inc.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.synopsys.integration.detectable.detectable.executable.impl;

import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

import org.antlr.v4.runtime.misc.Nullable;

import com.synopsys.integration.detectable.detectable.file.FileFinder;
import com.synopsys.integration.util.OperatingSystemType;

public class SimpleExecutableFinder {
private final List<String> extensions;
private final FileFinder fileFinder;

public static SimpleExecutableFinder forCurrentOperatingSystem(final FileFinder fileFinder) {
return SimpleExecutableFinder.forOperatingSystem(OperatingSystemType.determineFromSystem(), fileFinder);
}

public static SimpleExecutableFinder forOperatingSystem(final OperatingSystemType operatingSystemType, final FileFinder fileFinder) {
if (operatingSystemType == OperatingSystemType.WINDOWS) {
return new SimpleExecutableFinder(Arrays.asList(".cmd", ".bat", ".exe"), fileFinder);
} else {
return new SimpleExecutableFinder(Collections.emptyList(), fileFinder);
}
}

public SimpleExecutableFinder(final List<String> extensions, final FileFinder fileFinder) {
this.extensions = extensions;
this.fileFinder = fileFinder;
}

private List<String> executablesFromName(final String name) {
if (extensions.isEmpty()) {
return Collections.singletonList(name);
} else {
return extensions.stream().map(ext -> name + ext).collect(Collectors.toList());
}
}

@Nullable
public File findExecutable(final String executable, final File location) {
return findExecutable(executable, Collections.singletonList(location));
}

@Nullable
public File findExecutable(final String executable, final List<File> locations) {
final List<String> executables = executablesFromName(executable);

for (final File location : locations) {
for (final String possibleExecutable : executables) {
final File foundFile = fileFinder.findFile(location, possibleExecutable);
if (foundFile != null && foundFile.exists() && foundFile.canExecute()) {
return foundFile;
}
}
}

return null;
}
/**
* detectable
*
* Copyright (c) 2020 Synopsys, Inc.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.synopsys.integration.detectable.detectable.executable.impl;

import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

import org.jetbrains.annotations.Nullable;

import com.synopsys.integration.detectable.detectable.file.FileFinder;
import com.synopsys.integration.util.OperatingSystemType;

public class SimpleExecutableFinder {
private final List<String> extensions;
private final FileFinder fileFinder;

public static SimpleExecutableFinder forCurrentOperatingSystem(final FileFinder fileFinder) {
return SimpleExecutableFinder.forOperatingSystem(OperatingSystemType.determineFromSystem(), fileFinder);
}

public static SimpleExecutableFinder forOperatingSystem(final OperatingSystemType operatingSystemType, final FileFinder fileFinder) {
if (operatingSystemType == OperatingSystemType.WINDOWS) {
return new SimpleExecutableFinder(Arrays.asList(".cmd", ".bat", ".exe"), fileFinder);
} else {
return new SimpleExecutableFinder(Collections.emptyList(), fileFinder);
}
}

public SimpleExecutableFinder(final List<String> extensions, final FileFinder fileFinder) {
this.extensions = extensions;
this.fileFinder = fileFinder;
}

private List<String> executablesFromName(final String name) {
if (extensions.isEmpty()) {
return Collections.singletonList(name);
} else {
return extensions.stream().map(ext -> name + ext).collect(Collectors.toList());
}
}

@Nullable
public File findExecutable(final String executable, final File location) {
return findExecutable(executable, Collections.singletonList(location));
}

@Nullable
public File findExecutable(final String executable, final List<File> locations) {
final List<String> executables = executablesFromName(executable);

for (final File location : locations) {
for (final String possibleExecutable : executables) {
final File foundFile = fileFinder.findFile(location, possibleExecutable);
if (foundFile != null && foundFile.exists() && foundFile.canExecute()) {
return foundFile;
}
}
}

return null;
}
}
Expand Up @@ -27,7 +27,7 @@
import java.util.List;

import org.antlr.v4.runtime.misc.NotNull;
import org.antlr.v4.runtime.misc.Nullable;
import org.jetbrains.annotations.Nullable;

public interface FileFinder {
@Nullable
Expand Down
Expand Up @@ -24,7 +24,7 @@

import java.io.File;

import org.antlr.v4.runtime.misc.Nullable;
import org.jetbrains.annotations.Nullable;

import com.synopsys.integration.detectable.detectable.exception.DetectableException;

Expand Down
Expand Up @@ -26,7 +26,7 @@
import java.util.List;
import java.util.Optional;

import org.antlr.v4.runtime.misc.Nullable;
import org.jetbrains.annotations.Nullable;

public class BitbakeGraph {
private final List<BitbakeNode> nodes = new ArrayList<>();
Expand Down
Expand Up @@ -26,7 +26,7 @@
import java.util.Optional;

import org.antlr.v4.runtime.misc.NotNull;
import org.antlr.v4.runtime.misc.Nullable;
import org.jetbrains.annotations.Nullable;

public class BlackDuckConnectionDetails {
private final Boolean offline;
Expand Down
Expand Up @@ -23,7 +23,7 @@
package com.synopsys.integration.detect.configuration.connection;

import org.antlr.v4.runtime.misc.NotNull;
import org.antlr.v4.runtime.misc.Nullable;
import org.jetbrains.annotations.Nullable;

import com.synopsys.integration.detect.util.ProxyUtil;
import com.synopsys.integration.log.IntLogger;
Expand Down
Expand Up @@ -27,7 +27,7 @@
import java.util.List;
import java.util.Optional;

import org.antlr.v4.runtime.misc.Nullable;
import org.jetbrains.annotations.Nullable;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Expand Up @@ -25,7 +25,7 @@
import java.util.List;
import java.util.Optional;

import org.antlr.v4.runtime.misc.Nullable;
import org.jetbrains.annotations.Nullable;

import com.synopsys.integration.detect.DetectTool;
import com.synopsys.integration.detect.util.filter.DetectToolFilter;
Expand Down
Expand Up @@ -27,7 +27,7 @@
import java.util.List;
import java.util.Optional;

import org.antlr.v4.runtime.misc.Nullable;
import org.jetbrains.annotations.Nullable;

import com.synopsys.integration.detect.workflow.codelocation.DetectCodeLocation;
import com.synopsys.integration.detect.workflow.project.DetectToolProjectInfo;
Expand Down
Expand Up @@ -26,7 +26,7 @@
import java.util.List;
import java.util.Optional;

import org.antlr.v4.runtime.misc.Nullable;
import org.jetbrains.annotations.Nullable;

public class BinaryScanOptions {
private final Path singleTargetFilePath;
Expand Down
Expand Up @@ -26,7 +26,7 @@
import java.util.List;
import java.util.Optional;

import org.antlr.v4.runtime.misc.Nullable;
import org.jetbrains.annotations.Nullable;

import com.synopsys.integration.blackduck.codelocation.signaturescanner.command.IndividualFileMatching;
import com.synopsys.integration.blackduck.codelocation.signaturescanner.command.SnippetMatching;
Expand Down
Expand Up @@ -30,7 +30,7 @@
import java.util.Map;
import java.util.stream.Collectors;

import org.antlr.v4.runtime.misc.Nullable;
import org.jetbrains.annotations.Nullable;
import org.apache.commons.lang3.StringUtils;

import com.synopsys.integration.detect.workflow.file.DetectFileUtils;
Expand Down

0 comments on commit db429cd

Please sign in to comment.