Author: akazakov
Date: 2009-11-09 14:52:09 -0500 (Mon, 09 Nov 2009)
New Revision: 18514
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/ELValidator.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/ELReference.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/refactoring/SeamRefactorContributionFactory.java
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/refactoring/SeamComponentRefactoringTest.java
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/refactoring/SeamContextVariableRefactoringTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5179
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2009-11-09
19:32:58 UTC (rev 18513)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2009-11-09
19:52:09 UTC (rev 18514)
@@ -12,7 +12,6 @@
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
@@ -64,7 +63,6 @@
import org.jboss.tools.common.model.project.IModelNature;
import org.jboss.tools.common.model.project.ModelNature;
import org.jboss.tools.common.model.project.ModelNatureExtension;
-import org.jboss.tools.common.util.FileUtil;
import org.osgi.framework.Bundle;
public class EclipseResourceUtil {
@@ -986,23 +984,4 @@
path = path.toLowerCase();
return path.endsWith(".jar") || path.endsWith(".zip");
//$NON-NLS-1$ //$NON-NLS-2$
}
-
- public static String getFileContent(IFile file) {
- InputStream is = null;
- try {
- is = file.getContents();
- return FileUtil.readStream(is);
- } catch (CoreException e) {
- ModelPlugin.getPluginLog().logError(e);
- return null;
- } finally {
- if(is!=null) {
- try {
- is.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
- }
}
\ No newline at end of file
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/ELValidator.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/ELValidator.java 2009-11-09
19:32:58 UTC (rev 18513)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/ELValidator.java 2009-11-09
19:52:09 UTC (rev 18514)
@@ -73,6 +73,7 @@
import org.jboss.tools.common.el.core.resolver.TypeInfoCollector;
import org.jboss.tools.common.el.core.resolver.Var;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.jsf.JSFModelPlugin;
import org.jboss.tools.jsf.preferences.JSFSeverityPreferences;
import org.jboss.tools.jsf.project.JSFNature;
@@ -268,7 +269,13 @@
removeAllMessagesFromResource(file);
displaySubtask(JSFValidationMessages.VALIDATING_EL_FILE, new
String[]{file.getProject().getName(), file.getName()});
String ext = file.getFileExtension();
- String content = EclipseResourceUtil.getFileContent(file);
+ String content = null;
+ try {
+ content = FileUtil.readStream(file);
+ } catch (CoreException e) {
+ JSFModelPlugin.getDefault().logError(e);
+ }
+
if(ext.equalsIgnoreCase(JAVA_EXT)) {
validateJava(file, content);
} else {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/ELReference.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/ELReference.java 2009-11-09
19:32:58 UTC (rev 18513)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/ELReference.java 2009-11-09
19:52:09 UTC (rev 18514)
@@ -28,8 +28,8 @@
import org.jboss.tools.common.el.core.parser.ELParser;
import org.jboss.tools.common.el.core.parser.ELParserUtil;
import org.jboss.tools.common.el.core.parser.SyntaxError;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.text.ITextSourceReference;
+import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.jst.web.kb.WebKbPlugin;
import org.w3c.dom.Element;
@@ -117,7 +117,12 @@
public ELExpression[] getEl() {
if(el==null) {
Set<ELExpression> exps = new HashSet<ELExpression>();
- String content = EclipseResourceUtil.getFileContent(getResource());
+ String content = null;
+ try {
+ content = FileUtil.readStream(getResource());
+ } catch (CoreException e) {
+ WebKbPlugin.getDefault().logError(e);
+ }
String elText = content.substring(startPosition, startPosition + length);
int startEl = elText.indexOf("#{"); //$NON-NLS-1$
if(startEl>-1) {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java 2009-11-09
19:32:58 UTC (rev 18513)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java 2009-11-09
19:52:09 UTC (rev 18514)
@@ -30,8 +30,8 @@
import org.eclipse.text.edits.TextEdit;
import org.jboss.tools.common.el.core.model.ELInvocationExpression;
import org.jboss.tools.common.el.core.model.ELPropertyInvocation;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.text.ITextSourceReference;
+import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.seam.core.BijectedAttributeType;
import org.jboss.tools.seam.core.IBijectedAttribute;
import org.jboss.tools.seam.core.ISeamComponent;
@@ -218,7 +218,13 @@
if(!isFileCorrect(file))
return;
- String content = EclipseResourceUtil.getFileContent(file);
+ String content = null;
+ try {
+ content = FileUtil.readStream(file);
+ } catch (CoreException e) {
+ SeamCorePlugin.getDefault().logError(e);
+ }
+
String text = content.substring(location.getStartPosition(),
location.getStartPosition()+location.getLength());
if(text.startsWith("<")){ //$NON-NLS-1$
int position = text.lastIndexOf("/>"); //$NON-NLS-1$
@@ -238,7 +244,13 @@
if(!isFileCorrect(file))
return;
- String content = EclipseResourceUtil.getFileContent(file);
+ String content = null;
+ try {
+ content = FileUtil.readStream(file);
+ } catch (CoreException e) {
+ SeamCorePlugin.getDefault().logError(e);
+ }
+
String text = content.substring(location.getStartPosition(),
location.getStartPosition()+location.getLength());
int openBracket = text.indexOf("("); //$NON-NLS-1$
int openQuote = text.indexOf("\""); //$NON-NLS-1$
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/refactoring/SeamRefactorContributionFactory.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/refactoring/SeamRefactorContributionFactory.java 2009-11-09
19:32:58 UTC (rev 18513)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/refactoring/SeamRefactorContributionFactory.java 2009-11-09
19:52:09 UTC (rev 18514)
@@ -78,7 +78,6 @@
import
org.jboss.tools.seam.internal.core.refactoring.RenameSeamContextVariableProcessor;
import org.jboss.tools.seam.ui.SeamGuiPlugin;
import org.jboss.tools.seam.ui.SeamUIMessages;
-import org.jboss.tools.seam.ui.SeamUIUtil;
import org.jboss.tools.seam.ui.wizard.RenameComponentWizard;
import org.jboss.tools.seam.ui.wizard.RenameSeamContextVariableWizard;
import org.w3c.dom.Node;
@@ -175,7 +174,11 @@
selectedText = selection.getText();
- fileContent = EclipseResourceUtil.getFileContent(editorFile);
+ try {
+ fileContent = FileUtil.readStream(editorFile);
+ } catch (CoreException e) {
+ SeamGuiPlugin.getDefault().logError(e);
+ }
boolean status = false;
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/refactoring/SeamComponentRefactoringTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/refactoring/SeamComponentRefactoringTest.java 2009-11-09
19:32:58 UTC (rev 18513)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/refactoring/SeamComponentRefactoringTest.java 2009-11-09
19:52:09 UTC (rev 18514)
@@ -9,7 +9,6 @@
import org.eclipse.ltk.core.refactoring.CompositeChange;
import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.text.edits.MultiTextEdit;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.seam.core.ISeamComponent;
import org.jboss.tools.seam.core.ISeamProject;
@@ -131,15 +130,17 @@
assertNotNull("Can't load component " + newName,
seamProject.getComponent(newName));
for(TestChangeStructure changeStructure : changeList){
IFile file = changeStructure.getProject().getFile(changeStructure.getFileName());
- String content = EclipseResourceUtil.getFileContent(file);
+ String content = null;
+ try {
+ content = FileUtil.readStream(file);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
//System.out.println("File - "+file.getName()+" offset -
"+changeStructure.getOffset()+" expected -
["+changeStructure.getText()+"] actual -
["+content.substring(changeStructure.getOffset(),
changeStructure.getOffset()+changeStructure.getLength())+"]");
for(TestTextChange change : changeStructure.getTextChanges()){
assertEquals("There is unexpected change in resource -
"+file.getName(),change.getText(), content.substring(change.getOffset(),
change.getOffset()+change.getLength()));
}
}
}
-
-
-
-
}
\ No newline at end of file
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/refactoring/SeamContextVariableRefactoringTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/refactoring/SeamContextVariableRefactoringTest.java 2009-11-09
19:32:58 UTC (rev 18513)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/refactoring/SeamContextVariableRefactoringTest.java 2009-11-09
19:52:09 UTC (rev 18514)
@@ -9,7 +9,6 @@
import org.eclipse.ltk.core.refactoring.CompositeChange;
import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.text.edits.MultiTextEdit;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.seam.core.ISeamProject;
import
org.jboss.tools.seam.internal.core.refactoring.RenameSeamContextVariableProcessor;
@@ -26,14 +25,21 @@
// Test before renaming
for(TestChangeStructure changeStructure : changeList){
IFile file = changeStructure.getProject().getFile(changeStructure.getFileName());
- String content = EclipseResourceUtil.getFileContent(file);
+ String content = null;
+ try {
+ content = FileUtil.readStream(file);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+
for(TestTextChange change : changeStructure.getTextChanges()){
assertNotSame(change.getText(), content.substring(change.getOffset(),
change.getOffset()+change.getLength()));
}
}
IFile sourceFile = seamProject.getProject().getFile(fileName);
-
+
// Rename Seam Context Variable
RenameSeamContextVariableProcessor processor = new
RenameSeamContextVariableProcessor(sourceFile, variableName);
processor.setNewName(newName);