Bug 253231 - Validators need to ignore .* resources by default

I picked up Bug 253231 on Monday evening.   This bug is about validator resource handling.  It suggests that the validator should skip validation on .* resources(files, folders) by default.  Those who familiar with standard posix OS, *nix for example, probaby know what .* files are...   .* resources are hidden from viewing by default.   They are hidden in eclipse project explorer.  So there is no point to validate hidden files because they are not meant to be view/edit by a person.

The target milestone is 3.1.  Um... someone might be working on it.  I went to check the bug activity.  It got prosponed from 3.0.4 to 3.1.   Also, I came up a "solution" of this bug by the time i finished reading the bug report.  So I thought I'll give it a shot.
My "solution" was "if(resourceName.startsWith("."))  skip validation".   BUT that looked too simple to be true!
 
1.  Reproducing bug... 
- created couple .* resources, both files and folders. (.grrrr.html in .hiddenFolder, .arrr.html in root)
- opened Eclipse Project Explorer... those .* files/folders are not showing
- made some html errors in both .grrr.html and .arrr.html
- executed validate from Project Explorer
- "HTML Problems" warnings shown up in Problem view

Conclusion.... This bug is still exist on 3.1M5-20090202...

2.  Hunting bug...
- perform a Java "*validate" method search with all occurrences; hope to finding something like the one below =D
- found a function that seems have very close relation to this bug, shouldValidate()
- comment for shouldValidate() is  "Answer true if this validator, based on it's filters, should validate this resource."   Ar... I think I'm heading the right direction.
- did another Java "shouldvalidate" method search with decoration occurrences; narrowed down to 9 occurrences
- saw most of shouldValidate() call the shouldValidate() from FilterGroup.java
- added a breakpoint and ran debug... see if the validator reaches the breakpoint....
- breakpoint reached...
- ran debug couple times to investigate how shouldValidate() runs.....

3.  Fixing bug...

- applied my solution "if(resourceName.startsWith("."))  skip validation"...
----- CODE START -----
	/**
	 * Answer whether or not we should validate the resource based on the filters in this group.
	 * 
	 * @param project the project that is being validated.
	 * @param resource the resource that is being validated. This can be null, in which case
	 * only the project level checks are performed.
	 */
	public boolean shouldValidate(IProject project, IResource resource, ContentTypeWrapper contentTypeWrapper) {
		boolean exclude = isExclude();
		boolean include = isInclude();
		int count = 0;
		for (FilterRule rule : _rules){
			if (resource != null){
				//Quick Fix Bug 253231
				if(resource.getName().startsWith(".")) return false;//$NON-NLS-1$ 
				Boolean match = rule.matchesResource(resource, contentTypeWrapper);
				if (match != null)count++;
				if (exclude && match != null && match)return false;
				if (include && match != null && match)return true;
			}
			
			Boolean match = rule.matchesProject(project);
			if (match != null)count++;
			if (exclude && match != null && match)return false;
			if (include && match != null && match)return true;
		}
		if (exclude)return true;
		if (count == 0)return true;
		return false;
	}
----- CODE END -----
- ran debug again...
- eeee???..... the .* files were no longer appear in Problem View
- ran debug couple times again with different project structure and resources to make sure the bug is "fixed"
- all .* files and files in .* folder were no longer appear in Problem View...

IT SEEMS FIXED!!! But is this the way to do it? I don't know... probably not...
I submitted the patch... now I'm waiting to see what WTP developer say about it... =D

Comments

Waiting Bugzilla


Hi, Allen.

I've noticed that you posted your solution on Bugzialla.
Good job! Just wait for a reply. I did that too with my bug.

Peter.

Post new comment

The content of this field is kept private and will not be shown publicly.