-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve names inside BUILD files to take into account available targe…
…t types (#454) Previously, all BUILD files would have functions like scala_library or java_library underlined red despite them being valid. Now, we additionally query while exporting for available target types and save them to the PropertiesComponent. This will work with newest pants version, so we might need to wait until there is nightly release. Not sure what is the procedure for changes both to pants and this plugin. Fixes #355
- Loading branch information
1 parent
c5a730f
commit c44af98
Showing
13 changed files
with
153 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
tests/com/twitter/intellij/pants/integration/TargetFileResolutionIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2019 Pants project contributors (see CONTRIBUTORS.md). | ||
// Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
package com.twitter.intellij.pants.integration; | ||
|
||
import com.intellij.codeInsight.TargetElementUtil; | ||
import com.intellij.openapi.vfs.VirtualFile; | ||
import com.intellij.psi.PsiElement; | ||
import com.intellij.psi.PsiFile; | ||
import com.intellij.psi.PsiManager; | ||
import com.intellij.psi.PsiReference; | ||
import com.twitter.intellij.pants.testFramework.OSSPantsIntegrationTest; | ||
import com.twitter.intellij.pants.util.PantsUtil; | ||
|
||
import java.io.IOException; | ||
import java.util.Collection; | ||
|
||
public class TargetFileResolutionIntegrationTest extends OSSPantsIntegrationTest { | ||
|
||
public void testAvailableTargetTypes() throws IOException { | ||
String helloProjectPath = "examples/src/scala/org/pantsbuild/example/hello/"; | ||
doImport(helloProjectPath); | ||
// should be only tested with pants versions above 1.24.0 | ||
if (PantsUtil.isCompatiblePantsVersion(myProjectRoot.getPath(), "1.24.0")) { | ||
VirtualFile vfile = myProjectRoot.findFileByRelativePath(helloProjectPath + "BUILD"); | ||
assertNotNull(vfile); | ||
String input = new String(vfile.contentsToByteArray()); | ||
PsiFile build = PsiManager.getInstance(myProject).findFile(vfile); | ||
final PsiReference reference = build.findReferenceAt(input.indexOf("target(") + 1); | ||
assertNotNull("no reference", reference); | ||
final Collection<PsiElement> elements = TargetElementUtil.getInstance().getTargetCandidates(reference); | ||
assertNotNull(elements); | ||
assertEquals(1, elements.size()); | ||
} | ||
} | ||
} |
Oops, something went wrong.