diff options
20 files changed, 114 insertions, 1052 deletions
diff --git a/bundles/org.eclipse.jst.jsp.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.jst.jsp.ui/META-INF/MANIFEST.MF index 92002e21a0..8c6aa0a284 100644 --- a/bundles/org.eclipse.jst.jsp.ui/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.jst.jsp.ui/META-INF/MANIFEST.MF @@ -21,7 +21,6 @@ Export-Package: org.eclipse.jst.jsp.ui, org.eclipse.jst.jsp.ui.internal.preferences, org.eclipse.jst.jsp.ui.internal.preferences.ui, org.eclipse.jst.jsp.ui.internal.projection, - org.eclipse.jst.jsp.ui.internal.reconcile, org.eclipse.jst.jsp.ui.internal.registry, org.eclipse.jst.jsp.ui.internal.style, org.eclipse.jst.jsp.ui.internal.style.java, diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPCompletionProcessor.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPCompletionProcessor.java index 0741695bd8..d00537ac4f 100644 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPCompletionProcessor.java +++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPCompletionProcessor.java @@ -20,7 +20,9 @@ import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.Position; import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.jface.text.contentassist.IContentAssistProcessor; +import org.eclipse.jst.jsp.core.internal.java.IELHandler; import org.eclipse.jst.jsp.core.internal.java.IJSPTranslation; +import org.eclipse.jst.jsp.core.internal.java.JSPELHandler; import org.eclipse.jst.jsp.core.internal.java.JSPTranslation; import org.eclipse.jst.jsp.core.internal.java.JSPTranslationAdapter; import org.eclipse.jst.jsp.ui.internal.JSPUIMessages; @@ -82,7 +84,7 @@ public class JSPCompletionProcessor implements IContentAssistProcessor, IReleasa fTranslationAdapter = (JSPTranslationAdapter) xmlDoc.getAdapterFor(IJSPTranslation.class); if (fTranslationAdapter != null) { - JSPTranslation translation = fTranslationAdapter.getJSPTranslation(); + JSPTranslation translation = fTranslationAdapter.getJSPTranslation(getELHandler()); fJavaPosition = translation.getJavaOffset(getDocumentPosition()); if (DEBUG) @@ -127,6 +129,10 @@ public class JSPCompletionProcessor implements IContentAssistProcessor, IReleasa return results; } + protected IELHandler getELHandler() { + return JSPELHandler.getJSPELHandler(); + } + protected JSPProposalCollector getProposalCollector(ICompilationUnit cu, JSPTranslation translation) { return new JSPProposalCollector(cu, translation); } diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/format/FormattingStrategyJSPJava.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/format/FormattingStrategyJSPJava.java index 2c9b02dd3d..c50fdf7b01 100644 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/format/FormattingStrategyJSPJava.java +++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/format/FormattingStrategyJSPJava.java @@ -25,6 +25,7 @@ import org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy; import org.eclipse.jface.text.formatter.FormattingContextProperties; import org.eclipse.jface.text.formatter.IFormattingContext; import org.eclipse.jst.jsp.core.internal.Logger; +import org.eclipse.jst.jsp.core.internal.java.JSPELHandler; import org.eclipse.jst.jsp.core.internal.java.JSPTranslation; import org.eclipse.jst.jsp.core.internal.java.JSPTranslationUtil; import org.eclipse.text.edits.MalformedTreeException; @@ -58,7 +59,7 @@ public class FormattingStrategyJSPJava extends ContextBasedFormattingStrategy { if (document != null && partition != null) { try { - JSPTranslationUtil translationUtil = new JSPTranslationUtil(document); + JSPTranslationUtil translationUtil = new JSPTranslationUtil(document, JSPELHandler.getJSPELHandler()); ICompilationUnit cu = translationUtil.getCompilationUnit(); if (cu != null) { String cuSource = cu.getSource(); diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/hyperlink/JSPJavaHyperlinkDetector.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/hyperlink/JSPJavaHyperlinkDetector.java index be5c52d0e0..84b28f3f92 100644 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/hyperlink/JSPJavaHyperlinkDetector.java +++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/hyperlink/JSPJavaHyperlinkDetector.java @@ -21,6 +21,7 @@ import org.eclipse.jface.text.Region; import org.eclipse.jface.text.hyperlink.IHyperlink; import org.eclipse.jface.text.hyperlink.IHyperlinkDetector; import org.eclipse.jst.jsp.core.internal.java.IJSPTranslation; +import org.eclipse.jst.jsp.core.internal.java.JSPELHandler; import org.eclipse.jst.jsp.core.internal.java.JSPTranslation; import org.eclipse.jst.jsp.core.internal.java.JSPTranslationAdapter; import org.eclipse.jst.jsp.ui.internal.Logger; @@ -179,7 +180,7 @@ public class JSPJavaHyperlinkDetector implements IHyperlinkDetector { IDOMDocument xmlDoc = xmlModel.getDocument(); JSPTranslationAdapter adapter = (JSPTranslationAdapter) xmlDoc.getAdapterFor(IJSPTranslation.class); if (adapter != null) { - translation = adapter.getJSPTranslation(); + translation = adapter.getJSPTranslation(JSPELHandler.getJSPELHandler()); } } } diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPJavaSelectionProvider.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPJavaSelectionProvider.java index 1ac5f8a3b3..b119c2f8c3 100644 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPJavaSelectionProvider.java +++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPJavaSelectionProvider.java @@ -16,6 +16,7 @@ import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jst.jsp.core.internal.java.IJSPTranslation; +import org.eclipse.jst.jsp.core.internal.java.JSPELHandler; import org.eclipse.jst.jsp.core.internal.java.JSPTranslation; import org.eclipse.jst.jsp.core.internal.java.JSPTranslationAdapter; import org.eclipse.ui.texteditor.ITextEditor; @@ -39,7 +40,7 @@ class JSPJavaSelectionProvider { JSPTranslationAdapter adapter = (JSPTranslationAdapter) xmlDoc.getAdapterFor(IJSPTranslation.class); if (adapter != null) { - JSPTranslation translation = adapter.getJSPTranslation(); + JSPTranslation translation = adapter.getJSPTranslation(JSPELHandler.getJSPELHandler()); elements = translation.getElementsFromJspRange(textSelection.getOffset(), textSelection.getOffset() + textSelection.getLength()); } } diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/JSPFindOccurrencesProcessor.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/JSPFindOccurrencesProcessor.java index a8742cb1fa..4462e6c9ae 100644 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/JSPFindOccurrencesProcessor.java +++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/JSPFindOccurrencesProcessor.java @@ -16,6 +16,7 @@ import org.eclipse.core.resources.IFile; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextSelection; +import org.eclipse.jst.jsp.core.internal.java.IELHandler; import org.eclipse.jst.jsp.core.internal.java.IJSPTranslation; import org.eclipse.jst.jsp.core.internal.java.JSPTranslation; import org.eclipse.jst.jsp.core.internal.java.JSPTranslationAdapter; @@ -35,6 +36,12 @@ import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; */ public class JSPFindOccurrencesProcessor extends FindOccurrencesProcessor { + protected IELHandler fELHandler; + + public JSPFindOccurrencesProcessor(IELHandler handler) { + fELHandler = handler; + } + protected String[] getPartitionTypes() { return new String[]{IJSPPartitionTypes.JSP_DEFAULT, IJSPPartitionTypes.JSP_CONTENT_JAVA}; } @@ -66,7 +73,7 @@ public class JSPFindOccurrencesProcessor extends FindOccurrencesProcessor { IDOMDocument xmlDoc = ((IDOMModel) model).getDocument(); JSPTranslationAdapter adapter = (JSPTranslationAdapter) xmlDoc.getAdapterFor(IJSPTranslation.class); if (adapter != null) { - JSPTranslation translation = adapter.getJSPTranslation(); + JSPTranslation translation = adapter.getJSPTranslation(fELHandler); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=102211 elements = translation.getElementsFromJspRange(selection.getOffset(), selection.getOffset() + selection.getLength()); diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/provisional/StructuredTextViewerConfigurationJSP.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/provisional/StructuredTextViewerConfigurationJSP.java new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/provisional/StructuredTextViewerConfigurationJSP.java diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/reconcile/JSPTranslationWrapper.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/reconcile/JSPTranslationWrapper.java deleted file mode 100644 index a119c2b02f..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/reconcile/JSPTranslationWrapper.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsp.ui.internal.reconcile; - -import org.eclipse.jface.text.reconciler.IReconcilableModel; -import org.eclipse.jst.jsp.core.internal.java.JSPTranslationExtension; - -/** - * Wrapper class to make a JSPTranslation into an IReconcilableModel. - * Translation must be accessed via getTranslation() - * - * @pavery - */ -public class JSPTranslationWrapper implements IReconcilableModel { - private JSPTranslationExtension fTranslation = null; - - public JSPTranslationWrapper(JSPTranslationExtension trans) { - fTranslation = trans; - } - - public JSPTranslationExtension getTranslation() { - return fTranslation; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/reconcile/ReconcileStepForJava.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/reconcile/ReconcileStepForJava.java deleted file mode 100644 index c46c503d8b..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/reconcile/ReconcileStepForJava.java +++ /dev/null @@ -1,184 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsp.ui.internal.reconcile; - -import java.util.List; - -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.compiler.IProblem; -import org.eclipse.jface.text.Assert; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.Position; -import org.eclipse.jface.text.reconciler.DirtyRegion; -import org.eclipse.jface.text.reconciler.IReconcilableModel; -import org.eclipse.jface.text.reconciler.IReconcileResult; -import org.eclipse.jface.text.reconciler.IReconcileStep; -import org.eclipse.jst.jsp.core.internal.java.JSPTranslation; -import org.eclipse.jst.jsp.core.internal.java.JSPTranslationExtension; -import org.eclipse.jst.jsp.core.internal.provisional.text.IJSPPartitionTypes; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.sse.ui.internal.reconcile.DocumentAdapter; -import org.eclipse.wst.sse.ui.internal.reconcile.ReconcileAnnotationKey; -import org.eclipse.wst.sse.ui.internal.reconcile.StructuredReconcileStep; -import org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation; - -/** - * This reconcile step has a Java source document as input model and maintains - * a Java working copy as its model. - * - * @plannedfor 1.0 - */ -public class ReconcileStepForJava extends StructuredReconcileStep { - - /** - * Adapts an <code>ICompilationUnit</code> to the - * <code>ITextModel</code> interface. - * - * ISSUE: according to "never used" compiler warnings, - * this class doesn't do anything? - */ - private class CompilationUnitAdapter implements IReconcilableModel { - - // private ICompilationUnit fCompilationUnit; - - CompilationUnitAdapter(ICompilationUnit cu) { - // fCompilationUnit = cu; - } - // never used - // private ICompilationUnit getCompilationUnit() { - // return fCompilationUnit; - // } - } - - private JSPTranslation fJspTranslation; - private CompilationUnitAdapter fModel; - - /** - * Creates the last reconcile step of the pipe. - */ - public ReconcileStepForJava() { - super(); - } - - /** - * Creates an intermediate reconcile step which adds the given step to the - * pipe. - */ - public ReconcileStepForJava(IReconcileStep step) { - super(step); - } - - /* - * @see AbstractReconcileStep#reconcileModel(DirtyRegion, IRegion) - */ - protected IReconcileResult[] reconcileModel(DirtyRegion dirtyRegion, IRegion subRegion) { - Assert.isTrue(getInputModel() instanceof JSPTranslationWrapper, "wrong model"); //$NON-NLS-1$ - - fJspTranslation = ((JSPTranslationWrapper) getInputModel()).getTranslation(); - - if (DEBUG) - System.out.println("[trace reconciler] > reconciling model in JAVA step w/ dirty region: " + dirtyRegion.getText()); //$NON-NLS-1$ - - try { - fJspTranslation.setProblemCollectingActive(true); - fJspTranslation.reconcileCompilationUnit(); - } - finally { - if (fJspTranslation != null) - fJspTranslation.setProblemCollectingActive(false); - } - - List problems = null; - // I was frequently seeing null here, especially as editors closed, - // so just gaurding against that. (Not sure why it was null). - if (fJspTranslation != null) { - problems = fJspTranslation.getProblems(); - } - IReconcileResult[] results = adaptProblemsToAnnotations(problems); - return results; - } - - /** - * @return - */ - private IReconcileResult[] adaptProblemsToAnnotations(List problems) { - if (problems == null) - return new IReconcileResult[0]; - - TemporaryAnnotation[] annotations = new TemporaryAnnotation[problems.size()]; - IProblem p = null; - for (int i = 0; i < problems.size(); i++) { - p = (IProblem) problems.get(i); - annotations[i] = createTemporaryAnnotationFromProblem(p); - } - return annotations; - } - - /** - * Converts an IProblem to a TemporaryAnnotation. - * - * @param problem - * @return - */ - private TemporaryAnnotation createTemporaryAnnotationFromProblem(IProblem problem) { - String type = TemporaryAnnotation.ANNOT_ERROR; - if (problem.isWarning()) - type = TemporaryAnnotation.ANNOT_WARNING; - Position pos = new Position(problem.getSourceStart(), problem.getSourceEnd() - problem.getSourceStart() + 1); - JSPTranslationExtension translation = ((JSPTranslationWrapper) getInputModel()).getTranslation(); - int jspOffset = translation.getJspOffset(pos.offset); - - ReconcileAnnotationKey key = null; - IStructuredDocument document = getInputStructuredDocument(); - if (jspOffset != -1 && document != null) { - key = createKey(document.getRegionAtCharacterOffset(jspOffset), ReconcileAnnotationKey.TOTAL); - } - else { - key = createKey(IJSPPartitionTypes.JSP_DEFAULT, ReconcileAnnotationKey.TOTAL); - } - TemporaryAnnotation annotation = new TemporaryAnnotation(pos, type, problem.getMessage(), key, problem.getID()); - annotation.setAdditionalFixInfo(problem); - - return annotation; - } - - private IStructuredDocument getInputStructuredDocument() { - IStructuredDocument structuredDocument = null; - - IReconcilableModel inputModel = getInputModel(); - IDocument document = null; - if (inputModel instanceof DocumentAdapter) - document = ((DocumentAdapter) inputModel).getDocument(); - if (document instanceof IStructuredDocument) - structuredDocument = (IStructuredDocument) document; - return structuredDocument; - } - - /* - * @see AbstractReconcileStep#getModel() - */ - public IReconcilableModel getModel() { - if (fModel == null) { - fModel = new CompilationUnitAdapter(fJspTranslation.getCompilationUnit()); - } - return fModel; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.reconciler.IReconcileStep#setInputModel(org.eclipse.jface.text.reconciler.IReconcilableModel) - */ - public void setInputModel(IReconcilableModel inputModel) { - super.setInputModel(inputModel); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/reconcile/ReconcileStepForJspTranslation.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/reconcile/ReconcileStepForJspTranslation.java deleted file mode 100644 index 6ba0896d83..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/reconcile/ReconcileStepForJspTranslation.java +++ /dev/null @@ -1,379 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsp.ui.internal.reconcile; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.Position; -import org.eclipse.jface.text.reconciler.DirtyRegion; -import org.eclipse.jface.text.reconciler.IReconcilableModel; -import org.eclipse.jface.text.reconciler.IReconcileResult; -import org.eclipse.jface.text.reconciler.IReconcileStep; -import org.eclipse.jst.jsp.core.internal.java.ELProblem; -import org.eclipse.jst.jsp.core.internal.java.IJSPTranslation; -import org.eclipse.jst.jsp.core.internal.java.JSPTranslationAdapter; -import org.eclipse.jst.jsp.core.internal.java.JSPTranslationExtension; -import org.eclipse.jst.jsp.core.internal.regions.DOMJSPRegionContexts; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList; -import org.eclipse.wst.sse.core.internal.util.StringUtils; -import org.eclipse.wst.sse.ui.internal.reconcile.DocumentAdapter; -import org.eclipse.wst.sse.ui.internal.reconcile.ReconcileAnnotationKey; -import org.eclipse.wst.sse.ui.internal.reconcile.StructuredReconcileStep; -import org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; - -/** - * Creates a JSPTranslation for use w/ the JavaReconcileStep. Adapts Java - * error positions to the JSP positions. - * - * @author pavery - */ -public class ReconcileStepForJspTranslation extends StructuredReconcileStep { - - /** - * This contains is the translated java document. We create this here, - * then set it as the model on the next step, ReconcileStepForJava - */ - private JSPTranslationWrapper fModel = null; - private IReconcileResult[] EMPTY_RECONCILE_RESULT_SET = new IReconcileResult[0]; - private JSPTranslationAdapter fTranslationAdapter = null; - private JSPTranslationExtension fJSPTranslation = null; - - public ReconcileStepForJspTranslation(IReconcileStep step) { - super(step); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.reconciler.AbstractReconcileStep#reconcileModel(org.eclipse.jface.text.reconciler.DirtyRegion, - * org.eclipse.jface.text.IRegion) - */ - protected IReconcileResult[] reconcileModel(DirtyRegion dirtyRegion, IRegion subRegion) { - - - if (DEBUG) { - System.out.println("[trace reconciler] > translating JSP in JSP TRANSLATE step"); //$NON-NLS-1$ - } - - IReconcileResult[] result = EMPTY_RECONCILE_RESULT_SET; - - if (!(isCanceled() || dirtyRegion == null)) { - - // create java model for java reconcile - JSPTranslationAdapter adapter = getJSPTranslationAdapter(); - - if (adapter != null) { - - fJSPTranslation = adapter.getJSPTranslation(); - fModel = new JSPTranslationWrapper(fJSPTranslation); - - result = adaptELProblems(); - } - } - if (DEBUG) { - System.out.println("[trace reconciler] > JSP TRANSLATE step done"); //$NON-NLS-1$ - } - - return result; - } - - private IReconcileResult[] adaptELProblems() { - List problems = fJSPTranslation.getELProblems(); - TemporaryAnnotation[] annotations = new TemporaryAnnotation[problems.size()]; - for (int i = 0; i < problems.size(); i++) { - annotations[i] = createTemporaryAnnotationFromProblem((ELProblem) problems.get(i)); - } - return annotations; - } - - private TemporaryAnnotation createTemporaryAnnotationFromProblem(ELProblem problem) { - IStructuredDocument sDoc = (IStructuredDocument) ((DocumentAdapter) getInputModel()).getDocument(); - String type = TemporaryAnnotation.ANNOT_ERROR; - ReconcileAnnotationKey key = null; - key = createKey(sDoc.getRegionAtCharacterOffset(problem.getPosition().getOffset()), ReconcileAnnotationKey.TOTAL); - TemporaryAnnotation annotation = new TemporaryAnnotation(problem.getPosition(), type, problem.getMessage(), key); - annotation.setAdditionalFixInfo(problem); - return annotation; - } - - /** - * @return - */ - private JSPTranslationAdapter getJSPTranslationAdapter() { - if (fTranslationAdapter == null) { - IReconcilableModel reconcilableModel = getInputModel(); - IDocument doc = null; - - if (reconcilableModel instanceof DocumentAdapter) - doc = ((DocumentAdapter) reconcilableModel).getDocument(); - - if (doc != null) { - IStructuredModel model = null; - try { - model = StructuredModelManager.getModelManager().getExistingModelForRead(doc); - if (model != null) { - IDOMDocument xmlDoc = ((IDOMModel) model).getDocument(); - fTranslationAdapter = (JSPTranslationAdapter) xmlDoc.getAdapterFor(IJSPTranslation.class); - } - } - finally { - if (model != null) - model.releaseFromRead(); - } - } - } - return fTranslationAdapter; - } - - public IReconcilableModel getModel() { - return fModel; - } - - /* - * @see org.eclipse.text.reconcilerpipe.AbstractReconcilePipeParticipant#convertToInputModel(org.eclipse.text.reconcilerpipe.IReconcileResult[]) - */ - protected IReconcileResult[] convertToInputModel(IReconcileResult[] inputResults) { - - if (inputResults == null) - return EMPTY_RECONCILE_RESULT_SET; - - // we filter out unmapped errors here - // so they don't show up in the problems view. - List filtered = new ArrayList(); - - HashMap java2jspRanges = fJSPTranslation.getJava2JspMap(); - for (int i = 0; i < inputResults.length; i++) { - if (isCanceled()) - return EMPTY_RECONCILE_RESULT_SET; - if (!(inputResults[i] instanceof TemporaryAnnotation)) - continue; - TemporaryAnnotation result = (TemporaryAnnotation) inputResults[i]; - adaptJava2JspPosition(result, java2jspRanges); - - if (result.getPosition().offset != -1) - filtered.add(result); - } - return (IReconcileResult[]) filtered.toArray(new IReconcileResult[filtered.size()]); - } - - /** - * @param pos - * @param java2jspRanges - */ - private void adaptJava2JspPosition(TemporaryAnnotation annotation, HashMap java2jspRanges) { - Position pos = annotation.getPosition(); - int javaOffset = pos.offset; - int offsetInRange = 0; - Position jspPos, javaPos = null; - boolean found = false; - - // iterate all mapped java ranges - Iterator it = java2jspRanges.keySet().iterator(); - while (it.hasNext()) { - javaPos = (Position) it.next(); - if (!javaPos.includes(javaOffset)) - continue; - - offsetInRange = javaOffset - javaPos.offset; - jspPos = (Position) java2jspRanges.get(javaPos); - if (jspPos != null) { - pos.offset = jspPos.offset + offsetInRange; - found = true; - additionalPositionAdjustment(annotation, jspPos); - } - break; - } - // hide unmapped errors - if (!found) { - pos.offset = -1; - pos.length = 0; - } - } - - /** - * Adjusts java position to JSP position for ranges that don't map - * "exactly". eg. <%@include file=""%>, <jsp:useBean/>, <%@import - * src=""%>... - * - * @param pos - * @param jspPos - */ - private void additionalPositionAdjustment(TemporaryAnnotation annotation, Position jspPos) { - Position pos = annotation.getPosition(); - IStructuredDocument sDoc = null; - IStructuredDocumentRegion sdRegion = null; - // analyze the sdRegion to see if it's import, expression, include - ITextRegionList regions = null; - ITextRegion r = null; - String tagName = ""; //$NON-NLS-1$ - - sDoc = (IStructuredDocument) ((DocumentAdapter) getInputModel()).getDocument(); - sdRegion = sDoc.getRegionAtCharacterOffset(jspPos.offset); - // analyze the sdRegion to see if it's import, expression, include, - // useBean... - regions = sdRegion.getRegions(); - for (int i = 0; i < regions.size(); i++) { - r = regions.get(i); - if (r.getType() == DOMJSPRegionContexts.JSP_DIRECTIVE_NAME || r.getType() == DOMRegionContext.XML_TAG_NAME) { - tagName = sdRegion.getText(r).trim(); - if (tagName.equals("include") || tagName.equals("jsp:directive.include")) { //$NON-NLS-1$ //$NON-NLS-2$ - adjustForInclude(annotation, pos, sdRegion, regions, i); - } - else if (tagName.equals("page") || tagName.equals("jsp:directive.page")) { //$NON-NLS-1$ //$NON-NLS-2$ - adjustForPage(annotation, pos, sdRegion, regions, i); - } - else if (tagName.equals("jsp:useBean")) { //$NON-NLS-1$ - adjustForUseBean(pos, sdRegion, regions, i); - // do nothing for usebean for now... - break; - } - // this can actually cause the WRONG node to be underlined - // esp in the case of embedded attr regions - // else { - // // catch all for all other cases for now, at least we'll - // // get - // // the squiggle in the general area of the problem instead - // // of some random place - // pos.offset = sdRegion.getStartOffset(r); - // pos.length = 1; - // break; - // } - } - } - } - - private void adjustForInclude(TemporaryAnnotation annotation, Position pos, IStructuredDocumentRegion sdRegion, ITextRegionList regions, int startingRegionNumber) { - ITextRegion r; - String tagName; - String noQuotes; - for (int j = startingRegionNumber; j < regions.size(); j++) { - r = regions.get(j); - if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME && !sdRegion.getText(r).trim().equals("file")) //$NON-NLS-1$ - // there's only one attribute allowed for <@include - break; - else if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) { - tagName = sdRegion.getText(r).trim(); - noQuotes = StringUtils.strip(tagName); - pos.offset = sdRegion.getStartOffset(r) + ((tagName.length() - noQuotes.length()) == 2 ? 1 : 0); - pos.length = noQuotes.length(); - annotation.setText(annotation.getText() + " (in file: \"" + noQuotes + "\")"); //$NON-NLS-1$ //$NON-NLS-2$ - break; - } - } - } - - private void adjustForPage(TemporaryAnnotation annotation, Position pos, IStructuredDocumentRegion sdRegion, ITextRegionList regions, int startingRegionNumber) { - ITextRegion r; - String value; - int size = regions.size(); - - for (int j = startingRegionNumber; j < size; j++) { - r = regions.get(j); - if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME && sdRegion.getText(r).trim().equals("import")) { //$NON-NLS-1$ - if (size > j + 2) { - r = regions.get(j + 2); - if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) { - value = sdRegion.getText(r); - pos.offset = sdRegion.getStartOffset(r); - pos.length = value.trim().length(); - annotation.setText(annotation.getText() + " (in file: \"" + StringUtils.stripQuotes(value) + "\")"); //$NON-NLS-1$ //$NON-NLS-2$ - break; - } - } - } - } - } - - private void adjustForUseBean(Position pos, IStructuredDocumentRegion sdRegion, ITextRegionList regions, int startingRegionNumber) { - ITextRegion r; - String value; - int size = regions.size(); - - for (int j = startingRegionNumber; j < size; j++) { - r = regions.get(j); - if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME && sdRegion.getText(r).trim().equals("id")) { //$NON-NLS-1$ - if (size > j + 2) { - r = regions.get(j + 2); - if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) { - value = sdRegion.getText(r); - pos.offset = sdRegion.getStartOffset(r); - pos.length = value.trim().length(); - break; - } - } - } - } - } - - public void release() { - if (fTranslationAdapter != null) { - if (DEBUG) { - System.out.println("ReconcileStepForJSPTranslation [" + this + "] releasing JSPTranslationAdapter " + fTranslationAdapter); //$NON-NLS-1$ //$NON-NLS-2$ - } - fTranslationAdapter.release(); - } - super.release(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.reconciler.IReconcileStep#setInputModel(org.eclipse.jface.text.reconciler.IReconcilableModel) - */ - public void setInputModel(IReconcilableModel inputModel) { - // force to rebuild translation - fTranslationAdapter = null; - if (DEBUG) { - System.out.println("======================================"); //$NON-NLS-1$ - System.out.println("setting input model" + inputModel); //$NON-NLS-1$ - System.out.println("======================================"); //$NON-NLS-1$ - } - super.setInputModel(inputModel); - - reinitTranslationAdapter(inputModel); - } - - /** - * @param inputModel - */ - private void reinitTranslationAdapter(IReconcilableModel inputModel) { - - IDocument doc = null; - if (inputModel instanceof DocumentAdapter) - doc = ((DocumentAdapter) inputModel).getDocument(); - - if (doc != null) { - IStructuredModel model = null; - try { - model = StructuredModelManager.getModelManager().getExistingModelForRead(doc); - if (getJSPTranslationAdapter() != null) - getJSPTranslationAdapter().setXMLModel((IDOMModel) model); - } - finally { - if (model != null) - model.releaseFromRead(); - } - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/reconcile/StructuredTextReconcilingStrategyForJSP.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/reconcile/StructuredTextReconcilingStrategyForJSP.java deleted file mode 100644 index e7c04e6c33..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/reconcile/StructuredTextReconcilingStrategyForJSP.java +++ /dev/null @@ -1,172 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsp.ui.internal.reconcile; - -import java.io.IOException; -import java.io.InputStream; - -import org.eclipse.core.filebuffers.FileBuffers; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.core.runtime.content.IContentDescription; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.reconciler.DirtyRegion; -import org.eclipse.jface.text.reconciler.IReconcileStep; -import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.jst.jsp.core.internal.JSPCorePlugin; -import org.eclipse.jst.jsp.core.internal.preferences.JSPCorePreferenceNames; -import org.eclipse.jst.jsp.core.internal.provisional.contenttype.ContentTypeIdForJSP; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager; -import org.eclipse.wst.sse.ui.internal.reconcile.StructuredTextReconcilingStrategy; - -/** - * - * @author pavery - */ -public class StructuredTextReconcilingStrategyForJSP extends StructuredTextReconcilingStrategy { - private boolean fShouldReconcile = true; - private boolean fStepsCreated = false; - - public StructuredTextReconcilingStrategyForJSP(ISourceViewer viewer) { - super(viewer); - } - - public void createReconcileSteps() { - - // the order is: - // 1. translation step - // 2. java step - if (getDocument() != null) { - IReconcileStep javaStep = new ReconcileStepForJava(); - setFirstStep(new ReconcileStepForJspTranslation(javaStep)); - fStepsCreated = true; - } - } - - /** - * Returns an IFile for given document if it exists - * - * @param document - * document open in an editor - * @return IFile for given document, null if undetermined - */ - private IFile getFile(IDocument document) { - // determine IFile - IFile file = null; - IStructuredModel model = null; - String baselocation = null; - try { - model = StructuredModelManager.getModelManager().getExistingModelForRead(document); - if (model != null) { - baselocation = model.getBaseLocation(); - } - } - finally { - if (model != null) - model.releaseFromRead(); - } - if (baselocation != null) { - // assumes document is open in editor - // copied from JSPTranslator#getFile() - file = FileBuffers.getWorkspaceFileAtLocation(new Path(baselocation)); - - } - return file; - } - - /** - * Determines if file is jsp fragment or not - * - * @param file - * assumes file is not null and exists - * @return true if file is jsp fragment, false otherwise - */ - private boolean isFragment(IFile file) { - boolean isFragment = false; - InputStream is = null; - try { - IContentType contentTypeJSP = Platform.getContentTypeManager().getContentType(ContentTypeIdForJSP.ContentTypeID_JSPFRAGMENT); - // check this before description, it's less expensive - if (contentTypeJSP.isAssociatedWith(file.getName())) { - - IContentDescription contentDescription = file.getContentDescription(); - // it can be null - if (contentDescription == null) { - is = file.getContents(); - contentDescription = Platform.getContentTypeManager().getDescriptionFor(is, file.getName(), new QualifiedName[]{IContentDescription.CHARSET}); - } - if (contentDescription != null) { - String fileCtId = contentDescription.getContentType().getId(); - isFragment = (fileCtId != null && ContentTypeIdForJSP.ContentTypeID_JSPFRAGMENT.equals(fileCtId)); - } - } - } - catch (IOException e) { - // ignore, assume it's invalid JSP - } - catch (CoreException e) { - // ignore, assume it's invalid JSP - } - finally { - // must close input stream in case others need it - if (is != null) - try { - is.close(); - } - catch (Exception e) { - // not sure how to recover at this point - } - } - return isFragment; - } - - /** - * @return <code>true</code> if the entire document is validated for - * each edit (this strategy can't handle partial document - * validation). This will greatly help performance. - */ - public boolean isTotalScope() { - return true; - } - - public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) { - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=87351 - if (fShouldReconcile) - super.reconcile(dirtyRegion, subRegion); - } - - public void setDocument(IDocument document) { - if (!fStepsCreated) - createReconcileSteps(); - - super.setDocument(document); - - if (document != null) { - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=87351 - // get preference for validate jsp fragments - boolean shouldReconcileFragments = Platform.getPreferencesService().getBoolean(JSPCorePlugin.getDefault().getBundle().getSymbolicName(), JSPCorePreferenceNames.VALIDATE_FRAGMENTS, true, null); - boolean isFragment = false; - if (!shouldReconcileFragments) { - IFile file = getFile(document); - if (file != null && file.exists()) { - isFragment = isFragment(file); - } - } - fShouldReconcile = (shouldReconcileFragments || !isFragment); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/taginfo/JSPJavaJavadocHoverProcessor.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/taginfo/JSPJavaJavadocHoverProcessor.java index 7ee1293ea8..9e97b0ccd0 100644 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/taginfo/JSPJavaJavadocHoverProcessor.java +++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/taginfo/JSPJavaJavadocHoverProcessor.java @@ -21,6 +21,7 @@ import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextHover; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jst.jsp.core.internal.java.IJSPTranslation; +import org.eclipse.jst.jsp.core.internal.java.JSPELHandler; import org.eclipse.jst.jsp.core.internal.java.JSPTranslation; import org.eclipse.jst.jsp.core.internal.java.JSPTranslationAdapter; import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager; @@ -106,7 +107,7 @@ public class JSPJavaJavadocHoverProcessor implements ITextHover { IDOMDocument xmlDoc = xmlModel.getDocument(); JSPTranslationAdapter adapter = (JSPTranslationAdapter) xmlDoc.getAdapterFor(IJSPTranslation.class); if (adapter != null) { - JSPTranslation translation = adapter.getJSPTranslation(); + JSPTranslation translation = adapter.getJSPTranslation(JSPELHandler.getJSPELHandler()); IJavaElement[] result = translation.getElementsFromJspRange(hoverRegion.getOffset(), hoverRegion.getOffset() + hoverRegion.getLength()); return getHoverInfo(result); } diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/AbstractStructuredTextReconcilingStrategy.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/AbstractStructuredTextReconcilingStrategy.java index 78091d06d8..fae0606ce5 100644 --- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/AbstractStructuredTextReconcilingStrategy.java +++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/AbstractStructuredTextReconcilingStrategy.java @@ -28,7 +28,6 @@ import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.reconciler.DirtyRegion; import org.eclipse.jface.text.reconciler.IReconcileResult; -import org.eclipse.jface.text.reconciler.IReconcileStep; import org.eclipse.jface.text.reconciler.IReconcilingStrategy; import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension; import org.eclipse.jface.text.source.IAnnotationModel; @@ -64,7 +63,7 @@ public abstract class AbstractStructuredTextReconcilingStrategy implements IReco public static final int ELEMENT_ERROR_LIMIT = 25; private IDocument fDocument = null; - private IReconcileStep fFirstStep = null; +// private IReconcileStep fFirstStep = null; private IProgressMonitor fProgressMonitor = null; private ISourceViewer fSourceViewer = null; private Comparator fComparator; @@ -110,23 +109,24 @@ public abstract class AbstractStructuredTextReconcilingStrategy implements IReco * @return if this strategy is responisble for adding this type of key */ protected boolean canHandlePartition(String partition) { - String[] haystack = getPartitionTypes(); - for (int i = 0; i < haystack.length; i++) { - if (haystack[i].equals(partition)) - return true; - } +// String[] haystack = getPartitionTypes(); +// for (int i = 0; i < haystack.length; i++) { +// if (haystack[i].equals(partition)) +// return true; +// } +// return false; return false; } - /** - * @param step - * @return - */ - protected boolean containsStep(IReconcileStep step) { - if (fFirstStep instanceof StructuredReconcileStep) - return ((StructuredReconcileStep) fFirstStep).isSiblingStep(step); - return false; - } +// /** +// * @param step +// * @return +// */ +// protected boolean containsStep(IReconcileStep step) { +// if (fFirstStep instanceof StructuredReconcileStep) +// return ((StructuredReconcileStep) fFirstStep).isSiblingStep(step); +// return false; +// } /** * This is where you should create the steps for this strategy @@ -150,7 +150,7 @@ public abstract class AbstractStructuredTextReconcilingStrategy implements IReco ReconcileAnnotationKey key = (ReconcileAnnotationKey) annotation.getKey(); // then if this strategy knows how to add/remove this // partition type - if (canHandlePartition(key.getPartitionType()) && containsStep(key.getStep())) + if (canHandlePartition(key.getPartitionType()) /*&& containsStep(key.getStep())*/) removals.add(annotation); } } @@ -197,7 +197,7 @@ public abstract class AbstractStructuredTextReconcilingStrategy implements IReco // then if this strategy knows how to add/remove this // partition type - if (canHandlePartition(key.getPartitionType()) && containsStep(key.getStep())) { + if (canHandlePartition(key.getPartitionType()) /*&& containsStep(key.getStep())*/) { if (key.getScope() == ReconcileAnnotationKey.PARTIAL && annotation.getPosition().overlapsWith(dr.getOffset(), dr.getLength())) { remove.add(annotation); } @@ -216,11 +216,11 @@ public abstract class AbstractStructuredTextReconcilingStrategy implements IReco * * @return parition types from all steps */ - public String[] getPartitionTypes() { - if (fFirstStep instanceof StructuredReconcileStep) - return ((StructuredReconcileStep) fFirstStep).getPartitionTypes(); - return new String[0]; - } +// public String[] getPartitionTypes() { +// if (fFirstStep instanceof StructuredReconcileStep) +// return ((StructuredReconcileStep) fFirstStep).getPartitionTypes(); +// return new String[0]; +// } public void init() { createReconcileSteps(); @@ -277,19 +277,21 @@ public abstract class AbstractStructuredTextReconcilingStrategy implements IReco * org.eclipse.jface.text.IRegion) */ public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) { - - // external files may be null - if (isCanceled() || fFirstStep == null) - return; - - TemporaryAnnotation[] annotationsToRemove = new TemporaryAnnotation[0]; - IReconcileResult[] annotationsToAdd = new IReconcileResult[0]; - StructuredReconcileStep structuredStep = (StructuredReconcileStep) fFirstStep; - - annotationsToRemove = getAnnotationsToRemove(dirtyRegion); - annotationsToAdd = structuredStep.reconcile(dirtyRegion, subRegion); - - smartProcess(annotationsToRemove, annotationsToAdd); + // not used + // we only have validator strategy now + +// // external files may be null +// if (isCanceled() || fFirstStep == null) +// return; +// +// TemporaryAnnotation[] annotationsToRemove = new TemporaryAnnotation[0]; +// IReconcileResult[] annotationsToAdd = new IReconcileResult[0]; +// StructuredReconcileStep structuredStep = (StructuredReconcileStep) fFirstStep; +// +// annotationsToRemove = getAnnotationsToRemove(dirtyRegion); +// annotationsToAdd = structuredStep.reconcile(dirtyRegion, subRegion); +// +// smartProcess(annotationsToRemove, annotationsToAdd); } /** @@ -307,8 +309,8 @@ public abstract class AbstractStructuredTextReconcilingStrategy implements IReco */ public void release() { // release steps (each step calls release on the next) - if (fFirstStep != null && fFirstStep instanceof IReleasable) - ((IReleasable) fFirstStep).release(); + //if (fFirstStep != null && fFirstStep instanceof IReleasable) + // ((IReleasable) fFirstStep).release(); // we don't to null out the steps, in case // it's reconfigured later } @@ -381,8 +383,8 @@ public abstract class AbstractStructuredTextReconcilingStrategy implements IReco if (document == null) release(); - if (getFirstStep() != null) - getFirstStep().setInputModel(new DocumentAdapter(document)); +// if (getFirstStep() != null) +// getFirstStep().setInputModel(new DocumentAdapter(document)); fDocument = document; } @@ -396,9 +398,9 @@ public abstract class AbstractStructuredTextReconcilingStrategy implements IReco * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) */ public void setProgressMonitor(IProgressMonitor monitor) { - fProgressMonitor = monitor; - if (fFirstStep != null) - fFirstStep.setProgressMonitor(fProgressMonitor); +// fProgressMonitor = monitor; +// if (fFirstStep != null) +// fFirstStep.setProgressMonitor(fProgressMonitor); } /** @@ -474,11 +476,11 @@ public abstract class AbstractStructuredTextReconcilingStrategy implements IReco return fMarkerAnnotations; } - public IReconcileStep getFirstStep() { - return fFirstStep; - } - - public void setFirstStep(IReconcileStep firstStep) { - fFirstStep = firstStep; - } +// public IReconcileStep getFirstStep() { +// return fFirstStep; +// } +// +// public void setFirstStep(IReconcileStep firstStep) { +// fFirstStep = firstStep; +// } } diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DirtyRegionProcessor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DirtyRegionProcessor.java index b19aa68f2a..a5d05394f0 100644 --- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DirtyRegionProcessor.java +++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DirtyRegionProcessor.java @@ -14,14 +14,11 @@ package org.eclipse.wst.sse.ui.internal.reconcile; import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.Iterator; import java.util.List; -import java.util.Map; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; @@ -35,7 +32,6 @@ import org.eclipse.jface.text.TextUtilities; import org.eclipse.jface.text.reconciler.DirtyRegion; import org.eclipse.jface.text.reconciler.IReconciler; import org.eclipse.jface.text.reconciler.IReconcilingStrategy; -import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension; import org.eclipse.wst.sse.ui.internal.Logger; import org.eclipse.wst.sse.ui.internal.SSEUIMessages; @@ -70,19 +66,11 @@ public class DirtyRegionProcessor extends Job implements IReconciler { */ private boolean fIsInstalled = false; - private IProgressMonitor fLocalProgressMonitor = null; - /** * The partitioning this reconciler uses. */ private String fPartitioning; - /** The map of reconciling strategies. */ - private Map fStrategies = new HashMap(); - - /** the list of partition types for which there are strategies */ - private List fStrategyTypes = new ArrayList(); - /** the text viewer */ private ITextViewer fViewer; @@ -95,8 +83,7 @@ public class DirtyRegionProcessor extends Job implements IReconciler { super(SSEUIMessages.proc_dirty_regions_0); //$NON-NLS-1$ setPriority(Job.LONG); setSystem(true); - setLocalProgressMonitor(new NullProgressMonitor()); - + // init reconciler stuff setDelay(UPDATE_DELAY); } @@ -236,17 +223,6 @@ public class DirtyRegionProcessor extends Job implements IReconciler { } /** - * We use our own local progress monitor to cancel long running - * strategies/steps. Currently used when widget is disposed (user is - * trying to close the editor), and on uninstall. - * - * @return the local progress monitor - */ - IProgressMonitor getLocalProgressMonitor() { - return fLocalProgressMonitor; - } - - /** * Utility method to get partitions of a dirty region * * @param dirtyRegion @@ -289,9 +265,8 @@ public class DirtyRegionProcessor extends Job implements IReconciler { * @see IReconciler#getReconcilingStrategy(String) */ public IReconcilingStrategy getReconcilingStrategy(String contentType) { - if (fStrategies == null) - return null; - return (IReconcilingStrategy) fStrategies.get(contentType); + // we don't use this, we only have a validator strategy + return null; } /** @@ -322,16 +297,6 @@ public class DirtyRegionProcessor extends Job implements IReconciler { } /** - * A list of strategy types (keys) for this reconciler. Each strategy - * should have a unique key. - * - * @return - */ - public List getStrategyTypes() { - return fStrategyTypes; - } - - /** * Returns the text viewer this reconciler is installed on. * * @return the text viewer this reconciler is installed on @@ -344,11 +309,10 @@ public class DirtyRegionProcessor extends Job implements IReconciler { * @see org.eclipse.jface.text.reconciler.IReconciler#install(ITextViewer) */ public void install(ITextViewer textViewer) { - // we might be called multiple times with the same viewer, + // we might be called multiple times with the same viewe.r, // maybe after being uninstalled as well, so track separately if (!isInstalled()) { fViewer = textViewer; - getLocalProgressMonitor().setCanceled(false); setInstalled(true); } } @@ -363,8 +327,6 @@ public class DirtyRegionProcessor extends Job implements IReconciler { return fIsInstalled; } - - /** * Subclasses should implement for specific handling of dirty regions. * @@ -400,7 +362,7 @@ public class DirtyRegionProcessor extends Job implements IReconciler { */ protected void reconcilerDocumentChanged(IDocument document) { setDocument(document); - setDocumentOnAllStrategies(document); +// setDocumentOnAllStrategies(document); } protected IStatus run(IProgressMonitor monitor) { @@ -435,25 +397,6 @@ public class DirtyRegionProcessor extends Job implements IReconciler { public void setDocument(IDocument doc) { fDocument = doc; - setDocumentOnAllStrategies(doc); - } - - /** - * Propagates a new document to all strategies and steps. - * - * @param document - */ - protected void setDocumentOnAllStrategies(IDocument document) { - if (isInstalled()) { - // set document on all regular strategies - if (fStrategies != null) { - Iterator e = fStrategies.values().iterator(); - while (e.hasNext()) { - IReconcilingStrategy strategy = (IReconcilingStrategy) e.next(); - strategy.setDocument(document); - } - } - } } /** @@ -474,49 +417,12 @@ public class DirtyRegionProcessor extends Job implements IReconciler { fIsInstalled = isInstalled; } - private void setLocalProgressMonitor(IProgressMonitor pm) { - fLocalProgressMonitor = pm; - List strategyTypes = getStrategyTypes(); - // set on all other strategies - if (!strategyTypes.isEmpty()) { - Iterator it = strategyTypes.iterator(); - String type = null; - while (it.hasNext()) { - type = (String) it.next(); - if (getReconcilingStrategy(type) instanceof IReconcilingStrategyExtension) - ((IReconcilingStrategyExtension) getReconcilingStrategy(type)).setProgressMonitor(pm); - } - } - } - - /** - * Sets the strategy for a given contentType (partitionType) - * - * @see org.eclipse.jface.text.reconciler.Reconciler#setReconcilingStrategy(org.eclipse.jface.text.reconciler.IReconcilingStrategy, - * java.lang.String) - */ - public void setReconcilingStrategy(IReconcilingStrategy strategy, String contentType) { - - if (strategy == null) { - fStrategies.remove(contentType); - } - else { - fStrategies.put(contentType, strategy); - if (strategy instanceof IReconcilingStrategyExtension && getLocalProgressMonitor() != null) { - ((IReconcilingStrategyExtension)strategy).setProgressMonitor(getLocalProgressMonitor()); - } - strategy.setDocument(fDocument); - } - getStrategyTypes().add(contentType); - } - /** * @see org.eclipse.jface.text.reconciler.IReconciler#uninstall() */ public void uninstall() { if (isInstalled()) { setInstalled(false); - getLocalProgressMonitor().setCanceled(true); } setDocument(null); } diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DocumentRegionProcessor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DocumentRegionProcessor.java index cf787900db..0a039d5c3a 100644 --- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DocumentRegionProcessor.java +++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DocumentRegionProcessor.java @@ -4,7 +4,6 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import org.eclipse.core.runtime.Platform; @@ -18,7 +17,6 @@ import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.ITypedRegion; import org.eclipse.jface.text.reconciler.DirtyRegion; import org.eclipse.jface.text.reconciler.IReconcilingStrategy; -import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.wst.sse.ui.internal.IReleasable; import org.eclipse.wst.sse.ui.internal.reconcile.validator.ValidatorBuilder; @@ -30,7 +28,6 @@ import org.eclipse.wst.sse.ui.internal.reconcile.validator.ValidatorStrategy; * * - IDocumentListener * - ValidatorStrategy - * - DefaultStrategy * - Text viewer(dispose, input changed) listeners. * - default and validator strategies * - DirtyRegion processing logic. @@ -59,10 +56,6 @@ public class DocumentRegionProcessor extends DirtyRegionProcessor implements IDo /** for initital reconcile when document is opened */ private SourceTextInputListener fTextInputListener = null; - - /** strategy called for unmapped partitions */ - private IReconcilingStrategy fDefaultStrategy; - /** * The strategy that runs validators contributed via * <code>org.eclipse.wst.sse.ui.extensions.sourcevalidation</code> @@ -72,6 +65,9 @@ public class DocumentRegionProcessor extends DirtyRegionProcessor implements IDo private final String SSE_EDITOR_ID = "org.eclipse.wst.sse.ui"; //$NON-NLS-1$ + /** + * so we can tell if a partition changed after the last edit + */ private String[] fLastPartitions; /** @@ -90,7 +86,6 @@ public class DocumentRegionProcessor extends DirtyRegionProcessor implements IDo public void uninstall() { if (isInstalled()) { - getLocalProgressMonitor().setCanceled(true); cancel(); // removes document listeners @@ -98,30 +93,9 @@ public class DocumentRegionProcessor extends DirtyRegionProcessor implements IDo // removes widget listener getTextViewer().removeTextInputListener(fTextInputListener); - // getTextViewer().getTextWidget().removeDisposeListener(fDisposeListener); - - // release all strategies - List strategyTypes = getStrategyTypes(); - if (!strategyTypes.isEmpty()) { - Iterator it = strategyTypes.iterator(); - IReconcilingStrategy strategy = null; - while (it.hasNext()) { - strategy = getReconcilingStrategy((String) it.next()); - if (strategy instanceof IReleasable) { - ((IReleasable) strategy).release(); - strategy = null; - } - } - } - - IReconcilingStrategy defaultStrategy = getDefaultStrategy(); + IReconcilingStrategy validatorStrategy = getValidatorStrategy(); - if(defaultStrategy != null) { - if(defaultStrategy instanceof IReleasable) - ((IReleasable)defaultStrategy).release(); - } - if(validatorStrategy != null) { if(validatorStrategy instanceof IReleasable) ((IReleasable)validatorStrategy).release(); @@ -140,13 +114,19 @@ public class DocumentRegionProcessor extends DirtyRegionProcessor implements IDo if (isInstalled()) { reconcilerDocumentChanged(newInput); - setDocument(newInput); - setDocumentOnAllStrategies(newInput); setEntireDocumentDirty(newInput); } } + public void setDocument(IDocument doc) { + super.setDocument(doc); + IReconcilingStrategy validatorStrategy = getValidatorStrategy(); + if(validatorStrategy != null) { + validatorStrategy.setDocument(doc); + } + } + /** * Reinitializes listeners and sets new document onall strategies. * @@ -246,35 +226,6 @@ public class DocumentRegionProcessor extends DirtyRegionProcessor implements IDo } /** - * @param defaultStrategy - * The fDefaultStrategy to set. - */ - public void setDefaultStrategy(IReconcilingStrategy defaultStrategy) { - fDefaultStrategy = defaultStrategy; - if (fDefaultStrategy != null) { - fDefaultStrategy.setDocument(getDocument()); - if (fDefaultStrategy instanceof IReconcilingStrategyExtension) - ((IReconcilingStrategyExtension) fDefaultStrategy).setProgressMonitor(getLocalProgressMonitor()); - } - } - /** - * @return Returns the fDefaultStrategy. - */ - public IReconcilingStrategy getDefaultStrategy() { - return fDefaultStrategy; - } - - /** - * @see org.eclipse.wst.sse.ui.internal.reconcile.DirtyRegionProcessor#getAppropriateStrategy(org.eclipse.jface.text.reconciler.DirtyRegion) - */ - protected IReconcilingStrategy getStrategy(DirtyRegion dirtyRegion) { - IReconcilingStrategy strategy = super.getStrategy(dirtyRegion); - if (strategy == null) - strategy = getDefaultStrategy(); - return strategy; - } - - /** * @return Returns the fValidatorStrategy. */ public ValidatorStrategy getValidatorStrategy() { @@ -330,25 +281,7 @@ public class DocumentRegionProcessor extends DirtyRegionProcessor implements IDo } return contentTypeId; } - /** - * @see org.eclipse.wst.sse.ui.internal.reconcile.DirtyRegionProcessor#setDocumentOnAllStrategies(org.eclipse.jface.text.IDocument) - */ - protected void setDocumentOnAllStrategies(IDocument document) { - super.setDocumentOnAllStrategies(document); - - IReconcilingStrategy defaultStrategy = getDefaultStrategy(); - IReconcilingStrategy validatorStrategy = getValidatorStrategy(); - - // default strategies - if (defaultStrategy != null) - defaultStrategy.setDocument(document); - - // external validator strategy - if (validatorStrategy != null) - validatorStrategy.setDocument(document); - } - public void documentAboutToBeChanged(DocumentEvent event) { // save partition type (to see if it changes in documentChanged()) fLastPartitions = getPartitions(event.getOffset(), event.getLength()); diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/StructuredReconcileStep.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/StructuredReconcileStep.java index 5e98e91a68..430313c795 100644 --- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/StructuredReconcileStep.java +++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/StructuredReconcileStep.java @@ -27,7 +27,6 @@ import org.eclipse.jface.text.reconciler.AbstractReconcileStep; import org.eclipse.jface.text.reconciler.DirtyRegion; import org.eclipse.jface.text.reconciler.IReconcilableModel; import org.eclipse.jface.text.reconciler.IReconcileResult; -import org.eclipse.jface.text.reconciler.IReconcileStep; import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredPartitionTypes; @@ -57,8 +56,7 @@ public abstract class StructuredReconcileStep extends AbstractReconcileStep impl } protected final IReconcileResult[] EMPTY_RECONCILE_RESULT_SET = new IReconcileResult[0]; - - private StructuredReconcileStep fNextStructuredStep = null; + /** * It's possible for a partial step to get called on the same area twice * (as w/ a full document reconcile) this list keeps track of area already @@ -72,13 +70,6 @@ public abstract class StructuredReconcileStep extends AbstractReconcileStep impl fPartitionTypes = new HashSet(); } - public StructuredReconcileStep(IReconcileStep step) { - super(step); - if (step instanceof StructuredReconcileStep) - fNextStructuredStep = (StructuredReconcileStep) step; - fPartitionTypes = new HashSet(); - } - public ReconcileAnnotationKey createKey(IStructuredDocumentRegion sdRegion, int scope) { ITypedRegion tr = getPartition(sdRegion); @@ -149,12 +140,6 @@ public abstract class StructuredReconcileStep extends AbstractReconcileStep impl HashSet tempResults = new HashSet(); // add these partition types tempResults.addAll(fPartitionTypes); - // add next step's partition types - if (fNextStructuredStep != null) { - String[] nextResults = fNextStructuredStep.getPartitionTypes(); - for (int i = 0; i < nextResults.length; i++) - tempResults.add(nextResults[i]); - } return (String[]) tempResults.toArray(new String[tempResults.size()]); } @@ -167,23 +152,6 @@ public abstract class StructuredReconcileStep extends AbstractReconcileStep impl } /** - * If step passed in is found somewhere in the chain of steps. - * - * @return true if step passed in is found somewhere in the chain of - * steps, else false - */ - public boolean isSiblingStep(IReconcileStep step) { - if (step == null) - return false; - else if (step.equals(this)) - return true; - else if (isLastStep()) - return false; - else - return fNextStructuredStep.isSiblingStep(step); - } - - /** * Removes duplicates. * * @param results1 @@ -220,10 +188,6 @@ public abstract class StructuredReconcileStep extends AbstractReconcileStep impl * release through all steps. */ public void release() { - if (fNextStructuredStep != null) - fNextStructuredStep.release(); - // we don't to null out the steps, in case - // it's reconfigured later - // fNextStructuredStep = null; + // } }
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/StructuredRegionProcessor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/StructuredRegionProcessor.java index 177fc60308..92420c243d 100644 --- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/StructuredRegionProcessor.java +++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/StructuredRegionProcessor.java @@ -47,16 +47,20 @@ public class StructuredRegionProcessor extends DocumentRegionProcessor implement int start = dirtyRegion.getOffset(); IndexedRegion ir = sModel.getIndexedRegion(start); - int end = ir.getEndOffset(); - ITypedRegion[] unfiltered = computePartitioning(start, end); - // remove duplicate typed regions (partitions) - // that are handled by the same "total scope" strategy - ITypedRegion[] filtered = filterTotalScopeRegions(unfiltered); - - // iterate dirty partitions - for (int i = 0; i < filtered.length; i++) { - process(filtered[i]); + if(ir != null) { + + int end = ir.getEndOffset(); + + ITypedRegion[] unfiltered = computePartitioning(start, end); + // remove duplicate typed regions (partitions) + // that are handled by the same "total scope" strategy + ITypedRegion[] filtered = filterTotalScopeRegions(unfiltered); + + // iterate dirty partitions + for (int i = 0; i < filtered.length; i++) { + process(filtered[i]); + } } } } @@ -208,7 +212,7 @@ public class StructuredRegionProcessor extends DocumentRegionProcessor implement } setDocument(sDoc); // propagate document change - setDocumentOnAllStrategies(sDoc); + // setDocumentOnAllStrategies(sDoc); // ensure that the document is re-reconciled setEntireDocumentDirty(sDoc); } diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/StructuredTextReconcilingStrategy.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/StructuredTextReconcilingStrategy.java index 7a586fc8ee..ca4b90bc60 100644 --- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/StructuredTextReconcilingStrategy.java +++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/StructuredTextReconcilingStrategy.java @@ -68,7 +68,7 @@ public abstract class StructuredTextReconcilingStrategy extends AbstractStructur // then if this strategy knows how to add/remove this // partition type - if (canHandlePartition(key.getPartitionType()) && containsStep(key.getStep())) { + if (canHandlePartition(key.getPartitionType()) /*&& containsStep(key.getStep())*/) { if (key.getScope() == ReconcileAnnotationKey.PARTIAL && overlaps(annotation.getPosition(), sdRegions)) { remove.add(annotation); } diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ReconcileStepForValidator.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ReconcileStepForValidator.java index 881c804a75..afee08dcec 100644 --- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ReconcileStepForValidator.java +++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ReconcileStepForValidator.java @@ -72,7 +72,7 @@ public class ReconcileStepForValidator extends StructuredReconcileStep { } public ReconcileStepForValidator(IValidator v, IReconcileStep step, int scope) { - super(step); +// super(step); fValidator = v; fScope = scope; } diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ValidatorStrategy.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ValidatorStrategy.java index 8dc8a6dd69..e36b5f3365 100644 --- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ValidatorStrategy.java +++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ValidatorStrategy.java @@ -103,6 +103,10 @@ public class ValidatorStrategy extends StructuredTextReconcilingStrategy { } return false; } + + protected boolean canHandlePartition(String partition) { + return canValidatePartition(partition); + } /* * so that removal will work properly |