File tree 3 files changed +29
-2
lines changed
eclipse/ts.eclipse.ide.core/src/ts/eclipse/ide
3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change 10
10
*/
11
11
package ts .eclipse .ide .core .resources ;
12
12
13
+ import org .eclipse .core .resources .IResource ;
14
+
13
15
import ts .eclipse .ide .core .nodejs .IEmbeddedNodejs ;
14
16
import ts .resources .ITypeScriptProjectSettings ;
15
17
@@ -36,4 +38,12 @@ public interface IIDETypeScriptProjectSettings extends ITypeScriptProjectSetting
36
38
*/
37
39
boolean isTraceOnConsole ();
38
40
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
+
39
49
}
Original file line number Diff line number Diff line change @@ -192,6 +192,9 @@ public IIDETypeScriptProjectSettings getProjectSettings() {
192
192
@ Override
193
193
public boolean canValidate (IResource resource ) {
194
194
try {
195
+ if (!getProjectSettings ().canValidate (resource )) {
196
+ return false ;
197
+ }
195
198
IDETsconfigJson tsconfig = JsonConfigResourcesManager .getInstance ().findTsconfig (resource );
196
199
if (tsconfig != null ) {
197
200
// check if the given file is declared in the "files"
Original file line number Diff line number Diff line change 12
12
13
13
import java .io .File ;
14
14
15
+ import org .eclipse .core .resources .IResource ;
15
16
import org .eclipse .core .runtime .IPath ;
16
17
import org .eclipse .core .runtime .preferences .IEclipsePreferences .PreferenceChangeEvent ;
17
18
@@ -112,8 +113,7 @@ public File getTsserverFile() {
112
113
113
114
private File resolvePath (String path ) {
114
115
if (!StringUtils .isEmpty (path )) {
115
- IPath p = TypeScriptCorePlugin .getTypeScriptRepositoryManager ().getPath (path ,
116
- super .getProject ());
116
+ IPath p = TypeScriptCorePlugin .getTypeScriptRepositoryManager ().getPath (path , super .getProject ());
117
117
return p != null ? p .toFile () : new File (path );
118
118
}
119
119
return null ;
@@ -158,6 +158,20 @@ private boolean isTscPreferencesChanged(PreferenceChangeEvent event) {
158
158
|| TypeScriptCorePreferenceConstants .TSC_INSTALLED_TYPESCRIPT_PATH .equals (event .getKey ());
159
159
}
160
160
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
+
161
175
private ITypeScriptProject getTypeScriptProject () {
162
176
return tsProject ;
163
177
}
You can’t perform that action at this time.
0 commit comments