Skip to content

Commit 497efe6

Browse files
author
angelozerr
committed
Exclude "node_modules" (hard coded) folder for the validation. Don't
validate ts file which tsconfig.json cannot be found. See #40 (comment)
1 parent 9ce209c commit 497efe6

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

eclipse/ts.eclipse.ide.core/src/ts/eclipse/ide/core/resources/IIDETypeScriptProjectSettings.java

+10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
*/
1111
package ts.eclipse.ide.core.resources;
1212

13+
import org.eclipse.core.resources.IResource;
14+
1315
import ts.eclipse.ide.core.nodejs.IEmbeddedNodejs;
1416
import ts.resources.ITypeScriptProjectSettings;
1517

@@ -36,4 +38,12 @@ public interface IIDETypeScriptProjectSettings extends ITypeScriptProjectSetting
3638
*/
3739
boolean isTraceOnConsole();
3840

41+
/**
42+
* Returns true if the given resources can be validated and false otherwise.
43+
*
44+
* @param resource
45+
* @return
46+
*/
47+
boolean canValidate(IResource resource);
48+
3949
}

eclipse/ts.eclipse.ide.core/src/ts/eclipse/ide/internal/core/resources/IDETypeScriptProject.java

+3
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ public IIDETypeScriptProjectSettings getProjectSettings() {
192192
@Override
193193
public boolean canValidate(IResource resource) {
194194
try {
195+
if (!getProjectSettings().canValidate(resource)) {
196+
return false;
197+
}
195198
IDETsconfigJson tsconfig = JsonConfigResourcesManager.getInstance().findTsconfig(resource);
196199
if (tsconfig != null) {
197200
// check if the given file is declared in the "files"

eclipse/ts.eclipse.ide.core/src/ts/eclipse/ide/internal/core/resources/IDETypeScriptProjectSettings.java

+16-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import java.io.File;
1414

15+
import org.eclipse.core.resources.IResource;
1516
import org.eclipse.core.runtime.IPath;
1617
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
1718

@@ -112,8 +113,7 @@ public File getTsserverFile() {
112113

113114
private File resolvePath(String path) {
114115
if (!StringUtils.isEmpty(path)) {
115-
IPath p = TypeScriptCorePlugin.getTypeScriptRepositoryManager().getPath(path,
116-
super.getProject());
116+
IPath p = TypeScriptCorePlugin.getTypeScriptRepositoryManager().getPath(path, super.getProject());
117117
return p != null ? p.toFile() : new File(path);
118118
}
119119
return null;
@@ -158,6 +158,20 @@ private boolean isTscPreferencesChanged(PreferenceChangeEvent event) {
158158
|| TypeScriptCorePreferenceConstants.TSC_INSTALLED_TYPESCRIPT_PATH.equals(event.getKey());
159159
}
160160

161+
@Override
162+
public boolean canValidate(IResource resource) {
163+
// TODO: add a preferences to customize path to exclude for validation.
164+
// today we exclude validation for files which are hosted inside
165+
// node_modules.
166+
IPath location = resource.getProjectRelativePath();
167+
for (int i = 0; i < location.segmentCount(); i++) {
168+
if ("node_modules".equals(location.segment(i))) {
169+
return false;
170+
}
171+
}
172+
return true;
173+
}
174+
161175
private ITypeScriptProject getTypeScriptProject() {
162176
return tsProject;
163177
}

0 commit comments

Comments
 (0)