-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
"Import directive overrides auto-imported BIF" inspection
- Loading branch information
Showing
10 changed files
with
118 additions
and
2 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
resources/inspectionDescriptions/ErlangImportDirectiveOverridesAutoimportedBif.html
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,21 @@ | ||
<!-- | ||
~ Copyright 2012-2014 Sergey Ignatov | ||
~ | ||
~ 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. | ||
--> | ||
|
||
<html> | ||
<body> | ||
Import directive overrides pre R14 auto-imported BIF. | ||
</body> | ||
</html> |
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
52 changes: 52 additions & 0 deletions
52
...g/intellij/erlang/inspection/ErlangImportDirectiveOverridesAutoimportedBifInspection.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,52 @@ | ||
/* | ||
* Copyright 2012-2014 Sergey Ignatov | ||
* | ||
* 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 org.intellij.erlang.inspection; | ||
|
||
import com.intellij.codeInspection.ProblemHighlightType; | ||
import com.intellij.codeInspection.ProblemsHolder; | ||
import org.intellij.erlang.bif.ErlangBifDescriptor; | ||
import org.intellij.erlang.bif.ErlangBifTable; | ||
import org.intellij.erlang.psi.ErlangFile; | ||
import org.intellij.erlang.psi.ErlangImportFunction; | ||
import org.intellij.erlang.psi.impl.ErlangPsiImplUtil; | ||
import org.intellij.erlang.quickfixes.ErlangRemoveFunctionFromImportFixBase; | ||
import org.intellij.erlang.sdk.ErlangSdkRelease; | ||
import org.intellij.erlang.sdk.ErlangSdkType; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class ErlangImportDirectiveOverridesAutoimportedBifInspection extends ErlangInspectionBase { | ||
@Override | ||
protected boolean canRunOn(@NotNull ErlangFile file) { | ||
ErlangSdkRelease release = ErlangSdkType.getRelease(file); | ||
return release == null || release.isNewerThan(ErlangSdkRelease.V_R14A); | ||
} | ||
|
||
protected void checkFile(@NotNull ErlangFile file, @NotNull ProblemsHolder problemsHolder) { | ||
for (ErlangImportFunction importFunction : file.getImportedFunctions()) { | ||
ErlangBifDescriptor bifDescriptor = ErlangBifTable.getBif( | ||
"erlang", | ||
ErlangPsiImplUtil.getName(importFunction.getQAtom()), | ||
ErlangPsiImplUtil.getArity(importFunction.getInteger())); | ||
if (bifDescriptor == null || !bifDescriptor.isAutoImported()) continue; | ||
problemsHolder.registerProblem(importFunction, | ||
"Import directive overrides pre R14 auto-imported BIF '" + ErlangPsiImplUtil.createFunctionPresentation(importFunction) + "'", | ||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, | ||
new ErlangRemoveFunctionFromImportFixBase.ErlangRemoveFunctionFromImportFix()); | ||
} | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-import(incl, [dt_get_tag/0, crc32/1, <error>abs/1</error>]). | ||
-export([foo/0]). | ||
foo() -> ok. |
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 @@ | ||
-import(incl, [dt_get_tag/0, crc32/1]). |
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 @@ | ||
-import(incl, [dt_get_tag/0, crc32/1, abs<caret> / 1]). |
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