1.1 --- a/Options/manifest.mf Tue Feb 14 17:36:37 2012 +0100
1.2 +++ b/Options/manifest.mf Wed Aug 15 20:45:01 2012 +0200
1.3 @@ -5,5 +5,5 @@
1.4 OpenIDE-Module: org.netbeans.modules.plsqlsupport.options
1.5 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/plsqlsupport/op
1.6 tions/Bundle.properties
1.7 -OpenIDE-Module-Specification-Version: 1.7.15
1.8 +OpenIDE-Module-Specification-Version: 1.7.17
1.9
2.1 --- a/Options/src/org/netbeans/modules/plsqlsupport/options/Bundle.properties Tue Feb 14 17:36:37 2012 +0100
2.2 +++ b/Options/src/org/netbeans/modules/plsqlsupport/options/Bundle.properties Wed Aug 15 20:45:01 2012 +0200
2.3 @@ -37,5 +37,6 @@
2.4 GeneralPanel.jPanel3.AccessibleContext.accessibleName=Command Window
2.5 GeneralPanel.cbDeployAllDatabasesAutomatically.text=Prompt before deploying to databases other than the project's main database
2.6 GeneralPanel.jPanel3.border.title=Command Window
2.7 -GeneralPanel.cbAutoCommit.text=Auto Commit
2.8 +GeneralPanel.cbAutoCommit.text=AutoCommit SQL
2.9 +GeneralPanel.cbAutoSelect.text=AutoSelect Statement
2.10 GeneralPanel.cbExpandFolds.text=Expand All Code Folds by Default
3.1 --- a/Options/src/org/netbeans/modules/plsqlsupport/options/GeneralPanel.form Tue Feb 14 17:36:37 2012 +0100
3.2 +++ b/Options/src/org/netbeans/modules/plsqlsupport/options/GeneralPanel.form Wed Aug 15 20:45:01 2012 +0200
3.3 @@ -36,7 +36,7 @@
3.4 <Component id="jPanel2" min="-2" max="-2" attributes="0"/>
3.5 <EmptySpace type="unrelated" max="-2" attributes="0"/>
3.6 <Component id="jPanel3" min="-2" max="-2" attributes="0"/>
3.7 - <EmptySpace pref="79" max="32767" attributes="0"/>
3.8 + <EmptySpace pref="56" max="32767" attributes="0"/>
3.9 </Group>
3.10 </Group>
3.11 </DimensionLayout>
3.12 @@ -64,7 +64,7 @@
3.13 <Group type="102" alignment="0" attributes="0">
3.14 <EmptySpace max="-2" attributes="0"/>
3.15 <Component id="cbDeployAllDatabasesAutomatically" min="-2" max="-2" attributes="0"/>
3.16 - <EmptySpace pref="94" max="32767" attributes="0"/>
3.17 + <EmptySpace pref="215" max="32767" attributes="0"/>
3.18 </Group>
3.19 </Group>
3.20 </DimensionLayout>
3.21 @@ -109,7 +109,7 @@
3.22 <Group type="102" alignment="0" attributes="0">
3.23 <EmptySpace max="-2" attributes="0"/>
3.24 <Component id="cbExpandFolds" min="-2" max="-2" attributes="0"/>
3.25 - <EmptySpace pref="384" max="32767" attributes="0"/>
3.26 + <EmptySpace pref="429" max="32767" attributes="0"/>
3.27 </Group>
3.28 </Group>
3.29 </DimensionLayout>
3.30 @@ -151,10 +151,13 @@
3.31 <Layout>
3.32 <DimensionLayout dim="0">
3.33 <Group type="103" groupAlignment="0" attributes="0">
3.34 - <Group type="102" alignment="0" attributes="0">
3.35 + <Group type="102" attributes="0">
3.36 <EmptySpace max="-2" attributes="0"/>
3.37 - <Component id="cbAutoCommit" min="-2" max="-2" attributes="0"/>
3.38 - <EmptySpace pref="509" max="32767" attributes="0"/>
3.39 + <Group type="103" groupAlignment="0" attributes="0">
3.40 + <Component id="cbAutoCommit" alignment="0" min="-2" max="-2" attributes="0"/>
3.41 + <Component id="cbAutoSelect" min="-2" max="-2" attributes="0"/>
3.42 + </Group>
3.43 + <EmptySpace pref="483" max="32767" attributes="0"/>
3.44 </Group>
3.45 </Group>
3.46 </DimensionLayout>
3.47 @@ -162,6 +165,8 @@
3.48 <Group type="103" groupAlignment="0" attributes="0">
3.49 <Group type="102" alignment="0" attributes="0">
3.50 <Component id="cbAutoCommit" min="-2" max="-2" attributes="0"/>
3.51 + <EmptySpace max="-2" attributes="0"/>
3.52 + <Component id="cbAutoSelect" min="-2" max="-2" attributes="0"/>
3.53 <EmptySpace max="32767" attributes="0"/>
3.54 </Group>
3.55 </Group>
3.56 @@ -175,6 +180,13 @@
3.57 </Property>
3.58 </Properties>
3.59 </Component>
3.60 + <Component class="javax.swing.JCheckBox" name="cbAutoSelect">
3.61 + <Properties>
3.62 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
3.63 + <ResourceString bundle="org/netbeans/modules/plsqlsupport/options/Bundle.properties" key="GeneralPanel.cbAutoSelect.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
3.64 + </Property>
3.65 + </Properties>
3.66 + </Component>
3.67 </SubComponents>
3.68 </Container>
3.69 </SubComponents>
4.1 --- a/Options/src/org/netbeans/modules/plsqlsupport/options/GeneralPanel.java Tue Feb 14 17:36:37 2012 +0100
4.2 +++ b/Options/src/org/netbeans/modules/plsqlsupport/options/GeneralPanel.java Wed Aug 15 20:45:01 2012 +0200
4.3 @@ -67,6 +67,7 @@
4.4 cbExpandFolds = new javax.swing.JCheckBox();
4.5 jPanel3 = new javax.swing.JPanel();
4.6 cbAutoCommit = new javax.swing.JCheckBox();
4.7 + cbAutoSelect = new javax.swing.JCheckBox();
4.8
4.9 jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(GeneralPanel.class, "GeneralPanel.Database.Border.Title"))); // NOI18N
4.10
4.11 @@ -79,7 +80,7 @@
4.12 .addGroup(jPanel1Layout.createSequentialGroup()
4.13 .addContainerGap()
4.14 .addComponent(cbDeployAllDatabasesAutomatically)
4.15 - .addContainerGap(94, Short.MAX_VALUE))
4.16 + .addContainerGap(215, Short.MAX_VALUE))
4.17 );
4.18 jPanel1Layout.setVerticalGroup(
4.19 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
4.20 @@ -99,7 +100,7 @@
4.21 .addGroup(jPanel2Layout.createSequentialGroup()
4.22 .addContainerGap()
4.23 .addComponent(cbExpandFolds)
4.24 - .addContainerGap(384, Short.MAX_VALUE))
4.25 + .addContainerGap(429, Short.MAX_VALUE))
4.26 );
4.27 jPanel2Layout.setVerticalGroup(
4.28 jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
4.29 @@ -112,19 +113,25 @@
4.30
4.31 org.openide.awt.Mnemonics.setLocalizedText(cbAutoCommit, org.openide.util.NbBundle.getMessage(GeneralPanel.class, "GeneralPanel.cbAutoCommit.text")); // NOI18N
4.32
4.33 + org.openide.awt.Mnemonics.setLocalizedText(cbAutoSelect, org.openide.util.NbBundle.getMessage(GeneralPanel.class, "GeneralPanel.cbAutoSelect.text")); // NOI18N
4.34 +
4.35 javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
4.36 jPanel3.setLayout(jPanel3Layout);
4.37 jPanel3Layout.setHorizontalGroup(
4.38 jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
4.39 .addGroup(jPanel3Layout.createSequentialGroup()
4.40 .addContainerGap()
4.41 - .addComponent(cbAutoCommit)
4.42 - .addContainerGap(509, Short.MAX_VALUE))
4.43 + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
4.44 + .addComponent(cbAutoCommit)
4.45 + .addComponent(cbAutoSelect))
4.46 + .addContainerGap(483, Short.MAX_VALUE))
4.47 );
4.48 jPanel3Layout.setVerticalGroup(
4.49 jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
4.50 .addGroup(jPanel3Layout.createSequentialGroup()
4.51 .addComponent(cbAutoCommit)
4.52 + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
4.53 + .addComponent(cbAutoSelect)
4.54 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
4.55 );
4.56
4.57 @@ -149,7 +156,7 @@
4.58 .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
4.59 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
4.60 .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
4.61 - .addContainerGap(79, Short.MAX_VALUE))
4.62 + .addContainerGap(56, Short.MAX_VALUE))
4.63 );
4.64
4.65 jPanel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(GeneralPanel.class, "GeneralPanel.Database.Border.Title")); // NOI18N
4.66 @@ -161,12 +168,14 @@
4.67 cbDeployAllDatabasesAutomatically.setSelected(NbPreferences.forModule(GeneralPanel.class).getBoolean(OptionsUtilities.AUTO_DEPLOY_ALL_DATABASES_KEY, true));
4.68 cbExpandFolds.setSelected(NbPreferences.forModule(GeneralPanel.class).getBoolean(OptionsUtilities.PLSQL_EXPAND_FOLDS_KEY, false));
4.69 cbAutoCommit.setSelected(NbPreferences.forModule(GeneralPanel.class).getBoolean(OptionsUtilities.COMMAND_WINDOW_AUTO_COMMIT_KEY, false));
4.70 + cbAutoSelect.setSelected(NbPreferences.forModule(GeneralPanel.class).getBoolean(OptionsUtilities.COMMAND_WINDOW_AUTO_SELECT_KEY, false));
4.71 }
4.72
4.73 void store() {
4.74 NbPreferences.forModule(GeneralPanel.class).putBoolean(OptionsUtilities.AUTO_DEPLOY_ALL_DATABASES_KEY, cbDeployAllDatabasesAutomatically.isSelected());
4.75 NbPreferences.forModule(GeneralPanel.class).putBoolean(OptionsUtilities.PLSQL_EXPAND_FOLDS_KEY, cbExpandFolds.isSelected());
4.76 NbPreferences.forModule(GeneralPanel.class).putBoolean(OptionsUtilities.COMMAND_WINDOW_AUTO_COMMIT_KEY, cbAutoCommit.isSelected());
4.77 + NbPreferences.forModule(GeneralPanel.class).putBoolean(OptionsUtilities.COMMAND_WINDOW_AUTO_SELECT_KEY, cbAutoSelect.isSelected());
4.78 }
4.79
4.80 boolean valid() {
4.81 @@ -175,6 +184,7 @@
4.82 }
4.83 // Variables declaration - do not modify//GEN-BEGIN:variables
4.84 private javax.swing.JCheckBox cbAutoCommit;
4.85 + private javax.swing.JCheckBox cbAutoSelect;
4.86 private javax.swing.JCheckBox cbDeployAllDatabasesAutomatically;
4.87 private javax.swing.JCheckBox cbExpandFolds;
4.88 private javax.swing.JPanel jPanel1;
5.1 --- a/Options/src/org/netbeans/modules/plsqlsupport/options/OptionsUtilities.java Tue Feb 14 17:36:37 2012 +0100
5.2 +++ b/Options/src/org/netbeans/modules/plsqlsupport/options/OptionsUtilities.java Wed Aug 15 20:45:01 2012 +0200
5.3 @@ -49,6 +49,7 @@
5.4 public static final String PLSQL_ANNOTATIONS_ENABLED_KEY = "plsql.annotations.enabled";
5.5 public static final String PLSQL_EXPAND_FOLDS_KEY = "plsql.folds.expand";
5.6 public static final String COMMAND_WINDOW_AUTO_COMMIT_KEY = "command.window.auto.commit";
5.7 + public static final String COMMAND_WINDOW_AUTO_SELECT_KEY = "command.window.auto.select";
5.8 public static final String PLSQL_ANNOTATIONS_GENERAL_KEY = "plsql.annotations.general";
5.9 public static final String PLSQL_ANNOTATIONS_IFS_KEY = "plsql.annotations.ifs";
5.10 public static final String PLSQL_ANNOTATIONS_CURSOR_WHERE_KEY = "plsql.annotations.cursor.where";
5.11 @@ -78,6 +79,10 @@
5.12 public static boolean isCommandWindowAutoCommitEnabled() {
5.13 return NbPreferences.forModule(GeneralPanel.class).getBoolean(COMMAND_WINDOW_AUTO_COMMIT_KEY, false);
5.14 }
5.15 +
5.16 + public static boolean isCommandWindowAutoSelectEnabled() {
5.17 + return NbPreferences.forModule(GeneralPanel.class).getBoolean(COMMAND_WINDOW_AUTO_SELECT_KEY, false);
5.18 + }
5.19
5.20 public static boolean isPlSqlAnnotationCursorWhereEnabled() {
5.21 return NbPreferences.forModule(PLSQLAnnotationsPanel.class).getBoolean(PLSQL_ANNOTATIONS_CURSOR_WHERE_KEY, true);
6.1 --- a/Options/src/org/netbeans/modules/plsqlsupport/options/PLSQLAnnotationsPanel.java Tue Feb 14 17:36:37 2012 +0100
6.2 +++ b/Options/src/org/netbeans/modules/plsqlsupport/options/PLSQLAnnotationsPanel.java Wed Aug 15 20:45:01 2012 +0200
6.3 @@ -43,7 +43,7 @@
6.4
6.5 import java.awt.Component;
6.6 import java.awt.event.ItemEvent;
6.7 -import java.awt.event.MouseAdapter;
6.8 +import java.awt.event.MouseListener;
6.9 import java.awt.event.MouseEvent;
6.10 import java.util.Enumeration;
6.11 import javax.swing.JCheckBox;
6.12 @@ -72,33 +72,57 @@
6.13 treeAnnotations.setRootVisible(false);
6.14 treeAnnotations.setShowsRootHandles(true);
6.15 treeAnnotations.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
6.16 - treeAnnotations.addMouseListener(new MouseAdapter() {
6.17 + treeAnnotations.addMouseListener(new MouseListener() {
6.18
6.19 - @Override
6.20 - public void mouseClicked(MouseEvent e) {
6.21 - valueChanged(e);
6.22 - }
6.23 + @Override
6.24 + public void mouseClicked(MouseEvent e) {
6.25 + // throw new UnsupportedOperationException("Not supported yet.");
6.26 + }
6.27 +
6.28 + @Override
6.29 + public void mousePressed(MouseEvent e) {
6.30 + valueChanged(e);
6.31 + }
6.32 +
6.33 + @Override
6.34 + public void mouseReleased(MouseEvent e) {
6.35 + // throw new UnsupportedOperationException("Not supported yet.");
6.36 + }
6.37 +
6.38 + @Override
6.39 + public void mouseEntered(MouseEvent e) {
6.40 + // throw new UnsupportedOperationException("Not supported yet.");
6.41 + }
6.42 +
6.43 + @Override
6.44 + public void mouseExited(MouseEvent e) {
6.45 + // throw new UnsupportedOperationException("Not supported yet.");
6.46 + }
6.47 });
6.48 }
6.49
6.50 - private void valueChanged(MouseEvent e) {
6.51 - Object obj = e.getSource();
6.52 - if (obj != null && obj instanceof JTree) {
6.53 - JTree tree = (JTree) obj;
6.54 - DefaultMutableTreeNode node = getSelectedNode(root, tree.getSelectionPath());
6.55 - if (node != null) {
6.56 - Object tmp = node.getUserObject();
6.57 - if (tmp != null && tmp instanceof PrefNode) {
6.58 - if (((PrefNode) tmp).enabled) {
6.59 - ((PrefNode) tmp).selected = !((PrefNode) tmp).selected;
6.60 - setChildrenEnabled(node, false, ((PrefNode) tmp).selected);
6.61 - setChildrenEnabled(node, true, ((PrefNode) tmp).selected);
6.62 - updateUI();
6.63 - }
6.64 + private void valueChanged(MouseEvent e) {
6.65 + Object obj = e.getSource();
6.66 + if (obj != null && obj instanceof JTree) {
6.67 + JTree tree = (JTree) obj;
6.68 + int row = tree.getRowForLocation(e.getX(), e.getY());
6.69 + TreePath path = tree.getPathForRow(row);
6.70 + if (path != null) {
6.71 + DefaultMutableTreeNode node = getSelectedNode(root, path);
6.72 + if (node != null) {
6.73 + Object tmp = node.getUserObject();
6.74 + if (tmp != null && tmp instanceof PrefNode) {
6.75 + if (((PrefNode) tmp).enabled) {
6.76 + ((PrefNode) tmp).selected = !((PrefNode) tmp).selected;
6.77 + setChildrenEnabled(node, false, ((PrefNode) tmp).selected);
6.78 + setChildrenEnabled(node, true, ((PrefNode) tmp).selected);
6.79 + updateUI();
6.80 + }
6.81 + }
6.82 + }
6.83 }
6.84 - }
6.85 - }
6.86 - }
6.87 + }
6.88 + }
6.89
6.90 /** This method is called from within the constructor to
6.91 * initialize the form.
7.1 --- a/PLSQL/Annotation/manifest.mf Tue Feb 14 17:36:37 2012 +0100
7.2 +++ b/PLSQL/Annotation/manifest.mf Wed Aug 15 20:45:01 2012 +0200
7.3 @@ -6,5 +6,5 @@
7.4 OpenIDE-Module-Layer: org/netbeans/modules/plsql/annotation/layer.xml
7.5 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/plsql/annotatio
7.6 n/Bundle.properties
7.7 -OpenIDE-Module-Specification-Version: 1.8.12
7.8 +OpenIDE-Module-Specification-Version: 8.72.0.8
7.9
8.1 --- a/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/PlsqlAnnotationManager.java Tue Feb 14 17:36:37 2012 +0100
8.2 +++ b/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/PlsqlAnnotationManager.java Wed Aug 15 20:45:01 2012 +0200
8.3 @@ -115,6 +115,9 @@
8.4 public void update(final Observable obj1, final Object obj2) {
8.5 if ((obj1 instanceof PlsqlBlockFactory) && (obj2 instanceof Document)) {
8.6 final PlsqlBlockFactory blockFactory = (PlsqlBlockFactory) obj1;
8.7 + if(doc !=null){
8.8 + clearAllAnnotations();
8.9 + }
8.10 doc = (Document) obj2;
8.11
8.12 //Update start offsets of the changed annotations
8.13 @@ -143,6 +146,7 @@
8.14 detachAnnotation(temp);
8.15 }
8.16 }
8.17 + plsqlAnnotations.clear();
8.18 errorSysCalls.clear();
8.19 allowedTablesOrViews.clear();
8.20 }
9.1 --- a/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/PlsqlMethodAnnotationUtil.java Tue Feb 14 17:36:37 2012 +0100
9.2 +++ b/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/PlsqlMethodAnnotationUtil.java Wed Aug 15 20:45:01 2012 +0200
9.3 @@ -64,6 +64,9 @@
9.4 * @author YADHLK
9.5 */
9.6 public class PlsqlMethodAnnotationUtil {
9.7 +static int hasReturn = 0;
9.8 +private static final int HAS_RETURNS = 1;
9.9 +private static final int NO_RETURNS = 2;
9.10
9.11 private static Comparator<PlsqlBlock> comparator = new Comparator<PlsqlBlock>() {
9.12
9.13 @@ -253,6 +256,21 @@
9.14 }
9.15 return false;
9.16 }
9.17 +
9.18 + public static int isReturnExist(final Document doc, final PlsqlBlock block) {
9.19 + hasReturn = 0;
9.20 + boolean isMissing = isReturn(doc, block);
9.21 +
9.22 + if (!isMissing) {
9.23 + if (hasReturn == HAS_RETURNS) {
9.24 + return HAS_RETURNS;
9.25 + } else {
9.26 + return NO_RETURNS;
9.27 + }
9.28 + } else {
9.29 + return 0;
9.30 + }
9.31 + }
9.32
9.33 public static boolean isReturn(final Document doc, final PlsqlBlock block) {
9.34 boolean isReturn = false;
9.35 @@ -265,7 +283,7 @@
9.36 && child.getType() != PlsqlBlockType.CUSTOM_FOLD
9.37 && startOffset < child.getStartOffset()) {
9.38 if (!isReturnMissing(startOffset, child.getStartOffset(), doc, true)) {
9.39 - isReturn = true;
9.40 + isReturn = true;
9.41 break;
9.42 }
9.43 }
9.44 @@ -332,6 +350,7 @@
9.45 || token.toString().equalsIgnoreCase("RAISE")) {
9.46 if (moveToReturnEnd(ts, endOffset)) {
9.47 isReturnMissing = false;
9.48 + hasReturn = HAS_RETURNS;
9.49 }
9.50 } else if (token.toString().equalsIgnoreCase("ERROR_SYS")
9.51 || token.toString().equalsIgnoreCase("APPLICATION_SEARCH_SYS")) {
9.52 @@ -343,6 +362,7 @@
9.53 if (!token.toString().toLowerCase(Locale.ENGLISH).startsWith("check")) {
9.54 if (moveToReturnEnd(ts, endOffset)) {
9.55 isReturnMissing = false;
9.56 + hasReturn = HAS_RETURNS;
9.57 }
9.58 }
9.59 }
10.1 --- a/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/PlsqlPackageAnnotationUtil.java Tue Feb 14 17:36:37 2012 +0100
10.2 +++ b/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/PlsqlPackageAnnotationUtil.java Wed Aug 15 20:45:01 2012 +0200
10.3 @@ -104,6 +104,37 @@
10.4
10.5 return offset;
10.6 }
10.7 + //Use in global variable annotation to get the end of CONSTANT variables
10.8 + public static int checkForFirstImplBlock(final PlsqlBlock temp) {
10.9 + int offset = temp.getEndOffset();
10.10 + final Comparator<PlsqlBlock> comparator = new Comparator<PlsqlBlock>() {
10.11 +
10.12 + @Override
10.13 + public int compare(final PlsqlBlock block1, final PlsqlBlock block2) {
10.14 + Integer o1pos, o2pos;
10.15 + if (block1.getStartOffset() > -1 && block2.getStartOffset() > -1) {
10.16 + o1pos = Integer.valueOf(block1.getStartOffset());
10.17 + o2pos = Integer.valueOf(block2.getStartOffset());
10.18 + } else {
10.19 + o1pos = Integer.valueOf(block1.getEndOffset());
10.20 + o2pos = Integer.valueOf(block2.getEndOffset());
10.21 + }
10.22 + return o1pos.compareTo(o2pos);
10.23 + }
10.24 + };
10.25 +
10.26 + final List<PlsqlBlock> blocks = temp.getChildBlocks();
10.27 + Collections.sort(blocks, comparator);
10.28 + for (PlsqlBlock child : blocks) {
10.29 + PlsqlBlockType type = child.getType();
10.30 + if (!(type == PlsqlBlockType.COMMENT || type == PlsqlBlockType.CURSOR)) {
10.31 + offset = child.getStartOffset();
10.32 + break;
10.33 + }
10.34 + }
10.35 +
10.36 + return offset;
10.37 + }
10.38
10.39 public static boolean insertPackageDeclaration(final DataObject dataObj, final Document doc, final String decType, final int offset) {
10.40 if (PlsqlAnnotationUtil.isFileReadOnly(doc)) {
11.1 --- a/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/PlsqlValidateFilesSummary.java Tue Feb 14 17:36:37 2012 +0100
11.2 +++ b/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/PlsqlValidateFilesSummary.java Wed Aug 15 20:45:01 2012 +0200
11.3 @@ -42,7 +42,6 @@
11.4 package org.netbeans.modules.plsql.annotation;
11.5
11.6 import org.netbeans.modules.plsql.annotation.annotations.PlsqlAnnotation;
11.7 -import org.netbeans.modules.plsql.utilities.PlsqlFileUtil;
11.8 import java.io.IOException;
11.9 import java.util.List;
11.10 import java.util.Map;
11.11 @@ -78,6 +77,7 @@
11.12 protected void performAction(final Node[] activatedNodes) {
11.13 RequestProcessor.getDefault().post(new Runnable() {
11.14
11.15 + @Override
11.16 public void run() {
11.17 ProgressHandle handle = ProgressHandleFactory.createHandle("Validating files of the component...");
11.18 handle.start();
12.1 --- a/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/annotations/Bundle.properties Tue Feb 14 17:36:37 2012 +0100
12.2 +++ b/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/annotations/Bundle.properties Wed Aug 15 20:45:01 2012 +0200
12.3 @@ -1,4 +1,5 @@
12.4 function_return_annotation=Function without RETURN statement
12.5 +function_return_annotation_warning=Function may RETURN without a value
12.6 if_null_annotation=This condition will always return false
12.7 missing_end_name_annotation=Function/Procedure name is missing in the END statement
12.8 unreachable_annotation=Unreachable statement
13.1 --- a/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/annotations/PlsqlAnnotation.java Tue Feb 14 17:36:37 2012 +0100
13.2 +++ b/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/annotations/PlsqlAnnotation.java Wed Aug 15 20:45:01 2012 +0200
13.3 @@ -159,12 +159,7 @@
13.4 }
13.5
13.6 private boolean addApproveMarker(Document doc, int ignoreOffset) {
13.7 - String user = JOptionPane.showInputDialog(WindowManager.getDefault().getMainWindow(), "Please insert the User Id", "Information", JOptionPane.INFORMATION_MESSAGE);
13.8 - if (user == null || user.trim().equals("")) {
13.9 - return false;
13.10 - }
13.11 -
13.12 - String key = "--@" + getIgnoreKey() + "(" + user + "," + getDateTime() + ")\n";
13.13 + String key = "--@" + getIgnoreKey() + "(" + System.getProperty("user.name") + "," + getDateTime() + ")\n";
13.14 return addMarker(doc, key, ignoreOffset);
13.15 }
13.16
14.1 --- a/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/annotations/PlsqlCursorWhereAnnotation.java Tue Feb 14 17:36:37 2012 +0100
14.2 +++ b/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/annotations/PlsqlCursorWhereAnnotation.java Wed Aug 15 20:45:01 2012 +0200
14.3 @@ -121,6 +121,7 @@
14.4 if (!isIgnoreAlowed() || -1 == ignoreMarkerOffset) {
14.5 PlsqlAnnotationUtil.addAnnotation(annotation, annotationsToAdd);
14.6 }
14.7 + checkIgnoreAnnotation(annotationsToAdd, getIgnoreKey(), ignoreMarkerOffset, exists);
14.8 }
14.9 param1 = "";
14.10 param2 = "";
14.11 @@ -129,9 +130,7 @@
14.12 isCheck = true;
14.13 }
14.14 }
14.15 - }
14.16 -
14.17 - checkIgnoreAnnotation(annotationsToAdd, getIgnoreKey(), ignoreMarkerOffset, exists);
14.18 + }
14.19 }
14.20
14.21 @Override
15.1 --- a/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/annotations/PlsqlFunctionReturnAnnotation.java Tue Feb 14 17:36:37 2012 +0100
15.2 +++ b/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/annotations/PlsqlFunctionReturnAnnotation.java Wed Aug 15 20:45:01 2012 +0200
15.3 @@ -63,10 +63,10 @@
15.4 return new PlsqlFunctionReturnAnnotation();
15.5 }
15.6
15.7 - public PlsqlFunctionReturnAnnotation(int offset, int ignoreOffset) {
15.8 + public PlsqlFunctionReturnAnnotation(int offset, int ignoreOffset, int severity) {
15.9 this.offset = offset;
15.10 this.ignoreOffset = ignoreOffset;
15.11 - this.severity = ERROR;
15.12 + this.severity = severity;
15.13 this.category = GENERAL;
15.14 }
15.15
15.16 @@ -82,25 +82,30 @@
15.17
15.18 @Override
15.19 public String getShortDescription() {
15.20 - return NbBundle.getMessage(this.getClass(), "function_return_annotation");
15.21 + if (this.severity == WARNING) {
15.22 + return NbBundle.getMessage(this.getClass(), "function_return_annotation_warning");
15.23 + } else {
15.24 + return NbBundle.getMessage(this.getClass(), "function_return_annotation");
15.25 + }
15.26 }
15.27
15.28 - @Override
15.29 - public void evaluateAnnotation(Map<Integer, List<PlsqlAnnotation>> annotationsToAdd, Document doc, PlsqlBlock block, Document specDoc, PlsqlBlockFactory specBlockFac) {
15.30 - boolean isMissing = true;
15.31 - isMissing = !PlsqlMethodAnnotationUtil.isReturn(doc, block);
15.32 - int ignoreMarkerOffset = isIgnoreSpecified(doc, block.getStartOffset(), getIgnoreKey(), true);
15.33 - boolean exists = false;
15.34 + @Override
15.35 + public void evaluateAnnotation(Map<Integer, List<PlsqlAnnotation>> annotationsToAdd, Document doc, PlsqlBlock block, Document specDoc, PlsqlBlockFactory specBlockFac) {
15.36 + int isReturn = PlsqlMethodAnnotationUtil.isReturnExist(doc, block);
15.37 + int ignoreMarkerOffset = isIgnoreSpecified(doc, block.getStartOffset(), getIgnoreKey(), true);
15.38 + boolean exists = false;
15.39
15.40 - if (isMissing) {
15.41 - exists = true;
15.42 - PlsqlFunctionReturnAnnotation annotation = new PlsqlFunctionReturnAnnotation(block.getStartOffset(), block.getStartOffset());
15.43 - if (!isIgnoreAlowed() || -1 == ignoreMarkerOffset)
15.44 - PlsqlAnnotationUtil.addAnnotation(annotation, annotationsToAdd);
15.45 - }
15.46 -
15.47 - checkIgnoreAnnotation(annotationsToAdd, getIgnoreKey(), ignoreMarkerOffset, exists);
15.48 - }
15.49 + if (isReturn > 0) {
15.50 + exists = true;
15.51 + PlsqlFunctionReturnAnnotation annotation = new PlsqlFunctionReturnAnnotation(block.getStartOffset(), block.getStartOffset(), isReturn);
15.52 + if (annotation != null) {
15.53 + if (!isIgnoreAlowed() || -1 == ignoreMarkerOffset) {
15.54 + PlsqlAnnotationUtil.addAnnotation(annotation, annotationsToAdd);
15.55 + }
15.56 + checkIgnoreAnnotation(annotationsToAdd, getIgnoreKey(), ignoreMarkerOffset, exists);
15.57 + }
15.58 + }
15.59 + }
15.60
15.61 @Override
15.62 public Action[] getActions() {
16.1 --- a/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/annotations/PlsqlIfNullAnnotation.java Tue Feb 14 17:36:37 2012 +0100
16.2 +++ b/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/annotations/PlsqlIfNullAnnotation.java Wed Aug 15 20:45:01 2012 +0200
16.3 @@ -119,6 +119,7 @@
16.4 if (!isIgnoreAlowed() || -1 == ignoreMarkerOffset) {
16.5 PlsqlAnnotationUtil.addAnnotation(endNameAnnotation, annotationsToAdd);
16.6 }
16.7 + checkIgnoreAnnotation(annotationsToAdd, getIgnoreKey(), ignoreMarkerOffset, exists);
16.8 }
16.9 }
16.10 break;
16.11 @@ -126,9 +127,7 @@
16.12 break;
16.13 }
16.14 }
16.15 - }
16.16 -
16.17 - checkIgnoreAnnotation(annotationsToAdd, getIgnoreKey(), ignoreMarkerOffset, exists);
16.18 + }
16.19 }
16.20
16.21 @Override
17.1 --- a/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/annotations/PlsqlMissingEndNameAnnotation.java Tue Feb 14 17:36:37 2012 +0100
17.2 +++ b/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/annotations/PlsqlMissingEndNameAnnotation.java Wed Aug 15 20:45:01 2012 +0200
17.3 @@ -122,15 +122,14 @@
17.4 if (!isIgnoreAlowed() || -1 == ignoreMarkerOffset) {
17.5 PlsqlAnnotationUtil.addAnnotation(endNameAnnotation, annotationsToAdd);
17.6 }
17.7 + checkIgnoreAnnotation(annotationsToAdd, getIgnoreKey(), ignoreMarkerOffset, exists);
17.8 }
17.9 break;
17.10 } else if (token.id() == PlsqlTokenId.IDENTIFIER || token.id() == PlsqlTokenId.KEYWORD) { //because there are some functions with keyword names (close,cancel etc)
17.11 isName = true;
17.12 }
17.13 }
17.14 - }
17.15 -
17.16 - checkIgnoreAnnotation(annotationsToAdd, getIgnoreKey(), ignoreMarkerOffset, exists);
17.17 + }
17.18 }
17.19
17.20 @Override
18.1 --- a/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/annotations/PlsqlTokenAnnotation.java Tue Feb 14 17:36:37 2012 +0100
18.2 +++ b/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/annotations/PlsqlTokenAnnotation.java Wed Aug 15 20:45:01 2012 +0200
18.3 @@ -45,7 +45,11 @@
18.4 import java.util.List;
18.5 import java.util.Map;
18.6 import javax.swing.text.Document;
18.7 +import javax.swing.text.JTextComponent;
18.8 +import org.netbeans.api.editor.EditorRegistry;
18.9 import org.netbeans.api.lexer.Token;
18.10 +import org.netbeans.modules.plsql.annotation.PlsqlAnnotationManager;
18.11 +import org.netbeans.modules.plsql.annotation.PlsqlAnnotationUtil;
18.12
18.13 /**
18.14 * Annotation class for annotations based on tokens
18.15 @@ -55,4 +59,33 @@
18.16
18.17 public abstract void evaluateAnnotation(Map<Integer, List<PlsqlAnnotation>> annotationsToAdd,
18.18 Document doc, Token<PlsqlTokenId> token, int tokenOffset, int endParse, Object obj);
18.19 +
18.20 + /**
18.21 + * Check and remove/add the ignore marker annotation
18.22 + * @param annotationsToAdd
18.23 + * @param ignoreKey
18.24 + * @param ignoreMarkerOffset
18.25 + * @param exists
18.26 + */
18.27 + public void checkIgnoreAnnotation(final Map<Integer, List<PlsqlAnnotation>> annotationsToAdd, final String ignoreKey, final int ignoreMarkerOffset, final boolean exists) {
18.28 + if (!exists && -1 != ignoreMarkerOffset) {
18.29 + PlsqlAnnotationUtil.addAnnotation(new PlsqlWrongIgnoreMarkerAnnotation(ignoreKey, ignoreMarkerOffset), annotationsToAdd);
18.30 + } else if (exists && -1 != ignoreMarkerOffset) {
18.31 + //Remove the WrongIgnoreMarkerAnnotation if existing
18.32 + final JTextComponent comp = EditorRegistry.lastFocusedComponent();
18.33 + if (comp == null) {
18.34 + return;
18.35 + }
18.36 +
18.37 + final Document doc = comp.getDocument();
18.38 + if (doc == null) {
18.39 + return;
18.40 + }
18.41 +
18.42 + final PlsqlAnnotationManager annotationManager = PlsqlAnnotationUtil.getAnnotationManager(doc);
18.43 + if (annotationManager != null) {
18.44 + annotationManager.removeAnnotation(ignoreMarkerOffset, "Plsql-wrong-ignore-marker-annotation");
18.45 + }
18.46 + }
18.47 + }
18.48 }
19.1 --- a/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/annotations/PlsqlUnreachableAnnotation.java Tue Feb 14 17:36:37 2012 +0100
19.2 +++ b/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/annotations/PlsqlUnreachableAnnotation.java Wed Aug 15 20:45:01 2012 +0200
19.3 @@ -101,9 +101,8 @@
19.4 if (!isIgnoreAlowed() || -1 == ignoreMarkerOffset) {
19.5 PlsqlAnnotationUtil.addAnnotation(annotation, annotationsToAdd);
19.6 }
19.7 - }
19.8 -
19.9 - checkIgnoreAnnotation(annotationsToAdd, getIgnoreKey(), ignoreMarkerOffset, exists);
19.10 + checkIgnoreAnnotation(annotationsToAdd, getIgnoreKey(), ignoreMarkerOffset, exists);
19.11 + }
19.12 } catch (BadLocationException ex) {
19.13 Exceptions.printStackTrace(ex);
19.14 }
20.1 --- a/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/annotations/PlsqlWrongEndNameAnnotation.java Tue Feb 14 17:36:37 2012 +0100
20.2 +++ b/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/annotations/PlsqlWrongEndNameAnnotation.java Wed Aug 15 20:45:01 2012 +0200
20.3 @@ -124,6 +124,7 @@
20.4 if (!isIgnoreAlowed() || -1 == ignoreMarkerOffset) {
20.5 PlsqlAnnotationUtil.addAnnotation(endNameAnnotation, annotationsToAdd);
20.6 }
20.7 + checkIgnoreAnnotation(annotationsToAdd, getIgnoreKey(), ignoreMarkerOffset, exists);
20.8 }
20.9 break;
20.10 } else if (token.id() == PlsqlTokenId.IDENTIFIER || token.id() == PlsqlTokenId.KEYWORD) { //because there are some functions with keyword names (close,cancel etc)
20.11 @@ -131,9 +132,7 @@
20.12 tokenOffset = ts.offset();
20.13 }
20.14 }
20.15 - }
20.16 -
20.17 - checkIgnoreAnnotation(annotationsToAdd, getIgnoreKey(), ignoreMarkerOffset, exists);
20.18 + }
20.19 }
20.20
20.21 @Override
21.1 --- a/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/annotations/PlsqlWrongFunctionParamAnnotation.java Tue Feb 14 17:36:37 2012 +0100
21.2 +++ b/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/annotations/PlsqlWrongFunctionParamAnnotation.java Wed Aug 15 20:45:01 2012 +0200
21.3 @@ -112,6 +112,7 @@
21.4 if (!isIgnoreAlowed() || -1 == ignoreMarkerOffset) {
21.5 PlsqlAnnotationUtil.addAnnotation(annotation, annotationsToAdd);
21.6 }
21.7 + checkIgnoreAnnotation(annotationsToAdd, getIgnoreKey(), ignoreMarkerOffset, exists);
21.8 break;
21.9 }
21.10 }
21.11 @@ -124,9 +125,7 @@
21.12 param = param + " " + token.text().toString().toUpperCase(Locale.ENGLISH);
21.13 }
21.14 }
21.15 - }
21.16 -
21.17 - checkIgnoreAnnotation(annotationsToAdd, getIgnoreKey(), ignoreMarkerOffset, exists);
21.18 + }
21.19 }
21.20
21.21 @Override
22.1 --- a/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/annotations/PlsqlWrongParamOrderAnnotation.java Tue Feb 14 17:36:37 2012 +0100
22.2 +++ b/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/annotations/PlsqlWrongParamOrderAnnotation.java Wed Aug 15 20:45:01 2012 +0200
22.3 @@ -136,14 +136,13 @@
22.4 if (!isIgnoreAlowed() || -1 == ignoreMarkerOffset) {
22.5 PlsqlAnnotationUtil.addAnnotation(annotation, annotationsToAdd);
22.6 }
22.7 + checkIgnoreAnnotation(annotationsToAdd, getIgnoreKey(), ignoreMarkerOffset, exists);
22.8 break;
22.9 }
22.10 }
22.11 pre = type;
22.12 }
22.13 - }
22.14 -
22.15 - checkIgnoreAnnotation(annotationsToAdd, getIgnoreKey(), ignoreMarkerOffset, exists);
22.16 + }
22.17 }
22.18
22.19 private int getParamOrderNo(final String param) {
23.1 --- a/PLSQL/Completion/manifest.mf Tue Feb 14 17:36:37 2012 +0100
23.2 +++ b/PLSQL/Completion/manifest.mf Wed Aug 15 20:45:01 2012 +0200
23.3 @@ -5,6 +5,6 @@
23.4 OpenIDE-Module-Layer: org/netbeans/modules/plsql/completion/layer.xml
23.5 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/plsql/completio
23.6 n/Bundle.properties
23.7 -OpenIDE-Module-Specification-Version: 1.8.5
23.8 +OpenIDE-Module-Specification-Version: 1.8.8
23.9 AutoUpdate-Show-In-Client: false
23.10
24.1 --- a/PLSQL/Completion/src/org/netbeans/modules/plsql/completion/PlsqlCodeCompletionItemsProvider.java Tue Feb 14 17:36:37 2012 +0100
24.2 +++ b/PLSQL/Completion/src/org/netbeans/modules/plsql/completion/PlsqlCodeCompletionItemsProvider.java Wed Aug 15 20:45:01 2012 +0200
24.3 @@ -60,6 +60,7 @@
24.4 import org.netbeans.api.lexer.Token;
24.5 import org.netbeans.api.lexer.TokenSequence;
24.6 import org.netbeans.editor.BaseDocument;
24.7 +import org.openide.util.Exceptions;
24.8
24.9 /**
24.10 *
24.11 @@ -802,7 +803,7 @@
24.12 try {
24.13 sql = doc.getText(start, end - start);
24.14 } catch (BadLocationException ex) {
24.15 - ex.printStackTrace();
24.16 + Exceptions.printStackTrace(ex);
24.17 }
24.18
24.19 if (!sql.equals("")) {
25.1 --- a/PLSQL/Completion/src/org/netbeans/modules/plsql/completion/PlsqlContext.java Tue Feb 14 17:36:37 2012 +0100
25.2 +++ b/PLSQL/Completion/src/org/netbeans/modules/plsql/completion/PlsqlContext.java Wed Aug 15 20:45:01 2012 +0200
25.3 @@ -168,16 +168,21 @@
25.4 }
25.5
25.6 private int findNextFrom(TokenSequence<PlsqlTokenId> ts) {
25.7 + int parenCount = 0;
25.8 while (ts.moveNext()) {
25.9 Token<PlsqlTokenId> token = ts.token();
25.10 PlsqlTokenId tokenID = token.id();
25.11 String value = token.toString();
25.12 if(tokenID == PlsqlTokenId.OPERATOR && ";".equals(value)) {
25.13 return -1;
25.14 + }else if(tokenID == PlsqlTokenId.LPAREN) {
25.15 + parenCount++;
25.16 + } else if(tokenID == PlsqlTokenId.RPAREN) {
25.17 + parenCount--;
25.18 } else if (tokenID == PlsqlTokenId.KEYWORD) {
25.19 if("NULL".equalsIgnoreCase(value)) {
25.20 //ignore NULL since this is a valid SQL keyword
25.21 - } else if("FROM".equalsIgnoreCase(value)) {
25.22 + } else if(parenCount==0 && "FROM".equalsIgnoreCase(value)) {
25.23 return ts.offset()+5;
25.24 }
25.25 }
25.26 @@ -191,6 +196,7 @@
25.27 private int findTableAndViewListStartPosition(TokenSequence<PlsqlTokenId> ts) {
25.28 boolean whereFound = false;
25.29 boolean setFound = false;
25.30 + boolean asFound = false;
25.31 int rParenCount=0;
25.32 int lParenCount=0;
25.33 PlsqlTokenId previousKeyWordTokenId = null;
25.34 @@ -209,12 +215,15 @@
25.35 lParenCount++;
25.36 previousKeyWordTokenId = null;
25.37 }
25.38 - } else if(tokenId == PlsqlTokenId.KEYWORD) {
25.39 + } else if(tokenId == PlsqlTokenId.KEYWORD || "SET".equalsIgnoreCase(value)) {
25.40 if(rParenCount==0) {
25.41 if("WHERE".equalsIgnoreCase(value) || "BY".equalsIgnoreCase(value)) {
25.42 //set for where as well as order by and group by
25.43 whereFound = true;
25.44 } else if("SET".equalsIgnoreCase(value)) {
25.45 + if(whereFound){
25.46 + return ts.offset()+5;
25.47 + }
25.48 setFound = true;
25.49 } else if("FROM".equalsIgnoreCase(value)) {
25.50 if(whereFound)
25.51 @@ -227,9 +236,12 @@
25.52 else
25.53 return -1; //found update before where or set...
25.54 } else if(lParenCount==1 && "INTO".equalsIgnoreCase(value)) { //find "INSERT INTO xxx (" type of statements
25.55 - if(previousKeyWordTokenId==null) //no other keywords between INTO and the parenthesis
25.56 + if(previousKeyWordTokenId==null || asFound) //no other keywords between INTO and the parenthesis
25.57 return ts.offset()+5;
25.58 + } else if("AS".equalsIgnoreCase(value)){
25.59 + asFound = true;
25.60 }
25.61 +
25.62 }
25.63 previousKeyWordTokenId = tokenId;
25.64 }
25.65 @@ -267,29 +279,38 @@
25.66 } else if (parenCount==0 && tokenID == PlsqlTokenId.KEYWORD) {
25.67 if(keyWord.equalsIgnoreCase(value)) {
25.68 return ts.offset();
25.69 - }
25.70 + }
25.71 + else if(value.equalsIgnoreCase("SELECT") || value.equalsIgnoreCase("UPDATE") || value.equalsIgnoreCase("INSERT") || value.equalsIgnoreCase("DELETE")){
25.72 + return -1;
25.73 + }
25.74 }
25.75 }
25.76 return -1;
25.77 }
25.78
25.79 private HashMap<String, String> extractAliases(TokenSequence<PlsqlTokenId> ts) {
25.80 - //start at the first point after the FROM statement
25.81 - //extract list of tables/views and aliases.
25.82 HashMap<String, String> map = new HashMap<String, String>();
25.83 int parenCount = 0;
25.84 String viewName = null;
25.85 String alias = null;
25.86 final String SELECT_STATEMENT="select...";
25.87 + if(isUpdateStmt(ts.offset())){
25.88 + ts.move(findStmtStart(ts, "UPDATE"));
25.89 + ts.moveIndex(ts.index()+1);
25.90 + }
25.91 while (ts.moveNext()) {
25.92 Token<PlsqlTokenId> token = ts.token();
25.93 PlsqlTokenId tokenID = token.id();
25.94 String value = token.toString();
25.95 - if(tokenID == PlsqlTokenId.OPERATOR && ";".equals(value)) {
25.96 - break;
25.97 + if(tokenID == PlsqlTokenId.OPERATOR && (";".equals(value) || "=".equals(value))) {
25.98 + if("=".equals(value))
25.99 + viewName = null;
25.100 + else
25.101 + break;
25.102 } else if(tokenID == PlsqlTokenId.DOT && viewName!=null) {
25.103 //schema prefix for the object - ignore the schema
25.104 - viewName = null;
25.105 + if(!isInsertStmt(ts.offset()))
25.106 + viewName = null;
25.107 } else if(tokenID == PlsqlTokenId.LPAREN) {
25.108 parenCount++;
25.109 } else if(tokenID == PlsqlTokenId.RPAREN) {
25.110 @@ -298,6 +319,8 @@
25.111 parenCount--;
25.112 if(parenCount==0 && viewName==null) //closing parenthesis. If viewName != null this is probably an insert into statement...
25.113 viewName = SELECT_STATEMENT;
25.114 + else
25.115 + break;
25.116 } else if(parenCount==0) {
25.117 if(tokenID == PlsqlTokenId.IDENTIFIER || tokenID==PlsqlTokenId.STRING_LITERAL) {
25.118 if(viewName==null) {
25.119 @@ -311,8 +334,9 @@
25.120 else if(viewName!=null && viewName!=SELECT_STATEMENT) //Yes - this should be "==..." and not equals(...)
25.121 selectViewsWithoutAlias.add(viewName);
25.122 viewName = alias = null;
25.123 - } else if(tokenID==PlsqlTokenId.KEYWORD) {
25.124 - break;
25.125 + } else if(tokenID==PlsqlTokenId.KEYWORD || "SET".equals(value)) {
25.126 + if(!("AS".equalsIgnoreCase(value)))
25.127 + break;
25.128 }
25.129 }
25.130 }
25.131 @@ -330,6 +354,22 @@
25.132 ts.move(caretOffset);
25.133 return findStmtStart(ts, "SELECT")>-1;
25.134 }
25.135 +
25.136 + private boolean isUpdateStmt(int caretOffset) {
25.137 + TokenHierarchy tokenHierarchy = TokenHierarchy.get(doc);
25.138 + @SuppressWarnings("unchecked")
25.139 + TokenSequence<PlsqlTokenId> ts = tokenHierarchy.tokenSequence(PlsqlTokenId.language());
25.140 + ts.move(caretOffset);
25.141 + return findStmtStart(ts, "UPDATE")>-1;
25.142 + }
25.143 +
25.144 + private boolean isInsertStmt(int caretOffset) {
25.145 + TokenHierarchy tokenHierarchy = TokenHierarchy.get(doc);
25.146 + @SuppressWarnings("unchecked")
25.147 + TokenSequence<PlsqlTokenId> ts = tokenHierarchy.tokenSequence(PlsqlTokenId.language());
25.148 + ts.move(caretOffset);
25.149 + return findStmtStart(ts, "INSERT")>-1;
25.150 + }
25.151
25.152 private boolean isExceptionStmt(int caretOffset) {
25.153 //for now just return true...
26.1 --- a/PLSQL/Debugging/manifest.mf Tue Feb 14 17:36:37 2012 +0100
26.2 +++ b/PLSQL/Debugging/manifest.mf Wed Aug 15 20:45:01 2012 +0200
26.3 @@ -5,6 +5,6 @@
26.4 OpenIDE-Module-Layer: org/netbeans/modules/plsql/debug/layer.xml
26.5 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/plsql/debug/Bun
26.6 dle.properties
26.7 -OpenIDE-Module-Specification-Version: 1.7.19
26.8 +OpenIDE-Module-Specification-Version: 1.7.23
26.9 AutoUpdate-Show-In-Client: false
26.10
27.1 --- a/PLSQL/Debugging/nbproject/project.xml Tue Feb 14 17:36:37 2012 +0100
27.2 +++ b/PLSQL/Debugging/nbproject/project.xml Wed Aug 15 20:45:01 2012 +0200
27.3 @@ -7,43 +7,21 @@
27.4 <suite-component/>
27.5 <module-dependencies>
27.6 <dependency>
27.7 - <code-name-base>org.netbeans.modules.plsqlsupport.db</code-name-base>
27.8 + <code-name-base>org.jdesktop.beansbinding</code-name-base>
27.9 <build-prerequisite/>
27.10 <compile-dependency/>
27.11 <run-dependency>
27.12 - <specification-version>1.0</specification-version>
27.13 + <release-version>1</release-version>
27.14 + <specification-version>1.11.1.121</specification-version>
27.15 </run-dependency>
27.16 </dependency>
27.17 <dependency>
27.18 - <code-name-base>org.netbeans.modules.plsql.execution</code-name-base>
27.19 + <code-name-base>org.jdesktop.layout</code-name-base>
27.20 <build-prerequisite/>
27.21 <compile-dependency/>
27.22 <run-dependency>
27.23 - <specification-version>1.0.2</specification-version>
27.24 - </run-dependency>
27.25 - </dependency>
27.26 - <dependency>
27.27 - <code-name-base>org.netbeans.modules.plsql.hyperlink</code-name-base>
27.28 - <build-prerequisite/>
27.29 - <compile-dependency/>
27.30 - <run-dependency>
27.31 - <specification-version>1.0</specification-version>
27.32 - </run-dependency>
27.33 - </dependency>
27.34 - <dependency>
27.35 - <code-name-base>org.netbeans.modules.plsql.lexer</code-name-base>
27.36 - <build-prerequisite/>
27.37 - <compile-dependency/>
27.38 - <run-dependency>
27.39 - <specification-version>1.0</specification-version>
27.40 - </run-dependency>
27.41 - </dependency>
27.42 - <dependency>
27.43 - <code-name-base>org.netbeans.modules.plsql.utilities</code-name-base>
27.44 - <build-prerequisite/>
27.45 - <compile-dependency/>
27.46 - <run-dependency>
27.47 - <specification-version>1.0.15</specification-version>
27.48 + <release-version>1</release-version>
27.49 + <specification-version>1.17.1</specification-version>
27.50 </run-dependency>
27.51 </dependency>
27.52 <dependency>
27.53 @@ -83,6 +61,46 @@
27.54 </run-dependency>
27.55 </dependency>
27.56 <dependency>
27.57 + <code-name-base>org.netbeans.modules.plsql.execution</code-name-base>
27.58 + <build-prerequisite/>
27.59 + <compile-dependency/>
27.60 + <run-dependency>
27.61 + <specification-version>1.0.2</specification-version>
27.62 + </run-dependency>
27.63 + </dependency>
27.64 + <dependency>
27.65 + <code-name-base>org.netbeans.modules.plsql.hyperlink</code-name-base>
27.66 + <build-prerequisite/>
27.67 + <compile-dependency/>
27.68 + <run-dependency>
27.69 + <specification-version>1.0</specification-version>
27.70 + </run-dependency>
27.71 + </dependency>
27.72 + <dependency>
27.73 + <code-name-base>org.netbeans.modules.plsql.lexer</code-name-base>
27.74 + <build-prerequisite/>
27.75 + <compile-dependency/>
27.76 + <run-dependency>
27.77 + <specification-version>1.0</specification-version>
27.78 + </run-dependency>
27.79 + </dependency>
27.80 + <dependency>
27.81 + <code-name-base>org.netbeans.modules.plsql.utilities</code-name-base>
27.82 + <build-prerequisite/>
27.83 + <compile-dependency/>
27.84 + <run-dependency>
27.85 + <specification-version>1.0.15</specification-version>
27.86 + </run-dependency>
27.87 + </dependency>
27.88 + <dependency>
27.89 + <code-name-base>org.netbeans.modules.plsqlsupport.db</code-name-base>
27.90 + <build-prerequisite/>
27.91 + <compile-dependency/>
27.92 + <run-dependency>
27.93 + <specification-version>1.0</specification-version>
27.94 + </run-dependency>
27.95 + </dependency>
27.96 + <dependency>
27.97 <code-name-base>org.netbeans.modules.projectapi</code-name-base>
27.98 <build-prerequisite/>
27.99 <compile-dependency/>
27.100 @@ -101,6 +119,14 @@
27.101 </run-dependency>
27.102 </dependency>
27.103 <dependency>
27.104 + <code-name-base>org.openide.awt</code-name-base>
27.105 + <build-prerequisite/>
27.106 + <compile-dependency/>
27.107 + <run-dependency>
27.108 + <specification-version>7.31.2</specification-version>
27.109 + </run-dependency>
27.110 + </dependency>
27.111 + <dependency>
27.112 <code-name-base>org.openide.dialogs</code-name-base>
27.113 <build-prerequisite/>
27.114 <compile-dependency/>
28.1 --- a/PLSQL/Debugging/src/org/netbeans/modules/plsql/debug/Bundle.properties Tue Feb 14 17:36:37 2012 +0100
28.2 +++ b/PLSQL/Debugging/src/org/netbeans/modules/plsql/debug/Bundle.properties Wed Aug 15 20:45:01 2012 +0200
28.3 @@ -7,3 +7,5 @@
28.4 TOOLTIP_CURRENT_EXP_LINE=Current Program Counter In Expression
28.5 TOOLTIP_OTHER_THREAD=Thread {0} suspended at this line
28.6 TOOLTIP_CALLSITE=Call Stack Line
28.7 +GetProjectDialog.okButton.text=OK
28.8 +GetProjectDialog.lblProject.text=Select a project to debug
29.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
29.2 +++ b/PLSQL/Debugging/src/org/netbeans/modules/plsql/debug/GetProjectDialog.form Wed Aug 15 20:45:01 2012 +0200
29.3 @@ -0,0 +1,86 @@
29.4 +<?xml version="1.1" encoding="UTF-8" ?>
29.5 +
29.6 +<Form version="1.5" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
29.7 + <Properties>
29.8 + <Property name="defaultCloseOperation" type="int" value="2"/>
29.9 + </Properties>
29.10 + <SyntheticProperties>
29.11 + <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
29.12 + </SyntheticProperties>
29.13 + <AuxValues>
29.14 + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
29.15 + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
29.16 + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
29.17 + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
29.18 + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
29.19 + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
29.20 + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
29.21 + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
29.22 + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
29.23 + </AuxValues>
29.24 +
29.25 + <Layout>
29.26 + <DimensionLayout dim="0">
29.27 + <Group type="103" groupAlignment="0" attributes="0">
29.28 + <Group type="102" attributes="0">
29.29 + <Group type="103" groupAlignment="0" attributes="0">
29.30 + <Group type="102" alignment="0" attributes="0">
29.31 + <EmptySpace max="-2" attributes="0"/>
29.32 + <Component id="lblProject" min="-2" max="-2" attributes="0"/>
29.33 + </Group>
29.34 + <Group type="102" alignment="0" attributes="0">
29.35 + <EmptySpace min="-2" pref="31" max="-2" attributes="0"/>
29.36 + <Group type="103" groupAlignment="1" attributes="0">
29.37 + <Component id="okButton" alignment="1" min="-2" max="-2" attributes="0"/>
29.38 + <Component id="cbProjects" alignment="1" min="-2" pref="214" max="-2" attributes="0"/>
29.39 + </Group>
29.40 + </Group>
29.41 + </Group>
29.42 + <EmptySpace pref="31" max="32767" attributes="0"/>
29.43 + </Group>
29.44 + </Group>
29.45 + </DimensionLayout>
29.46 + <DimensionLayout dim="1">
29.47 + <Group type="103" groupAlignment="0" attributes="0">
29.48 + <Group type="102" alignment="0" attributes="0">
29.49 + <EmptySpace min="-2" pref="24" max="-2" attributes="0"/>
29.50 + <Component id="lblProject" min="-2" max="-2" attributes="0"/>
29.51 + <EmptySpace type="separate" max="-2" attributes="0"/>
29.52 + <Component id="cbProjects" min="-2" max="-2" attributes="0"/>
29.53 + <EmptySpace type="unrelated" max="-2" attributes="0"/>
29.54 + <Component id="okButton" min="-2" max="-2" attributes="0"/>
29.55 + <EmptySpace max="32767" attributes="0"/>
29.56 + </Group>
29.57 + </Group>
29.58 + </DimensionLayout>
29.59 + </Layout>
29.60 + <SubComponents>
29.61 + <Component class="javax.swing.JButton" name="okButton">
29.62 + <Properties>
29.63 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
29.64 + <ResourceString bundle="org/netbeans/modules/plsql/debug/Bundle.properties" key="GetProjectDialog.okButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
29.65 + </Property>
29.66 + </Properties>
29.67 + <Events>
29.68 + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
29.69 + </Events>
29.70 + </Component>
29.71 + <Component class="javax.swing.JLabel" name="lblProject">
29.72 + <Properties>
29.73 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
29.74 + <ResourceString bundle="org/netbeans/modules/plsql/debug/Bundle.properties" key="GetProjectDialog.lblProject.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
29.75 + </Property>
29.76 + </Properties>
29.77 + </Component>
29.78 + <Component class="javax.swing.JComboBox" name="cbProjects">
29.79 + <Properties>
29.80 + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
29.81 + <StringArray count="0"/>
29.82 + </Property>
29.83 + </Properties>
29.84 + <BindingProperties>
29.85 + <BindingProperty name="elements" source="cbProjects" target="cbProjects" targetPath="elements" updateStrategy="0" immediately="false"/>
29.86 + </BindingProperties>
29.87 + </Component>
29.88 + </SubComponents>
29.89 +</Form>
30.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
30.2 +++ b/PLSQL/Debugging/src/org/netbeans/modules/plsql/debug/GetProjectDialog.java Wed Aug 15 20:45:01 2012 +0200
30.3 @@ -0,0 +1,152 @@
30.4 +/*
30.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
30.6 + *
30.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
30.8 + *
30.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
30.10 + * Other names may be trademarks of their respective owners.
30.11 + *
30.12 + * The contents of this file are subject to the terms of either the GNU
30.13 + * General Public License Version 2 only ("GPL") or the Common
30.14 + * Development and Distribution License("CDDL") (collectively, the
30.15 + * "License"). You may not use this file except in compliance with the
30.16 + * License. You can obtain a copy of the License at
30.17 + * http://www.netbeans.org/cddl-gplv2.html
30.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
30.19 + * specific language governing permissions and limitations under the
30.20 + * License. When distributing the software, include this License Header
30.21 + * Notice in each file and include the License file at
30.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
30.23 + * particular file as subject to the "Classpath" exception as provided
30.24 + * by Oracle in the GPL Version 2 section of the License file that
30.25 + * accompanied this code. If applicable, add the following below the
30.26 + * License Header, with the fields enclosed by brackets [] replaced by
30.27 + * your own identifying information:
30.28 + * "Portions Copyrighted [year] [name of copyright owner]"
30.29 + *
30.30 + * If you wish your version of this file to be governed by only the CDDL
30.31 + * or only the GPL Version 2, indicate your decision by adding
30.32 + * "[Contributor] elects to include this software in this distribution
30.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
30.34 + * single choice of license, a recipient has the option to distribute
30.35 + * your version of this file under either the CDDL, the GPL Version 2 or
30.36 + * to extend the choice of license to its licensees as provided above.
30.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
30.38 + * Version 2 license, then the option applies only if the new code is
30.39 + * made subject to such option by the copyright holder.
30.40 + *
30.41 + * Contributor(s):
30.42 + *
30.43 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
30.44 + */
30.45 +package org.netbeans.modules.plsql.debug;
30.46 +
30.47 +import java.util.HashMap;
30.48 +import java.util.Map;
30.49 +
30.50 +/**
30.51 + *
30.52 + * @author YaDhLK
30.53 + */
30.54 +public class GetProjectDialog extends javax.swing.JDialog {
30.55 +
30.56 + static final Map<String, String> previousValues = new HashMap<String, String>();
30.57 + String variableName = null;
30.58 +
30.59 + /** Creates new form PromptValue */
30.60 + public GetProjectDialog(java.awt.Frame parent, String[] variable, boolean modal) {
30.61 + super(parent, modal);
30.62 + initComponents();
30.63 + getRootPane().setDefaultButton(okButton);
30.64 + this.setLocation(325, 125);
30.65 + this.setTitle("Select Debug Project");
30.66 + for(int x =0; x < variable.length; x++){
30.67 + this.cbProjects.addItem(variable[x]);
30.68 + }
30.69 + }
30.70 +
30.71 +
30.72 + /**
30.73 + * Return the value of the text field
30.74 + * @return
30.75 + */
30.76 + public String getValue() {
30.77 + String value = cbProjects.getSelectedItem().toString();
30.78 + return value;
30.79 + }
30.80 +
30.81 + /** This method is called from within the constructor to
30.82 + * initialize the form.
30.83 + * WARNING: Do NOT modify this code. The content of this method is
30.84 + * always regenerated by the Form Editor.
30.85 + */
30.86 + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
30.87 + private void initComponents() {
30.88 + bindingGroup = new org.jdesktop.beansbinding.BindingGroup();
30.89 +
30.90 + okButton = new javax.swing.JButton();
30.91 + lblProject = new javax.swing.JLabel();
30.92 + cbProjects = new javax.swing.JComboBox();
30.93 +
30.94 + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
30.95 +
30.96 + okButton.setText(org.openide.util.NbBundle.getMessage(GetProjectDialog.class, "GetProjectDialog.okButton.text")); // NOI18N
30.97 + okButton.addActionListener(new java.awt.event.ActionListener() {
30.98 + public void actionPerformed(java.awt.event.ActionEvent evt) {
30.99 + okButtonActionPerformed(evt);
30.100 + }
30.101 + });
30.102 +
30.103 + lblProject.setText(org.openide.util.NbBundle.getMessage(GetProjectDialog.class, "GetProjectDialog.lblProject.text")); // NOI18N
30.104 +
30.105 + org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cbProjects, org.jdesktop.beansbinding.ObjectProperty.create(), cbProjects, org.jdesktop.beansbinding.BeanProperty.create("elements"));
30.106 + bindingGroup.addBinding(binding);
30.107 +
30.108 + org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
30.109 + getContentPane().setLayout(layout);
30.110 + layout.setHorizontalGroup(
30.111 + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
30.112 + .add(layout.createSequentialGroup()
30.113 + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
30.114 + .add(layout.createSequentialGroup()
30.115 + .addContainerGap()
30.116 + .add(lblProject))
30.117 + .add(layout.createSequentialGroup()
30.118 + .add(31, 31, 31)
30.119 + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
30.120 + .add(okButton)
30.121 + .add(cbProjects, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 214, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
30.122 + .addContainerGap(31, Short.MAX_VALUE))
30.123 + );
30.124 + layout.setVerticalGroup(
30.125 + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
30.126 + .add(layout.createSequentialGroup()
30.127 + .add(24, 24, 24)
30.128 + .add(lblProject)
30.129 + .add(18, 18, 18)
30.130 + .add(cbProjects, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
30.131 + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
30.132 + .add(okButton)
30.133 + .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
30.134 + );
30.135 +
30.136 + bindingGroup.bind();
30.137 +
30.138 + pack();
30.139 + }// </editor-fold>//GEN-END:initComponents
30.140 +
30.141 + private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
30.142 + // TODO add your handling code here:
30.143 + this.setVisible(false);
30.144 + this.dispose();
30.145 +}//GEN-LAST:event_okButtonActionPerformed
30.146 +
30.147 +
30.148 + // Variables declaration - do not modify//GEN-BEGIN:variables
30.149 + private javax.swing.JComboBox cbProjects;
30.150 + private javax.swing.JLabel lblProject;
30.151 + private javax.swing.JButton okButton;
30.152 + private org.jdesktop.beansbinding.BindingGroup bindingGroup;
30.153 + // End of variables declaration//GEN-END:variables
30.154 +
30.155 +}
31.1 --- a/PLSQL/Debugging/src/org/netbeans/modules/plsql/debug/PlsqlDebugAction.java Tue Feb 14 17:36:37 2012 +0100
31.2 +++ b/PLSQL/Debugging/src/org/netbeans/modules/plsql/debug/PlsqlDebugAction.java Wed Aug 15 20:45:01 2012 +0200
31.3 @@ -41,15 +41,6 @@
31.4 */
31.5 package org.netbeans.modules.plsql.debug;
31.6
31.7 -import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
31.8 -import org.netbeans.modules.plsqlsupport.db.DatabaseContentUtilities;
31.9 -import org.netbeans.modules.plsqlsupport.db.ui.SQLCommandWindow;
31.10 -import org.netbeans.modules.plsql.execution.PlsqlExecutableBlocksMaker;
31.11 -import org.netbeans.modules.plsql.execution.PlsqlExecutableObject;
31.12 -import org.netbeans.modules.plsql.execution.PlsqlFileExecutor;
31.13 -import org.netbeans.modules.plsql.lexer.PlsqlBlock;
31.14 -import org.netbeans.modules.plsql.lexer.PlsqlBlockFactory;
31.15 -import org.netbeans.modules.plsql.lexer.PlsqlBlockUtilities;
31.16 import java.io.File;
31.17 import java.io.IOException;
31.18 import java.io.UnsupportedEncodingException;
31.19 @@ -66,32 +57,53 @@
31.20 import javax.swing.text.Document;
31.21 import javax.swing.text.StyledDocument;
31.22 import org.netbeans.api.db.explorer.DatabaseConnection;
31.23 -import org.netbeans.api.project.FileOwnerQuery;
31.24 -import org.netbeans.api.project.Project;
31.25 -import org.openide.cookies.EditorCookie;
31.26 -import org.openide.loaders.DataObject;
31.27 -import org.openide.loaders.DataObjectNotFoundException;
31.28 -import org.openide.nodes.Node;
31.29 -import org.openide.util.Exceptions;
31.30 -import org.openide.util.HelpCtx;
31.31 -import org.openide.util.NbBundle;
31.32 -import org.openide.util.actions.CookieAction;
31.33 -import org.openide.windows.IOProvider;
31.34 -import org.openide.windows.InputOutput;
31.35 -import org.openide.windows.OutputWriter;
31.36 import org.netbeans.api.debugger.Breakpoint;
31.37 import org.netbeans.api.debugger.DebuggerInfo;
31.38 import org.netbeans.api.debugger.DebuggerManager;
31.39 import org.netbeans.api.debugger.Session;
31.40 import org.netbeans.api.debugger.jpda.LineBreakpoint;
31.41 import org.netbeans.api.debugger.jpda.ListeningDICookie;
31.42 +import org.netbeans.api.project.FileOwnerQuery;
31.43 +import org.netbeans.api.project.Project;
31.44 +import org.netbeans.modules.plsql.execution.PlsqlExecutableBlocksMaker;
31.45 +import org.netbeans.modules.plsql.execution.PlsqlExecutableObject;
31.46 +import org.netbeans.modules.plsql.execution.PlsqlFileExecutor;
31.47 +import org.netbeans.modules.plsql.lexer.PlsqlBlock;
31.48 +import org.netbeans.modules.plsql.lexer.PlsqlBlockFactory;
31.49 +import org.netbeans.modules.plsql.lexer.PlsqlBlockUtilities;
31.50 +import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
31.51 +import org.netbeans.modules.plsqlsupport.db.DatabaseContentUtilities;
31.52 +import org.netbeans.modules.plsqlsupport.db.ui.SQLCommandWindow;
31.53 +import org.openide.awt.ActionID;
31.54 +import org.openide.awt.ActionReference;
31.55 +import org.openide.awt.ActionReferences;
31.56 +import org.openide.awt.ActionRegistration;
31.57 +import org.openide.cookies.EditorCookie;
31.58 import org.openide.filesystems.FileObject;
31.59 import org.openide.filesystems.FileUtil;
31.60 import org.openide.loaders.DataFolder;
31.61 +import org.openide.loaders.DataObject;
31.62 +import org.openide.loaders.DataObjectNotFoundException;
31.63 +import org.openide.nodes.Node;
31.64 import org.openide.text.NbDocument;
31.65 +import org.openide.util.Exceptions;
31.66 +import org.openide.util.HelpCtx;
31.67 +import org.openide.util.NbBundle;
31.68 import org.openide.util.RequestProcessor;
31.69 import org.openide.util.RequestProcessor.Task;
31.70 +import org.openide.util.actions.CookieAction;
31.71 +import org.openide.windows.IOProvider;
31.72 +import org.openide.windows.InputOutput;
31.73 +import org.openide.windows.OutputWriter;
31.74
31.75 +@ActionID(id = "org.netbeans.modules.plsql.debug.PlsqlDebugAction", category = "PLSQL")
31.76 +@ActionRegistration(displayName = "#CTL_PlsqlDebugAction", iconBase = "org/netbeans/modules/plsql/debug/debug.png")
31.77 +@ActionReferences({
31.78 + @ActionReference(path = "Shortcuts", name = "DS-D"),
31.79 + @ActionReference(path = "Shortcuts", name = "OS-D"),
31.80 + @ActionReference(path = "Editors/text/x-plsql/Popup", name = "org-netbeans-modules-plsql-debug-PlsqlDebugAction",
31.81 + position = 1020, separatorAfter = 1050)
31.82 +})
31.83 public final class PlsqlDebugAction extends CookieAction {
31.84
31.85 private static final RequestProcessor RP = new RequestProcessor(PlsqlDebugAction.class.getName());
31.86 @@ -152,6 +164,7 @@
31.87
31.88 /**
31.89 * Enable this action only for the SQL execution window
31.90 + *
31.91 * @param nodes
31.92 * @return
31.93 */
32.1 --- a/PLSQL/Debugging/src/org/netbeans/modules/plsql/debug/PlsqlDebugCompileAction.java Tue Feb 14 17:36:37 2012 +0100
32.2 +++ b/PLSQL/Debugging/src/org/netbeans/modules/plsql/debug/PlsqlDebugCompileAction.java Wed Aug 15 20:45:01 2012 +0200
32.3 @@ -41,47 +41,48 @@
32.4 */
32.5 package org.netbeans.modules.plsql.debug;
32.6
32.7 -import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
32.8 -import org.netbeans.modules.plsqlsupport.db.DatabaseContentManager;
32.9 -import org.netbeans.modules.plsqlsupport.db.DatabaseContentUtilities;
32.10 -import org.netbeans.modules.plsql.lexer.PlsqlBlock;
32.11 -import org.netbeans.modules.plsql.lexer.PlsqlBlockFactory;
32.12 -import org.netbeans.modules.plsql.utilities.PlsqlParserUtil;
32.13 import java.sql.Connection;
32.14 import java.sql.PreparedStatement;
32.15 import java.sql.ResultSet;
32.16 import java.sql.SQLException;
32.17 -import java.sql.Statement;
32.18 -import java.util.List;
32.19 import java.util.Locale;
32.20 import javax.swing.JEditorPane;
32.21 import javax.swing.text.Caret;
32.22 import org.netbeans.api.db.explorer.DatabaseConnection;
32.23 +import org.netbeans.modules.plsql.lexer.PlsqlBlockFactory;
32.24 +import org.netbeans.modules.plsql.utilities.PlsqlParserUtil;
32.25 +import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
32.26 +import org.netbeans.modules.plsqlsupport.db.DatabaseContentUtilities;
32.27 +import org.openide.awt.ActionID;
32.28 +import org.openide.awt.ActionReference;
32.29 +import org.openide.awt.ActionRegistration;
32.30 import org.openide.cookies.EditorCookie;
32.31 import org.openide.loaders.DataObject;
32.32 import org.openide.nodes.Node;
32.33 import org.openide.util.Exceptions;
32.34 import org.openide.util.HelpCtx;
32.35 import org.openide.util.NbBundle;
32.36 -import org.openide.util.RequestProcessor;
32.37 import org.openide.util.actions.CookieAction;
32.38 import org.openide.windows.IOProvider;
32.39 import org.openide.windows.InputOutput;
32.40 import org.openide.windows.OutputWriter;
32.41
32.42 -
32.43 +@ActionID(id = "org.netbeans.modules.plsql.debug.PlsqlDebugCompileAction", category = "PLSQL")
32.44 +@ActionRegistration(displayName = "#CTL_PlsqlDebugCompileAction")
32.45 +@ActionReference(path = "Editors/text/x-plsql/Popup", name = "org-netbeans-modules-plsql-debug-DebugCompileAction", position = 1000)
32.46 public final class PlsqlDebugCompileAction extends CookieAction {
32.47
32.48 String objectName;
32.49 - @Override
32.50 - protected int mode() {
32.51 - return CookieAction.MODE_EXACTLY_ONE;
32.52 - }
32.53
32.54 - @Override
32.55 - protected Class<?>[] cookieClasses() {
32.56 - return new Class[]{EditorCookie.class};
32.57 - }
32.58 + @Override
32.59 + protected int mode() {
32.60 + return CookieAction.MODE_EXACTLY_ONE;
32.61 + }
32.62 +
32.63 + @Override
32.64 + protected Class<?>[] cookieClasses() {
32.65 + return new Class[]{EditorCookie.class};
32.66 + }
32.67
32.68 @Override
32.69 protected boolean asynchronous() {
32.70 @@ -136,20 +137,20 @@
32.71 }
32.72 }
32.73
32.74 - @Override
32.75 - public String getName() {
32.76 - return NbBundle.getMessage(PlsqlDebugCompileAction.class, "CTL_PlsqlDebugCompileAction");
32.77 - }
32.78 + @Override
32.79 + public String getName() {
32.80 + return NbBundle.getMessage(PlsqlDebugCompileAction.class, "CTL_PlsqlDebugCompileAction");
32.81 + }
32.82
32.83 - @Override
32.84 - public HelpCtx getHelpCtx() {
32.85 - return HelpCtx.DEFAULT_HELP;
32.86 - }
32.87 + @Override
32.88 + public HelpCtx getHelpCtx() {
32.89 + return HelpCtx.DEFAULT_HELP;
32.90 + }
32.91
32.92 - @Override
32.93 + @Override
32.94 protected boolean enable(Node[] activatedNodes) {
32.95 - objectName = getObjectName(activatedNodes);
32.96 - return objectName!=null;
32.97 + objectName = getObjectName(activatedNodes);
32.98 + return objectName != null;
32.99 }
32.100
32.101 private String getObjectName(Node[] activatedNodes) {
32.102 @@ -166,12 +167,12 @@
32.103 return null;
32.104 }
32.105 String selection = panes[0].getSelectedText();
32.106 - if(selection!=null) { //check that this is a valid oracle identifier
32.107 - if(selection.startsWith("\"") && selection.endsWith("\"")) {
32.108 + if (selection != null) { //check that this is a valid oracle identifier
32.109 + if (selection.startsWith("\"") && selection.endsWith("\"")) {
32.110 return selection;
32.111 }
32.112 String upper = selection.toUpperCase(Locale.ENGLISH);
32.113 - if(DatabaseContentUtilities.isValidOracleUppercaseIdentifier(upper)) {
32.114 + if (DatabaseContentUtilities.isValidOracleUppercaseIdentifier(upper)) {
32.115 return upper;
32.116 }
32.117 return null;
32.118 @@ -181,16 +182,15 @@
32.119 //go through the parse tree and find the "top" node. This is the object we should debug complie
32.120 DataObject dataObject = activatedNodes[0].getLookup().lookup(DataObject.class);
32.121 PlsqlBlockFactory fac = dataObject.getLookup().lookup(PlsqlBlockFactory.class);
32.122 - List<PlsqlBlock> blockHierarchy = fac.getBlockHierarchy();
32.123 - String objectName = PlsqlParserUtil.getPackageName(fac, position);
32.124 - if(objectName==null || objectName.length()==0) {
32.125 - objectName = PlsqlParserUtil.getMethodName(fac, position);
32.126 + String packageName = PlsqlParserUtil.getPackageName(fac, position);
32.127 + if (packageName == null || packageName.length() == 0) {
32.128 + packageName = PlsqlParserUtil.getMethodName(fac, position);
32.129 }
32.130 - if(objectName!=null && objectName.length()>0) {
32.131 - if(objectName.startsWith("\"")) {
32.132 - return objectName;
32.133 + if (packageName != null && packageName.length() > 0) {
32.134 + if (packageName.startsWith("\"")) {
32.135 + return packageName;
32.136 } else {
32.137 - return objectName.toUpperCase(Locale.ENGLISH);
32.138 + return packageName.toUpperCase(Locale.ENGLISH);
32.139 }
32.140 }
32.141 return null;
33.1 --- a/PLSQL/Debugging/src/org/netbeans/modules/plsql/debug/PlsqlDebugListenAction.java Tue Feb 14 17:36:37 2012 +0100
33.2 +++ b/PLSQL/Debugging/src/org/netbeans/modules/plsql/debug/PlsqlDebugListenAction.java Wed Aug 15 20:45:01 2012 +0200
33.3 @@ -41,42 +41,48 @@
33.4 */
33.5 package org.netbeans.modules.plsql.debug;
33.6
33.7 +import org.netbeans.api.debugger.DebuggerInfo;
33.8 +import org.netbeans.api.debugger.DebuggerManager;
33.9 +import org.netbeans.api.debugger.Session;
33.10 +import org.netbeans.api.debugger.jpda.ListeningDICookie;
33.11 import org.netbeans.api.project.Project;
33.12 +import org.openide.awt.ActionID;
33.13 +import org.openide.awt.ActionRegistration;
33.14 import org.openide.loaders.DataObject;
33.15 import org.openide.nodes.Node;
33.16 import org.openide.util.Exceptions;
33.17 import org.openide.util.HelpCtx;
33.18 import org.openide.util.NbBundle;
33.19 -import org.openide.util.actions.CookieAction;
33.20 -import org.netbeans.api.debugger.DebuggerInfo;
33.21 -import org.netbeans.api.debugger.DebuggerManager;
33.22 -import org.netbeans.api.debugger.Session;
33.23 -import org.netbeans.api.debugger.jpda.ListeningDICookie;
33.24 import org.openide.util.RequestProcessor;
33.25 import org.openide.util.RequestProcessor.Task;
33.26 +import org.openide.util.actions.CookieAction;
33.27
33.28 -
33.29 +@ActionID(id = "org.netbeans.modules.plsql.debug.PlsqlDebugListenAction", category = "Project/Node")
33.30 +@ActionRegistration(displayName = "#CTL_PlsqlDebugListenAction")
33.31 public final class PlsqlDebugListenAction extends CookieAction {
33.32
33.33 - private static final int DEBUG_PORT=13406;
33.34 + private static final int DEBUG_PORT = 13406;
33.35
33.36 @Override
33.37 protected void performAction(Node[] activatedNodes) {
33.38 Project project = activatedNodes[0].getLookup().lookup(Project.class);
33.39 - if(project!=null) {
33.40 + if (project != null) {
33.41 PlsqlToggleBreakpointActionProvider.setProject(project);
33.42 startNetbeansDebugListener();
33.43 }
33.44 }
33.45
33.46 + @Override
33.47 protected int mode() {
33.48 return CookieAction.MODE_EXACTLY_ONE;
33.49 }
33.50
33.51 + @Override
33.52 public String getName() {
33.53 return NbBundle.getMessage(PlsqlDebugListenAction.class, "CTL_PlsqlDebugListenAction");
33.54 }
33.55
33.56 + @Override
33.57 protected Class[] cookieClasses() {
33.58 return new Class[]{DataObject.class};
33.59 }
33.60 @@ -86,6 +92,7 @@
33.61 return "org/netbeans/modules/plsql/debug/debug.png";
33.62 }
33.63
33.64 + @Override
33.65 public HelpCtx getHelpCtx() {
33.66 return HelpCtx.DEFAULT_HELP;
33.67 }
33.68 @@ -103,18 +110,20 @@
33.69 @Override
33.70 protected boolean enable(Node[] activatedNodes) {
33.71 if (!super.enable(activatedNodes)) {
33.72 - return (activatedNodes.length==1 && activatedNodes[0].getLookup().lookup(Project.class)!=null);
33.73 + return (activatedNodes.length == 1 && activatedNodes[0].getLookup().lookup(Project.class) != null);
33.74 }
33.75 - return activatedNodes.length==1;
33.76 + return activatedNodes.length == 1;
33.77 }
33.78
33.79 private boolean startNetbeansDebugListener() {
33.80 Task task = RequestProcessor.getDefault().post(new Runnable() {
33.81 +
33.82 + @Override
33.83 public void run() {
33.84 - DebuggerManager debugManager = DebuggerManager.getDebuggerManager ();
33.85 + DebuggerManager debugManager = DebuggerManager.getDebuggerManager();
33.86 Session[] sessions = debugManager.getSessions();
33.87 - if(sessions.length==0) {
33.88 - Object [] services = new Object[] { ListeningDICookie.create(DEBUG_PORT), this };
33.89 + if (sessions.length == 0) {
33.90 + Object[] services = new Object[]{ListeningDICookie.create(DEBUG_PORT), this};
33.91
33.92 DebuggerInfo debugInfo = DebuggerInfo.create(ListeningDICookie.ID, services);
33.93 debugManager.startDebugging(debugInfo);
33.94 @@ -130,4 +139,3 @@
33.95 return true;
33.96 }
33.97 }
33.98 -
34.1 --- a/PLSQL/Debugging/src/org/netbeans/modules/plsql/debug/PlsqlEditorContext.java Tue Feb 14 17:36:37 2012 +0100
34.2 +++ b/PLSQL/Debugging/src/org/netbeans/modules/plsql/debug/PlsqlEditorContext.java Wed Aug 15 20:45:01 2012 +0200
34.3 @@ -41,6 +41,7 @@
34.4 */
34.5 package org.netbeans.modules.plsql.debug;
34.6
34.7 +import java.io.UnsupportedEncodingException;
34.8 import static org.netbeans.modules.plsql.lexer.PlsqlBlockType.*;
34.9 import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
34.10 import org.netbeans.modules.plsqlsupport.db.DatabaseContentManager;
34.11 @@ -52,6 +53,7 @@
34.12 import java.beans.PropertyChangeEvent;
34.13 import java.beans.PropertyChangeListener;
34.14 import java.beans.PropertyChangeSupport;
34.15 +import java.io.File;
34.16 import java.lang.reflect.InvocationTargetException;
34.17 import java.net.MalformedURLException;
34.18 import java.net.URL;
34.19 @@ -63,8 +65,11 @@
34.20 import javax.swing.SwingUtilities;
34.21 import javax.swing.text.StyledDocument;
34.22 import org.netbeans.api.db.explorer.DatabaseConnection;
34.23 +import org.netbeans.api.debugger.Breakpoint;
34.24 +import org.netbeans.api.debugger.DebuggerManager;
34.25 import org.netbeans.api.debugger.jpda.JPDAThread;
34.26 import org.netbeans.api.debugger.jpda.LineBreakpoint;
34.27 +import org.netbeans.api.project.FileOwnerQuery;
34.28 import org.netbeans.spi.debugger.jpda.EditorContext;
34.29 import org.netbeans.spi.debugger.ui.EditorContextDispatcher;
34.30 import org.openide.cookies.EditorCookie;
34.31 @@ -77,6 +82,8 @@
34.32 import org.openide.util.WeakListeners;
34.33 import org.netbeans.api.project.Project;
34.34 import org.openide.cookies.LineCookie;
34.35 +import org.openide.filesystems.FileUtil;
34.36 +import org.openide.loaders.DataFolder;
34.37 import org.openide.text.Annotation;
34.38 import org.openide.text.Line;
34.39 import org.openide.util.actions.SystemAction;
34.40 @@ -125,8 +132,8 @@
34.41 }
34.42 return false;
34.43 }
34.44 -
34.45 - private String extractMethodName(String url, String namespace) {
34.46 +
34.47 + private String extractMethodName(String url, String namespace) {
34.48 return null;
34.49 }
34.50
34.51 @@ -184,7 +191,7 @@
34.52 for (Iterator it = annotations.iterator(); it.hasNext();) {
34.53 removeSingleAnnotation((Annotation) it.next());
34.54 }
34.55 - } else {
34.56 + } else if(a instanceof Annotation){
34.57 removeSingleAnnotation((Annotation) a);
34.58 }
34.59 }
34.60 @@ -345,12 +352,9 @@
34.61 if (blockFactory == null) {
34.62 return null;
34.63 }
34.64 -
34.65 +
34.66 int offset = NbDocument.findLineOffset(document, lineNumber - 1);
34.67 PlsqlBlock block = PlsqlBlockUtilities.getCurrentBlock(offset, blockFactory.getBlockHierarchy());
34.68 - if (block == null) {
34.69 - return null;
34.70 - }
34.71
34.72 DatabaseConnectionManager connectionProvider = DatabaseConnectionManager.getInstance(dataObject);
34.73 if (connectionProvider == null) {
34.74 @@ -360,6 +364,17 @@
34.75 if (databaseConnection == null) {
34.76 return null;
34.77 }
34.78 +
34.79 + if (block == null) {
34.80 + //to avoid making the classname null
34.81 + DatabaseContentManager cache = DatabaseContentManager.getInstance(databaseConnection);
34.82 + FileObject primaryFile = dataObject.getPrimaryFile();
34.83 + String fileName = primaryFile.getName();
34.84 + if(cache !=null)
34.85 + return "$Oracle.PackageBody." + cache.getOwner(fileName) + "." + fileName;
34.86 + else
34.87 + return null;
34.88 + }
34.89
34.90 return PlsqlDebuggerUtilities.getClassName(block, databaseConnection);
34.91 }
34.92 @@ -399,7 +414,7 @@
34.93 String url,
34.94 int lineNumber,
34.95 String annotationType,
34.96 - Object timeStamp) {
34.97 + Object timeStamp) {
34.98 return annotate(url, lineNumber, annotationType, timeStamp, null);
34.99 }
34.100
34.101 @@ -445,31 +460,94 @@
34.102 }
34.103
34.104 @Override
34.105 - public Object annotate(final String url,
34.106 - int lineNumber,
34.107 - String annotationType,
34.108 - Object timeStamp,
34.109 - JPDAThread thread) {
34.110 - if (url == null) {
34.111 + public Object annotate(final String url,
34.112 + int lineNumber,
34.113 + String annotationType,
34.114 + Object timeStamp,
34.115 + JPDAThread thread) {
34.116 + if (url == null) {
34.117 + return null;
34.118 + }
34.119 + Project project = PlsqlToggleBreakpointActionProvider.getProject();
34.120 + if (project == null) {
34.121 + return setDebugProject();
34.122 + }
34.123 + DataObject dataObject = getDataObject(url);
34.124 + if (dataObject == null) {
34.125 + final List result = new ArrayList();
34.126 + getDataObject(url, lineNumber, result);
34.127 + if (result.size() > 0) {
34.128 + lineNumber = ((Integer) result.get(0)).intValue();
34.129 + dataObject = (DataObject) result.get(1);
34.130 + }
34.131 + }
34.132 + if (dataObject == null || lineNumber < 1) {
34.133 + return null;
34.134 + }
34.135 + LineCookie lc = dataObject.getCookie(LineCookie.class);
34.136 + if (lc == null) {
34.137 + return null;
34.138 + }
34.139 + Line line = lc.getLineSet().getCurrent(lineNumber - 1);
34.140 + return new DebuggerAnnotation(annotationType, line, thread);
34.141 + }
34.142 +
34.143 + private DataObject setDebugProject() {
34.144 + String debugProj = null;
34.145 + Breakpoint[] breakpoints = DebuggerManager.getDebuggerManager().getBreakpoints();
34.146 + ArrayList<String> projNames = new ArrayList<String>();
34.147 +
34.148 + for(Breakpoint breakpoint : breakpoints){
34.149 + if(projNames.indexOf(breakpoint.getGroupName()) == -1)
34.150 + projNames.add(breakpoint.getGroupName());
34.151 + }
34.152 + if (projNames.isEmpty()) {
34.153 + debugProj = null;
34.154 + } else if (projNames.size() == 1) {
34.155 + debugProj = projNames.get(0);
34.156 + } else {
34.157 + String[] nameArry = new String[projNames.size()];
34.158 + nameArry = projNames.toArray(nameArry);
34.159 + if (!projNames.isEmpty()) {
34.160 + GetProjectDialog projDialog = new GetProjectDialog(null, nameArry, true);
34.161 + projDialog.setVisible(true);
34.162 + debugProj = projDialog.getValue();
34.163 + }
34.164 + }
34.165 + if (debugProj != null) {
34.166 + DataObject dataObject = null;
34.167 + for (Breakpoint breakpoint : breakpoints) {
34.168 + if (breakpoint.getGroupName().equalsIgnoreCase(debugProj)) {
34.169 + if (breakpoint instanceof LineBreakpoint) {
34.170 + LineBreakpoint lbp = (LineBreakpoint) breakpoint;
34.171 + String url = lbp.getURL();
34.172 + int lineNumber = lbp.getLineNumber();
34.173 + if (url != null && lineNumber > -1) {
34.174 + String fileName = url.substring(6);
34.175 + try {
34.176 + fileName = java.net.URLDecoder.decode(fileName, "UTF-8");
34.177 + } catch (UnsupportedEncodingException ex) {
34.178 + Exceptions.printStackTrace(ex);
34.179 + }
34.180 + final File file = new File(fileName);
34.181 + if (!file.exists()) {
34.182 + return null;
34.183 + }
34.184 + try {
34.185 + dataObject = DataFolder.find(FileUtil.toFileObject(file));
34.186 + if (dataObject != null) {
34.187 + Project debugProject = FileOwnerQuery.getOwner(dataObject.getPrimaryFile());
34.188 + PlsqlToggleBreakpointActionProvider.setProject(debugProject);
34.189 + return dataObject;
34.190 + }
34.191 + } catch (DataObjectNotFoundException ex) {
34.192 + return null;
34.193 + }
34.194 + }
34.195 + }
34.196 + }
34.197 + }
34.198 + }
34.199 return null;
34.200 - }
34.201 - DataObject dataObject = getDataObject(url);
34.202 - if (dataObject == null) {
34.203 - final List result = new ArrayList();
34.204 - getDataObject(url, lineNumber, result);
34.205 - if (result.size() > 0) {
34.206 - lineNumber = ((Integer) result.get(0)).intValue();
34.207 - dataObject = (DataObject) result.get(1);
34.208 - }
34.209 - }
34.210 - if (dataObject == null || lineNumber < 1) {
34.211 - return null;
34.212 - }
34.213 - LineCookie lc = dataObject.getCookie(LineCookie.class);
34.214 - if (lc == null) {
34.215 - return null;
34.216 - }
34.217 - Line line = lc.getLineSet().getCurrent(lineNumber - 1);
34.218 - return new DebuggerAnnotation(annotationType, line, thread);
34.219 - }
34.220 + }
34.221 }
35.1 --- a/PLSQL/Debugging/src/org/netbeans/modules/plsql/debug/PlsqlToggleBreakpointActionProvider.java Tue Feb 14 17:36:37 2012 +0100
35.2 +++ b/PLSQL/Debugging/src/org/netbeans/modules/plsql/debug/PlsqlToggleBreakpointActionProvider.java Wed Aug 15 20:45:01 2012 +0200
35.3 @@ -77,16 +77,15 @@
35.4 import org.netbeans.api.project.FileOwnerQuery;
35.5 import org.netbeans.api.project.ProjectUtils;
35.6
35.7 -public class PlsqlToggleBreakpointActionProvider extends ActionsProviderSupport
35.8 - implements PropertyChangeListener {
35.9 +public class PlsqlToggleBreakpointActionProvider extends ActionsProviderSupport implements PropertyChangeListener {
35.10
35.11 private final static Set<Object> ACTIONS = Collections.singleton(ActionsManager.ACTION_TOGGLE_BREAKPOINT);
35.12 - private static Project project=null;
35.13 + private static Project project = null;
35.14
35.15 public PlsqlToggleBreakpointActionProvider() {
35.16 setEnabled(ActionsManager.ACTION_TOGGLE_BREAKPOINT, true);
35.17 TopComponent.getRegistry().addPropertyChangeListener(
35.18 - WeakListeners.propertyChange(this, TopComponent.getRegistry()));
35.19 + WeakListeners.propertyChange(this, TopComponent.getRegistry()));
35.20 }
35.21
35.22 public static Project getProject() {
35.23 @@ -98,9 +97,9 @@
35.24 //enable all breakpoints in this project, disable all other breakpoints
35.25 Breakpoint[] breakpoints = DebuggerManager.getDebuggerManager().getBreakpoints();
35.26 String projectName = ProjectUtils.getInformation(project).getName();
35.27 - for(int i=0; i<breakpoints.length; i++) {
35.28 + for (int i = 0; i < breakpoints.length; i++) {
35.29 Breakpoint breakpoint = breakpoints[i];
35.30 - if(breakpoint.getGroupName()!=null && breakpoint.getGroupName().equals(projectName)) {
35.31 + if (breakpoint.getGroupName() != null && breakpoint.getGroupName().equals(projectName)) {
35.32 breakpoint.enable();
35.33 } else {
35.34 breakpoint.disable();
35.35 @@ -110,26 +109,32 @@
35.36
35.37 public void doAction(Object action) {
35.38 Node node = getActivatedPlsqlNode();
35.39 - if (node == null)
35.40 + if (node == null) {
35.41 return;
35.42 + }
35.43
35.44 DataObject dataObject = node.getLookup().lookup(DataObject.class);
35.45 EditorCookie editorCookie = node.getLookup().lookup(EditorCookie.class);
35.46 - if (dataObject == null || editorCookie == null)
35.47 + if (dataObject == null || editorCookie == null) {
35.48 return;
35.49 + }
35.50 project = FileOwnerQuery.getOwner(dataObject.getPrimaryFile());
35.51 - if(project==null) //don't allow debugging outside of projects...
35.52 + if (project == null) //don't allow debugging outside of projects...
35.53 + {
35.54 return;
35.55 + }
35.56
35.57 JEditorPane editorPane = getEditorPane(editorCookie);
35.58 StyledDocument document = editorCookie.getDocument();
35.59 - if (editorPane == null || document == null)
35.60 + if (editorPane == null || document == null) {
35.61 return;
35.62 + }
35.63
35.64 int caretDot = editorPane.getCaret().getDot();
35.65 int lineNumber = NbDocument.findLineNumber(document, caretDot);
35.66 - if (lineNumber == -1)
35.67 + if (lineNumber == -1) {
35.68 return;
35.69 + }
35.70
35.71 FileObject fileObject = node.getLookup().lookup(FileObject.class);
35.72 String url;
35.73 @@ -144,54 +149,59 @@
35.74 String methodName = null;
35.75 PlsqlBlock block = PlsqlBlockUtilities.getCurrentBlock(caretDot, dataObject.getLookup().lookup(PlsqlBlockFactory.class).getBlockHierarchy());
35.76 if (block != null && lineNumber == NbDocument.findLineNumber(document, block.getStartOffset())) {
35.77 - if (block.getType() == PlsqlBlockType.PROCEDURE_DEF || block.getType() == PlsqlBlockType.PROCEDURE_IMPL)
35.78 + if (block.getType() == PlsqlBlockType.PROCEDURE_DEF || block.getType() == PlsqlBlockType.PROCEDURE_IMPL) {
35.79 methodName = block.getName().toUpperCase(Locale.ENGLISH);
35.80 - else if (block.getType() == PlsqlBlockType.FUNCTION_DEF || block.getType() == PlsqlBlockType.FUNCTION_IMPL)
35.81 + } else if (block.getType() == PlsqlBlockType.FUNCTION_DEF || block.getType() == PlsqlBlockType.FUNCTION_IMPL) {
35.82 methodName = block.getName().toUpperCase(Locale.ENGLISH);
35.83 - else if (block.getType() == PlsqlBlockType.PACKAGE || block.getType() == PlsqlBlockType.PACKAGE_BODY)
35.84 + } else if (block.getType() == PlsqlBlockType.PACKAGE || block.getType() == PlsqlBlockType.PACKAGE_BODY) {
35.85 methodName = ""; // All methods
35.86 -
35.87 + }
35.88 if (methodName != null) {
35.89 DatabaseConnectionManager connectionProvider = DatabaseConnectionManager.getInstance(dataObject);
35.90 - if (connectionProvider == null)
35.91 + if (connectionProvider == null) {
35.92 return;
35.93 + }
35.94 DatabaseConnection databaseConnection = connectionProvider.getTemplateConnection();
35.95 - if (databaseConnection == null)
35.96 + if (databaseConnection == null) {
35.97 return;
35.98 + }
35.99
35.100 className = PlsqlDebuggerUtilities.getClassName(block, databaseConnection);
35.101 - if (className.startsWith("$Oracle.Procedure"))
35.102 + if (className.startsWith("$Oracle.Procedure")) {
35.103 methodName = ""; // All methods
35.104 + }
35.105 }
35.106 }
35.107
35.108 Breakpoint oldBreakpoint = null;
35.109 - String[] classNames = new String[] {className};
35.110 - for (Breakpoint point : DebuggerManager.getDebuggerManager().getBreakpoints())
35.111 + String[] classNames = new String[]{className};
35.112 + for (Breakpoint point : DebuggerManager.getDebuggerManager().getBreakpoints()) {
35.113 if (className != null && point instanceof MethodBreakpoint) {
35.114 - MethodBreakpoint methodBreakpoint = (MethodBreakpoint)point;
35.115 + MethodBreakpoint methodBreakpoint = (MethodBreakpoint) point;
35.116 if (methodName.equals(methodBreakpoint.getMethodName())
35.117 - && Arrays.deepEquals(classNames, methodBreakpoint.getClassFilters())) {
35.118 + && Arrays.deepEquals(classNames, methodBreakpoint.getClassFilters())) {
35.119 oldBreakpoint = methodBreakpoint;
35.120 break;
35.121 }
35.122 } else if (point instanceof LineBreakpoint) {
35.123 - LineBreakpoint lineBreakpoint = (LineBreakpoint)point;
35.124 - if (lineBreakpoint.getURL().equals(url) &&
35.125 - lineBreakpoint.getLineNumber() == lineNumber + 1) {
35.126 + LineBreakpoint lineBreakpoint = (LineBreakpoint) point;
35.127 + if (lineBreakpoint.getURL().equals(url)
35.128 + && lineBreakpoint.getLineNumber() == lineNumber + 1) {
35.129 oldBreakpoint = lineBreakpoint;
35.130 break;
35.131 }
35.132 }
35.133 + }
35.134
35.135 - if (oldBreakpoint != null)
35.136 + if (oldBreakpoint != null) {
35.137 DebuggerManager.getDebuggerManager().removeBreakpoint(oldBreakpoint);
35.138 - else {
35.139 + } else {
35.140 Breakpoint breakpoint = null;
35.141 - if (className != null)
35.142 + if (className != null) {
35.143 breakpoint = MethodBreakpoint.create(className, methodName);
35.144 - else
35.145 + } else {
35.146 breakpoint = LineBreakpoint.create(url, lineNumber + 1);
35.147 + }
35.148 breakpoint.setGroupName(ProjectUtils.getInformation(project).getName());
35.149 DebuggerManager.getDebuggerManager().addBreakpoint(breakpoint);
35.150 }
35.151 @@ -209,8 +219,9 @@
35.152 Node[] nodes = TopComponent.getRegistry().getCurrentNodes();
35.153 if (nodes != null && nodes.length == 1) {
35.154 FileObject file = nodes[0].getLookup().lookup(FileObject.class);
35.155 - if (file != null && file.getMIMEType().equals("text/x-plsql"))
35.156 + if (file != null && file.getMIMEType().equals("text/x-plsql")) {
35.157 return nodes[0];
35.158 + }
35.159 }
35.160 return null;
35.161 }
35.162 @@ -223,15 +234,16 @@
35.163 final JEditorPane[] paneArray = new JEditorPane[1];
35.164 try {
35.165 EventQueue.invokeAndWait(new Runnable() {
35.166 +
35.167 public void run() {
35.168 JEditorPane[] panes = editorCookie.getOpenedPanes();
35.169 paneArray[0] = panes != null && panes.length == 1 ? panes[0] : null;
35.170 }
35.171 });
35.172 } catch (InvocationTargetException ex) {
35.173 - ex.printStackTrace();
35.174 + Exceptions.printStackTrace(ex);
35.175 } catch (InterruptedException ex) {
35.176 - ex.printStackTrace();
35.177 + Exceptions.printStackTrace(ex);
35.178 }
35.179 return paneArray[0];
35.180 }
36.1 --- a/PLSQL/Debugging/src/org/netbeans/modules/plsql/debug/layer.xml Tue Feb 14 17:36:37 2012 +0100
36.2 +++ b/PLSQL/Debugging/src/org/netbeans/modules/plsql/debug/layer.xml Wed Aug 15 20:45:01 2012 +0200
36.3 @@ -1,28 +1,6 @@
36.4 <?xml version="1.0" encoding="UTF-8"?>
36.5 <!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
36.6 <filesystem>
36.7 - <folder name="Actions">
36.8 - <folder name="PLSQL">
36.9 - <file name="org-netbeans-modules-plsql-debug-PlsqlDebugAction.instance">
36.10 - <attr name="instanceClass" stringvalue="org.netbeans.modules.plsql.debug.PlsqlDebugAction"/>
36.11 - </file>
36.12 - <file name="org-netbeans-modules-plsql-debug-PlsqlDebugCompileAction.instance">
36.13 - <attr name="instanceClass" stringvalue="org.netbeans.modules.plsql.debug.PlsqlDebugCompileAction"/>
36.14 - </file>
36.15 - </folder>
36.16 - <folder name="Project">
36.17 - <folder name="Node">
36.18 - <file name="org-netbeans-modules-plsql-debug-PlsqlDebugListenAction-separatorBefore.instance">
36.19 - <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
36.20 - <attr name="position" intvalue="700"/>
36.21 - </file>
36.22 - <file name="org-netbeans-modules-plsql-debug-PlsqlDebugListenAction.instance">
36.23 - <attr name="instanceClass" stringvalue="org.netbeans.modules.plsql.debug.PlsqlDebugListenAction"/>
36.24 - <attr name="position" intvalue="710"/>
36.25 - </file>
36.26 - </folder>
36.27 - </folder>
36.28 - </folder>
36.29 <folder name="Editors">
36.30 <folder name="text">
36.31 <folder name="x-plsql">
36.32 @@ -33,22 +11,15 @@
36.33 </file>
36.34 </folder>
36.35 <folder name="Popup">
36.36 - <file name="org-netbeans-modules-plsql-debug-DebugCompileAction.shadow">
36.37 - <attr name="originalFile" stringvalue="Actions/PLSQL/org-netbeans-modules-plsql-debug-PlsqlDebugCompileAction.instance"/>
36.38 - <attr name="position" intvalue="695"/>
36.39 - </file>
36.40 - <file name="org-netbeans-modules-debugger-ui-actions-ToggleBreakpointAction.shadow">
36.41 - <attr name="originalFile" stringvalue="Actions/Debug/org-netbeans-modules-debugger-ui-actions-ToggleBreakpointAction.instance"/>
36.42 - <attr name="position" intvalue="1005"/>
36.43 - </file>
36.44 - <file name="org-netbeans-modules-debugger-ui-actions-ToggleBreakpointAction.instance">
36.45 - <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
36.46 - <attr name="position" intvalue="1010"/>
36.47 - </file>
36.48 + <file name="org-netbeans-modules-debugger-ui-actions-ToggleBreakpointAction.shadow">
36.49 + <attr name="originalFile" stringvalue="Actions/Debug/org-netbeans-modules-debugger-ui-actions-ToggleBreakpointAction.instance"/>
36.50 + <attr name="position" intvalue="1005"/>
36.51 + </file>
36.52 </folder>
36.53 <folder name="Toolbars">
36.54 <folder name="Default">
36.55 <file name="org-netbeans-modules-plsql-debug-PlsqlDebugAction.instance">
36.56 + <attr bundlevalue="org.netbeans.modules.plsql.debug.Bundle#CTL_PlsqlDebugAction" name="displayName"/>
36.57 <attr name="position" intvalue="19600"/>
36.58 </file>
36.59 </folder>
37.1 --- a/PLSQL/Execution/manifest.mf Tue Feb 14 17:36:37 2012 +0100
37.2 +++ b/PLSQL/Execution/manifest.mf Wed Aug 15 20:45:01 2012 +0200
37.3 @@ -5,6 +5,6 @@
37.4 OpenIDE-Module-Layer: org/netbeans/modules/plsql/execution/layer.xml
37.5 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/plsql/execution
37.6 /Bundle.properties
37.7 -OpenIDE-Module-Specification-Version: 1.8.20
37.8 +OpenIDE-Module-Specification-Version: 8.72.0.8
37.9 AutoUpdate-Show-In-Client: false
37.10
38.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/Bundle.properties Tue Feb 14 17:36:37 2012 +0100
38.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/Bundle.properties Wed Aug 15 20:45:01 2012 +0200
38.3 @@ -6,7 +6,8 @@
38.4 CTL_DescribeAction=Describe
38.5 CTL_CopyAsJavaStringAction=Copy as Java String
38.6 CTL_PasteAsSqlCommandAction=Paste as SQL Command
38.7 -CTL_fileExecution=Execute (Alt+Shift+E)
38.8 +CTL_Execution=Execute
38.9 +CTL_ExecutionDescription=Execute (Ctrl+Shift+E)
38.10 CTL_fileCommit=Auto Commit ON
38.11 CTL_PlsqlExecutionHistoryAction=Execution History
38.12 CTL_PlsqlExecutionHistoryNextAction=Next Entry in Execution History
38.13 @@ -23,3 +24,5 @@
38.14 PromptDialog.okButton.text=OK
38.15 PromptDialog.lblPrompt.text=
38.16 PromptDialog.fieldSubstitutionValue.text=
38.17 +SelectMethodDialog.jLabel1.text=Available Methods
38.18 +SelectMethodDialog.btnOk.text=OK
39.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/CopyAsJavaStringAction.java Tue Feb 14 17:36:37 2012 +0100
39.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/CopyAsJavaStringAction.java Wed Aug 15 20:45:01 2012 +0200
39.3 @@ -61,7 +61,7 @@
39.4
39.5 @ActionID(id = "org.netbeans.modules.plsql.execution.CopyAsJavaStringAction", category = "PLSQL")
39.6 @ActionRegistration(displayName = "#CTL_CopyAsJavaStringAction")
39.7 -@ActionReference(path = "Editors/text/x-plsql/Popup", position = 285)
39.8 +@ActionReference(path = "Editors/text/x-plsql/Popup", position = 3995)
39.9 public class CopyAsJavaStringAction extends CookieAction {
39.10
39.11 @Override
39.12 @@ -84,7 +84,7 @@
39.13
39.14 //first check if the user has selected some text
39.15 if ((panes != null) && (panes.length != 0)) {
39.16 - selectedText = panes[0].getSelectedText();
39.17 + selectedText = panes[0].getSelectedText();
39.18 }
39.19 //if no selection then consider the contents of the whole document
39.20 if (selectedText == null || selectedText.equals("")) {
39.21 @@ -102,16 +102,16 @@
39.22 String[] lines = selectedText.trim().split("\n");
39.23 for (int i = 0; i < lines.length; i++) {
39.24 String line = lines[i].replaceAll("\"", "\\\\\""); //escape any " found in the SQL command
39.25 - if(i==0){ //first line
39.26 - if (i==lines.length-1) //single line SQL command
39.27 - sb.append("String dbStmt = \"" ).append(line.replaceAll("\\s+$", "")).append("\";");
39.28 - else
39.29 - sb.append("String dbStmt = \"" ).append(line.replaceAll("\\s+$", "")).append(" \"\n\t\t");
39.30 - }
39.31 - else if(i == lines.length - 1) { //last line when multiple lines exist
39.32 + if (i == 0) { //first line
39.33 + if (i == lines.length - 1) //single line SQL command
39.34 + {
39.35 + sb.append("String dbStmt = \"").append(line.replaceAll("\\s+$", "")).append("\";");
39.36 + } else {
39.37 + sb.append("String dbStmt = \"").append(line.replaceAll("\\s+$", "")).append(" \"\n\t\t");
39.38 + }
39.39 + } else if (i == lines.length - 1) { //last line when multiple lines exist
39.40 sb.append(" +\"").append(line.replaceAll("\\s+$", "")).append("\";");
39.41 - }
39.42 - else {
39.43 + } else {
39.44 sb.append(" +\"").append(line.replaceAll("\\s+$", "")).append(" \"\n\t\t");
39.45 }
39.46 }
39.47 @@ -119,14 +119,14 @@
39.48 String formattedText = sb.toString();
39.49 Clipboard clipboard = Lookup.getDefault().lookup(ExClipboard.class);
39.50 //should we check for system clipboard as well?
39.51 - if (clipboard != null) {
39.52 + if (clipboard != null) {
39.53 clipboard.setContents(new StringSelection(formattedText), null);
39.54 }
39.55 }
39.56 }
39.57
39.58 @Override
39.59 - public String getName() {
39.60 + public String getName() {
39.61 return NbBundle.getMessage(CopyAsJavaStringAction.class, "CTL_CopyAsJavaStringAction");
39.62 }
39.63
40.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/CreateTestBlockAction.java Tue Feb 14 17:36:37 2012 +0100
40.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/CreateTestBlockAction.java Wed Aug 15 20:45:01 2012 +0200
40.3 @@ -41,17 +41,6 @@
40.4 */
40.5 package org.netbeans.modules.plsql.execution;
40.6
40.7 -import static org.netbeans.modules.plsql.lexer.PlsqlBlockType.*;
40.8 -import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
40.9 -import org.netbeans.modules.plsqlsupport.db.DatabaseContentManager;
40.10 -import org.netbeans.modules.plsqlsupport.db.ui.SQLCommandWindow;
40.11 -import org.netbeans.modules.plsql.lexer.PlsqlBlockFactory;
40.12 -import org.netbeans.modules.plsql.lexer.PlsqlBlock;
40.13 -import org.netbeans.modules.plsql.lexer.PlsqlTokenId;
40.14 -import org.netbeans.modules.plsql.utilities.NotConnectedToDbException;
40.15 -import org.netbeans.modules.plsql.utilities.PlsqlFileUtil;
40.16 -import org.netbeans.modules.plsql.utilities.PlsqlFileValidatorService;
40.17 -import org.netbeans.modules.plsql.utilities.PlsqlParserUtil;
40.18 import java.util.ArrayList;
40.19 import java.util.List;
40.20 import java.util.StringTokenizer;
40.21 @@ -66,6 +55,17 @@
40.22 import org.netbeans.api.lexer.TokenSequence;
40.23 import org.netbeans.api.project.FileOwnerQuery;
40.24 import org.netbeans.api.project.Project;
40.25 +import org.netbeans.modules.plsql.lexer.PlsqlBlock;
40.26 +import org.netbeans.modules.plsql.lexer.PlsqlBlockFactory;
40.27 +import static org.netbeans.modules.plsql.lexer.PlsqlBlockType.*;
40.28 +import org.netbeans.modules.plsql.lexer.PlsqlTokenId;
40.29 +import org.netbeans.modules.plsql.utilities.NotConnectedToDbException;
40.30 +import org.netbeans.modules.plsql.utilities.PlsqlFileUtil;
40.31 +import org.netbeans.modules.plsql.utilities.PlsqlFileValidatorService;
40.32 +import org.netbeans.modules.plsql.utilities.PlsqlParserUtil;
40.33 +import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
40.34 +import org.netbeans.modules.plsqlsupport.db.DatabaseContentManager;
40.35 +import org.netbeans.modules.plsqlsupport.db.ui.SQLCommandWindow;
40.36 import org.openide.awt.ActionID;
40.37 import org.openide.awt.ActionReference;
40.38 import org.openide.awt.ActionReferences;
40.39 @@ -84,7 +84,7 @@
40.40 @ActionRegistration(displayName = "#CTL_CreateTestBlockAction")
40.41 @ActionReferences(value = {
40.42 @ActionReference(path = "Shortcuts", name = "AS-B"),
40.43 - @ActionReference(path = "Editors/text/x-plsql/Popup", position = 281)})
40.44 + @ActionReference(path = "Editors/text/x-plsql/Popup", position = 1010)})
40.45 public final class CreateTestBlockAction extends CookieAction {
40.46
40.47 private static final PlsqlFileValidatorService validator = Lookup.getDefault().lookup(PlsqlFileValidatorService.class);
40.48 @@ -106,7 +106,7 @@
40.49 return;
40.50 }
40.51
40.52 - String tempTemplate = "";
40.53 + String tempTemplate = "-- Enter values for your parameters. Use enter to move to the next parameter\n";
40.54
40.55 Project project = FileOwnerQuery.getOwner(dataObject.getPrimaryFile());
40.56 if (project == null) {
40.57 @@ -119,10 +119,10 @@
40.58 DatabaseConnection databaseConnection = dbConnectionProvider != null ? dbConnectionProvider.getPooledDatabaseConnection(false) : null;
40.59 try {
40.60 if (selectedBlock != null && selectedBlock.getType() == VIEW) {
40.61 - tempTemplate = "SELECT ${*} FROM " + selectedName + ";\n${cursor}";
40.62 + tempTemplate = tempTemplate + "SELECT ${*} FROM " + selectedName + ";\n${cursor}";
40.63 } else if (selectedBlock != null && selectedBlock.getType() == CURSOR) {
40.64 try {
40.65 - tempTemplate = doc.getText(selectedBlock.getStartOffset(), selectedBlock.getEndOffset() - selectedBlock.getStartOffset());
40.66 + tempTemplate = tempTemplate + doc.getText(selectedBlock.getStartOffset(), selectedBlock.getEndOffset() - selectedBlock.getStartOffset());
40.67 } catch (BadLocationException ex) {
40.68 //Failed to extract statement from cursor. This shouldn't happen, but if it does - do nothing;
40.69 return;
40.70 @@ -156,6 +156,7 @@
40.71 selectedBlock = null;
40.72 DataObject dataObj = null;
40.73 PlsqlBlock block = PlsqlParserUtil.findMatchingBlock(PlsqlParserUtil.getBlockHierarchy(dataObject), doc, doc, selectedName, parentName, temp.getStartOffset(), false, false, true);
40.74 +
40.75 if (block == null) {
40.76 Document specDoc = getSpecDocument(doc);
40.77 if (specDoc == null) {
40.78 @@ -183,7 +184,7 @@
40.79 if (selectedBlock.getParent() != null) {
40.80 selectedName = selectedBlock.getParent().getName() + "." + selectedBlock.getName();
40.81 }
40.82 - tempTemplate = createMethodTemplate(doc);
40.83 + tempTemplate = tempTemplate + createMethodTemplate(doc);
40.84 } catch (NotConnectedToDbException e) {
40.85 Exceptions.printStackTrace(e);
40.86 }
40.87 @@ -357,7 +358,7 @@
40.88 }
40.89
40.90 //Now we have got the parameters and types
40.91 - tempTemplate = "DECLARE\n";
40.92 + tempTemplate = tempTemplate + "DECLARE\n";
40.93 for (int i = 0; i < keys.size(); i++) {
40.94 boolean out = false;
40.95 boolean in = false;
40.96 @@ -663,7 +664,8 @@
40.97
40.98 private void selectMatchingBlock(DataObject dataObj, Document specDoc, int offset) {
40.99 List<PlsqlBlock> newBlockHier = PlsqlParserUtil.getBlockHierarchy(dataObj);
40.100 - PlsqlBlock block = PlsqlParserUtil.findMatchingBlock(newBlockHier, doc, specDoc, selectedName, parentName, offset, false, false, true);
40.101 + // PlsqlBlock block = null;
40.102 + PlsqlBlock block = PlsqlParserUtil.findMatchingBlock(newBlockHier, doc, specDoc, selectedName, parentName, offset, false, false, true);
40.103 if (block != null && block.getParent() != null) {
40.104 selectedBlock = block;
40.105 doc = specDoc;
41.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/DescribeAction.java Tue Feb 14 17:36:37 2012 +0100
41.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/DescribeAction.java Wed Aug 15 20:45:01 2012 +0200
41.3 @@ -41,12 +41,12 @@
41.4 */
41.5 package org.netbeans.modules.plsql.execution;
41.6
41.7 -import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
41.8 -import org.netbeans.modules.plsqlsupport.db.DatabaseContentManager;
41.9 import java.util.ArrayList;
41.10 import java.util.List;
41.11 import javax.swing.text.Document;
41.12 import org.netbeans.api.db.explorer.DatabaseConnection;
41.13 +import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
41.14 +import org.netbeans.modules.plsqlsupport.db.DatabaseContentManager;
41.15 import org.openide.awt.ActionID;
41.16 import org.openide.awt.ActionReference;
41.17 import org.openide.awt.ActionRegistration;
41.18 @@ -64,91 +64,91 @@
41.19 */
41.20 @ActionID(id = "org.netbeans.modules.plsql.execution.DescribeAction", category = "PLSQL")
41.21 @ActionRegistration(displayName = "#CTL_DescribeAction")
41.22 -@ActionReference(path = "Editors/text/x-plsql/Popup", position = 283)
41.23 +@ActionReference(path = "Editors/text/x-plsql/Popup", position = 440, separatorAfter = 450)
41.24 public class DescribeAction extends CookieAction {
41.25
41.26 - private String viewName = null;
41.27 + private static final RequestProcessor RP = new RequestProcessor(DescribeAction.class);
41.28 + private String viewName = null;
41.29
41.30 - @Override
41.31 - protected int mode() {
41.32 - return CookieAction.MODE_EXACTLY_ONE;
41.33 - }
41.34 + @Override
41.35 + protected int mode() {
41.36 + return CookieAction.MODE_EXACTLY_ONE;
41.37 + }
41.38
41.39 - @Override
41.40 - protected Class<?>[] cookieClasses() {
41.41 - return new Class[]{DataObject.class, EditorCookie.class};
41.42 - }
41.43 + @Override
41.44 + protected Class<?>[] cookieClasses() {
41.45 + return new Class[]{DataObject.class, EditorCookie.class};
41.46 + }
41.47
41.48 - @Override
41.49 - protected void performAction(Node[] activatedNodes) {
41.50 - DataObject dataObject = activatedNodes[0].getLookup().lookup(DataObject.class);
41.51 - EditorCookie ec = dataObject.getCookie(EditorCookie.class);
41.52 - final Document doc = ec.getDocument();
41.53 - final DatabaseConnectionManager connectionProvider = DatabaseConnectionManager.getInstance(dataObject);
41.54 - final DatabaseConnection connection = connectionProvider.getPooledDatabaseConnection(true);
41.55 - if (connection == null) {
41.56 - return;
41.57 - }
41.58 + @Override
41.59 + protected void performAction(Node[] activatedNodes) {
41.60 + DataObject dataObject = activatedNodes[0].getLookup().lookup(DataObject.class);
41.61 + EditorCookie ec = dataObject.getCookie(EditorCookie.class);
41.62 + final Document doc = ec.getDocument();
41.63 + final DatabaseConnectionManager connectionProvider = DatabaseConnectionManager.getInstance(dataObject);
41.64 + final DatabaseConnection connection = connectionProvider.getPooledDatabaseConnection(true);
41.65 + if (connection == null) {
41.66 + return;
41.67 + }
41.68
41.69 - RequestProcessor processor = RequestProcessor.getDefault();
41.70 - processor.post(new Runnable() {
41.71 + RP.post(new Runnable() {
41.72
41.73 - @Override
41.74 - public void run() {
41.75 - try {
41.76 - String selectStatement = "DESC " + viewName;
41.77 - PlsqlFileExecutor executor = new PlsqlFileExecutor(connectionProvider, connection);
41.78 - List<PlsqlExecutableObject> exeBlocks = new ArrayList<PlsqlExecutableObject>();
41.79 - exeBlocks.add(new PlsqlExecutableObject(0, selectStatement, "DESC", PlsqlExecutableObjectType.STATEMENT, 0, selectStatement.length() - 1));
41.80 - executor.executePLSQL(exeBlocks, doc, true, true);
41.81 - } finally {
41.82 - if (connection != null) {
41.83 - connectionProvider.releaseDatabaseConnection(connection);
41.84 - }
41.85 + @Override
41.86 + public void run() {
41.87 + try {
41.88 + String selectStatement = "DESC " + viewName;
41.89 + PlsqlFileExecutor executor = new PlsqlFileExecutor(connectionProvider, connection);
41.90 + List<PlsqlExecutableObject> exeBlocks = new ArrayList<PlsqlExecutableObject>();
41.91 + exeBlocks.add(new PlsqlExecutableObject(0, selectStatement, "DESC", PlsqlExecutableObjectType.STATEMENT, 0, selectStatement.length() - 1));
41.92 + executor.executePLSQL(exeBlocks, doc, true, true);
41.93 + } finally {
41.94 + if (connection != null) {
41.95 + connectionProvider.releaseDatabaseConnection(connection);
41.96 + }
41.97 + }
41.98 }
41.99 - }
41.100 - });
41.101 - }
41.102 + });
41.103 + }
41.104
41.105 - @Override
41.106 - public String getName() {
41.107 - return NbBundle.getMessage(ViewDataAction.class, "CTL_DescribeAction");
41.108 - }
41.109 + @Override
41.110 + public String getName() {
41.111 + return NbBundle.getMessage(ViewDataAction.class, "CTL_DescribeAction");
41.112 + }
41.113
41.114 - @Override
41.115 - public HelpCtx getHelpCtx() {
41.116 - return HelpCtx.DEFAULT_HELP;
41.117 - }
41.118 + @Override
41.119 + public HelpCtx getHelpCtx() {
41.120 + return HelpCtx.DEFAULT_HELP;
41.121 + }
41.122
41.123 - @Override
41.124 - protected boolean enable(Node[] activatedNodes) {
41.125 - viewName = null;
41.126 + @Override
41.127 + protected boolean enable(Node[] activatedNodes) {
41.128 + viewName = null;
41.129
41.130 - if (!super.enable(activatedNodes)) {
41.131 - return false;
41.132 - }
41.133 + if (!super.enable(activatedNodes)) {
41.134 + return false;
41.135 + }
41.136
41.137 - DataObject dataObject = activatedNodes[0].getLookup().lookup(DataObject.class);
41.138 - if (dataObject == null) {
41.139 - return false;
41.140 - }
41.141 + DataObject dataObject = activatedNodes[0].getLookup().lookup(DataObject.class);
41.142 + if (dataObject == null) {
41.143 + return false;
41.144 + }
41.145
41.146 - DatabaseConnectionManager connectionProvider = DatabaseConnectionManager.getInstance(dataObject);
41.147 - if (connectionProvider == null) {
41.148 - return false;
41.149 - }
41.150 + DatabaseConnectionManager connectionProvider = DatabaseConnectionManager.getInstance(dataObject);
41.151 + if (connectionProvider == null) {
41.152 + return false;
41.153 + }
41.154
41.155 - DatabaseConnection connection = connectionProvider.getDatabaseConnection(false);
41.156 - if (connection == null) {
41.157 - return false;
41.158 - }
41.159 + DatabaseConnection connection = connectionProvider.getDatabaseConnection(false);
41.160 + if (connection == null) {
41.161 + return false;
41.162 + }
41.163
41.164 - viewName = ViewDataAction.getSelectedViewOrTable(activatedNodes);
41.165 - if (viewName == null) {
41.166 - return false;
41.167 - }
41.168 + viewName = ViewDataAction.getSelectedViewOrTable(activatedNodes);
41.169 + if (viewName == null) {
41.170 + return false;
41.171 + }
41.172
41.173 - DatabaseContentManager dbCache = DatabaseContentManager.getInstance(connection);
41.174 - return dbCache.isView(viewName, connection) || dbCache.isTable(viewName, connection);
41.175 - }
41.176 + DatabaseContentManager dbCache = DatabaseContentManager.getInstance(connection);
41.177 + return dbCache.isView(viewName, connection) || dbCache.isTable(viewName, connection);
41.178 + }
41.179 }
42.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PasteAsSqlCommandAction.java Tue Feb 14 17:36:37 2012 +0100
42.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PasteAsSqlCommandAction.java Wed Aug 15 20:45:01 2012 +0200
42.3 @@ -67,7 +67,7 @@
42.4
42.5 @ActionID(id = "org.netbeans.modules.plsql.execution.PasteAsSqlCommandAction", category = "PLSQL")
42.6 @ActionRegistration(displayName = "#CTL_PasteAsSqlCommandAction")
42.7 -@ActionReference(path = "Editors/text/x-plsql/Popup", position = 286)
42.8 +@ActionReference(path = "Editors/text/x-plsql/Popup", position = 4010)
42.9 public class PasteAsSqlCommandAction extends CookieAction {
42.10
42.11 @Override
42.12 @@ -88,62 +88,62 @@
42.13 Clipboard clipboard = Lookup.getDefault().lookup(ExClipboard.class);
42.14 Transferable trn = clipboard.getContents(null);
42.15 if (trn != null) {
42.16 - try {
42.17 - String contents = (String) trn.getTransferData(DataFlavor.stringFlavor);
42.18 - StringBuilder sb = new StringBuilder();
42.19 - String[] lines = contents.trim().split("\n");
42.20 - int paramCount = 0; //counter for '?' in SQL
42.21 - for (int i = 0; i < lines.length; i++) {
42.22 - String line = lines[i].replaceAll("\\s+$", ""); //remove trailing space
42.23 - line = line.replace("\\\"" , "\""); // remove java escape (i.e. \) for double quotes used for column aliases in selects
42.24 - line = line.replaceFirst("^\\s*\\+?\\s*\"", ""); // remove lines starting with " or +"
42.25 - line = line.replaceAll("\"\\s*\\+?$", ""); // remove " and "+ from eol
42.26 - line = line.replaceAll("\"\\s*;+$", ""); // remove "; from eol
42.27 - //replace ? with code template place holders
42.28 - for (;line.indexOf("?")>0;++paramCount){
42.29 - line = line.replaceFirst("\\?", "\\${<value_"+paramCount+">}");
42.30 - }
42.31 -
42.32 - if (line.trim().startsWith("\"")) {
42.33 - line = line.replaceFirst("\"", ""); //preserves spaces at begining
42.34 - }
42.35 -
42.36 - //finally append line to string builder
42.37 - if (i == lines.length - 1) {
42.38 - sb.append(line);
42.39 - } else {
42.40 - sb.append(line).append("\n");
42.41 - }
42.42 - }
42.43 - JEditorPane[] panes = ec.getOpenedPanes();
42.44 - if (panes != null && panes.length > 0) {
42.45 - insert(sb.toString(), panes[0], doc);
42.46 + try {
42.47 + String contents = (String) trn.getTransferData(DataFlavor.stringFlavor);
42.48 + StringBuilder sb = new StringBuilder();
42.49 + String[] lines = contents.trim().split("\n");
42.50 + int paramCount = 0; //counter for '?' in SQL
42.51 + for (int i = 0; i < lines.length; i++) {
42.52 + String line = lines[i].replaceAll("\\s+$", ""); //remove trailing space
42.53 + line = line.replace("\\\"", "\""); // remove java escape (i.e. \) for double quotes used for column aliases in selects
42.54 + line = line.replaceFirst("^\\s*\\+?\\s*\"", ""); // remove lines starting with " or +"
42.55 + line = line.replaceAll("\"\\s*\\+?$", ""); // remove " and "+ from eol
42.56 + line = line.replaceAll("\"\\s*;+$", ""); // remove "; from eol
42.57 + //replace ? with code template place holders
42.58 + for (; line.indexOf("?") > 0; ++paramCount) {
42.59 + line = line.replaceFirst("\\?", "\\${<value_" + paramCount + ">}");
42.60 }
42.61
42.62 - } catch (UnsupportedFlavorException ex) {
42.63 - Exceptions.printStackTrace(ex);
42.64 - } catch (Exception ex) {
42.65 - Exceptions.printStackTrace(ex);
42.66 + if (line.trim().startsWith("\"")) {
42.67 + line = line.replaceFirst("\"", ""); //preserves spaces at begining
42.68 + }
42.69 +
42.70 + //finally append line to string builder
42.71 + if (i == lines.length - 1) {
42.72 + sb.append(line);
42.73 + } else {
42.74 + sb.append(line).append("\n");
42.75 + }
42.76 }
42.77 + JEditorPane[] panes = ec.getOpenedPanes();
42.78 + if (panes != null && panes.length > 0) {
42.79 + insert(sb.toString(), panes[0], doc);
42.80 + }
42.81 +
42.82 + } catch (UnsupportedFlavorException ex) {
42.83 + Exceptions.printStackTrace(ex);
42.84 + } catch (Exception ex) {
42.85 + Exceptions.printStackTrace(ex);
42.86 + }
42.87 }
42.88 }
42.89 -
42.90 - private static void insert(String s, final JTextComponent target, final Document doc) {
42.91 +
42.92 + private static void insert(String s, final JTextComponent target, final Document doc) {
42.93 try {
42.94 //at first, find selected text range
42.95 Caret caret = target.getCaret();
42.96 int p0 = Math.min(caret.getDot(), caret.getMark());
42.97 int p1 = Math.max(caret.getDot(), caret.getMark());
42.98 - doc.remove(p0, p1 - p0);
42.99 + doc.remove(p0, p1 - p0);
42.100 CodeTemplate ct = CodeTemplateManager.get(target.getDocument()).createTemporary(s);
42.101 - ct.insert(target);
42.102 + ct.insert(target);
42.103 } catch (BadLocationException ble) {
42.104 Exceptions.printStackTrace(ble);
42.105 - }
42.106 + }
42.107 }
42.108
42.109 @Override
42.110 - public String getName() {
42.111 + public String getName() {
42.112 return NbBundle.getMessage(PasteAsSqlCommandAction.class, "CTL_PasteAsSqlCommandAction");
42.113 }
42.114
43.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
43.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlCommit.java Wed Aug 15 20:45:01 2012 +0200
43.3 @@ -0,0 +1,183 @@
43.4 +/*
43.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
43.6 + *
43.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
43.8 + *
43.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
43.10 + * Other names may be trademarks of their respective owners.
43.11 + *
43.12 + * The contents of this file are subject to the terms of either the GNU
43.13 + * General Public License Version 2 only ("GPL") or the Common
43.14 + * Development and Distribution License("CDDL") (collectively, the
43.15 + * "License"). You may not use this file except in compliance with the
43.16 + * License. You can obtain a copy of the License at
43.17 + * http://www.netbeans.org/cddl-gplv2.html
43.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
43.19 + * specific language governing permissions and limitations under the
43.20 + * License. When distributing the software, include this License Header
43.21 + * Notice in each file and include the License file at
43.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
43.23 + * particular file as subject to the "Classpath" exception as provided
43.24 + * by Oracle in the GPL Version 2 section of the License file that
43.25 + * accompanied this code. If applicable, add the following below the
43.26 + * License Header, with the fields enclosed by brackets [] replaced by
43.27 + * your own identifying information:
43.28 + * "Portions Copyrighted [year] [name of copyright owner]"
43.29 + *
43.30 + * If you wish your version of this file to be governed by only the CDDL
43.31 + * or only the GPL Version 2, indicate your decision by adding
43.32 + * "[Contributor] elects to include this software in this distribution
43.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
43.34 + * single choice of license, a recipient has the option to distribute
43.35 + * your version of this file under either the CDDL, the GPL Version 2 or
43.36 + * to extend the choice of license to its licensees as provided above.
43.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
43.38 + * Version 2 license, then the option applies only if the new code is
43.39 + * made subject to such option by the copyright holder.
43.40 + *
43.41 + * Contributor(s):
43.42 + *
43.43 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
43.44 + */
43.45 +package org.netbeans.modules.plsql.execution;
43.46 +
43.47 +import java.awt.event.ActionEvent;
43.48 +import java.beans.PropertyChangeListener;
43.49 +import java.beans.PropertyChangeSupport;
43.50 +import java.util.ArrayList;
43.51 +import java.util.List;
43.52 +import javax.swing.AbstractAction;
43.53 +import javax.swing.text.Document;
43.54 +import org.netbeans.api.db.explorer.DatabaseConnection;
43.55 +import org.openide.loaders.DataObject;
43.56 +import org.openide.windows.InputOutput;
43.57 +import org.netbeans.api.progress.ProgressHandle;
43.58 +import org.netbeans.api.progress.ProgressHandleFactory;
43.59 +import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
43.60 +import org.openide.cookies.EditorCookie;
43.61 +import org.openide.util.Exceptions;
43.62 +import org.openide.windows.IOProvider;
43.63 +
43.64 +/**
43.65 + *
43.66 + * @author SubSLK
43.67 + */
43.68 +public class PlsqlCommit extends AbstractAction {
43.69 +
43.70 + private boolean commit;
43.71 + private DataObject dataObject;
43.72 + private static List<PlsqlCommit> instance = new ArrayList<PlsqlCommit>();
43.73 + public static final String PROP_commit = "PlsqlCommit";
43.74 + private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
43.75 +
43.76 + private PlsqlCommit(DataObject obj) {
43.77 + commit = false;
43.78 + dataObject = obj;
43.79 + }
43.80 +
43.81 + public static PlsqlCommit getInstance(DataObject obj) {
43.82 + if (instance.isEmpty()) {
43.83 + instance.add(new PlsqlCommit(obj));
43.84 + return instance.get(0);
43.85 + } else {
43.86 + for (int i = 0; i < instance.size(); i++) {
43.87 + PlsqlCommit plsqlCommit = instance.get(i);
43.88 + if (plsqlCommit.dataObject.equals(obj)) {
43.89 + return plsqlCommit;
43.90 + }
43.91 + }
43.92 + PlsqlCommit plsqlCommit = new PlsqlCommit(obj);
43.93 + instance.add(plsqlCommit);
43.94 + return plsqlCommit;
43.95 +
43.96 + }
43.97 + }
43.98 +
43.99 + public void setCommit(boolean commit_) {
43.100 + boolean oldCommit = commit;
43.101 + commit = commit_;
43.102 + changeSupport.firePropertyChange(PROP_commit, oldCommit, commit);
43.103 + }
43.104 +
43.105 + public boolean getCommit() {
43.106 + return commit;
43.107 + }
43.108 +
43.109 + public void commitTransaction(DataObject fileObj, DatabaseConnection connection, DatabaseConnectionManager connectionProvider){
43.110 + EditorCookie edCookie = fileObj.getLookup().lookup(EditorCookie.class);
43.111 + Document document = edCookie.getDocument();
43.112 + InputOutput io = null;
43.113 + DataObject obj = FileExecutionUtil.getDataObject(document);
43.114 +
43.115 + ProgressHandle handle = ProgressHandleFactory.createHandle("Commit database file...", this);
43.116 + handle.start();
43.117 +
43.118 + try {
43.119 + io = IOProvider.getDefault().getIO(obj.getPrimaryFile().getNameExt(), false);
43.120 + if (!io.isClosed()) {
43.121 + io.getOut().println((new StringBuilder()).append("> Commit Statement successfully"));
43.122 + }
43.123 +
43.124 + if (connection.getJDBCConnection() != null) {
43.125 + connectionProvider.commitRollbackTransactions(connection, true);
43.126 + setCommit(false);
43.127 + }
43.128 +
43.129 + } catch (Exception ex) {
43.130 + io.getOut().println((new StringBuilder()).append(">!!! Error Commit Statement"));
43.131 + Exceptions.printStackTrace(ex);
43.132 + } finally {
43.133 + handle.finish();
43.134 + }
43.135 + }
43.136 +
43.137 + public void rollbackTransaction(DataObject obj, DatabaseConnection connection, DatabaseConnectionManager connectionProvider){
43.138 + InputOutput io = null;
43.139 + ProgressHandle handle = ProgressHandleFactory.createHandle("Commit database file...", this);
43.140 + handle.start();
43.141 +
43.142 + try {
43.143 + io = IOProvider.getDefault().getIO(obj.getPrimaryFile().getNameExt(), false);
43.144 + if (!io.isClosed()) {
43.145 + io.getOut().println((new StringBuilder()).append("> Rollback Statement successfully"));
43.146 + }
43.147 +
43.148 + if (connection.getJDBCConnection() != null) {
43.149 + connectionProvider.commitRollbackTransactions(connection, false);
43.150 + setCommit(false);
43.151 + }
43.152 +
43.153 + } catch (Exception ex) {
43.154 + io.getOut().println((new StringBuilder()).append(">!!! Error Rollback Statement"));
43.155 + Exceptions.printStackTrace(ex);
43.156 + } finally {
43.157 + handle.finish();
43.158 + }
43.159 + }
43.160 +
43.161 + @Override
43.162 + public void addPropertyChangeListener(PropertyChangeListener listener) {
43.163 + PropertyChangeListener[] listeners = changeSupport.getPropertyChangeListeners();
43.164 + for (int i = 0; i < listeners.length; i++) {
43.165 + if (listeners[i] == listener) {
43.166 + return;
43.167 + }
43.168 + }
43.169 + changeSupport.addPropertyChangeListener(listener);
43.170 + }
43.171 +
43.172 + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
43.173 + PropertyChangeListener[] listeners = changeSupport.getPropertyChangeListeners();
43.174 + for (int i = 0; i < listeners.length; i++) {
43.175 + if (listeners[i] == listener) {
43.176 + return;
43.177 + }
43.178 + }
43.179 + changeSupport.addPropertyChangeListener(propertyName, listener);
43.180 + }
43.181 +
43.182 + @Override
43.183 + public void actionPerformed(ActionEvent e) {
43.184 + // throw new UnsupportedOperationException("Not supported yet.");
43.185 + }
43.186 + }
44.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlCommitAction.java Tue Feb 14 17:36:37 2012 +0100
44.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlCommitAction.java Wed Aug 15 20:45:01 2012 +0200
44.3 @@ -44,6 +44,8 @@
44.4 import java.awt.Component;
44.5 import java.awt.event.ActionEvent;
44.6 import java.awt.image.BufferedImage;
44.7 +import java.beans.PropertyChangeEvent;
44.8 +import java.beans.PropertyChangeListener;
44.9 import java.io.IOException;
44.10 import java.util.Arrays;
44.11 import java.util.List;
44.12 @@ -52,10 +54,7 @@
44.13 import javax.swing.Action;
44.14 import javax.swing.ImageIcon;
44.15 import javax.swing.JButton;
44.16 -import javax.swing.text.Document;
44.17 import org.netbeans.api.db.explorer.DatabaseConnection;
44.18 -import org.netbeans.api.progress.ProgressHandle;
44.19 -import org.netbeans.api.progress.ProgressHandleFactory;
44.20 import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
44.21 import org.netbeans.modules.plsqlsupport.options.OptionsUtilities;
44.22 import org.openide.awt.ActionID;
44.23 @@ -66,8 +65,6 @@
44.24 import org.openide.loaders.DataObject;
44.25 import org.openide.util.*;
44.26 import org.openide.util.actions.Presenter;
44.27 -import org.openide.windows.IOProvider;
44.28 -import org.openide.windows.InputOutput;
44.29
44.30 @ActionID(id = "org.netbeans.modules.plsql.execution.PlsqlCommitAction", category = "PLSQL")
44.31 @ActionRegistration(displayName = "#CTL_PlsqlCommit")
44.32 @@ -78,7 +75,8 @@
44.33 private DatabaseConnectionManager connectionProvider;
44.34 private DatabaseConnection connection;
44.35 private JButton button;
44.36 - public boolean autoCommit = true;
44.37 + PlsqlCommit commit;
44.38 + private PropertyChangeListener EnableCommit;
44.39
44.40 public PlsqlCommitAction() {
44.41 this(Utilities.actionsGlobalContext());
44.42 @@ -107,7 +105,7 @@
44.43
44.44 if (dataObject != null) {
44.45 setEnabled(true);
44.46 - autoCommit = OptionsUtilities.isCommandWindowAutoCommitEnabled();
44.47 + commit = PlsqlCommit.getInstance(dataObject);
44.48 } else {
44.49 setEnabled(false);
44.50 }
44.51 @@ -139,47 +137,26 @@
44.52 return;
44.53 }
44.54
44.55 - EditorCookie edCookie = dataObject.getLookup().lookup(EditorCookie.class);
44.56 - Document document = edCookie.getDocument();
44.57 saveIfModified(dataObject);
44.58 -
44.59 - InputOutput io = null;
44.60 - DataObject obj = FileExecutionUtil.getDataObject(document);
44.61 - ProgressHandle handle = ProgressHandleFactory.createHandle("Commit database file...", this);
44.62 - handle.start();
44.63 -
44.64 - try {
44.65 - io = IOProvider.getDefault().getIO(obj.getPrimaryFile().getNameExt(), false);
44.66 - if (!io.isClosed()) {
44.67 - io.getOut().println((new StringBuilder()).append("> Commit Statement successfully"));
44.68 - }
44.69 -
44.70 - if (connection.getJDBCConnection() != null) {
44.71 - connectionProvider.commitRollbackTransactions(connection, true);
44.72 - }
44.73 -
44.74 - } catch (Exception ex) {
44.75 - io.getOut().println((new StringBuilder()).append(">!!! Error Commit Statement"));
44.76 - Exceptions.printStackTrace(ex);
44.77 - } finally {
44.78 - handle.finish();
44.79 - }
44.80 + commit.commitTransaction(dataObject, connection, connectionProvider);
44.81 }
44.82 -
44.83 +
44.84 @Override
44.85 public Component getToolbarPresenter() {
44.86 if (!isEnabled()) {
44.87 return null;
44.88 - }
44.89 + }
44.90 button = DropDownButtonFactory.createDropDownButton(
44.91 new ImageIcon(new BufferedImage(32, 32, BufferedImage.TYPE_BYTE_GRAY)), null);
44.92 button.setAction(this);
44.93 button.setSelected(!OptionsUtilities.isCommandWindowAutoCommitEnabled());
44.94 - button.setEnabled(!OptionsUtilities.isCommandWindowAutoCommitEnabled());
44.95 + button.setEnabled(false);
44.96 button.setDisabledIcon(new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/plsql/execution/database_commit_disable.png")));
44.97 + EnableCommit = new EnableCommit();
44.98 + commit.addPropertyChangeListener(EnableCommit);
44.99 return button;
44.100 }
44.101 -
44.102 +
44.103 private void saveIfModified(DataObject dataObj) {
44.104 try {
44.105 SaveCookie saveCookie = dataObj.getCookie(SaveCookie.class);
44.106 @@ -190,4 +167,20 @@
44.107 Exceptions.printStackTrace(ex);
44.108 }
44.109 }
44.110 +
44.111 + private class EnableCommit implements PropertyChangeListener {
44.112 +
44.113 + public EnableCommit() {}
44.114 +
44.115 + @Override
44.116 + public void propertyChange(PropertyChangeEvent event) {
44.117 + if(!OptionsUtilities.isCommandWindowAutoCommitEnabled() && commit.getCommit()){
44.118 + button.setEnabled(true);
44.119 + }
44.120 + else
44.121 + button.setEnabled(false);
44.122 + }
44.123 +
44.124 + }
44.125 }
44.126 +
45.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExecuteAction.java Tue Feb 14 17:36:37 2012 +0100
45.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExecuteAction.java Wed Aug 15 20:45:01 2012 +0200
45.3 @@ -55,19 +55,10 @@
45.4 import java.util.ArrayList;
45.5 import java.util.List;
45.6 import java.util.Locale;
45.7 -
45.8 -import javax.swing.AbstractAction;
45.9 -import javax.swing.Action;
45.10 -import javax.swing.ImageIcon;
45.11 -import javax.swing.JButton;
45.12 -import javax.swing.JEditorPane;
45.13 -import javax.swing.JMenuItem;
45.14 -import javax.swing.JOptionPane;
45.15 -import javax.swing.JPopupMenu;
45.16 +import javax.swing.*;
45.17 import javax.swing.event.PopupMenuEvent;
45.18 import javax.swing.event.PopupMenuListener;
45.19 import javax.swing.text.Document;
45.20 -
45.21 import org.netbeans.api.db.explorer.DatabaseConnection;
45.22 import org.netbeans.api.progress.ProgressHandle;
45.23 import org.netbeans.api.progress.ProgressHandleFactory;
45.24 @@ -75,29 +66,26 @@
45.25 import org.netbeans.modules.plsql.utilities.PlsqlFileValidatorService;
45.26 import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
45.27 import org.netbeans.modules.plsqlsupport.options.OptionsUtilities;
45.28 -import org.openide.awt.ActionID;
45.29 -import org.openide.awt.ActionReference;
45.30 -import org.openide.awt.ActionRegistration;
45.31 -import org.openide.awt.DropDownButtonFactory;
45.32 +import org.openide.awt.*;
45.33 import org.openide.cookies.EditorCookie;
45.34 import org.openide.cookies.SaveCookie;
45.35 import org.openide.filesystems.FileObject;
45.36 import org.openide.loaders.DataObject;
45.37 -import org.openide.util.Cancellable;
45.38 -import org.openide.util.ContextAwareAction;
45.39 -import org.openide.util.Exceptions;
45.40 -import org.openide.util.ImageUtilities;
45.41 -import org.openide.util.Lookup;
45.42 -import org.openide.util.NbBundle;
45.43 -import org.openide.util.RequestProcessor;
45.44 -import org.openide.util.Utilities;
45.45 +import org.openide.util.*;
45.46 import org.openide.util.actions.Presenter;
45.47
45.48 @ActionID(id = "org.netbeans.modules.plsql.execution.PlsqlExecuteAction", category = "PLSQL")
45.49 -@ActionRegistration(displayName = "#CTL_fileExecution")
45.50 -@ActionReference(path = "Shortcuts", name = "AS-E")
45.51 +@ActionRegistration(displayName = "#CTL_Execution", iconBase = "org/netbeans/modules/plsql/execution/execute.png")
45.52 +@ActionReferences({
45.53 + @ActionReference(path = "Shortcuts", name = "DS-E"),
45.54 + @ActionReference(path = "Shortcuts", name = "OS-E"),
45.55 + @ActionReference(path = "Editors/text/x-plsql/Popup", name = "org-netbeans-modules-plsql-execution-PlsqlExecuteAction",
45.56 + position = 405, separatorBefore = 404)
45.57 +})
45.58 public class PlsqlExecuteAction extends AbstractAction implements ContextAwareAction, Presenter.Toolbar {
45.59
45.60 + private static final String ICON_PATH = "org/netbeans/modules/plsql/execution/execute.png";
45.61 + private static final RequestProcessor RP = new RequestProcessor(PlsqlExecuteAction.class);
45.62 private static final PlsqlFileValidatorService validator = Lookup.getDefault().lookup(PlsqlFileValidatorService.class);
45.63 private static final String DATABASE_CONNECTION_KEY = "databaseConnection";
45.64 private static final String TEST_BLOCK_NAME_PREFIX = "TestBlock:";
45.65 @@ -110,15 +98,17 @@
45.66 private JButton button;
45.67 private ActionListener buttonListener = new ButtonListener();
45.68 private boolean autoCommit = true;
45.69 + PlsqlCommit commit;
45.70
45.71 public PlsqlExecuteAction() {
45.72 this(Utilities.actionsGlobalContext());
45.73 }
45.74
45.75 public PlsqlExecuteAction(Lookup context) {
45.76 - putValue(NAME, NbBundle.getMessage(PlsqlExecuteAction.class, "CTL_fileExecution"));
45.77 - putValue(SHORT_DESCRIPTION, NbBundle.getMessage(PlsqlExecuteAction.class, "CTL_fileExecution"));
45.78 - putValue(SMALL_ICON, new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/plsql/execution/execute.png")));
45.79 + putValue(NAME, NbBundle.getMessage(PlsqlExecuteAction.class, "CTL_Execution"));
45.80 + putValue(SHORT_DESCRIPTION, NbBundle.getMessage(PlsqlExecuteAction.class, "CTL_ExecutionDescription"));
45.81 +// putValue(LONG_DESCRIPTION, NbBundle.getMessage(PlsqlExecuteAction.class, "CTL_ExecutionDescription"));
45.82 + putValue(SMALL_ICON, new ImageIcon(ImageUtilities.loadImage(ICON_PATH)));
45.83
45.84 dataObject = context.lookup(DataObject.class);
45.85
45.86 @@ -138,6 +128,9 @@
45.87 if (validator.isValidTDB(dataObject)) {
45.88 autoCommit = OptionsUtilities.isCommandWindowAutoCommitEnabled();
45.89 }
45.90 + if (dataObject != null) {
45.91 + commit = PlsqlCommit.getInstance(dataObject);
45.92 + }
45.93 }
45.94
45.95 @Override
45.96 @@ -168,7 +161,7 @@
45.97
45.98 // If autocommit OFF - take the connection from data object.
45.99 if (!autoCommit) {
45.100 - connection = dataObject.getLookup().lookup(DatabaseConnection.class);
45.101 + setConnection(connectionProvider.getTemplateConnection());
45.102 }
45.103
45.104 if (connection == null) {
45.105 @@ -231,23 +224,75 @@
45.106
45.107 private void populatePopupMenu() {
45.108 popup.removeAll();
45.109 - if (autoCommit) {
45.110 - for (DatabaseConnection c : connectionProvider.getDatabaseConnections()) {
45.111 - String url = c.getDatabaseURL();
45.112 - String schema = c.getUser();
45.113 - int pos = url.indexOf("@") + 1;
45.114 - if (pos > 0) {
45.115 - url = url.substring(pos);
45.116 + for (DatabaseConnection c : connectionProvider.getDatabaseConnections()) {
45.117 + String url = c.getDatabaseURL();
45.118 + String schema = c.getUser();
45.119 + int pos = url.indexOf("@") + 1;
45.120 + if (pos > 0) {
45.121 + url = url.substring(pos);
45.122 + }
45.123 + url = schema + "@" + url;
45.124 + String alias = c.getDisplayName();
45.125 + if (alias != null && !alias.equals(c.getName())) {
45.126 + url = alias + " [" + url + "]";
45.127 + }
45.128 + JMenuItem item = new JMenuItem(url);
45.129 + item.putClientProperty(DATABASE_CONNECTION_KEY, c);
45.130 + item.addActionListener(buttonListener);
45.131 + popup.add(item);
45.132 + }
45.133 + }
45.134 +
45.135 + private void setConnection(DatabaseConnection newConnection) {
45.136 + if (connection != null && connection.getName().equals(newConnection.getName())) {
45.137 + connection = dataObject.getLookup().lookup(DatabaseConnection.class);
45.138 + } else {
45.139 + if (connection != null) {
45.140 + connection = dataObject.getLookup().lookup(DatabaseConnection.class);
45.141 + if (commit.getCommit()) {
45.142 + if (!OptionsUtilities.isDeployNoPromptEnabled()) {
45.143 +
45.144 + String msg = "Commit transactions for " + connection.getDisplayName() + " ?";
45.145 + String title = "Confirm!";
45.146 + int showOptionDialog = JOptionPane.showOptionDialog(null,
45.147 + msg,
45.148 + title,
45.149 + JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE,
45.150 + null, null, null);
45.151 +
45.152 + if (showOptionDialog == JOptionPane.YES_OPTION) {
45.153 + commit.commitTransaction(dataObject, connection, connectionProvider);
45.154 + } else if (showOptionDialog == JOptionPane.NO_OPTION) {
45.155 + commit.rollbackTransaction(dataObject, connection, connectionProvider);
45.156 + } else {
45.157 + return;
45.158 + }
45.159 + }
45.160 }
45.161 - url = schema + "@" + url;
45.162 - String alias = c.getDisplayName();
45.163 - if (alias != null && !alias.equals(c.getName())) {
45.164 - url = alias + " [" + url + "]";
45.165 + }
45.166 + if (!connectionProvider.isDefaultDatabase(newConnection)) {
45.167 + if (!OptionsUtilities.isDeployNoPromptEnabled()) {
45.168 + String msg = "You are now connecting to a secondary database.";
45.169 + String title = "Connecting to a Secondary Database!";
45.170 + if (JOptionPane.showOptionDialog(null,
45.171 + msg,
45.172 + title,
45.173 + JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
45.174 + null, null, null) == JOptionPane.NO_OPTION) {
45.175 + return;
45.176 + }
45.177 + connection = newConnection;
45.178 + try {
45.179 + Connection jdbcConnection = connection.getJDBCConnection();
45.180 + if (jdbcConnection == null || !jdbcConnection.isValid(1000)) {
45.181 + return;
45.182 + }
45.183 + } catch (SQLException ex) {
45.184 + return;
45.185 + }
45.186 }
45.187 - JMenuItem item = new JMenuItem(url);
45.188 - item.putClientProperty(DATABASE_CONNECTION_KEY, c);
45.189 - item.addActionListener(buttonListener);
45.190 - popup.add(item);
45.191 + } else {
45.192 + connection = newConnection;
45.193 }
45.194 }
45.195 }
45.196 @@ -267,35 +312,14 @@
45.197 if (file == null) {
45.198 return;
45.199 }
45.200 -
45.201 - if (autoCommit && !connectionProvider.isDefaultDatabase(connection)) {
45.202 - if (!OptionsUtilities.isDeployNoPromptEnabled()) {
45.203 - String msg = "You are now connecting to a secondary database.";
45.204 - String title = "Connecting to a Secondary Database!";
45.205 - if (JOptionPane.showOptionDialog(null,
45.206 - msg,
45.207 - title,
45.208 - JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
45.209 - null, null, null) == JOptionPane.NO_OPTION) {
45.210 - return;
45.211 - }
45.212 - connectionProvider.connect(connection);
45.213 - try {
45.214 - Connection jdbcConnection = connection.getJDBCConnection();
45.215 - if (jdbcConnection == null || !jdbcConnection.isValid(1000)) {
45.216 - return;
45.217 - }
45.218 - } catch (SQLException ex) {
45.219 - return;
45.220 - }
45.221 - }
45.222 - } else {
45.223 - //to reconnect if the connection is gone.
45.224 - if (connection.getJDBCConnection() == null) {
45.225 - connectionProvider.connect(connection);
45.226 - }
45.227 + //to reconnect if the connection is gone.
45.228 + if (connection.getJDBCConnection() == null) {
45.229 + connectionProvider.connect(connection);
45.230 }
45.231
45.232 + PlsqlExecutableBlocksMaker blockMaker = new PlsqlExecutableBlocksMaker(document);
45.233 + blocks = blockMaker.makeExceutableObjects();
45.234 +
45.235 //if the user has selected any text in the window, create exec block using selected text only
45.236 if (validator.isValidTDB(dataObject)) {
45.237 JEditorPane[] panes = edCookie.getOpenedPanes();
45.238 @@ -303,24 +327,46 @@
45.239 String selectedSql = panes[0].getSelectedText();
45.240 if (selectedSql != null && !selectedSql.trim().equals("")) { //some text has been selected
45.241 //create executable block with selected sql
45.242 - blocks = new ArrayList<PlsqlExecutableObject>();
45.243 - blocks.add(new PlsqlExecutableObject(0, selectedSql, "SQL", PlsqlExecutableObjectType.STATEMENT, 0, selectedSql.length() - 1));
45.244 + List<PlsqlExecutableObject> newblocks = new ArrayList<PlsqlExecutableObject>();
45.245 + int selectionStart = panes[0].getSelectionStart();
45.246 + int selectionEnd = panes[0].getSelectionEnd();
45.247 + for (PlsqlExecutableObject block : blocks) {
45.248 + if ((selectionStart <= block.getStartOffset()) && (selectionEnd >= block.getEndOffset())) {
45.249 + newblocks.add(block);
45.250 + }
45.251 + }
45.252 + if (!newblocks.isEmpty()) {
45.253 + blocks = newblocks;
45.254 + }else {
45.255 + blocks = new ArrayList<PlsqlExecutableObject>();
45.256 + blocks.add(new PlsqlExecutableObject(0, selectedSql, "SQL", PlsqlExecutableObjectType.STATEMENT, 0, selectedSql.length() - 1));
45.257 + }
45.258 + }else if (OptionsUtilities.isCommandWindowAutoSelectEnabled()) {
45.259 + List<PlsqlExecutableObject> newblocks = new ArrayList<PlsqlExecutableObject>();
45.260 +
45.261 + int caretPos = 0;
45.262 + if ((panes != null) && (panes.length > 0)) {
45.263 + caretPos = panes[0].getCaretPosition();
45.264 + }
45.265 + for (PlsqlExecutableObject block : blocks) {
45.266 + if (caretPos >= block.getStartOffset() && caretPos <= block.getEndOffset()) {
45.267 + if (block.getPlsqlString().startsWith("SELECT")) {
45.268 + newblocks.add(block);
45.269 + }
45.270 + }
45.271 + }
45.272 + if (!newblocks.isEmpty()) {
45.273 + blocks = newblocks;
45.274 + }
45.275 }
45.276 }
45.277 }
45.278 -
45.279 - //if blocks were not created using selected text, use entire document to create exec blocks
45.280 - if (blocks == null) {
45.281 - PlsqlExecutableBlocksMaker blockMaker = new PlsqlExecutableBlocksMaker(document);
45.282 - blocks = blockMaker.makeExceutableObjects();
45.283 - }
45.284 String extension = file.getExt();
45.285 if (blocks.size() > 0 && "tdb".equalsIgnoreCase(extension) && (dataObject.getNodeDelegate().getDisplayName() == null || !dataObject.getNodeDelegate().getDisplayName().contains(TEST_BLOCK_NAME_PREFIX))) {
45.286 String str = blocks.get(0).getPlsqlString().replaceAll("\n", " ");
45.287 dataObject.getNodeDelegate().setDisplayName(str.length() > 30 ? str.substring(0, 30) + "..." : str);
45.288 }
45.289 - RequestProcessor processor = RequestProcessor.getDefault();
45.290 - processor.post(new ExecutionHandler(connectionProvider, connection, blocks, document));
45.291 + RP.post(new ExecutionHandler(connectionProvider, connection, blocks, document));
45.292
45.293 }
45.294
45.295 @@ -409,7 +455,8 @@
45.296 public void actionPerformed(ActionEvent e) {
45.297
45.298 JMenuItem item = (JMenuItem) e.getSource();
45.299 - connection = (DatabaseConnection) item.getClientProperty(DATABASE_CONNECTION_KEY);
45.300 + DatabaseConnection newConnection = (DatabaseConnection) item.getClientProperty(DATABASE_CONNECTION_KEY);
45.301 + setConnection(newConnection);
45.302 saveAndExecute();
45.303
45.304 }
46.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlFileExecutor.java Tue Feb 14 17:36:37 2012 +0100
46.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlFileExecutor.java Wed Aug 15 20:45:01 2012 +0200
46.3 @@ -64,6 +64,7 @@
46.4 import org.netbeans.modules.db.sql.execute.SQLExecutionResults;
46.5 import org.netbeans.modules.db.sql.execute.StatementInfo;
46.6 import org.netbeans.modules.db.sql.history.SQLHistory;
46.7 +import org.netbeans.modules.db.sql.history.SQLHistoryEntry;
46.8 import org.netbeans.modules.db.sql.history.SQLHistoryManager;
46.9 import org.netbeans.modules.plsql.filetype.PlsqlEditor;
46.10 import org.netbeans.modules.plsql.filetype.StatementExecutionHistory;
46.11 @@ -196,15 +197,19 @@
46.12 }
46.13 if (state == NORMAL) {
46.14 nonCommentQuery.append(line).append("\n");
46.15 - }
46.16 + }
46.17 }
46.18 - nonCommentQuery.deleteCharAt(nonCommentQuery.length() - 1);
46.19 -
46.20 +
46.21 + String querryString = nonCommentQuery.toString().trim();
46.22 + if(querryString.endsWith(";")){
46.23 + querryString = querryString.substring(0, querryString.lastIndexOf(";"));
46.24 + }
46.25 +
46.26 String newQuery = "";
46.27 String token;
46.28 boolean format = false;
46.29
46.30 - StringTokenizer tokenizer = new StringTokenizer(nonCommentQuery.toString(), " \t\n");
46.31 + StringTokenizer tokenizer = new StringTokenizer(querryString, " \t\n");
46.32 while (tokenizer.hasMoreTokens()) {
46.33 token = tokenizer.nextToken();
46.34
46.35 @@ -407,9 +412,9 @@
46.36 }
46.37 Connection con;
46.38 Statement stm = null;
46.39 - String firstWord = null;
46.40 - boolean commit = false;
46.41 -
46.42 + String firstWord = null;
46.43 + PlsqlCommit commit = PlsqlCommit.getInstance((DataObject)object);
46.44 +
46.45 //quick & dirty fix to avoid having output tabs for the SQL Execution window (unless there's an exception)
46.46 //first check to see if this is a simple select statement and if so treat it separately.
46.47 if (executableObjs.size() == 1) {
46.48 @@ -522,11 +527,7 @@
46.49 } else {
46.50 firstWord = plsqlText;
46.51 }
46.52 -
46.53 - if (plsqlText.toUpperCase().contains("INSERT") || plsqlText.toUpperCase().contains("UPDATE") || plsqlText.toUpperCase().contains("DELETE")) {
46.54 - commit = true;
46.55 - }
46.56 -
46.57 +
46.58 if (firstWord.equalsIgnoreCase("SELECT")) {
46.59 //this should really never happen... Unless there are multiple parts of a file and some sections are select statements
46.60 if (plsqlEditor != null && firstSelectStatement) {
46.61 @@ -647,9 +648,6 @@
46.62 }
46.63 }
46.64 if (exeObj.getType() == PlsqlExecutableObjectType.BEGINEND) {
46.65 - if (plsqlText.toUpperCase().contains("INSERT") || plsqlText.toUpperCase().contains("UPDATE") || plsqlText.toUpperCase().contains("DELETE")) {
46.66 - commit = true;
46.67 - }
46.68 try {
46.69 stm.executeUpdate(plsqlText);
46.70 processDbmsOutputMessages(con, io.getOut());
46.71 @@ -668,9 +666,6 @@
46.72 }
46.73 }
46.74 if (exeObj.getType() == PlsqlExecutableObjectType.UNKNOWN) {
46.75 - if (plsqlText.toUpperCase().contains("INSERT") || plsqlText.toUpperCase().contains("UPDATE") || plsqlText.toUpperCase().contains("DELETE")) {
46.76 - commit = true;
46.77 - }
46.78 //Parse aliases
46.79 define = getAliases(definesMap, doc, exeObj.getStartOffset(), exeObj.getEndOffset(), define, io);
46.80 //Replace aliases
46.81 @@ -715,7 +710,7 @@
46.82 ignoreDefines = "OFF".equalsIgnoreCase(token);
46.83 if (!ignoreDefines && token.length() == 1) {
46.84 define.clear();
46.85 - define.add(token.charAt(0));
46.86 + define.add(token.charAt(0));
46.87 }
46.88 }
46.89 }
46.90 @@ -973,10 +968,16 @@
46.91 }
46.92
46.93 if (fileName.endsWith(".tdb") && !autoCommit) {
46.94 - if (!deploymentOk && !commit && !(firstWord != null
46.95 + if (!deploymentOk && !(firstWord != null
46.96 && (firstWord.equalsIgnoreCase("INSERT") || firstWord.equalsIgnoreCase("UPDATE") || firstWord.equalsIgnoreCase("DELETE")))) {
46.97 con.commit();
46.98 + }else{
46.99 + if(deploymentOk && (firstWord != null
46.100 + && (firstWord.equalsIgnoreCase("INSERT") || firstWord.equalsIgnoreCase("UPDATE") || firstWord.equalsIgnoreCase("DELETE")))){
46.101 + commit.setCommit(true);
46.102 + }
46.103 }
46.104 +
46.105 } else {
46.106 con.commit();
46.107 }
46.108 @@ -1160,7 +1161,7 @@
46.109 definesMap.put(alias.toUpperCase(Locale.ENGLISH), value);
46.110 }
46.111 } else if (tokenTxt.toUpperCase(Locale.ENGLISH).startsWith("SET ")) {
46.112 - StringTokenizer tokenizer = new StringTokenizer(tokenTxt);
46.113 + StringTokenizer tokenizer = new StringTokenizer(tokenTxt);
46.114 tokenizer.nextToken();
46.115 String alias;
46.116 boolean isNext = tokenizer.hasMoreTokens();
46.117 @@ -1172,11 +1173,6 @@
46.118 } else {
46.119 break;
46.120 }
46.121 -
46.122 - if (alias.length() == 1) {
46.123 - define.clear();
46.124 - define.add(alias.charAt(0));//If define changed we catch it here
46.125 - }
46.126 }
46.127 }
46.128 moveNext = ts.moveNext();
46.129 @@ -1340,16 +1336,9 @@
46.130 return null;
46.131 }
46.132
46.133 - private void closeExecutionResult() {
46.134 - if (executionResults != null) {
46.135 - executionResults = null;
46.136 - }
46.137 - }
46.138 -
46.139 private final class SQLExecutor implements Runnable, Cancellable {
46.140
46.141 private static final int DEFAULT_PAGE_SIZE = 100;
46.142 - private FileObject USERDIR = FileUtil.getConfigRoot();
46.143 private final DatabaseConnection dbconn;
46.144 private final String sqlStmt;
46.145 private String label;
46.146 @@ -1411,13 +1400,13 @@
46.147 DataView view = DataView.create(conn, sql, DEFAULT_PAGE_SIZE);
46.148
46.149 // Save SQL statements executed for the SQLHistoryManager
46.150 - SQLHistoryManager.getInstance().saveSQL(new SQLHistory(url, sql, new Date()));
46.151 + SQLHistoryManager.getInstance().saveSQL(new SQLHistoryEntry(url, sql, new Date()));
46.152 result = new SQLExecutionResult(info, view);
46.153 results.add(result);
46.154 }
46.155
46.156 // Persist SQL executed
46.157 - SQLHistoryManager.getInstance().save(USERDIR);
46.158 + SQLHistoryManager.getInstance().save();
46.159
46.160 if (!cancelled) {
46.161 return new SQLExecutionResults(results);
47.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlMultipleExecuteAction.java Tue Feb 14 17:36:37 2012 +0100
47.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlMultipleExecuteAction.java Wed Aug 15 20:45:01 2012 +0200
47.3 @@ -190,13 +190,13 @@
47.4
47.5 JMenu menu = new JMenu(getName());
47.6 ActionListener buttonListener = new ButtonListener();
47.7 - DatabaseConnection[] databaseConnections = connectionProvider.getDatabaseConnections();
47.8 - for (int i = 0; i < databaseConnections.length; i++) {
47.9 - JMenuItem item = new JMenuItem(formatDbConnectionName(databaseConnections[i]));
47.10 - item.putClientProperty(DATABASE_CONNECTION_KEY, databaseConnections[i]);
47.11 + List<DatabaseConnection> databaseConnections = connectionProvider.getDatabaseConnections();
47.12 + for (int i = 0; i < databaseConnections.size(); i++) {
47.13 + JMenuItem item = new JMenuItem(formatDbConnectionName(databaseConnections.get(i)));
47.14 + item.putClientProperty(DATABASE_CONNECTION_KEY, databaseConnections.get(i));
47.15 item.addActionListener(buttonListener);
47.16 menu.add(item);
47.17 - if (i == 0 && databaseConnections.length > 1) {
47.18 + if (i == 0 && databaseConnections.size() > 1) {
47.19 menu.add(new JSeparator());
47.20 }
47.21 }
48.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlOutputListener.java Tue Feb 14 17:36:37 2012 +0100
48.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlOutputListener.java Wed Aug 15 20:45:01 2012 +0200
48.3 @@ -56,138 +56,142 @@
48.4 import org.openide.filesystems.FileUtil;
48.5 import org.openide.loaders.*;
48.6 import org.openide.nodes.Node;
48.7 +import org.openide.util.Exceptions;
48.8 import org.openide.util.actions.SystemAction;
48.9 import org.openide.windows.OutputEvent;
48.10 import org.openide.windows.OutputListener;
48.11
48.12 -public class PlsqlOutputListener implements OutputListener {
48.13 +public class PlsqlOutputListener implements OutputListener {
48.14
48.15 - private List docLinesArray;
48.16 - private int lineNo;
48.17 - private int position;
48.18 - private String originalFileName=null;
48.19 - private String objectName=null;
48.20 - private Project project;
48.21 - private DatabaseContentManager cache;
48.22 + private List docLinesArray;
48.23 + private int lineNo;
48.24 + private int position;
48.25 + private String originalFileName = null;
48.26 + private String objectName = null;
48.27 + private Project project;
48.28 + private DatabaseContentManager cache;
48.29
48.30 - public PlsqlOutputListener() {
48.31 - }
48.32 + public PlsqlOutputListener() {
48.33 + }
48.34
48.35 - public PlsqlOutputListener(Project project, String objectName, int lineNo) {
48.36 - this.project = project;
48.37 - this.objectName = objectName;
48.38 - this.lineNo = lineNo;
48.39 - DatabaseConnectionManager provider = DatabaseConnectionManager.getInstance(project);
48.40 - this.cache = provider!=null ? DatabaseContentManager.getInstance(provider.getTemplateConnection()) : null;
48.41 - }
48.42 -
48.43 - public void outputLineSelected(OutputEvent outputevent) {
48.44 - }
48.45 + public PlsqlOutputListener(Project project, String objectName, int lineNo) {
48.46 + this.project = project;
48.47 + this.objectName = objectName;
48.48 + this.lineNo = lineNo;
48.49 + DatabaseConnectionManager provider = DatabaseConnectionManager.getInstance(project);
48.50 + this.cache = provider != null ? DatabaseContentManager.getInstance(provider.getTemplateConnection()) : null;
48.51 + }
48.52
48.53 - public void outputLineAction(OutputEvent outputEvent) {
48.54 - if (originalFileName != null) {
48.55 - try {
48.56 - File file = new File(originalFileName);
48.57 - if (file.exists()) {
48.58 - DataObject dObject = DataFolder.find(FileUtil.toFileObject(file));
48.59 - OpenCookie openCookie = dObject.getCookie(OpenCookie.class);
48.60 - openCookie.open();
48.61 - Node n = dObject.getNodeDelegate();
48.62 - EditorCookie ec = dObject.getCookie(EditorCookie.class);
48.63 - if (ec != null) {
48.64 - JEditorPane panes[] = ec.getOpenedPanes();
48.65 - if (panes.length > 0) {
48.66 - JEditorPane pane = panes[0];
48.67 - int caretPos = getCaretPositionFromLineNumber(lineNo, pane.getDocument());
48.68 - pane.setCaretPosition(caretPos);
48.69 - }
48.70 - }
48.71 + @Override
48.72 + public void outputLineSelected(OutputEvent outputevent) {
48.73 + }
48.74 +
48.75 + @Override
48.76 + public void outputLineAction(OutputEvent outputEvent) {
48.77 + if (originalFileName != null) {
48.78 + try {
48.79 + File file = new File(originalFileName);
48.80 + if (file.exists()) {
48.81 + DataObject dObject = DataFolder.find(FileUtil.toFileObject(file));
48.82 + OpenCookie openCookie = dObject.getCookie(OpenCookie.class);
48.83 + openCookie.open();
48.84 + Node n = dObject.getNodeDelegate();
48.85 + EditorCookie ec = dObject.getCookie(EditorCookie.class);
48.86 + if (ec != null) {
48.87 + JEditorPane panes[] = ec.getOpenedPanes();
48.88 + if (panes.length > 0) {
48.89 + JEditorPane pane = panes[0];
48.90 + int caretPos = getCaretPositionFromLineNumber(lineNo, pane.getDocument());
48.91 + pane.setCaretPosition(caretPos);
48.92 + }
48.93 + }
48.94 + } else {
48.95 + JOptionPane.showMessageDialog(null, "Required File Not found");
48.96 + }
48.97 + } catch (DataObjectNotFoundException ex) {
48.98 + Exceptions.printStackTrace(ex);
48.99 + }
48.100 + } else if (objectName != null && cache != null && project != null) { //navigate to object
48.101 + PlsqlGoToDbImplAction action = SystemAction.get(PlsqlGoToDbImplAction.class);
48.102 + if (cache.isFunction(objectName)) {
48.103 + action.goToFunction(objectName, project, lineNo);
48.104 + } else if (cache.isProcedure(objectName)) {
48.105 + action.goToProcedure(objectName, project, lineNo);
48.106 } else {
48.107 - JOptionPane.showMessageDialog(null, "Required File Not found");
48.108 + action.goToPackage(objectName, project, null, lineNo);
48.109 }
48.110 - } catch (DataObjectNotFoundException ex) {
48.111 - ex.printStackTrace();
48.112 - }
48.113 - } else if(objectName!=null && cache!=null && project!=null) { //navigate to object
48.114 - PlsqlGoToDbImplAction action = SystemAction.get(PlsqlGoToDbImplAction.class);
48.115 - if(cache.isFunction(objectName)) {
48.116 - action.goToFunction(objectName, project, lineNo);
48.117 - } else if(cache.isProcedure(objectName)) {
48.118 - action.goToProcedure(objectName, project, lineNo);
48.119 - } else {
48.120 - action.goToPackage(objectName, project, null, lineNo);
48.121 - }
48.122 - }
48.123 - }
48.124 + }
48.125 + }
48.126
48.127 - public void outputLineCleared(OutputEvent outputevent) {
48.128 - }
48.129 + @Override
48.130 + public void outputLineCleared(OutputEvent outputevent) {
48.131 + }
48.132
48.133 - public int getCaretPositionFormLineNumber(int lineNo, int pos) {
48.134 - if (getDocLinesArray() == null) {
48.135 - throw new RuntimeException("DocLinesArray is Null");
48.136 - }
48.137 - int caretPos = 0;
48.138 - for (int i = 0; i < lineNo; i++) {
48.139 - String line = (String) getDocLinesArray().get(i);
48.140 - caretPos += line.length();
48.141 - }
48.142 + public int getCaretPositionFormLineNumber(int lineNo, int pos) {
48.143 + if (getDocLinesArray() == null) {
48.144 + throw new RuntimeException("DocLinesArray is Null");
48.145 + }
48.146 + int caretPos = 0;
48.147 + for (int i = 0; i < lineNo; i++) {
48.148 + String line = (String) getDocLinesArray().get(i);
48.149 + caretPos += line.length();
48.150 + }
48.151
48.152 - caretPos += pos;
48.153 - return caretPos;
48.154 - }
48.155 + caretPos += pos;
48.156 + return caretPos;
48.157 + }
48.158
48.159 - public int getCaretPositionFromLineNumber(int lineNo, Document doc) {
48.160 - String docText = "";
48.161 - try {
48.162 - docText = doc.getText(0, doc.getLength());
48.163 - } catch (BadLocationException ex) {
48.164 - ex.printStackTrace();
48.165 - } catch (NullPointerException ex) {
48.166 - ex.printStackTrace();
48.167 - }
48.168 -
48.169 - int caret = 0;
48.170 - int linebrakCount = 0;
48.171 - for (int i = 0; i < docText.length() && linebrakCount + 1 < lineNo; i++) {
48.172 - caret++;
48.173 - if (docText.charAt(i) == '\n') {
48.174 - linebrakCount++;
48.175 - }
48.176 - }
48.177 + public int getCaretPositionFromLineNumber(int lineNo, Document doc) {
48.178 + String docText = "";
48.179 + try {
48.180 + docText = doc.getText(0, doc.getLength());
48.181 + } catch (BadLocationException ex) {
48.182 + Exceptions.printStackTrace(ex);
48.183 + } catch (NullPointerException ex) {
48.184 + Exceptions.printStackTrace(ex);
48.185 + }
48.186
48.187 - return caret;
48.188 - }
48.189 + int caret = 0;
48.190 + int linebrakCount = 0;
48.191 + for (int i = 0; i < docText.length() && linebrakCount + 1 < lineNo; i++) {
48.192 + caret++;
48.193 + if (docText.charAt(i) == '\n') {
48.194 + linebrakCount++;
48.195 + }
48.196 + }
48.197
48.198 - public List getDocLinesArray() {
48.199 - return docLinesArray;
48.200 - }
48.201 + return caret;
48.202 + }
48.203
48.204 - public void setDocLinesArray(List docLinesArray) {
48.205 - this.docLinesArray = docLinesArray;
48.206 - }
48.207 + public List getDocLinesArray() {
48.208 + return docLinesArray;
48.209 + }
48.210
48.211 - public int getLineNo() {
48.212 - return lineNo;
48.213 - }
48.214 + public void setDocLinesArray(List docLinesArray) {
48.215 + this.docLinesArray = docLinesArray;
48.216 + }
48.217
48.218 - public void setLineNo(int lineNo) {
48.219 - this.lineNo = lineNo;
48.220 - }
48.221 + public int getLineNo() {
48.222 + return lineNo;
48.223 + }
48.224
48.225 - public int getPosition() {
48.226 - return position;
48.227 - }
48.228 + public void setLineNo(int lineNo) {
48.229 + this.lineNo = lineNo;
48.230 + }
48.231
48.232 - public void setPosition(int position) {
48.233 - this.position = position;
48.234 - }
48.235 + public int getPosition() {
48.236 + return position;
48.237 + }
48.238
48.239 - public String getOriginalFileName() {
48.240 - return originalFileName;
48.241 - }
48.242 + public void setPosition(int position) {
48.243 + this.position = position;
48.244 + }
48.245
48.246 - public void setOriginalFileName(String originalFileName) {
48.247 - this.originalFileName = originalFileName;
48.248 - }
48.249 + public String getOriginalFileName() {
48.250 + return originalFileName;
48.251 + }
48.252 +
48.253 + public void setOriginalFileName(String originalFileName) {
48.254 + this.originalFileName = originalFileName;
48.255 + }
48.256 }
49.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlRollbackAction.java Tue Feb 14 17:36:37 2012 +0100
49.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlRollbackAction.java Wed Aug 15 20:45:01 2012 +0200
49.3 @@ -44,6 +44,8 @@
49.4 import java.awt.Component;
49.5 import java.awt.event.ActionEvent;
49.6 import java.awt.image.BufferedImage;
49.7 +import java.beans.PropertyChangeEvent;
49.8 +import java.beans.PropertyChangeListener;
49.9 import java.io.IOException;
49.10 import java.util.Arrays;
49.11 import java.util.List;
49.12 @@ -77,8 +79,9 @@
49.13 private DataObject dataObject;
49.14 private DatabaseConnectionManager connectionProvider;
49.15 private JButton button;
49.16 - public boolean autoCommit = true;
49.17 private DatabaseConnection connection;
49.18 + PlsqlCommit commit;
49.19 + private PropertyChangeListener EnableRollback;
49.20
49.21 public PlsqlRollbackAction() {
49.22 this(Utilities.actionsGlobalContext());
49.23 @@ -107,8 +110,8 @@
49.24 }
49.25
49.26 if (dataObject != null) {
49.27 - setEnabled(true);
49.28 - autoCommit = OptionsUtilities.isCommandWindowAutoCommitEnabled();
49.29 + setEnabled(true);
49.30 + commit = PlsqlCommit.getInstance(dataObject);
49.31 } else {
49.32 setEnabled(false);
49.33 }
49.34 @@ -139,31 +142,9 @@
49.35 return;
49.36 }
49.37
49.38 - EditorCookie edCookie = dataObject.getLookup().lookup(EditorCookie.class);
49.39 - Document document = edCookie.getDocument();
49.40 saveIfModified(dataObject);
49.41 -
49.42 - InputOutput io = null;
49.43 - DataObject obj = FileExecutionUtil.getDataObject(document);
49.44 - ProgressHandle handle = ProgressHandleFactory.createHandle("Commit database file...", this);
49.45 - handle.start();
49.46 -
49.47 - try {
49.48 - io = IOProvider.getDefault().getIO(obj.getPrimaryFile().getNameExt(), false);
49.49 - if (!io.isClosed()) {
49.50 - io.getOut().println((new StringBuilder()).append("> Rollback Statement successfully"));
49.51 - }
49.52 -
49.53 - if (connection.getJDBCConnection() != null) {
49.54 - connectionProvider.commitRollbackTransactions(connection, false);
49.55 - }
49.56 -
49.57 - } catch (Exception ex) {
49.58 - io.getOut().println((new StringBuilder()).append(">!!! Error Rollback Statement "));
49.59 - Exceptions.printStackTrace(ex);
49.60 - } finally {
49.61 - handle.finish();
49.62 - }
49.63 + commit.rollbackTransaction(dataObject, connection, connectionProvider);
49.64 + commit.setCommit(false);
49.65 }
49.66
49.67 @Override
49.68 @@ -175,8 +156,10 @@
49.69 new ImageIcon(new BufferedImage(32, 32, BufferedImage.TYPE_BYTE_GRAY)), null);
49.70 button.setAction(this);
49.71 button.setSelected(!OptionsUtilities.isCommandWindowAutoCommitEnabled());
49.72 - button.setEnabled(!OptionsUtilities.isCommandWindowAutoCommitEnabled());
49.73 + button.setEnabled(false);
49.74 button.setDisabledIcon(new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/plsql/execution/database_rollback_disable.png")));
49.75 + EnableRollback = new EnableRollback();
49.76 + commit.addPropertyChangeListener(EnableRollback);
49.77 return button;
49.78 }
49.79
49.80 @@ -190,4 +173,18 @@
49.81 Exceptions.printStackTrace(ex);
49.82 }
49.83 }
49.84 +
49.85 + private class EnableRollback implements PropertyChangeListener {
49.86 +
49.87 + public EnableRollback() {}
49.88 +
49.89 + @Override
49.90 + public void propertyChange(PropertyChangeEvent event) {
49.91 + if(!OptionsUtilities.isCommandWindowAutoCommitEnabled() && commit.getCommit()){
49.92 + button.setEnabled(true);
49.93 + }
49.94 + else
49.95 + button.setEnabled(false);
49.96 + }
49.97 + }
49.98 }
50.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
50.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/SelectMethodDialog.form Wed Aug 15 20:45:01 2012 +0200
50.3 @@ -0,0 +1,93 @@
50.4 +<?xml version="1.1" encoding="UTF-8" ?>
50.5 +
50.6 +<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
50.7 + <Properties>
50.8 + <Property name="defaultCloseOperation" type="int" value="2"/>
50.9 + </Properties>
50.10 + <SyntheticProperties>
50.11 + <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
50.12 + </SyntheticProperties>
50.13 + <AuxValues>
50.14 + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
50.15 + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
50.16 + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
50.17 + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
50.18 + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
50.19 + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
50.20 + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
50.21 + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
50.22 + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
50.23 + </AuxValues>
50.24 +
50.25 + <Layout>
50.26 + <DimensionLayout dim="0">
50.27 + <Group type="103" groupAlignment="0" attributes="0">
50.28 + <Group type="102" attributes="0">
50.29 + <EmptySpace max="-2" attributes="0"/>
50.30 + <Group type="103" groupAlignment="0" attributes="0">
50.31 + <Component id="jScrollPane1" alignment="0" pref="790" max="32767" attributes="0"/>
50.32 + <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
50.33 + <Component id="btnOk" alignment="1" min="-2" max="-2" attributes="0"/>
50.34 + </Group>
50.35 + <EmptySpace max="-2" attributes="0"/>
50.36 + </Group>
50.37 + </Group>
50.38 + </DimensionLayout>
50.39 + <DimensionLayout dim="1">
50.40 + <Group type="103" groupAlignment="0" attributes="0">
50.41 + <Group type="102" alignment="0" attributes="0">
50.42 + <EmptySpace max="-2" attributes="0"/>
50.43 + <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
50.44 + <EmptySpace max="-2" attributes="0"/>
50.45 + <Component id="jScrollPane1" min="-2" pref="242" max="-2" attributes="0"/>
50.46 + <EmptySpace type="unrelated" max="-2" attributes="0"/>
50.47 + <Component id="btnOk" min="-2" max="-2" attributes="0"/>
50.48 + <EmptySpace max="32767" attributes="0"/>
50.49 + </Group>
50.50 + </Group>
50.51 + </DimensionLayout>
50.52 + </Layout>
50.53 + <SubComponents>
50.54 + <Component class="javax.swing.JLabel" name="jLabel1">
50.55 + <Properties>
50.56 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
50.57 + <ResourceString bundle="org/netbeans/modules/plsql/execution/Bundle.properties" key="SelectMethodDialog.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
50.58 + </Property>
50.59 + </Properties>
50.60 + </Component>
50.61 + <Container class="javax.swing.JScrollPane" name="jScrollPane1">
50.62 + <AuxValues>
50.63 + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
50.64 + </AuxValues>
50.65 +
50.66 + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
50.67 + <SubComponents>
50.68 + <Component class="javax.swing.JList" name="lstMethods">
50.69 + <Properties>
50.70 + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
50.71 + <StringArray count="5">
50.72 + <StringItem index="0" value="Item 1"/>
50.73 + <StringItem index="1" value="Item 2"/>
50.74 + <StringItem index="2" value="Item 3"/>
50.75 + <StringItem index="3" value="Item 4"/>
50.76 + <StringItem index="4" value="Item 5"/>
50.77 + </StringArray>
50.78 + </Property>
50.79 + <Property name="selectionMode" type="int" value="0"/>
50.80 + </Properties>
50.81 + </Component>
50.82 + </SubComponents>
50.83 + </Container>
50.84 + <Component class="javax.swing.JButton" name="btnOk">
50.85 + <Properties>
50.86 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
50.87 + <ResourceString bundle="org/netbeans/modules/plsql/execution/Bundle.properties" key="SelectMethodDialog.btnOk.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
50.88 + </Property>
50.89 + <Property name="enabled" type="boolean" value="false"/>
50.90 + </Properties>
50.91 + <Events>
50.92 + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnOkActionPerformed"/>
50.93 + </Events>
50.94 + </Component>
50.95 + </SubComponents>
50.96 +</Form>
51.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
51.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/SelectMethodDialog.java Wed Aug 15 20:45:01 2012 +0200
51.3 @@ -0,0 +1,158 @@
51.4 +/*
51.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
51.6 + *
51.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
51.8 + *
51.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
51.10 + * Other names may be trademarks of their respective owners.
51.11 + *
51.12 + * The contents of this file are subject to the terms of either the GNU
51.13 + * General Public License Version 2 only ("GPL") or the Common
51.14 + * Development and Distribution License("CDDL") (collectively, the
51.15 + * "License"). You may not use this file except in compliance with the
51.16 + * License. You can obtain a copy of the License at
51.17 + * http://www.netbeans.org/cddl-gplv2.html
51.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
51.19 + * specific language governing permissions and limitations under the
51.20 + * License. When distributing the software, include this License Header
51.21 + * Notice in each file and include the License file at
51.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
51.23 + * particular file as subject to the "Classpath" exception as provided
51.24 + * by Oracle in the GPL Version 2 section of the License file that
51.25 + * accompanied this code. If applicable, add the following below the
51.26 + * License Header, with the fields enclosed by brackets [] replaced by
51.27 + * your own identifying information:
51.28 + * "Portions Copyrighted [year] [name of copyright owner]"
51.29 + *
51.30 + * If you wish your version of this file to be governed by only the CDDL
51.31 + * or only the GPL Version 2, indicate your decision by adding
51.32 + * "[Contributor] elects to include this software in this distribution
51.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
51.34 + * single choice of license, a recipient has the option to distribute
51.35 + * your version of this file under either the CDDL, the GPL Version 2 or
51.36 + * to extend the choice of license to its licensees as provided above.
51.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
51.38 + * Version 2 license, then the option applies only if the new code is
51.39 + * made subject to such option by the copyright holder.
51.40 + *
51.41 + * Contributor(s):
51.42 + *
51.43 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
51.44 + */
51.45 +package org.netbeans.modules.plsql.execution;
51.46 +
51.47 +import java.util.ArrayList;
51.48 +import java.util.List;
51.49 +import javax.swing.event.ListSelectionEvent;
51.50 +import javax.swing.event.ListSelectionListener;
51.51 +import javax.swing.text.Document;
51.52 +import org.netbeans.modules.plsql.lexer.PlsqlBlock;
51.53 +import org.netbeans.modules.plsql.utilities.PlsqlParserUtil;
51.54 +
51.55 +/**
51.56 + *
51.57 + * @author shaalk
51.58 + */
51.59 +public class SelectMethodDialog extends javax.swing.JDialog {
51.60 +
51.61 + private List<PlsqlBlock> blocks = null;
51.62 +
51.63 + /** Creates new form SelectMethodDialog */
51.64 + public SelectMethodDialog(java.awt.Frame parent, boolean modal, Document doc, List<PlsqlBlock> blocks) {
51.65 + super(parent, modal);
51.66 + initComponents();
51.67 + this.blocks = blocks;
51.68 + lstMethods.removeAll();
51.69 + ArrayList<String> items = new ArrayList<String>();
51.70 + for (PlsqlBlock block : blocks) {
51.71 + items.add(PlsqlParserUtil.fetchMethodHeader(doc, block.getStartOffset()));
51.72 + }
51.73 + lstMethods.setListData(items.toArray());
51.74 + lstMethods.addListSelectionListener(new ListSelectionListener() {
51.75 +
51.76 + @Override
51.77 + public void valueChanged(ListSelectionEvent e) {
51.78 + if (!lstMethods.isSelectionEmpty()) {
51.79 + btnOk.setEnabled(true);
51.80 + }
51.81 + }
51.82 + });
51.83 + }
51.84 +
51.85 + public PlsqlBlock getSelectedPlsqlBlock() {
51.86 + return blocks.get(lstMethods.getSelectedIndex());
51.87 + }
51.88 +
51.89 + /** This method is called from within the constructor to
51.90 + * initialize the form.
51.91 + * WARNING: Do NOT modify this code. The content of this method is
51.92 + * always regenerated by the Form Editor.
51.93 + */
51.94 + @SuppressWarnings("unchecked")
51.95 + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
51.96 + private void initComponents() {
51.97 +
51.98 + jLabel1 = new javax.swing.JLabel();
51.99 + jScrollPane1 = new javax.swing.JScrollPane();
51.100 + lstMethods = new javax.swing.JList();
51.101 + btnOk = new javax.swing.JButton();
51.102 +
51.103 + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
51.104 +
51.105 + jLabel1.setText(org.openide.util.NbBundle.getMessage(SelectMethodDialog.class, "SelectMethodDialog.jLabel1.text")); // NOI18N
51.106 +
51.107 + lstMethods.setModel(new javax.swing.AbstractListModel() {
51.108 + String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
51.109 + public int getSize() { return strings.length; }
51.110 + public Object getElementAt(int i) { return strings[i]; }
51.111 + });
51.112 + lstMethods.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
51.113 + jScrollPane1.setViewportView(lstMethods);
51.114 +
51.115 + btnOk.setText(org.openide.util.NbBundle.getMessage(SelectMethodDialog.class, "SelectMethodDialog.btnOk.text")); // NOI18N
51.116 + btnOk.setEnabled(false);
51.117 + btnOk.addActionListener(new java.awt.event.ActionListener() {
51.118 + public void actionPerformed(java.awt.event.ActionEvent evt) {
51.119 + btnOkActionPerformed(evt);
51.120 + }
51.121 + });
51.122 +
51.123 + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
51.124 + getContentPane().setLayout(layout);
51.125 + layout.setHorizontalGroup(
51.126 + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
51.127 + .addGroup(layout.createSequentialGroup()
51.128 + .addContainerGap()
51.129 + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
51.130 + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 790, Short.MAX_VALUE)
51.131 + .addComponent(jLabel1)
51.132 + .addComponent(btnOk, javax.swing.GroupLayout.Alignment.TRAILING))
51.133 + .addContainerGap())
51.134 + );
51.135 + layout.setVerticalGroup(
51.136 + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
51.137 + .addGroup(layout.createSequentialGroup()
51.138 + .addContainerGap()
51.139 + .addComponent(jLabel1)
51.140 + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
51.141 + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 242, javax.swing.GroupLayout.PREFERRED_SIZE)
51.142 + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
51.143 + .addComponent(btnOk)
51.144 + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
51.145 + );
51.146 +
51.147 + pack();
51.148 + }// </editor-fold>//GEN-END:initComponents
51.149 +
51.150 +private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
51.151 + this.setVisible(false);
51.152 +}//GEN-LAST:event_btnOkActionPerformed
51.153 +
51.154 +
51.155 + // Variables declaration - do not modify//GEN-BEGIN:variables
51.156 + private javax.swing.JButton btnOk;
51.157 + private javax.swing.JLabel jLabel1;
51.158 + private javax.swing.JScrollPane jScrollPane1;
51.159 + private javax.swing.JList lstMethods;
51.160 + // End of variables declaration//GEN-END:variables
51.161 +}
52.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/ViewDataAction.java Tue Feb 14 17:36:37 2012 +0100
52.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/ViewDataAction.java Wed Aug 15 20:45:01 2012 +0200
52.3 @@ -59,16 +59,16 @@
52.4
52.5 @ActionID(id = "org.netbeans.modules.plsql.execution.ViewDataAction", category = "PLSQL")
52.6 @ActionRegistration(displayName = "#CTL_ViewDataAction")
52.7 -@ActionReference(path = "Editors/text/x-plsql/Popup", position = 282)
52.8 +@ActionReference(path = "Editors/text/x-plsql/Popup", position = 430)
52.9 public final class ViewDataAction extends CookieAction {
52.10
52.11 /**
52.12 - * Create a sql execution window for the selected methoad
52.13 + * Create a SQL execution window for the selected method
52.14 * @param activatedNodes
52.15 */
52.16 @Override
52.17 protected void performAction(Node[] activatedNodes) {
52.18 - String selectStatement = "SELECT ${*} FROM " + getSelectedViewOrTable(activatedNodes) + ";\n${cursor}";
52.19 + String selectStatement = "SELECT * FROM " + getSelectedViewOrTable(activatedNodes) + ";\n";
52.20 SQLCommandWindow.createSQLCommandWindow(activatedNodes, selectStatement, null);
52.21 }
52.22
53.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/actions/Bundle.properties Tue Feb 14 17:36:37 2012 +0100
53.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/actions/Bundle.properties Wed Aug 15 20:45:01 2012 +0200
53.3 @@ -2,6 +2,7 @@
53.4 # and open the template in the editor.
53.5 LBL_DatabaseNodeName=Database
53.6 CTL_DeployFilesAction=Deploy Files...
53.7 +CTL_DeployFilesOpenInEditorAction=Deploy Files Open in Editor...
53.8 CTL_DeploySelectedCodeAction=Deploy Selection
53.9 LBL_DeployDialogTitle=Select Files to Deploy
53.10 -
53.11 +OpenPlsqlFilesSelectorPanel.lblOpenFiles.text=Files Open In Editor
54.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/actions/DeployFilesAction.java Tue Feb 14 17:36:37 2012 +0100
54.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/actions/DeployFilesAction.java Wed Aug 15 20:45:01 2012 +0200
54.3 @@ -41,32 +41,28 @@
54.4 */
54.5 package org.netbeans.modules.plsql.execution.actions;
54.6
54.7 -import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
54.8 +import java.io.File;
54.9 +import java.io.IOException;
54.10 +import java.util.List;
54.11 +import java.util.Locale;
54.12 +import javax.swing.JFileChooser;
54.13 +import javax.swing.text.Document;
54.14 +import org.netbeans.api.db.explorer.DatabaseConnection;
54.15 +import org.netbeans.api.progress.ProgressHandle;
54.16 +import org.netbeans.api.progress.ProgressHandleFactory;
54.17 +import org.netbeans.api.project.Project;
54.18 import org.netbeans.modules.plsql.execution.PlsqlExecutableBlocksMaker;
54.19 import org.netbeans.modules.plsql.execution.PlsqlFileExecutor;
54.20 import org.netbeans.modules.plsql.utilities.PlsqlExecutorService;
54.21 -import java.io.IOException;
54.22 -import javax.swing.text.Document;
54.23 -import org.netbeans.api.progress.ProgressHandle;
54.24 -import org.netbeans.api.progress.ProgressHandleFactory;
54.25 -import org.netbeans.api.project.Project;
54.26 +import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
54.27 +import org.openide.DialogDescriptor;
54.28 +import org.openide.DialogDisplayer;
54.29 import org.openide.cookies.EditorCookie;
54.30 +import org.openide.filesystems.FileUtil;
54.31 import org.openide.loaders.DataObject;
54.32 import org.openide.nodes.Node;
54.33 -import org.openide.util.Cancellable;
54.34 -import org.openide.util.Exceptions;
54.35 -import org.openide.util.HelpCtx;
54.36 -import org.openide.util.NbBundle;
54.37 -import org.openide.util.Task;
54.38 +import org.openide.util.*;
54.39 import org.openide.util.actions.CookieAction;
54.40 -import java.io.File;
54.41 -import java.util.List;
54.42 -import java.util.Locale;
54.43 -import javax.swing.JFileChooser;
54.44 -import org.netbeans.api.db.explorer.DatabaseConnection;
54.45 -import org.openide.filesystems.FileUtil;
54.46 -import org.openide.util.Lookup;
54.47 -import org.openide.util.RequestProcessor;
54.48 import org.openide.windows.IOProvider;
54.49 import org.openide.windows.InputOutput;
54.50 import org.openide.windows.OutputEvent;
54.51 @@ -76,210 +72,258 @@
54.52 *
54.53 * @author csamlk
54.54 */
54.55 -public class DeployFilesAction extends CookieAction {
54.56 +public abstract class DeployFilesAction extends CookieAction {
54.57
54.58 - private static final PlsqlExecutorService executorService = Lookup.getDefault().lookup(PlsqlExecutorService.class);
54.59 - private Project project;
54.60 - //private DatabaseConnection connection;
54.61 - private Node[] activatedNodes;
54.62 - private static File lastLocation = null;
54.63 + private static final PlsqlExecutorService executorService = Lookup.getDefault().lookup(PlsqlExecutorService.class);
54.64 + private static final RequestProcessor RP = new RequestProcessor(DeployFilesAction.class);
54.65 + private Project project;
54.66 + private Node[] activatedNodes;
54.67
54.68 - @Override
54.69 - protected int mode() {
54.70 - return CookieAction.MODE_EXACTLY_ONE;
54.71 - }
54.72 + @Override
54.73 + protected int mode() {
54.74 + return CookieAction.MODE_EXACTLY_ONE;
54.75 + }
54.76
54.77 - @Override
54.78 - protected Class<?>[] cookieClasses() {
54.79 - return new Class[]{Project.class};
54.80 - }
54.81 + @Override
54.82 + protected Class<?>[] cookieClasses() {
54.83 + return new Class[]{Project.class};
54.84 + }
54.85
54.86 - @Override
54.87 - protected void performAction(Node[] arg0) {
54.88 - final JFileChooser fc = new JFileChooser();
54.89 - fc.setMultiSelectionEnabled(true);
54.90 - fc.setCurrentDirectory(lastLocation);
54.91 - fc.setDialogTitle(NbBundle.getMessage(DeployFilesAction.class, "LBL_DeployDialogTitle"));
54.92 - fc.setApproveButtonText("OK");
54.93 - File[] files = null;
54.94 - int returnVal = fc.showOpenDialog(null);
54.95 + protected abstract File[] getFilesToDeploy();
54.96
54.97 - if (returnVal == JFileChooser.APPROVE_OPTION) {
54.98 - files = fc.getSelectedFiles();
54.99 - lastLocation = fc.getCurrentDirectory();
54.100 - }
54.101 + @Override
54.102 + protected boolean asynchronous() {
54.103 + return false;
54.104 + }
54.105
54.106 - if (files != null) {
54.107 - try {
54.108 - execute(files);
54.109 - } catch (IOException ex) {
54.110 - Exceptions.printStackTrace(ex);
54.111 - }
54.112 - }
54.113 - }
54.114 + @Override
54.115 + protected void performAction(Node[] arg0) {
54.116 + File[] files = getFilesToDeploy();
54.117 + if (files != null && files.length > 0) {
54.118 + try {
54.119 + execute(files);
54.120 + } catch (IOException ex) {
54.121 + Exceptions.printStackTrace(ex);
54.122 + }
54.123 + }
54.124 + }
54.125
54.126 - @Override
54.127 - public String getName() {
54.128 - return NbBundle.getMessage(DeployFilesAction.class, "CTL_DeployFilesAction");
54.129 - }
54.130 + @Override
54.131 + public abstract String getName();
54.132
54.133 - @Override
54.134 - public HelpCtx getHelpCtx() {
54.135 - return HelpCtx.DEFAULT_HELP;
54.136 - }
54.137 + @Override
54.138 + public HelpCtx getHelpCtx() {
54.139 + return HelpCtx.DEFAULT_HELP;
54.140 + }
54.141
54.142 - @Override
54.143 - protected boolean enable(Node[] activatedNodes) {
54.144 - this.activatedNodes = activatedNodes;
54.145 - if (!super.enable(activatedNodes)) {
54.146 - return false;
54.147 - }
54.148 + @Override
54.149 + protected boolean enable(Node[] activatedNodes) {
54.150 + this.activatedNodes = activatedNodes;
54.151 + if (!super.enable(activatedNodes)) {
54.152 + return false;
54.153 + }
54.154
54.155 - Project p = activatedNodes[0].getLookup().lookup(Project.class);
54.156 + Project p = activatedNodes[0].getLookup().lookup(Project.class);
54.157
54.158 - return DatabaseConnectionManager.getInstance(p).isOnline();
54.159 - }
54.160 + return DatabaseConnectionManager.getInstance(p).isOnline();
54.161 + }
54.162
54.163 - static void execute(DatabaseConnection connection, DatabaseConnectionManager connectionProvider, File[] files, boolean isTemporyFile) throws IOException {
54.164 - if (connection == null || connection.getJDBCConnection() == null) {
54.165 - return;
54.166 - }
54.167 - RequestProcessor processor = RequestProcessor.getDefault();
54.168 - processor.post(new MultipleDbFileExecutionHandler(connection, connectionProvider, files, isTemporyFile));
54.169 - }
54.170 + static void execute(DatabaseConnection connection, DatabaseConnectionManager connectionProvider, File[] files, boolean isTemporyFile) throws IOException {
54.171 + if (connection == null || connection.getJDBCConnection() == null) {
54.172 + return;
54.173 + }
54.174 + RP.post(new MultipleDbFileExecutionHandler(connection, connectionProvider, files, isTemporyFile));
54.175 + }
54.176
54.177 - private void execute(File[] files) throws IOException {
54.178 - DatabaseConnectionManager connectionProvider = null;
54.179 - project = activatedNodes[0].getLookup().lookup(Project.class);
54.180 + private void execute(File[] files) throws IOException {
54.181 + project = activatedNodes[0].getLookup().lookup(Project.class);
54.182
54.183 - connectionProvider = DatabaseConnectionManager.getInstance(project);
54.184 - RequestProcessor processor = RequestProcessor.getDefault();
54.185 - processor.post(new MultipleDbFileExecutionHandler(connectionProvider, files));
54.186 - }
54.187 + DatabaseConnectionManager connectionProvider = DatabaseConnectionManager.getInstance(project);
54.188 + RP.post(new MultipleDbFileExecutionHandler(connectionProvider, files));
54.189 + }
54.190
54.191 - private static class DeploymentError implements OutputListener {
54.192 + private static class DeploymentError implements OutputListener {
54.193
54.194 - private InputOutput errorTab;
54.195 + private InputOutput errorTab;
54.196
54.197 - public DeploymentError(InputOutput errorTab) {
54.198 - this.errorTab = errorTab;
54.199 - }
54.200 + public DeploymentError(InputOutput errorTab) {
54.201 + this.errorTab = errorTab;
54.202 + }
54.203
54.204 - @Override
54.205 - public void outputLineSelected(OutputEvent arg0) {
54.206 - //do nothing
54.207 - }
54.208 + @Override
54.209 + public void outputLineSelected(OutputEvent arg0) {
54.210 + //do nothing
54.211 + }
54.212
54.213 - @Override
54.214 - public void outputLineAction(OutputEvent arg0) {
54.215 - if (errorTab != null && !errorTab.isClosed()) {
54.216 - errorTab.select();
54.217 - }
54.218 - }
54.219 + @Override
54.220 + public void outputLineAction(OutputEvent arg0) {
54.221 + if (errorTab != null && !errorTab.isClosed()) {
54.222 + errorTab.select();
54.223 + }
54.224 + }
54.225
54.226 - @Override
54.227 - public void outputLineCleared(OutputEvent arg0) {
54.228 - //do nothing
54.229 - }
54.230 - }
54.231 + @Override
54.232 + public void outputLineCleared(OutputEvent arg0) {
54.233 + //do nothing
54.234 + }
54.235 + }
54.236
54.237 - private static class MultipleDbFileExecutionHandler implements Runnable, Cancellable {
54.238 + private static class MultipleDbFileExecutionHandler implements Runnable, Cancellable {
54.239
54.240 - private PlsqlFileExecutor executor;
54.241 - private boolean cancelDeployment = false;
54.242 - private final DatabaseConnectionManager connectionProvider;
54.243 - private DatabaseConnection connection = null;
54.244 - private final File[] files;
54.245 - private boolean isTemporyFile = false;
54.246 + private PlsqlFileExecutor executor;
54.247 + private boolean cancelDeployment = false;
54.248 + private final DatabaseConnectionManager connectionProvider;
54.249 + private DatabaseConnection connection = null;
54.250 + private final File[] files;
54.251 + private boolean isTemporyFile = false;
54.252
54.253 - public MultipleDbFileExecutionHandler(DatabaseConnectionManager connectionProvider, File[] files) {
54.254 - this.connectionProvider = connectionProvider;
54.255 - this.connection = null;
54.256 - this.files = files;
54.257 - }
54.258 + public MultipleDbFileExecutionHandler(DatabaseConnectionManager connectionProvider, File[] files) {
54.259 + this.connectionProvider = connectionProvider;
54.260 + this.connection = null;
54.261 + this.files = files;
54.262 + }
54.263
54.264 - public MultipleDbFileExecutionHandler(DatabaseConnection connection, DatabaseConnectionManager connectionProvider, File[] files, boolean isTemporyFile) {
54.265 - this.connectionProvider = connectionProvider;
54.266 - this.connection = connection;
54.267 - this.files = files;
54.268 - this.isTemporyFile = isTemporyFile;
54.269 - }
54.270 + public MultipleDbFileExecutionHandler(DatabaseConnection connection, DatabaseConnectionManager connectionProvider, File[] files, boolean isTemporyFile) {
54.271 + this.connectionProvider = connectionProvider;
54.272 + this.connection = connection;
54.273 + this.files = files;
54.274 + this.isTemporyFile = isTemporyFile;
54.275 + }
54.276
54.277 - @Override
54.278 - public void run() {
54.279 - List<String> executionOrder = executorService.getExecutionOrder();
54.280 - ProgressHandle handle = ProgressHandleFactory.createHandle("Deploying to database...", (Cancellable) this);
54.281 - cancelDeployment = false;
54.282 - //check if we're deploying to the "main" database. If so get a connection from the cache instead of using the "main" connection.
54.283 - if (connectionProvider != null && (connection == null || connection == connectionProvider.getTemplateConnection())) {
54.284 - connection = connectionProvider.getPooledDatabaseConnection(false);
54.285 - }
54.286 - try {
54.287 - handle.start();
54.288 - int count = 0;
54.289 - InputOutput io = IOProvider.getDefault().getIO("Deployment summary", false);
54.290 - io.getOut().reset();
54.291 - if (isTemporyFile) {
54.292 - io.getOut().println("Deploying to database");
54.293 - } else {
54.294 - io.getOut().println("Deploying database files");
54.295 + @Override
54.296 + public void run() {
54.297 + List<String> executionOrder = executorService.getExecutionOrder();
54.298 + ProgressHandle handle = ProgressHandleFactory.createHandle("Deploying to database...", (Cancellable) this);
54.299 + cancelDeployment = false;
54.300 + //check if we're deploying to the "main" database. If so get a connection from the cache instead of using the "main" connection.
54.301 + if (connectionProvider != null && (connection == null || connection == connectionProvider.getTemplateConnection())) {
54.302 + connection = connectionProvider.getPooledDatabaseConnection(false);
54.303 }
54.304 - executor = new PlsqlFileExecutor(connectionProvider, connection);
54.305 - for (int typeIndex = 0; !cancelDeployment && typeIndex < executionOrder.size(); typeIndex++) {
54.306 - for (int i = 0; !cancelDeployment && i < files.length; i++) {
54.307 - String fileName = files[i].getAbsolutePath();
54.308 - DataObject obj = DataObject.find(FileUtil.toFileObject(files[i]));
54.309 - if (obj != null) {
54.310 - if (fileName.toLowerCase(Locale.ENGLISH).endsWith(executionOrder.get(typeIndex))) {
54.311 - //Load the editor cookier and allow parsing
54.312 - EditorCookie ec = obj.getCookie(EditorCookie.class);
54.313 - Task task = ec.prepareDocument();
54.314 - task.waitFinished();
54.315 - Document doc = ec.getDocument();
54.316 - PlsqlExecutableBlocksMaker blockMaker = new PlsqlExecutableBlocksMaker(doc);
54.317 - final List exeBlocks = blockMaker.makeExceutableObjects();
54.318 - if (isTemporyFile) {
54.319 - io.getOut().print("> Deploying...");
54.320 - } else {
54.321 - io.getOut().print("> Deploying " + fileName + "...");
54.322 + try {
54.323 + handle.start();
54.324 + int count = 0;
54.325 + InputOutput io = IOProvider.getDefault().getIO("Deployment summary", false);
54.326 + io.getOut().reset();
54.327 + if (isTemporyFile) {
54.328 + io.getOut().println("Deploying to database");
54.329 + } else {
54.330 + io.getOut().println("Deploying database files");
54.331 + }
54.332 + executor = new PlsqlFileExecutor(connectionProvider, connection);
54.333 + for (int typeIndex = 0; !cancelDeployment && typeIndex < executionOrder.size(); typeIndex++) {
54.334 + for (int i = 0; !cancelDeployment && i < files.length; i++) {
54.335 + String fileName = files[i].getAbsolutePath();
54.336 + DataObject obj = DataObject.find(FileUtil.toFileObject(files[i]));
54.337 + if (obj != null) {
54.338 + if (fileName.toLowerCase(Locale.ENGLISH).endsWith(executionOrder.get(typeIndex))) {
54.339 + //Load the editor cookier and allow parsing
54.340 + EditorCookie ec = obj.getCookie(EditorCookie.class);
54.341 + Task task = ec.prepareDocument();
54.342 + task.waitFinished();
54.343 + Document doc = ec.getDocument();
54.344 + PlsqlExecutableBlocksMaker blockMaker = new PlsqlExecutableBlocksMaker(doc);
54.345 + final List exeBlocks = blockMaker.makeExceutableObjects();
54.346 + if (isTemporyFile) {
54.347 + io.getOut().print("> Deploying...");
54.348 + } else {
54.349 + io.getOut().print("> Deploying " + fileName + "...");
54.350 + }
54.351 + handle.setDisplayName("Deploying files to database (" + (++count) + ")");
54.352 + InputOutput errorTab = executor.executePLSQL(exeBlocks, doc, true, true);
54.353 + if (errorTab == null) {
54.354 + io.getOut().println("Ok");
54.355 + } else {
54.356 + io.getOut().println("Failed");
54.357 + try {
54.358 + io.getErr().println("!!!Error deploying file " + fileName, new DeploymentError(errorTab));
54.359 + } catch (IOException ex) {
54.360 + Exceptions.printStackTrace(ex);
54.361 + }
54.362 + cancelDeployment = true;
54.363 + }
54.364 + }
54.365 }
54.366 - handle.setDisplayName("Deploying files to database (" + (++count) + ")");
54.367 - InputOutput errorTab = executor.executePLSQL(exeBlocks, doc, true, true);
54.368 - if (errorTab == null) {
54.369 - io.getOut().println("Ok");
54.370 - } else {
54.371 - io.getOut().println("Failed");
54.372 - try {
54.373 - io.getErr().println("!!!Error deploying file " + fileName, new DeploymentError(errorTab));
54.374 - } catch (IOException ex) {
54.375 - Exceptions.printStackTrace(ex);
54.376 - }
54.377 - cancelDeployment = true;
54.378 - }
54.379 - }
54.380 - }
54.381 - }
54.382 + }
54.383 + }
54.384 + io.getOut().close();
54.385 + io.getErr().close();
54.386 + io.select();
54.387 + } catch (IOException ex) {
54.388 + Exceptions.printStackTrace(ex);
54.389 + } finally {
54.390 + if (connectionProvider != null) {
54.391 + connectionProvider.releaseDatabaseConnection(connection);
54.392 + }
54.393 + handle.finish();
54.394 }
54.395 - io.getOut().close();
54.396 - io.getErr().close();
54.397 - io.select();
54.398 - } catch (IOException ex) {
54.399 - Exceptions.printStackTrace(ex);
54.400 - } finally {
54.401 - if (connectionProvider != null) {
54.402 - connectionProvider.releaseDatabaseConnection(connection);
54.403 + }
54.404 +
54.405 + @Override
54.406 + public boolean cancel() {
54.407 + if (executor != null) {
54.408 + executor.cancel();
54.409 + cancelDeployment = true;
54.410 }
54.411 - handle.finish();
54.412 - }
54.413 - }
54.414 + return true;
54.415 + }
54.416 + }
54.417
54.418 - @Override
54.419 - public boolean cancel() {
54.420 - if (executor != null) {
54.421 - executor.cancel();
54.422 - cancelDeployment = true;
54.423 - }
54.424 - return true;
54.425 - }
54.426 - }
54.427 + /*
54.428 + * Displays a file chooser dialog which can be used to browse and select arbitrary
54.429 + * files from disk to be deployed to the database.
54.430 + */
54.431 +
54.432 + public static class GenericDeployFilesAction extends DeployFilesAction {
54.433 +
54.434 + private static File lastLocation = null;
54.435 +
54.436 + @Override
54.437 + protected final File[] getFilesToDeploy() {
54.438 + final JFileChooser fc = new JFileChooser();
54.439 + fc.setMultiSelectionEnabled(true);
54.440 + fc.setCurrentDirectory(lastLocation);
54.441 + fc.setDialogTitle(NbBundle.getMessage(DeployFilesAction.class, "LBL_DeployDialogTitle"));
54.442 + fc.setApproveButtonText("OK");
54.443 + int returnVal = fc.showOpenDialog(null);
54.444 + if (returnVal == JFileChooser.APPROVE_OPTION) {
54.445 + File[] files = fc.getSelectedFiles();
54.446 + lastLocation = fc.getCurrentDirectory();
54.447 + if (files != null) {
54.448 + return files;
54.449 + }
54.450 + }
54.451 + return new File[0];
54.452 + }
54.453 +
54.454 + @Override
54.455 + public String getName() {
54.456 + return NbBundle.getMessage(DeployFilesAction.class, "CTL_DeployFilesAction");
54.457 + }
54.458 + }
54.459 +
54.460 + /*
54.461 + * Displays a dialog listing files currently open in the editor which makes it
54.462 + * easy to select and deploy files to the database that are being worked on.
54.463 + */
54.464 + public static class DeployFilesOpenInEditorAction extends DeployFilesAction {
54.465 +
54.466 + @Override
54.467 + protected final File[] getFilesToDeploy() {
54.468 + OpenPlsqlFilesSelectorPanel editorSelector = new OpenPlsqlFilesSelectorPanel();
54.469 + DialogDescriptor openFilesDialog = new DialogDescriptor(editorSelector, NbBundle.getMessage(DeployFilesOpenInEditorAction.class, "LBL_DeployDialogTitle"));
54.470 + DialogDisplayer.getDefault().notify(openFilesDialog);
54.471 + if (openFilesDialog.getValue().equals(DialogDescriptor.OK_OPTION)) {
54.472 + List<File> filesToDeploy = editorSelector.getOpenFiles();
54.473 + if (!filesToDeploy.isEmpty()) {
54.474 + return filesToDeploy.toArray(new File[filesToDeploy.size()]);
54.475 + }
54.476 + }
54.477 + return new File[0];
54.478 + }
54.479 +
54.480 + @Override
54.481 + public String getName() {
54.482 + return NbBundle.getMessage(DeployFilesAction.class, "CTL_DeployFilesOpenInEditorAction");
54.483 + }
54.484 + }
54.485 }
55.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/actions/DeploySelectedCodeAction.java Tue Feb 14 17:36:37 2012 +0100
55.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/actions/DeploySelectedCodeAction.java Wed Aug 15 20:45:01 2012 +0200
55.3 @@ -46,7 +46,7 @@
55.4 import java.io.File;
55.5 import java.io.FileWriter;
55.6 import java.io.IOException;
55.7 -
55.8 +import java.util.List;
55.9 import javax.swing.JEditorPane;
55.10 import javax.swing.JMenu;
55.11 import javax.swing.JMenuItem;
55.12 @@ -54,7 +54,6 @@
55.13 import javax.swing.text.BadLocationException;
55.14 import javax.swing.text.Caret;
55.15 import javax.swing.text.Document;
55.16 -
55.17 import org.netbeans.api.db.explorer.DatabaseConnection;
55.18 import org.netbeans.api.project.FileOwnerQuery;
55.19 import org.netbeans.api.project.Project;
55.20 @@ -75,7 +74,8 @@
55.21
55.22 @ActionID(id = "org.netbeans.modules.plsql.execution.actions.DeploySelectedCodeAction", category = "PLSQL")
55.23 @ActionRegistration(displayName = "#CTL_DeploySelectedCodeAction")
55.24 -@ActionReference(path = "Editors/text/x-plsql/Popup", name = "org-netbeans-modules-plsql-execution-action-DeploySelectedCodeAction", position = 280)
55.25 +@ActionReference(path = "Editors/text/x-plsql/Popup", name = "org-netbeans-modules-plsql-execution-action-DeploySelectedCodeAction",
55.26 +position = 410)
55.27 public final class DeploySelectedCodeAction extends CookieAction {
55.28
55.29 private Node[] activatedNodes;
55.30 @@ -86,7 +86,8 @@
55.31 private final String TEMP_SQL_FILE_PREFIX = "Tempory";
55.32
55.33 /**
55.34 - * Create a sql execution window for the selected methoad
55.35 + * Create a SQL execution window for the selected method
55.36 + *
55.37 * @param activatedNodes
55.38 */
55.39 @Override
55.40 @@ -127,6 +128,7 @@
55.41
55.42 /**
55.43 * Enable this action when right clicked on procedures or functions
55.44 + *
55.45 * @param arg0
55.46 * @return
55.47 */
55.48 @@ -180,13 +182,13 @@
55.49
55.50 JMenu menu = new JMenu(getName());
55.51 ActionListener buttonListener = new ButtonListener();
55.52 - DatabaseConnection[] databaseConnections = connectionProvider.getDatabaseConnections();
55.53 - for (int i = 0; i < databaseConnections.length; i++) {
55.54 - JMenuItem item = new JMenuItem(databaseConnections[i].getName());
55.55 - item.putClientProperty(DATABASE_CONNECTION_KEY, databaseConnections[i]);
55.56 + List<DatabaseConnection> databaseConnections = connectionProvider.getDatabaseConnections();
55.57 + for (int i = 0; i < databaseConnections.size(); i++) {
55.58 + JMenuItem item = new JMenuItem(databaseConnections.get(i).getName());
55.59 + item.putClientProperty(DATABASE_CONNECTION_KEY, databaseConnections.get(i));
55.60 item.addActionListener(buttonListener);
55.61 menu.add(item);
55.62 - if (i == 0 && databaseConnections.length > 1) {
55.63 + if (i == 0 && databaseConnections.size() > 1) {
55.64 menu.add(new JSeparator());
55.65 }
55.66 }
55.67 @@ -208,15 +210,24 @@
55.68 Exceptions.printStackTrace(ex);
55.69 }
55.70 File tmpFile = null;
55.71 + FileWriter writer = null;
55.72 try {
55.73 tmpFile = File.createTempFile(TEMP_SQL_FILE_PREFIX, ".sql",
55.74 FileUtil.toFile(project.getLookup().lookup(CacheDirectoryProvider.class).getCacheDirectory()));
55.75 tmpFile.deleteOnExit();
55.76 - FileWriter writer = new FileWriter(tmpFile);
55.77 + writer = new FileWriter(tmpFile);
55.78 writer.write(output);
55.79 - writer.close();
55.80 +
55.81 } catch (IOException ex) {
55.82 Exceptions.printStackTrace(ex);
55.83 + } finally {
55.84 + if (writer != null) {
55.85 + try {
55.86 + writer.close();
55.87 + } catch (IOException ignore) {
55.88 + // Exceptions.printStackTrace(ex);
55.89 + }
55.90 + }
55.91 }
55.92 File[] files = {tmpFile};
55.93 try {
56.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
56.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/actions/OpenPlsqlFilesSelectorPanel.form Wed Aug 15 20:45:01 2012 +0200
56.3 @@ -0,0 +1,54 @@
56.4 +<?xml version="1.0" encoding="UTF-8" ?>
56.5 +
56.6 +<Form version="1.5" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
56.7 + <AuxValues>
56.8 + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
56.9 + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
56.10 + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
56.11 + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
56.12 + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
56.13 + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
56.14 + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
56.15 + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
56.16 + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
56.17 + </AuxValues>
56.18 +
56.19 + <Layout>
56.20 + <DimensionLayout dim="0">
56.21 + <Group type="103" groupAlignment="0" attributes="0">
56.22 + <Group type="102" alignment="0" attributes="0">
56.23 + <EmptySpace max="-2" attributes="0"/>
56.24 + <Group type="103" groupAlignment="0" attributes="0">
56.25 + <Component id="jPanel1" alignment="0" pref="237" max="32767" attributes="0"/>
56.26 + <Component id="lblOpenFiles" alignment="0" min="-2" max="-2" attributes="0"/>
56.27 + </Group>
56.28 + <EmptySpace max="-2" attributes="0"/>
56.29 + </Group>
56.30 + </Group>
56.31 + </DimensionLayout>
56.32 + <DimensionLayout dim="1">
56.33 + <Group type="103" groupAlignment="0" attributes="0">
56.34 + <Group type="102" alignment="0" attributes="0">
56.35 + <EmptySpace max="-2" attributes="0"/>
56.36 + <Component id="lblOpenFiles" min="-2" max="-2" attributes="0"/>
56.37 + <EmptySpace max="-2" attributes="0"/>
56.38 + <Component id="jPanel1" min="-2" pref="179" max="-2" attributes="0"/>
56.39 + <EmptySpace max="32767" attributes="0"/>
56.40 + </Group>
56.41 + </Group>
56.42 + </DimensionLayout>
56.43 + </Layout>
56.44 + <SubComponents>
56.45 + <Component class="javax.swing.JLabel" name="lblOpenFiles">
56.46 + <Properties>
56.47 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
56.48 + <ResourceString bundle="org/netbeans/modules/plsql/execution/actions/Bundle.properties" key="OpenPlsqlFilesSelectorPanel.lblOpenFiles.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
56.49 + </Property>
56.50 + </Properties>
56.51 + </Component>
56.52 + <Container class="javax.swing.JPanel" name="jPanel1">
56.53 +
56.54 + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
56.55 + </Container>
56.56 + </SubComponents>
56.57 +</Form>
57.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
57.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/actions/OpenPlsqlFilesSelectorPanel.java Wed Aug 15 20:45:01 2012 +0200
57.3 @@ -0,0 +1,229 @@
57.4 +/*
57.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
57.6 + *
57.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
57.8 + *
57.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
57.10 + * Other names may be trademarks of their respective owners.
57.11 + *
57.12 + * The contents of this file are subject to the terms of either the GNU
57.13 + * General Public License Version 2 only ("GPL") or the Common
57.14 + * Development and Distribution License("CDDL") (collectively, the
57.15 + * "License"). You may not use this file except in compliance with the
57.16 + * License. You can obtain a copy of the License at
57.17 + * http://www.netbeans.org/cddl-gplv2.html
57.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
57.19 + * specific language governing permissions and limitations under the
57.20 + * License. When distributing the software, include this License Header
57.21 + * Notice in each file and include the License file at
57.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
57.23 + * particular file as subject to the "Classpath" exception as provided
57.24 + * by Oracle in the GPL Version 2 section of the License file that
57.25 + * accompanied this code. If applicable, add the following below the
57.26 + * License Header, with the fields enclosed by brackets [] replaced by
57.27 + * your own identifying information:
57.28 + * "Portions Copyrighted [year] [name of copyright owner]"
57.29 + *
57.30 + * If you wish your version of this file to be governed by only the CDDL
57.31 + * or only the GPL Version 2, indicate your decision by adding
57.32 + * "[Contributor] elects to include this software in this distribution
57.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
57.34 + * single choice of license, a recipient has the option to distribute
57.35 + * your version of this file under either the CDDL, the GPL Version 2 or
57.36 + * to extend the choice of license to its licensees as provided above.
57.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
57.38 + * Version 2 license, then the option applies only if the new code is
57.39 + * made subject to such option by the copyright holder.
57.40 + *
57.41 + * Contributor(s):
57.42 + *
57.43 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
57.44 + */
57.45 +package org.netbeans.modules.plsql.execution.actions;
57.46 +
57.47 +import java.awt.Component;
57.48 +import java.awt.event.MouseEvent;
57.49 +import java.io.File;
57.50 +import java.util.*;
57.51 +import javax.swing.*;
57.52 +import javax.swing.event.ListSelectionEvent;
57.53 +import javax.swing.event.ListSelectionListener;
57.54 +import org.netbeans.modules.plsql.filetype.PlsqlDataLoader;
57.55 +import org.openide.filesystems.FileObject;
57.56 +import org.openide.filesystems.FileUtil;
57.57 +import org.openide.loaders.DataObject;
57.58 +import org.openide.util.Lookup;
57.59 +import org.openide.windows.Mode;
57.60 +import org.openide.windows.TopComponent;
57.61 +import org.openide.windows.WindowManager;
57.62 +
57.63 +/**
57.64 + *
57.65 + * @author riralk
57.66 + * based on org.netbeans.modules.diff.EditorBufferSelectorPanel by Maros Sandor *
57.67 + */
57.68 +class OpenPlsqlFilesSelectorPanel extends JPanel implements ListSelectionListener {
57.69 +
57.70 + private JList elementsList;
57.71 + private List<File> openFiles = new ArrayList<File>();
57.72 +
57.73 + public OpenPlsqlFilesSelectorPanel() {
57.74 + initComponents();
57.75 + initEditorDocuments();
57.76 + }
57.77 +
57.78 + private void initEditorDocuments() {
57.79 + elementsList = new JList() {
57.80 + @Override
57.81 + public String getToolTipText(MouseEvent event) {
57.82 + int index = locationToIndex(event.getPoint());
57.83 + if (index != -1) {
57.84 + PlsqlFileListElement element = (PlsqlFileListElement) elementsList.getModel().getElementAt(index);
57.85 + return element.fileObject.getPath();
57.86 + }
57.87 + return null;
57.88 + }
57.89 + };
57.90 +
57.91 + List<PlsqlFileListElement> elements = new ArrayList<PlsqlFileListElement>();
57.92 +
57.93 + WindowManager wm = WindowManager.getDefault();
57.94 + Set<? extends Mode> modes = wm.getModes();
57.95 + for (Mode mode : modes) {
57.96 + if (wm.isEditorMode(mode)) {
57.97 + TopComponent[] tcs = mode.getTopComponents();
57.98 + for (TopComponent tc : tcs) {
57.99 + Lookup lukap = tc.getLookup();
57.100 + FileObject fo = lukap.lookup(FileObject.class);
57.101 + if (fo == null) {
57.102 + DataObject dobj = lukap.lookup(DataObject.class);
57.103 + if (dobj != null) {
57.104 + fo = dobj.getPrimaryFile();
57.105 + }
57.106 + }
57.107 + if (fo != null && fo.getMIMEType().equals(PlsqlDataLoader.REQUIRED_MIME) && !fo.getExt().equals("tdb")) {
57.108 + if (tc.getHtmlDisplayName() != null) {
57.109 + elements.add(new PlsqlFileListElement(fo, tc.getHtmlDisplayName(), true));
57.110 + } else {
57.111 + elements.add(new PlsqlFileListElement(fo, tc.getName(), false));
57.112 + }
57.113 + }
57.114 + }
57.115 + }
57.116 + }
57.117 +
57.118 + elementsList.setListData(elements.toArray(new PlsqlFileListElement[elements.size()]));
57.119 + elementsList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
57.120 + elementsList.addListSelectionListener(this);
57.121 + elementsList.setCellRenderer(new DefaultListCellRenderer() {
57.122 + @Override
57.123 + public Component getListCellRendererComponent (JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
57.124 + if (isSelected && value instanceof PlsqlFileListElement && ((PlsqlFileListElement) value).isHtml()) {
57.125 + value = stripHtml(((PlsqlFileListElement) value).toString());
57.126 + }
57.127 + return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
57.128 + }
57.129 +
57.130 + private String stripHtml (String htmlText) {
57.131 + if (null == htmlText) {
57.132 + return null;
57.133 + }
57.134 + String res = htmlText.replaceAll("<[^>]*>", ""); // NOI18N // NOI18N
57.135 + res = res.replaceAll(" ", " "); // NOI18N // NOI18N
57.136 + res = res.trim();
57.137 + return res;
57.138 + }
57.139 + });
57.140 +
57.141 + JScrollPane sp = new JScrollPane(elementsList);
57.142 + jPanel1.add(sp);
57.143 + }
57.144 +
57.145 + @Override
57.146 + public void valueChanged(ListSelectionEvent e) {
57.147 + if (e.getValueIsAdjusting() == false) {
57.148 + Object[] elements = elementsList.getSelectedValues();
57.149 + //reinitialize list
57.150 + openFiles = new ArrayList<File>();
57.151 + if (elements != null && elements.length > 0) {
57.152 + for (int i = 0; i < elements.length; i++) {
57.153 + PlsqlFileListElement el = (PlsqlFileListElement) elements[i];
57.154 + openFiles.add(FileUtil.normalizeFile(FileUtil.toFile(el.fileObject)));
57.155 + }
57.156 + }
57.157 + }
57.158 + }
57.159 +
57.160 + /** This method is called from within the constructor to
57.161 + * initialize the form.
57.162 + * WARNING: Do NOT modify this code. The content of this method is
57.163 + * always regenerated by the Form Editor.
57.164 + */
57.165 + @SuppressWarnings("unchecked")
57.166 + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
57.167 + private void initComponents() {
57.168 +
57.169 + lblOpenFiles = new javax.swing.JLabel();
57.170 + jPanel1 = new javax.swing.JPanel();
57.171 +
57.172 + org.openide.awt.Mnemonics.setLocalizedText(lblOpenFiles, org.openide.util.NbBundle.getMessage(OpenPlsqlFilesSelectorPanel.class, "OpenPlsqlFilesSelectorPanel.lblOpenFiles.text")); // NOI18N
57.173 +
57.174 + jPanel1.setLayout(new java.awt.BorderLayout());
57.175 +
57.176 + org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
57.177 + this.setLayout(layout);
57.178 + layout.setHorizontalGroup(
57.179 + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
57.180 + .add(layout.createSequentialGroup()
57.181 + .addContainerGap()
57.182 + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
57.183 + .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 237, Short.MAX_VALUE)
57.184 + .add(lblOpenFiles))
57.185 + .addContainerGap())
57.186 + );
57.187 + layout.setVerticalGroup(
57.188 + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
57.189 + .add(layout.createSequentialGroup()
57.190 + .addContainerGap()
57.191 + .add(lblOpenFiles)
57.192 + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
57.193 + .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 179, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
57.194 + .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
57.195 + );
57.196 + }// </editor-fold>//GEN-END:initComponents
57.197 +
57.198 +
57.199 + // Variables declaration - do not modify//GEN-BEGIN:variables
57.200 + private javax.swing.JPanel jPanel1;
57.201 + private javax.swing.JLabel lblOpenFiles;
57.202 + // End of variables declaration//GEN-END:variables
57.203 +
57.204 + /**
57.205 + * @return the openFileSet
57.206 + */
57.207 + public List<File> getOpenFiles() {
57.208 + return Collections.unmodifiableList(openFiles);
57.209 + }
57.210 +
57.211 +
57.212 + private static class PlsqlFileListElement {
57.213 + FileObject fileObject;
57.214 + String displayName;
57.215 + private final boolean html;
57.216 +
57.217 + PlsqlFileListElement(FileObject tc, String displayName, boolean isHtml) {
57.218 + this.fileObject = tc;
57.219 + this.displayName = displayName;
57.220 + this.html = isHtml;
57.221 + }
57.222 +
57.223 + @Override
57.224 + public String toString() {
57.225 + return displayName;
57.226 + }
57.227 +
57.228 + public boolean isHtml () {
57.229 + return html;
57.230 + }
57.231 + }
57.232 +}
58.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/layer.xml Tue Feb 14 17:36:37 2012 +0100
58.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/layer.xml Wed Aug 15 20:45:01 2012 +0200
58.3 @@ -4,9 +4,12 @@
58.4 <folder name="Databases">
58.5 <folder name="Nodes">
58.6 <folder name="Oracle">
58.7 - <file name="org-netbeans-modules-plsql-execution-actions-DeployFilesAction.instance">
58.8 + <file name="org-netbeans-modules-plsql-execution-actions-DeployFilesAction$GenericDeployFilesAction.instance">
58.9 <attr name="position" intvalue="110"/>
58.10 </file>
58.11 + <file name="org-netbeans-modules-plsql-execution-actions-DeployFilesAction$DeployFilesOpenInEditorAction.instance">
58.12 + <attr name="position" intvalue="120"/>
58.13 + </file>
58.14 </folder>
58.15 </folder>
58.16 </folder>
58.17 @@ -46,7 +49,7 @@
58.18 <attr name="position" intvalue="19400"/>
58.19 </file>
58.20 <file name="org-netbeans-modules-plsql-execution-PlsqlExecuteAction.instance">
58.21 - <attr bundlevalue="org.netbeans.modules.plsql.execution.Bundle#CTL_fileExecution" name="displayName"/>
58.22 + <attr bundlevalue="org.netbeans.modules.plsql.execution.Bundle#CTL_ExecutionDescription" name="displayName"/>
58.23 <attr name="position" intvalue="19500"/>
58.24 </file>
58.25 <!-- <file name="org-netbeans-modules-plsql-execution-PlsqlCommitAction.instance">
59.1 --- a/PLSQL/FileType/manifest.mf Tue Feb 14 17:36:37 2012 +0100
59.2 +++ b/PLSQL/FileType/manifest.mf Wed Aug 15 20:45:01 2012 +0200
59.3 @@ -6,6 +6,6 @@
59.4 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/plsql/filetype/
59.5 Bundle.properties
59.6 OpenIDE-Module-Requires: org.netbeans.api.javahelp.Help
59.7 -OpenIDE-Module-Specification-Version: 1.8.10
59.8 +OpenIDE-Module-Specification-Version: 1.8.13
59.9 AutoUpdate-Show-In-Client: false
59.10
60.1 --- a/PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/PlsqlEditor.java Tue Feb 14 17:36:37 2012 +0100
60.2 +++ b/PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/PlsqlEditor.java Wed Aug 15 20:45:01 2012 +0200
60.3 @@ -90,21 +90,22 @@
60.4 if (connection.getJDBCConnection() != null) {
60.5
60.6 DatabaseConnectionManager connectionProvider = DatabaseConnectionManager.getInstance(dataObject);
60.7 -
60.8 - if (DatabaseConnectionManager.getInstance(dataObject).hasDataToCommit(connection)) {
60.9 - String msg = "There are pending transactions in the database. Do you want to commit?";
60.10 - String title = dataObject.getNodeDelegate().getDisplayName();
60.11 - int result = JOptionPane.showOptionDialog(null, msg, title, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, null, null);
60.12 - if (result == JOptionPane.YES_OPTION) {
60.13 - //commit
60.14 - connectionProvider.commitRollbackTransactions(connection, true);
60.15 - } else if (result == JOptionPane.NO_OPTION) {
60.16 - //rollback
60.17 - connectionProvider.commitRollbackTransactions(connection, false);
60.18 - } else {
60.19 - return false;
60.20 + if(connectionProvider.testConnection(connection)){
60.21 + if (DatabaseConnectionManager.getInstance(dataObject).hasDataToCommit(connection)) {
60.22 + String msg = "There are pending transactions in the database. Do you want to commit?";
60.23 + String title = dataObject.getNodeDelegate().getDisplayName();
60.24 + int result = JOptionPane.showOptionDialog(null, msg, title, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, null, null);
60.25 + if (result == JOptionPane.YES_OPTION) {
60.26 + //commit
60.27 + connectionProvider.commitRollbackTransactions(connection, true);
60.28 + } else if (result == JOptionPane.NO_OPTION) {
60.29 + //rollback
60.30 + connectionProvider.commitRollbackTransactions(connection, false);
60.31 + } else {
60.32 + return false;
60.33 + }
60.34 }
60.35 - }
60.36 + }
60.37 }
60.38 FileUtil.toFile(dataObject.getPrimaryFile()).delete();
60.39 }
61.1 --- a/PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/layer.xml Tue Feb 14 17:36:37 2012 +0100
61.2 +++ b/PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/layer.xml Wed Aug 15 20:45:01 2012 +0200
61.3 @@ -1,6 +1,6 @@
61.4 <?xml version="1.0" encoding="UTF-8"?>
61.5 <!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
61.6 -<filesystem>
61.7 +<filesystem>
61.8 <folder name="Loaders">
61.9 <folder name="text">
61.10 <folder name="x-plsql">
61.11 @@ -56,11 +56,11 @@
61.12 </folder>
61.13 </folder>
61.14 <folder name="Services">
61.15 - <folder name="JavaHelp">
61.16 +<!-- <folder name="JavaHelp">
61.17 <file name="org-netbeans-modules-plsql-helpset.xml" url="plsql-helpset.xml">
61.18 <attr name="position" intvalue="4230"/>
61.19 </file>
61.20 - </folder>
61.21 + </folder>-->
61.22 <folder name="MIMEResolver">
61.23 <file name="PlsqlResolver.xml" url="PlsqlResolver.xml">
61.24 <attr name="position" intvalue="2"/>
61.25 @@ -72,64 +72,15 @@
61.26 <folder name="PLSQL">
61.27 <attr name="position" intvalue="2"/>
61.28 <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.plsql.filetype.Bundle"/>
61.29 - <file name="LogicalUnit.api" url="resources/template.api">
61.30 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.plsql.filetype.Bundle"/>
61.31 - <attr name="template" boolvalue="true"/>
61.32 - <attr name="templateCategory" stringvalue="pl-sql"/>
61.33 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/plsql/filetype/resources/api.html"/>
61.34 - <attr name="position" intvalue="1"/>
61.35 - </file>
61.36 - <file name="LogicalUnit.apy" url="resources/template.apy">
61.37 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.plsql.filetype.Bundle"/>
61.38 - <attr name="template" boolvalue="true"/>
61.39 - <attr name="templateCategory" stringvalue="pl-sql"/>
61.40 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/plsql/filetype/resources/apy.html"/>
61.41 - <attr name="position" intvalue="2"/>
61.42 - </file>
61.43 - <file name="Report.rdf" url="resources/template.rdf">
61.44 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.plsql.filetype.Bundle"/>
61.45 - <attr name="template" boolvalue="true"/>
61.46 - <attr name="templateCategory" stringvalue="pl-sql"/>
61.47 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/plsql/filetype/resources/rdf.html"/>
61.48 - <attr name="position" intvalue="3"/>
61.49 - </file>
61.50 - <file name="Module.cre" url="resources/template.cre">
61.51 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.plsql.filetype.Bundle"/>
61.52 - <attr name="template" boolvalue="true"/>
61.53 - <attr name="templateCategory" stringvalue="pl-sql"/>
61.54 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/plsql/filetype/resources/cre.html"/>
61.55 - <attr name="position" intvalue="4"/>
61.56 - </file>
61.57 - <file name="Script.cdb" url="resources/template.cdb">
61.58 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.plsql.filetype.Bundle"/>
61.59 - <attr name="template" boolvalue="true"/>
61.60 - <attr name="templateCategory" stringvalue="pl-sql"/>
61.61 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/plsql/filetype/resources/cdb.html"/>
61.62 - <attr name="position" intvalue="5"/>
61.63 - </file>
61.64 - <file name="Script.upg" url="resources/template.upg">
61.65 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.plsql.filetype.Bundle"/>
61.66 - <attr name="template" boolvalue="true"/>
61.67 - <attr name="templateCategory" stringvalue="pl-sql"/>
61.68 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/plsql/filetype/resources/upg.html"/>
61.69 - <attr name="position" intvalue="6"/>
61.70 - </file>
61.71 <file name="Empty.sql">
61.72 <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.plsql.filetype.Bundle"/>
61.73 - <attr name="template" boolvalue="true"/>
61.74 + <attr name="template" boolvalue="true"/>
61.75 <attr name="templateCategory" stringvalue="pl-sql"/>
61.76 <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/plsql/filetype/resources/empty.html"/>
61.77 <attr name="position" intvalue="7"/>
61.78 </file>
61.79 - <file name="InsertScript.ins" url="resources/template.ins">
61.80 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.plsql.filetype.Bundle"/>
61.81 - <attr name="template" boolvalue="true"/>
61.82 - <attr name="templateCategory" stringvalue="pl-sql"/>
61.83 - <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/plsql/filetype/resources/ins.html"/>
61.84 - <attr name="position" intvalue="8"/>
61.85 - </file>
61.86 </folder>
61.87 - </folder>
61.88 + </folder>
61.89 <folder name="Actions">
61.90 <folder name="PLSQL">
61.91 <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.plsql.filetype.Bundle"/>
62.1 --- a/PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/resources/api.html Tue Feb 14 17:36:37 2012 +0100
62.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
62.3 @@ -1,7 +0,0 @@
62.4 -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
62.5 -<html xmlns="http://www.w3.org/1999/xhtml">
62.6 - <head><title/></head>
62.7 - <body>
62.8 - <div>Creates a new utility logical unit specification (API file).</div>
62.9 - </body>
62.10 -</html>
62.11 \ No newline at end of file
63.1 --- a/PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/resources/apy.html Tue Feb 14 17:36:37 2012 +0100
63.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
63.3 @@ -1,7 +0,0 @@
63.4 -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
63.5 -<html xmlns="http://www.w3.org/1999/xhtml">
63.6 - <head><title/></head>
63.7 - <body>
63.8 - <div>Creates a new utility logical unit implementation (APY file).</div>
63.9 - </body>
63.10 -</html>
63.11 \ No newline at end of file
64.1 Binary file PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/resources/badge_api.png has changed
65.1 Binary file PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/resources/badge_apy.png has changed
66.1 Binary file PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/resources/badge_cdb.png has changed
67.1 Binary file PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/resources/badge_cre.png has changed
68.1 Binary file PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/resources/badge_rdf.png has changed
69.1 Binary file PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/resources/badge_upg.png has changed
70.1 --- a/PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/resources/cdb.html Tue Feb 14 17:36:37 2012 +0100
70.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
70.3 @@ -1,7 +0,0 @@
70.4 -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
70.5 -<html xmlns="http://www.w3.org/1999/xhtml">
70.6 - <head><title/></head>
70.7 - <body>
70.8 - <div>Creates a new database change script (CDB file).</div>
70.9 - </body>
70.10 -</html>
70.11 \ No newline at end of file
71.1 --- a/PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/resources/cre.html Tue Feb 14 17:36:37 2012 +0100
71.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
71.3 @@ -1,7 +0,0 @@
71.4 -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
71.5 -<html xmlns="http://www.w3.org/1999/xhtml">
71.6 - <head><title/></head>
71.7 - <body>
71.8 - <div>Creates a new database creation script (CRE file).</div>
71.9 - </body>
71.10 -</html>
71.11 \ No newline at end of file
72.1 --- a/PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/resources/ins.html Tue Feb 14 17:36:37 2012 +0100
72.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
72.3 @@ -1,7 +0,0 @@
72.4 -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
72.5 -<html xmlns="http://www.w3.org/1999/xhtml">
72.6 - <head><title/></head>
72.7 - <body>
72.8 - <div>Creates a new insert script (INS file).</div>
72.9 - </body>
72.10 -</html>
72.11 \ No newline at end of file
73.1 --- a/PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/resources/rdf.html Tue Feb 14 17:36:37 2012 +0100
73.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
73.3 @@ -1,7 +0,0 @@
73.4 -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
73.5 -<html xmlns="http://www.w3.org/1999/xhtml">
73.6 - <head><title/></head>
73.7 - <body>
73.8 - <div>Creates a new report definition.</div>
73.9 - </body>
73.10 -</html>
73.11 \ No newline at end of file
74.1 --- a/PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/resources/template.api Tue Feb 14 17:36:37 2012 +0100
74.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
74.3 @@ -1,50 +0,0 @@
74.4 ------------------------------------------------------------------------------
74.5 ---
74.6 --- Logical unit: <<<LU: Put your LU name here>>>
74.7 ---
74.8 --- IFS Developer Studio Template Version 2.5
74.9 ---
74.10 --- Date Sign History
74.11 --- ------ ------ ---------------------------------------------------------
74.12 ------------------------------------------------------------------------------
74.13 -
74.14 -DEFINE MODULE = <<<MODULE: Put your module name here>>>
74.15 -DEFINE LU = <<<LU: Put your lu name here>>>
74.16 -DEFINE PKG = <<<PKG: Put your package name here>>>
74.17 -
74.18 -PROMPT Creating &PKG specification
74.19 -
74.20 -CREATE OR REPLACE PACKAGE &PKG IS
74.21 -
74.22 -module_ CONSTANT VARCHAR2(25) := '&MODULE';
74.23 -lu_name_ CONSTANT VARCHAR2(25) := '&LU';
74.24 -lu_type_ CONSTANT VARCHAR2(15) := 'Utility';
74.25 -
74.26 ------------------------------------------------------------------------------
74.27 --------------------- LU SPECIFIC PRIVATE METHODS ----------------------------
74.28 ------------------------------------------------------------------------------
74.29 -
74.30 -
74.31 ------------------------------------------------------------------------------
74.32 --------------------- LU SPECIFIC PROTECTED METHODS --------------------------
74.33 ------------------------------------------------------------------------------
74.34 -
74.35 -
74.36 ------------------------------------------------------------------------------
74.37 --------------------- LU SPECIFIC PUBLIC METHODS -----------------------------
74.38 ------------------------------------------------------------------------------
74.39 -
74.40 -
74.41 ------------------------------------------------------------------------------
74.42 --------------------- FOUNDATION1 METHODS ------------------------------------
74.43 ------------------------------------------------------------------------------
74.44 -
74.45 -PROCEDURE Init;
74.46 -
74.47 -END &PKG;
74.48 -/
74.49 -SHOW ERROR
74.50 -
74.51 -UNDEFINE MODULE
74.52 -UNDEFINE LU
74.53 -UNDEFINE PKG
75.1 --- a/PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/resources/template.apy Tue Feb 14 17:36:37 2012 +0100
75.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
75.3 @@ -1,51 +0,0 @@
75.4 ------------------------------------------------------------------------------
75.5 ---
75.6 --- Logical unit: <<<LU: Put your LU name here>>>
75.7 ---
75.8 --- IFS Developer Studio Template Version 2.5
75.9 ---
75.10 --- Date Sign History
75.11 --- ------ ------ ---------------------------------------------------------
75.12 ------------------------------------------------------------------------------
75.13 -
75.14 -DEFINE MODULE = <<<MODULE: Put your module name here>>>
75.15 -DEFINE LU = <<<LU: Put your lu name here>>>
75.16 -DEFINE PKG = <<<PKG: Put your package name here>>>
75.17 -
75.18 -PROMPT Creating &PKG specification
75.19 -
75.20 -CREATE OR REPLACE PACKAGE BODY &PKG IS
75.21 -
75.22 ------------------------------------------------------------------------------
75.23 --------------------- LU SPECIFIC IMPLEMENTATION METHODS ---------------------
75.24 ------------------------------------------------------------------------------
75.25 -
75.26 -
75.27 ------------------------------------------------------------------------------
75.28 --------------------- LU SPECIFIC PRIVATE METHODS ----------------------------
75.29 ------------------------------------------------------------------------------
75.30 -
75.31 -
75.32 ------------------------------------------------------------------------------
75.33 --------------------- LU SPECIFIC PROTECTED METHODS --------------------------
75.34 ------------------------------------------------------------------------------
75.35 -
75.36 -
75.37 ------------------------------------------------------------------------------
75.38 --------------------- LU SPECIFIC PUBLIC METHODS -----------------------------
75.39 ------------------------------------------------------------------------------
75.40 -
75.41 -
75.42 ------------------------------------------------------------------------------
75.43 --------------------- FOUNDATION1 METHODS ------------------------------------
75.44 ------------------------------------------------------------------------------
75.45 -
75.46 -PROCEDURE Init;
75.47 -
75.48 -END &PKG;
75.49 -/
75.50 -SHOW ERROR
75.51 -
75.52 -UNDEFINE MODULE
75.53 -UNDEFINE LU
75.54 -UNDEFINE PKG
76.1 --- a/PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/resources/template.cdb Tue Feb 14 17:36:37 2012 +0100
76.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
76.3 @@ -1,13 +0,0 @@
76.4 ------------------------------------------------------------------------------
76.5 --- Module : <<<Module name here>>>
76.6 ---
76.7 --- File : <<<Put your name here>>>.CDB
76.8 ---
76.9 --- IFS/Design Template Version 2.3
76.10 ---
76.11 --- Date Sign History
76.12 --- ------ ---- -----------------------------------------------------------
76.13 ------------------------------------------------------------------------------
76.14 -
76.15 -
76.16 -
77.1 --- a/PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/resources/template.cre Tue Feb 14 17:36:37 2012 +0100
77.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
77.3 @@ -1,18 +0,0 @@
77.4 ------------------------------------------------------------------------------
77.5 --- Module : <<<Module name here>>>
77.6 ---
77.7 --- File : <<<Put your name here>>>.CRE
77.8 ---
77.9 --- IFS/Design Template Version 2.3
77.10 ---
77.11 --- Date Sign History
77.12 --- ------ ---- -----------------------------------------------------------
77.13 ------------------------------------------------------------------------------
77.14 -
77.15 -
77.16 ------------------------------------------------------------------------------
77.17 --------------------- TABLES AND INDEXES -------------------------------------
77.18 ------------------------------------------------------------------------------
77.19 -
77.20 -PROMPT Creating tables and indexes
77.21 -
78.1 --- a/PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/resources/template.ins Tue Feb 14 17:36:37 2012 +0100
78.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
78.3 @@ -1,15 +0,0 @@
78.4 ------------------------------------------------------------------------------
78.5 --- Module : <<<Module name here>>>
78.6 ---
78.7 --- Purpose: <<<Purpose>>>
78.8 ---
78.9 --- File : <<<Put your name here>>>.INS
78.10 ---
78.11 --- IFS/Design Template Version 2.3
78.12 ---
78.13 --- Date Sign History
78.14 --- ------ ---- -----------------------------------------------------------
78.15 ------------------------------------------------------------------------------
78.16 -
78.17 -
78.18 -
79.1 --- a/PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/resources/template.rdf Tue Feb 14 17:36:37 2012 +0100
79.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
79.3 @@ -1,99 +0,0 @@
79.4 ------------------------------------------------------------------------------
79.5 ---
79.6 --- Logical unit: <<< Enter your logical unit description here >>>
79.7 ---
79.8 --- File: TEMPLATE.RDF
79.9 --- Version: Foundation1 2.2
79.10 ---
79.11 --- Date Sign History
79.12 --- ------ ---- -----------------------------------------------------------
79.13 ---
79.14 ------------------------------------------------------------------------------
79.15 -
79.16 -define MODULE = <<<MODULE: Put your module name here>>>
79.17 -define LU = <<<LU: Put your logical unit here>>>
79.18 -define PKG = <<<PKG: Put your Package name here>>>
79.19 -
79.20 -define TABLE = <<<TABLE: Put your generic Report Table here>>>
79.21 -define RAWVIEW = <<<RAWVIEW: Put your view showing Report Table here>>>
79.22 -define VIEW = <<<VIEW: Put your Report View here>>>
79.23 -define METHOD = <<<METHOD: Put your Report Method here>>>
79.24 -
79.25 ------------------------------------------------------------------------------
79.26 --- PACKAGE SPECIFICATION:
79.27 ------------------------------------------------------------------------------
79.28 -
79.29 -PROMPT Creating &PKG specification
79.30 -
79.31 -CREATE OR REPLACE PACKAGE &PKG IS
79.32 -
79.33 -module_ CONSTANT VARCHAR2(6) := '&MODULE';
79.34 -lu_name_ CONSTANT VARCHAR2(25) := '&LU';
79.35 -
79.36 -PROCEDURE &METHOD (
79.37 - report_attr_ IN VARCHAR2,
79.38 - parameter_attr_ IN VARCHAR2 );
79.39 -
79.40 -END &PKG;
79.41 -/
79.42 -SHOW ERROR
79.43 -
79.44 ------------------------------------------------------------------------------
79.45 --- REPORTS
79.46 ------------------------------------------------------------------------------
79.47 -
79.48 -PROMPT Refreshing RPV view &RAWVIEW
79.49 -
79.50 -BEGIN
79.51 - Report_SYS.Refresh_RPV_View ('&RAWVIEW', '&TABLE');
79.52 -END;
79.53 -/
79.54 -
79.55 -PROMPT Creating report view &VIEW
79.56 -
79.57 -CREATE OR REPLACE VIEW &VIEW AS
79.58 -SELECT RESULT_KEY RESULT_KEY,
79.59 - ROW_NO ROW_NO
79.60 -FROM &RAWVIEW
79.61 -WITH read only;
79.62 -
79.63 -COMMENT ON TABLE &VIEW IS
79.64 - 'MODULE=&MODULE^LU=&LU^PROMPT=&LU^
79.65 - ^METHOD=&PKG..&METHOD^MODE=PLSQL1.2^TABLE=&TABLE^';
79.66 -
79.67 -COMMENT ON COLUMN &VIEW..RESULT_KEY IS
79.68 - 'FLAGS=M----^DATATYPE=NUMBER^';
79.69 -COMMENT ON COLUMN &VIEW..ROW_NO IS
79.70 - 'FLAGS=M----^DATATYPE=NUMBER^';
79.71 -
79.72 -
79.73 -begin
79.74 - Report_SYS.Refresh_('&VIEW');
79.75 -end;
79.76 -/
79.77 ------------------------------------------------------------------------------
79.78 --- PACKAGE IMPLEMENTATION
79.79 ------------------------------------------------------------------------------
79.80 -
79.81 -PROMPT Creating &PKG implementation
79.82 -
79.83 -CREATE OR REPLACE PACKAGE BODY &PKG IS
79.84 -
79.85 -PROCEDURE &METHOD (
79.86 - report_attr_ IN VARCHAR2,
79.87 - parameter_attr_ IN VARCHAR2 )
79.88 -IS
79.89 - result_key_ NUMBER;
79.90 - row_no_ NUMBER := 1;
79.91 -BEGIN
79.92 - result_key_ := Client_SYS.Attr_Value_To_Number(Client_SYS.Get_Item_Value('RESULT_KEY', report_attr_));
79.93 -END &METHOD;
79.94 -
79.95 -END &PKG;
79.96 -/
79.97 -SHOW ERROR
79.98 -
79.99 ------------------------------------------------------------------------------
79.100 --- END
79.101 ------------------------------------------------------------------------------
79.102 -
80.1 --- a/PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/resources/template.upg Tue Feb 14 17:36:37 2012 +0100
80.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
80.3 @@ -1,15 +0,0 @@
80.4 ------------------------------------------------------------------------------
80.5 --- Module : <<<Module name here>>>
80.6 ---
80.7 --- Purpose: <<<Purpose>>>
80.8 ---
80.9 --- File : <<<Put your name here>>>.UPG
80.10 ---
80.11 --- IFS/Design Template Version 2.3
80.12 ---
80.13 --- Date Sign History
80.14 --- ------ ---- -----------------------------------------------------------
80.15 ------------------------------------------------------------------------------
80.16 -
80.17 -
80.18 -
81.1 --- a/PLSQL/FileType/src/org/netbeans/modules/plsql/filetype/resources/upg.html Tue Feb 14 17:36:37 2012 +0100
81.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
81.3 @@ -1,7 +0,0 @@
81.4 -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
81.5 -<html xmlns="http://www.w3.org/1999/xhtml">
81.6 - <head><title/></head>
81.7 - <body>
81.8 - <div>Creates a new database upgrade script (UPG file).</div>
81.9 - </body>
81.10 -</html>
81.11 \ No newline at end of file
82.1 --- a/PLSQL/Formatter/manifest.mf Tue Feb 14 17:36:37 2012 +0100
82.2 +++ b/PLSQL/Formatter/manifest.mf Wed Aug 15 20:45:01 2012 +0200
82.3 @@ -5,6 +5,6 @@
82.4 OpenIDE-Module-Layer: org/netbeans/modules/plsql/format/layer.xml
82.5 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/plsql/format/Bu
82.6 ndle.properties
82.7 -OpenIDE-Module-Specification-Version: 1.9.15
82.8 +OpenIDE-Module-Specification-Version: 1.9.20
82.9 AutoUpdate-Show-In-Client: false
82.10
83.1 --- a/PLSQL/Formatter/src/org/netbeans/modules/plsql/format/PlsqlFormatter.java Tue Feb 14 17:36:37 2012 +0100
83.2 +++ b/PLSQL/Formatter/src/org/netbeans/modules/plsql/format/PlsqlFormatter.java Wed Aug 15 20:45:01 2012 +0200
83.3 @@ -41,6 +41,7 @@
83.4 */
83.5 package org.netbeans.modules.plsql.format;
83.6
83.7 +import org.netbeans.modules.plsql.lexer.PlsqlBlockFactory;
83.8 import java.io.IOException;
83.9 import java.util.Arrays;
83.10 import java.util.HashSet;
83.11 @@ -68,7 +69,8 @@
83.12 */
83.13 public class PlsqlFormatter extends ExtFormatter {
83.14
83.15 - private boolean isIndentOnly = false;
83.16 + private boolean isAutoIndent = true;
83.17 + private boolean isAutoUppercase = true;
83.18 private boolean isTyping = false;
83.19
83.20 public PlsqlFormatter(Class kitClass) {
83.21 @@ -205,7 +207,7 @@
83.22 */
83.23 @Override
83.24 public int[] getReformatBlock(JTextComponent target, String arg1) {
83.25 - if (isIndentOnly || arg1.length() != 1) //We dont need to consider spaces
83.26 + if (arg1.length() != 1) //We dont need to consider spaces
83.27 {
83.28 return null;
83.29 }
83.30 @@ -237,7 +239,7 @@
83.31 DataObject dataObj = null;
83.32 Object obj = doc.getProperty(Document.StreamDescriptionProperty);
83.33 if (obj instanceof DataObject) {
83.34 - dataObj = (DataObject) obj;
83.35 + dataObj = (DataObject) obj;
83.36 }
83.37
83.38 if (dataObj == null) {
83.39 @@ -250,8 +252,9 @@
83.40
83.41 //Get indent only value from the preferences
83.42 Preferences prefs = MimeLookup.getLookup(PlsqlEditorKit.MIME_TYPE).lookup(Preferences.class);
83.43 - isIndentOnly = prefs.getBoolean("indentOnly", false);
83.44 -
83.45 + isAutoIndent = prefs.getBoolean("autoIndent", true);
83.46 + isAutoUppercase = prefs.getBoolean("autoUppercase", true);
83.47 +
83.48 try {
83.49 PlsqlFormatSupport plsqlFormatSup = (PlsqlFormatSupport) createFormatSupport(fw);
83.50 FormatTokenPosition pos = plsqlFormatSup.getFormatStartPosition();
83.51 @@ -272,38 +275,29 @@
83.52
83.53 if (pos != null && pos.getToken() != null) {
83.54 //if a new line indent
83.55 - if (!isIndentOnly) {
83.56 + if (isAutoUppercase) {
83.57 plsqlFormatSup.formatKeyWords(plsqlFormatSup, pos, blockFactory, startOffset - colStart);
83.58 if (startOffset != -1 && pane != null) {
83.59 pane.setCaretPosition(startOffset); // set the correct caret position
83.60 }
83.61 }
83.62 -
83.63 -// FormatTokenPosition firstNWS = plsqlFormatSup.findLineFirstNonWhitespace(pos);
83.64 -// if (firstNWS != null && firstNWS.getToken().getImage().equalsIgnoreCase("END")) {
83.65 -// plsqlFormatSup.indentLine(pos);
83.66 -// }
83.67 }
83.68 isTyping = false;
83.69 return;
83.70 }
83.71 -//
83.72 - //pos = formatPreviousLine(pos,plsqlFormatSup);
83.73 -
83.74 + if (isAutoUppercase) {
83.75 + if (startOffset == -1) {
83.76 + plsqlFormatSup.formatLine(plsqlFormatSup, pos, blockFactory);
83.77 + } else {
83.78 + plsqlFormatSup.formatKeyWords(plsqlFormatSup, pos, blockFactory, startOffset - colStart);
83.79 + }
83.80 + }
83.81 + if(isAutoIndent){
83.82 while (pos != null) {
83.83 // Indent the current line
83.84
83.85 plsqlFormatSup.indentLine(pos);
83.86
83.87 - //If not indent only format also
83.88 - if (!isIndentOnly) {
83.89 - if (startOffset == -1) {
83.90 - plsqlFormatSup.formatLine(plsqlFormatSup, pos, blockFactory);
83.91 - } else {
83.92 - plsqlFormatSup.formatKeyWords(plsqlFormatSup, pos, blockFactory, startOffset - colStart);
83.93 - }
83.94 - }
83.95 -
83.96 // Goto next line
83.97 FormatTokenPosition pos2 = plsqlFormatSup.findLineEnd(pos);
83.98 if (pos2 == null || pos2.getToken() == null) {
83.99 @@ -327,6 +321,7 @@
83.100 pos = plsqlFormatSup.findLineStart(pos);
83.101 }
83.102 }
83.103 + }
83.104 } catch (IllegalStateException e) {
83.105 }
83.106
83.107 @@ -335,7 +330,7 @@
83.108 isTyping = false;
83.109 }
83.110 } finally {
83.111 -// blockFactory.afterSave(doc);
83.112 +
83.113 }
83.114 }
83.115 }
83.116 @@ -693,15 +688,17 @@
83.117
83.118 if (temp != null) {
83.119 tokenTemp = getEndParent(temp);
83.120 - // check whether this is not just BEGIN/END block. i.e it's part of function/procedure BEGIN
83.121 - if (tokenTemp.getImage().trim().equalsIgnoreCase("BEGIN") && !nextToken.getImage().trim().equals(";")) {
83.122 - temp = getPreviousToken(tokenTemp);
83.123 + if (tokenTemp != null && nextToken != null) {
83.124 + // check whether this is not just BEGIN/END block. i.e it's part of function/procedure BEGIN
83.125 + if (tokenTemp.getImage().trim().equalsIgnoreCase("BEGIN") && !nextToken.getImage().trim().equals(";")) {
83.126 + temp = getPreviousToken(tokenTemp);
83.127
83.128 - if (temp != null) {
83.129 - tokenTemp = getBeginParent(temp);
83.130 - tokenTemp = getPreviousToken(tokenTemp);
83.131 - } else {
83.132 - break;
83.133 + if (temp != null) {
83.134 + tokenTemp = getBeginParent(temp);
83.135 + tokenTemp = getPreviousToken(tokenTemp);
83.136 + } else {
83.137 + break;
83.138 + }
83.139 }
83.140 }
83.141 } else {
84.1 --- a/PLSQL/Formatter/src/org/netbeans/modules/plsql/format/resources/snippets.xml Tue Feb 14 17:36:37 2012 +0100
84.2 +++ b/PLSQL/Formatter/src/org/netbeans/modules/plsql/format/resources/snippets.xml Wed Aug 15 20:45:01 2012 +0200
84.3 @@ -11,10 +11,8 @@
84.4 ${cursor}]]></code>
84.5 </codetemplate>
84.6 <codetemplate abbreviation="for" xml:space="preserve">
84.7 - <code><![CDATA[FOR rec_ IN ${cursor} LOOP
84.8 - BEGIN
84.9 - ${cursor}
84.10 - END;
84.11 + <code><![CDATA[FOR rec_ IN ${cursor} LOOP
84.12 + ${cursor}
84.13 END LOOP;]]></code>
84.14 </codetemplate>
84.15 <codetemplate abbreviation="wl" xml:space="preserve">
84.16 @@ -60,7 +58,7 @@
84.17 ${cursor} )
84.18 IS
84.19 BEGIN
84.20 - General_SYS.Init_Method(lu_name_, &PKG, '${proc_name}');
84.21 + General_SYS.Init_Method(lu_name_, '&PKG', '${proc_name}');
84.22
84.23 END ${proc_name};]]></code>
84.24 </codetemplate>
85.1 --- a/PLSQL/FormattingOptions/manifest.mf Tue Feb 14 17:36:37 2012 +0100
85.2 +++ b/PLSQL/FormattingOptions/manifest.mf Wed Aug 15 20:45:01 2012 +0200
85.3 @@ -6,6 +6,6 @@
85.4 xml
85.5 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/plsql/format/op
85.6 tions/Bundle.properties
85.7 -OpenIDE-Module-Specification-Version: 1.7.7
85.8 +OpenIDE-Module-Specification-Version: 1.7.8
85.9 AutoUpdate-Show-In-Client: false
85.10
86.1 --- a/PLSQL/FormattingOptions/src/org/netbeans/modules/plsql/format/options/Bundle.properties Tue Feb 14 17:36:37 2012 +0100
86.2 +++ b/PLSQL/FormattingOptions/src/org/netbeans/modules/plsql/format/options/Bundle.properties Wed Aug 15 20:45:01 2012 +0200
86.3 @@ -1,8 +1,8 @@
86.4 OpenIDE-Module-Name=PL/SQL Formatting Options
86.5 OpenIDE-Module-Display-Category=PL/SQL Support
86.6 -
86.7 -PlsqlTabsAndIndents.chkIndentOnly.text=Indent Only
86.8 AN_Preview=Preview
86.9 AD_Preview=Preview
86.10 SAMPLE_Default=Text
86.11 -SAMPLE_TabsIndents=Text
86.12 \ No newline at end of file
86.13 +SAMPLE_TabsIndents=Text
86.14 +PlsqlTabsAndIndents.chkIndent.text=Auto Indent
86.15 +PlsqlTabsAndIndents.chkUppercase.text=Auto Keyword Uppercase
87.1 --- a/PLSQL/FormattingOptions/src/org/netbeans/modules/plsql/format/options/PlsqlFormatOptions.java Tue Feb 14 17:36:37 2012 +0100
87.2 +++ b/PLSQL/FormattingOptions/src/org/netbeans/modules/plsql/format/options/PlsqlFormatOptions.java Wed Aug 15 20:45:01 2012 +0200
87.3 @@ -82,7 +82,8 @@
87.4 public static final String tabSize = SimpleValueNames.TAB_SIZE;
87.5 public static final String spacesPerTab = SimpleValueNames.SPACES_PER_TAB;
87.6 public static final String indentSize = SimpleValueNames.INDENT_SHIFT_WIDTH;
87.7 - public static final String indentOnly = "indentOnly"; //NOI18N
87.8 + public static final String autoIndent = "autoIndent"; //NOI18N
87.9 + public static final String autoUppercase = "autoUppercase";
87.10
87.11 private PlsqlFormatOptions() {
87.12 }
87.13 @@ -125,7 +126,8 @@
87.14 {tabSize, "3"}, //NOI18N
87.15 {spacesPerTab, "3"}, //NOI18N
87.16 {indentSize, "3"}, //NOI18N
87.17 - {indentOnly, FALSE}, //NOI18N
87.18 + {autoIndent, TRUE}, //NOI18N
87.19 + {autoUppercase, TRUE}, //NOI18N
87.20 };
87.21
87.22 defaults = new HashMap<String, String>();
88.1 --- a/PLSQL/FormattingOptions/src/org/netbeans/modules/plsql/format/options/PlsqlTabsAndIndents.form Tue Feb 14 17:36:37 2012 +0100
88.2 +++ b/PLSQL/FormattingOptions/src/org/netbeans/modules/plsql/format/options/PlsqlTabsAndIndents.form Wed Aug 15 20:45:01 2012 +0200
88.3 @@ -1,4 +1,4 @@
88.4 -<?xml version="1.0" encoding="UTF-8" ?>
88.5 +<?xml version="1.1" encoding="UTF-8" ?>
88.6
88.7 <Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
88.8 <AuxValues>
88.9 @@ -16,10 +16,13 @@
88.10 <Layout>
88.11 <DimensionLayout dim="0">
88.12 <Group type="103" groupAlignment="0" attributes="0">
88.13 - <Group type="102" alignment="0" attributes="0">
88.14 + <Group type="102" attributes="0">
88.15 <EmptySpace max="-2" attributes="0"/>
88.16 - <Component id="chkIndentOnly" min="-2" max="-2" attributes="0"/>
88.17 - <EmptySpace pref="66" max="32767" attributes="0"/>
88.18 + <Group type="103" groupAlignment="0" attributes="0">
88.19 + <Component id="chkIndent" alignment="0" min="-2" max="-2" attributes="0"/>
88.20 + <Component id="chkUppercase" alignment="0" min="-2" max="-2" attributes="0"/>
88.21 + </Group>
88.22 + <EmptySpace max="32767" attributes="0"/>
88.23 </Group>
88.24 </Group>
88.25 </DimensionLayout>
88.26 @@ -27,17 +30,26 @@
88.27 <Group type="103" groupAlignment="0" attributes="0">
88.28 <Group type="102" alignment="0" attributes="0">
88.29 <EmptySpace max="-2" attributes="0"/>
88.30 - <Component id="chkIndentOnly" min="-2" max="-2" attributes="0"/>
88.31 - <EmptySpace max="32767" attributes="0"/>
88.32 + <Component id="chkIndent" min="-2" max="-2" attributes="0"/>
88.33 + <EmptySpace pref="7" max="32767" attributes="0"/>
88.34 + <Component id="chkUppercase" min="-2" max="-2" attributes="0"/>
88.35 + <EmptySpace max="-2" attributes="0"/>
88.36 </Group>
88.37 </Group>
88.38 </DimensionLayout>
88.39 </Layout>
88.40 <SubComponents>
88.41 - <Component class="javax.swing.JCheckBox" name="chkIndentOnly">
88.42 + <Component class="javax.swing.JCheckBox" name="chkIndent">
88.43 <Properties>
88.44 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
88.45 - <ResourceString bundle="org/netbeans/modules/plsql/format/options/Bundle.properties" key="PlsqlTabsAndIndents.chkIndentOnly.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
88.46 + <ResourceString bundle="org/netbeans/modules/plsql/format/options/Bundle.properties" key="PlsqlTabsAndIndents.chkIndent.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
88.47 + </Property>
88.48 + </Properties>
88.49 + </Component>
88.50 + <Component class="javax.swing.JCheckBox" name="chkUppercase">
88.51 + <Properties>
88.52 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
88.53 + <ResourceString bundle="org/netbeans/modules/plsql/format/options/Bundle.properties" key="PlsqlTabsAndIndents.chkUppercase.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
88.54 </Property>
88.55 </Properties>
88.56 </Component>
89.1 --- a/PLSQL/FormattingOptions/src/org/netbeans/modules/plsql/format/options/PlsqlTabsAndIndents.java Tue Feb 14 17:36:37 2012 +0100
89.2 +++ b/PLSQL/FormattingOptions/src/org/netbeans/modules/plsql/format/options/PlsqlTabsAndIndents.java Wed Aug 15 20:45:01 2012 +0200
89.3 @@ -54,7 +54,8 @@
89.4 /** Creates new form PlsqlTabsAndIndents */
89.5 public PlsqlTabsAndIndents() {
89.6 initComponents();
89.7 - chkIndentOnly.putClientProperty(OPTION_ID, indentOnly);
89.8 + chkIndent.putClientProperty(OPTION_ID, autoIndent);
89.9 + chkUppercase.putClientProperty(OPTION_ID, autoUppercase);
89.10 }
89.11
89.12 public static PreferencesCustomizer.Factory getController() {
89.13 @@ -71,9 +72,12 @@
89.14 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
89.15 private void initComponents() {
89.16
89.17 - chkIndentOnly = new javax.swing.JCheckBox();
89.18 + chkIndent = new javax.swing.JCheckBox();
89.19 + chkUppercase = new javax.swing.JCheckBox();
89.20
89.21 - chkIndentOnly.setText(org.openide.util.NbBundle.getMessage(PlsqlTabsAndIndents.class, "PlsqlTabsAndIndents.chkIndentOnly.text")); // NOI18N
89.22 + chkIndent.setText(org.openide.util.NbBundle.getMessage(PlsqlTabsAndIndents.class, "PlsqlTabsAndIndents.chkIndent.text")); // NOI18N
89.23 +
89.24 + chkUppercase.setText(org.openide.util.NbBundle.getMessage(PlsqlTabsAndIndents.class, "PlsqlTabsAndIndents.chkUppercase.text")); // NOI18N
89.25
89.26 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
89.27 this.setLayout(layout);
89.28 @@ -81,21 +85,26 @@
89.29 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
89.30 .addGroup(layout.createSequentialGroup()
89.31 .addContainerGap()
89.32 - .addComponent(chkIndentOnly)
89.33 - .addContainerGap(66, Short.MAX_VALUE))
89.34 + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
89.35 + .addComponent(chkIndent)
89.36 + .addComponent(chkUppercase))
89.37 + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
89.38 );
89.39 layout.setVerticalGroup(
89.40 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
89.41 .addGroup(layout.createSequentialGroup()
89.42 .addContainerGap()
89.43 - .addComponent(chkIndentOnly)
89.44 - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
89.45 + .addComponent(chkIndent)
89.46 + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
89.47 + .addComponent(chkUppercase)
89.48 + .addContainerGap())
89.49 );
89.50 }// </editor-fold>//GEN-END:initComponents
89.51
89.52
89.53 // Variables declaration - do not modify//GEN-BEGIN:variables
89.54 - private javax.swing.JCheckBox chkIndentOnly;
89.55 + private javax.swing.JCheckBox chkIndent;
89.56 + private javax.swing.JCheckBox chkUppercase;
89.57 // End of variables declaration//GEN-END:variables
89.58
89.59 }
90.1 --- a/PLSQL/Lexer/manifest.mf Tue Feb 14 17:36:37 2012 +0100
90.2 +++ b/PLSQL/Lexer/manifest.mf Wed Aug 15 20:45:01 2012 +0200
90.3 @@ -5,6 +5,6 @@
90.4 OpenIDE-Module-Layer: org/netbeans/modules/plsql/lexer/layer.xml
90.5 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/plsql/lexer/Bun
90.6 dle.properties
90.7 -OpenIDE-Module-Specification-Version: 1.8.8
90.8 +OpenIDE-Module-Specification-Version: 1.8.10
90.9 AutoUpdate-Show-In-Client: false
90.10
91.1 --- a/PLSQL/Lexer/nbproject/project.properties Tue Feb 14 17:36:37 2012 +0100
91.2 +++ b/PLSQL/Lexer/nbproject/project.properties Wed Aug 15 20:45:01 2012 +0200
91.3 @@ -1,2 +1,9 @@
91.4 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
91.5 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=4
91.6 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=4
91.7 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
91.8 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=120
91.9 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
91.10 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
91.11 javac.source=1.6
91.12 javac.compilerargs=-Xlint -Xlint:-serial
92.1 --- a/PLSQL/Lexer/src/org/netbeans/modules/plsql/lexer/PlsqlBlockFactory.java Tue Feb 14 17:36:37 2012 +0100
92.2 +++ b/PLSQL/Lexer/src/org/netbeans/modules/plsql/lexer/PlsqlBlockFactory.java Wed Aug 15 20:45:01 2012 +0200
92.3 @@ -69,3818 +69,3822 @@
92.4 */
92.5 public class PlsqlBlockFactory extends Observable implements DocumentListener {
92.6
92.7 - private List<PlsqlBlock> blockHierarchy;
92.8 - private List<PlsqlBlock> customFoldBlocks;
92.9 - private List<PlsqlBlock> newBlocks;
92.10 - private List<PlsqlBlock> toBeRemoved;
92.11 - private List<PlsqlBlock> changedBlocks;
92.12 - private HashSet<Integer> unsuccessBlocks;
92.13 - private HashMap<String, String> definesMap;
92.14 - private TokenHierarchy tokenHierarchy;
92.15 - private int docStartOffset = 0;
92.16 - private int docEndOffset = 0;
92.17 - private int startParse = 0;
92.18 - private int endParse = 0;
92.19 - private int changedLength = 0;
92.20 - private boolean isDefineChanged = false;
92.21 - private static RequestProcessor.Task updateBlocksTask = null;
92.22 - private static final LinkedList<EventProperties> updateEvents = new LinkedList<EventProperties>();
92.23 - private static final int DEFAULT_WAIT_TIME = 500;
92.24 - private boolean saveInProgress = false;
92.25 - private boolean caseChangeInProgress = false;
92.26 - private static final String updateLock = "This is used to synchronize navigator updates";
92.27 -
92.28 - public PlsqlBlockFactory() {
92.29 - blockHierarchy = new ArrayList<PlsqlBlock>();
92.30 - tokenHierarchy = null;
92.31 - newBlocks = new ArrayList<PlsqlBlock>();
92.32 - toBeRemoved = new ArrayList<PlsqlBlock>();
92.33 - changedBlocks = new ArrayList<PlsqlBlock>();
92.34 - customFoldBlocks = new ArrayList<PlsqlBlock>();
92.35 - definesMap = new HashMap<String, String>();
92.36 - unsuccessBlocks = new HashSet<Integer>();
92.37 - }
92.38 -
92.39 - /**
92.40 - * Method used to reparse the whole document
92.41 - * @param doc
92.42 - */
92.43 - public void reParse(Document doc) {
92.44 - clear();
92.45 -
92.46 - if (doc == null) {
92.47 - return;
92.48 - }
92.49 -
92.50 - docStartOffset = doc.getStartPosition().getOffset();
92.51 - docEndOffset = doc.getEndPosition().getOffset();
92.52 - startParse = docStartOffset;
92.53 - endParse = docEndOffset - 1;
92.54 -
92.55 - //clean block hierarchy
92.56 - blockHierarchy.clear();
92.57 - customFoldBlocks.clear();
92.58 - generateBlocks(doc);
92.59 - }
92.60 -
92.61 - /**
92.62 - * Return new blocks that were recognized by the latest change
92.63 - * @return
92.64 - */
92.65 - public List<PlsqlBlock> getNewBlocks() {
92.66 - return newBlocks;
92.67 - }
92.68 -
92.69 - /**
92.70 - * Return the blocks who's offsets have changed
92.71 - * @return
92.72 - */
92.73 - public List<PlsqlBlock> getChangedBlocks() {
92.74 - return changedBlocks;
92.75 - }
92.76 -
92.77 - /**
92.78 - * Return the custom fold blocks that are there
92.79 - * @return
92.80 - */
92.81 - public List<PlsqlBlock> getCustomFolds() {
92.82 - return customFoldBlocks;
92.83 - }
92.84 -
92.85 - /**
92.86 - * Return block hierarchy
92.87 - * @return
92.88 - */
92.89 - public List<PlsqlBlock> getBlockHierarchy() {
92.90 - return blockHierarchy;
92.91 - }
92.92 -
92.93 - /**
92.94 - * Method that will return the blocks that are removed
92.95 - * @return
92.96 - */
92.97 - public List<PlsqlBlock> getRemovedBlocks() {
92.98 - return toBeRemoved;
92.99 - }
92.100 -
92.101 - /**
92.102 - * Check whether there are childrean of this fold here, if so add them
92.103 - * @param block
92.104 - * @param immediateBlockHier
92.105 - */
92.106 - private void addImmediateChildren(PlsqlBlock block, List<PlsqlBlock> immediateBlockHier) {
92.107 - for (int i = immediateBlockHier.size() - 1; i >= 0; i--) {
92.108 - PlsqlBlock tmp = immediateBlockHier.get(i);
92.109 - if ((tmp.getStartOffset() > block.getStartOffset())
92.110 - && (tmp.getEndOffset() < block.getEndOffset())) {
92.111 - if (checkExisting(tmp, newBlocks)) {
92.112 - newBlocks.remove(tmp);
92.113 + private List<PlsqlBlock> blockHierarchy;
92.114 + private List<PlsqlBlock> customFoldBlocks;
92.115 + private List<PlsqlBlock> newBlocks;
92.116 + private List<PlsqlBlock> toBeRemoved;
92.117 + private List<PlsqlBlock> changedBlocks;
92.118 + private HashSet<Integer> unsuccessBlocks;
92.119 + private HashMap<String, String> definesMap;
92.120 + private TokenHierarchy tokenHierarchy;
92.121 + private int docStartOffset = 0;
92.122 + private int docEndOffset = 0;
92.123 + private int startParse = 0;
92.124 + private int endParse = 0;
92.125 + private int changedLength = 0;
92.126 + private boolean isDefineChanged = false;
92.127 + private static RequestProcessor.Task updateBlocksTask = null;
92.128 + private static final LinkedList<EventProperties> updateEvents = new LinkedList<EventProperties>();
92.129 + private static final int DEFAULT_WAIT_TIME = 500;
92.130 + private boolean saveInProgress = false;
92.131 + private boolean caseChangeInProgress = false;
92.132 + private static final String updateLock = "This is used to synchronize navigator updates";
92.133 + private static final RequestProcessor RP = new RequestProcessor(PlsqlBlockFactory.class);
92.134 +
92.135 + public PlsqlBlockFactory() {
92.136 + blockHierarchy = new ArrayList<PlsqlBlock>();
92.137 + tokenHierarchy = null;
92.138 + newBlocks = new ArrayList<PlsqlBlock>();
92.139 + toBeRemoved = new ArrayList<PlsqlBlock>();
92.140 + changedBlocks = new ArrayList<PlsqlBlock>();
92.141 + customFoldBlocks = new ArrayList<PlsqlBlock>();
92.142 + definesMap = new HashMap<String, String>();
92.143 + unsuccessBlocks = new HashSet<Integer>();
92.144 + }
92.145 +
92.146 + /**
92.147 + * Method used to reparse the whole document
92.148 + * @param doc
92.149 + */
92.150 + public void reParse(Document doc) {
92.151 + clear();
92.152 +
92.153 + if (doc == null) {
92.154 + return;
92.155 + }
92.156 +
92.157 + docStartOffset = doc.getStartPosition().getOffset();
92.158 + docEndOffset = doc.getEndPosition().getOffset();
92.159 + startParse = docStartOffset;
92.160 + endParse = docEndOffset - 1;
92.161 +
92.162 + //clean block hierarchy
92.163 + blockHierarchy.clear();
92.164 + customFoldBlocks.clear();
92.165 + generateBlocks(doc);
92.166 + }
92.167 +
92.168 + /**
92.169 + * Return new blocks that were recognized by the latest change
92.170 + * @return
92.171 + */
92.172 + public List<PlsqlBlock> getNewBlocks() {
92.173 + return newBlocks;
92.174 + }
92.175 +
92.176 + /**
92.177 + * Return the blocks who's offsets have changed
92.178 + * @return
92.179 + */
92.180 + public List<PlsqlBlock> getChangedBlocks() {
92.181 + return changedBlocks;
92.182 + }
92.183 +
92.184 + /**
92.185 + * Return the custom fold blocks that are there
92.186 + * @return
92.187 + */
92.188 + public List<PlsqlBlock> getCustomFolds() {
92.189 + return customFoldBlocks;
92.190 + }
92.191 +
92.192 + /**
92.193 + * Return block hierarchy
92.194 + * @return
92.195 + */
92.196 + public List<PlsqlBlock> getBlockHierarchy() {
92.197 + return blockHierarchy;
92.198 + }
92.199 +
92.200 + /**
92.201 + * Method that will return the blocks that are removed
92.202 + * @return
92.203 + */
92.204 + public List<PlsqlBlock> getRemovedBlocks() {
92.205 + return toBeRemoved;
92.206 + }
92.207 +
92.208 + /**
92.209 + * Check whether there are childrean of this fold here, if so add them
92.210 + * @param block
92.211 + * @param immediateBlockHier
92.212 + */
92.213 + private void addImmediateChildren(PlsqlBlock block, List<PlsqlBlock> immediateBlockHier) {
92.214 + for (int i = immediateBlockHier.size() - 1; i >= 0; i--) {
92.215 + PlsqlBlock tmp = immediateBlockHier.get(i);
92.216 + if ((tmp.getStartOffset() > block.getStartOffset())
92.217 + && (tmp.getEndOffset() < block.getEndOffset())) {
92.218 + if (checkExisting(tmp, newBlocks)) {
92.219 + newBlocks.remove(tmp);
92.220 + } else {
92.221 + removeBlock(block, immediateBlockHier);
92.222 + }
92.223 +
92.224 + block.addChild(tmp);
92.225 + }
92.226 + }
92.227 + }
92.228 +
92.229 + /**
92.230 + * Method that will look for custom start or end token based on the given type
92.231 + * @param customEndToken
92.232 + * @param ts
92.233 + * @param immediateBlockHier
92.234 + * @param parent
92.235 + * @param type
92.236 + */
92.237 + private void checkCustom(Token<PlsqlTokenId> customToken, TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> immediateBlockHier, PlsqlBlock parent, String type) {
92.238 + Token<PlsqlTokenId> found = customToken;
92.239 + Token<PlsqlTokenId> token = customToken;
92.240 +
92.241 + if (type.equals("START")) {
92.242 + //We have to find the end fold token now
92.243 + ts.move(found.offset(tokenHierarchy));
92.244 + ts.moveNext();
92.245 + while (ts.moveNext()) {
92.246 + token = ts.token();
92.247 + String image = token.text().toString();
92.248 + PlsqlTokenId tokenID = token.id();
92.249 +
92.250 + if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.251 + //only single comment line
92.252 + if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.253 + //We have come to another start
92.254 + return;
92.255 + } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.256 + if (isTokenOk(token, immediateBlockHier, parent)) {
92.257 + String name = found.text().toString();
92.258 + int index = name.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.259 + name = name.substring(index + 7).trim();
92.260 + if (ts.moveNext()) {
92.261 + token = ts.token();
92.262 + PlsqlBlock custom = new PlsqlBlock(found.offset(tokenHierarchy),
92.263 + token.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.264 + customFoldBlocks.add(custom);
92.265 + }
92.266 + }
92.267 + //since we have found the other tag return
92.268 + return;
92.269 + }
92.270 + }
92.271 + }
92.272 + } else {
92.273 + ts.move(found.offset(tokenHierarchy));
92.274 + //We have to find the start fold token now
92.275 + while (ts.movePrevious()) {
92.276 + token = ts.token();
92.277 + String image = token.text().toString();
92.278 + PlsqlTokenId tokenID = token.id();
92.279 +
92.280 + if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.281 + //only single comment line
92.282 + if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.283 + if (isTokenOk(token, immediateBlockHier, parent)) {
92.284 + String name = image;
92.285 + int index = name.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.286 + name = name.substring(index + 7).trim();
92.287 + ts.move(found.offset(tokenHierarchy));
92.288 + ts.moveNext();
92.289 + if (ts.moveNext()) {
92.290 + found = ts.token();
92.291 + PlsqlBlock custom = new PlsqlBlock(token.offset(tokenHierarchy),
92.292 + found.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.293 + customFoldBlocks.add(custom);
92.294 + }
92.295 + }
92.296 + //since we have found the other tag return
92.297 + return;
92.298 + } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.299 + //We have come to another end
92.300 + return;
92.301 + }
92.302 + }
92.303 + }
92.304 + }
92.305 + }
92.306 +
92.307 + /**
92.308 + * Method that will check for a Java Source block
92.309 + * @param tempToken
92.310 + * @param ts
92.311 + * @param immediateBlockHier
92.312 + * @return
92.313 + */
92.314 + private PlsqlBlock checkJavaSource(Token<PlsqlTokenId> tempToken, TokenSequence<PlsqlTokenId> ts) {
92.315 + Token<PlsqlTokenId> begin = tempToken;
92.316 + Token<PlsqlTokenId> tmp = tempToken;
92.317 + PlsqlBlock block = null;
92.318 +
92.319 + //Check whether the beginning is in a SQL Plus command
92.320 + if (sqlPlusLine(ts)) {
92.321 + return null;
92.322 + }
92.323 +
92.324 + while (ts.moveNext()) {
92.325 + tmp = ts.token();
92.326 + String image = tmp.text().toString();
92.327 + PlsqlTokenId tokenID = tmp.id();
92.328 +
92.329 + if ((tmp != null) && (!image.equals("/")) && (tmp.offset(tokenHierarchy) > endParse)) {
92.330 + break;
92.331 + }
92.332 +
92.333 + //We might have come to the end of the procedure/function declaration
92.334 + if ((tokenID == PlsqlTokenId.OPERATOR) && image.equals("/")) {
92.335 + //check whether previous Non white space token to the identifier is END
92.336 + int offset = ts.offset();
92.337 + if (checkForOnlyChar(ts, offset)) {
92.338 + ts.move(offset);
92.339 + ts.moveNext();
92.340 + ts.moveNext();
92.341 + block = new PlsqlBlock(begin.offset(tokenHierarchy), offset, "", "", PlsqlBlockType.JAVA_SOURCE);
92.342 + checkPrefix(begin.offset(tokenHierarchy), ts, block);
92.343 + break;
92.344 + }
92.345 + }
92.346 + }
92.347 +
92.348 + return block;
92.349 + }
92.350 +
92.351 + /**
92.352 + * Check whether this current token is the only token in this line
92.353 + * @param ts
92.354 + * @param offset
92.355 + * @return
92.356 + */
92.357 + private boolean checkForOnlyChar(TokenSequence<PlsqlTokenId> ts, int offset) {
92.358 + boolean isStartOk = true;
92.359 + boolean isEndOk = true;
92.360 + ts.move(offset);
92.361 + Token<PlsqlTokenId> token = null;
92.362 + while (ts.movePrevious()) {
92.363 + token = ts.token();
92.364 + if (token.id() == PlsqlTokenId.WHITESPACE) {
92.365 + if (token.toString().contains("\n")) {
92.366 + break;
92.367 + }
92.368 + } else if (token.id() == PlsqlTokenId.JAVA_SOUCE) {
92.369 + break;
92.370 } else {
92.371 - removeBlock(block, immediateBlockHier);
92.372 + isStartOk = false;
92.373 + break;
92.374 }
92.375 -
92.376 - block.addChild(tmp);
92.377 - }
92.378 - }
92.379 - }
92.380 -
92.381 - /**
92.382 - * Method that will look for custom start or end token based on the given type
92.383 - * @param customEndToken
92.384 - * @param ts
92.385 - * @param immediateBlockHier
92.386 - * @param parent
92.387 - * @param type
92.388 - */
92.389 - private void checkCustom(Token<PlsqlTokenId> customToken, TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> immediateBlockHier, PlsqlBlock parent, String type) {
92.390 - Token<PlsqlTokenId> found = customToken;
92.391 - Token<PlsqlTokenId> token = customToken;
92.392 -
92.393 - if (type.equals("START")) {
92.394 - //We have to find the end fold token now
92.395 - ts.move(found.offset(tokenHierarchy));
92.396 - ts.moveNext();
92.397 - while (ts.moveNext()) {
92.398 + }
92.399 +
92.400 + ts.move(offset);
92.401 + ts.moveNext(); //current token
92.402 + while (ts.moveNext()) {
92.403 + token = ts.token();
92.404 + if (token.id() == PlsqlTokenId.WHITESPACE) {
92.405 + if (token.toString().contains("\n")) {
92.406 + break;
92.407 + }
92.408 + } else {
92.409 + isEndOk = false;
92.410 + break;
92.411 + }
92.412 + }
92.413 +
92.414 + ts.move(offset);
92.415 + ts.moveNext();
92.416 +
92.417 + if (isStartOk && isEndOk) {
92.418 + return true;
92.419 + }
92.420 +
92.421 + return false;
92.422 + }
92.423 +
92.424 + /**
92.425 + * Method that will check for statement blocks other than the CURSOR and VIEW
92.426 + * @param tempToken
92.427 + * @param ts
92.428 + * @param immediateBlockHier
92.429 + * @return
92.430 + */
92.431 + private PlsqlBlock checkStatementBlock(Token<PlsqlTokenId> current, TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> parentBlocks) {
92.432 + Token<PlsqlTokenId> stmtBegin = null;
92.433 + Token<PlsqlTokenId> token = null;
92.434 + List<PlsqlBlock> lstChild = new ArrayList<PlsqlBlock>();
92.435 + PlsqlBlock block = null;
92.436 + boolean moveNext = false;
92.437 +
92.438 + //Check whether the beginning is in a SQL Plus command
92.439 + if (sqlPlusLine(ts)) {
92.440 + return null;
92.441 + }
92.442 +
92.443 + moveNext = ts.moveNext();
92.444 + token = ts.token();
92.445 + stmtBegin = current;
92.446 + boolean getName = true;
92.447 + Token<PlsqlTokenId> customStartToken = null;
92.448 + String name = current.text().toString();
92.449 +
92.450 + while (moveNext) {
92.451 + String image = token.text().toString();
92.452 + PlsqlTokenId tokenID = token.id();
92.453 +
92.454 + if ((token != null) && (!image.equals(";")) && (!image.equals("/")) && (token.offset(tokenHierarchy) > endParse)) {
92.455 + break;
92.456 + }
92.457 +
92.458 + if (image.equals(";") || (image.equals("/") && checkForOnlyChar(ts, ts.offset()))) {
92.459 + block = new PlsqlBlock(stmtBegin.offset(tokenHierarchy), token.offset(tokenHierarchy), name.trim(), "", PlsqlBlockType.STATEMENT);
92.460 + checkPrefix(stmtBegin.offset(tokenHierarchy), ts, block);
92.461 + break;
92.462 + } else if (image.equalsIgnoreCase("CREATE")
92.463 + || image.equalsIgnoreCase("DECLARE")
92.464 + || image.equalsIgnoreCase("BEGIN")
92.465 + || image.equalsIgnoreCase("WHEN")
92.466 + || image.equalsIgnoreCase("THEN")
92.467 + || image.equalsIgnoreCase("IF")
92.468 + || image.equalsIgnoreCase("END")
92.469 + || image.equalsIgnoreCase("ELSE")
92.470 + || image.equalsIgnoreCase("LOOP")) {
92.471 + break;
92.472 + } else if (image.equalsIgnoreCase("CASE")) {
92.473 + int beforeOff = token.offset(tokenHierarchy);
92.474 + List children = checkCaseBlock(token, ts, lstChild, true);
92.475 + if (children == null || children.isEmpty()) {//If inner check seems to have failed need to continue this one
92.476 +
92.477 + ts.move(beforeOff);
92.478 + moveNext = ts.moveNext();
92.479 + } else {
92.480 + for (int i = 0; i < children.size(); i++) {
92.481 + PlsqlBlock child = (PlsqlBlock) children.get(i);
92.482 + if (checkExisting(child, lstChild) == false) {
92.483 + lstChild.add(child);
92.484 + }
92.485 + }
92.486 + }
92.487 + } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.488 + //only single comment line
92.489 + if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.490 + customStartToken = token;
92.491 + } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.492 + if (customStartToken != null) {
92.493 + String fname = customStartToken.text().toString();
92.494 + int index = fname.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.495 + fname = fname.substring(index + 7).trim();
92.496 + if (ts.moveNext()) {
92.497 + token = ts.token();
92.498 + PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.499 + token.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.500 + customFoldBlocks.add(custom);
92.501 + }
92.502 + customStartToken = null;
92.503 + }
92.504 + } else {
92.505 + PlsqlBlock child = checkComment(token, ts);
92.506 + if (child != null) {
92.507 + if (checkExisting(child, lstChild) == false) {
92.508 + lstChild.add(child);
92.509 + }
92.510 + }
92.511 + }
92.512 + } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.513 + int start = token.offset(tokenHierarchy);
92.514 + PlsqlBlock child = new PlsqlBlock(start,
92.515 + start + token.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.516 + if (child != null) {
92.517 + if (checkExisting(child, lstChild) == false) {
92.518 + lstChild.add(child);
92.519 + }
92.520 + }
92.521 + } else if (tokenID == PlsqlTokenId.WHITESPACE && image.contains("\n")) {
92.522 + getName = false;
92.523 + } else if (getName) {
92.524 + name = name + image;
92.525 + }
92.526 +
92.527 + moveNext = ts.moveNext();
92.528 + token = ts.token();
92.529 + }
92.530 +
92.531 + if (block != null) {
92.532 + //add children
92.533 + addChildren(block, lstChild, parentBlocks);
92.534 + }
92.535 +
92.536 + return block;
92.537 + }
92.538 +
92.539 + /**
92.540 + * Check whether the given token offest is inlcuded in any existing block
92.541 + * @param token
92.542 + * @param immediateBlockHier
92.543 + * @param parent
92.544 + * @return
92.545 + */
92.546 + private boolean isTokenOk(Token<PlsqlTokenId> token, List<PlsqlBlock> immediateBlockHier, PlsqlBlock parent) {
92.547 + boolean isOk = true;
92.548 + int offset = token.offset(tokenHierarchy);
92.549 + for (int i = immediateBlockHier.size() - 1; i >= 0; i--) {
92.550 + PlsqlBlock block = immediateBlockHier.get(i);
92.551 + if ((block.getStartOffset() <= offset) && (block.getEndOffset() >= offset)) {
92.552 + isOk = false;
92.553 + break;
92.554 + }
92.555 + }
92.556 +
92.557 + if (isOk && parent != null) {
92.558 + if (!((parent.getStartOffset() <= offset) && (parent.getEndOffset() >= offset))) {
92.559 + isOk = false;
92.560 + }
92.561 + }
92.562 + return isOk;
92.563 + }
92.564 +
92.565 + /**
92.566 + * Method that will look for trigger blocks
92.567 + * @param tempToken
92.568 + * @param ts
92.569 + * @param parentBlocks
92.570 + * @return
92.571 + */
92.572 + private PlsqlBlock checkTrigger(Token<PlsqlTokenId> tiggerToken, TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> parentBlocks) {
92.573 + Token<PlsqlTokenId> triggerBegin = tiggerToken;
92.574 + Token<PlsqlTokenId> tmp = tiggerToken;
92.575 + PlsqlBlock block = null;
92.576 + List<PlsqlBlock> lstChild = new ArrayList<PlsqlBlock>();
92.577 +
92.578 + String triggerName = "";
92.579 + boolean moveNext = false;
92.580 +
92.581 + //Check whether the beginning is in a SQL Plus command
92.582 + if (sqlPlusLine(ts)) {
92.583 + return null;
92.584 + }
92.585 +
92.586 + //Get procedure/function name which is the next non whitespace token
92.587 + moveNext = getNextNonWhitespace(ts, true);
92.588 + tmp = ts.token();
92.589 + if (moveNext == false) {
92.590 + return block;
92.591 + }
92.592 +
92.593 + triggerName = tmp.text().toString();
92.594 + triggerName = checkForOtherSchema(ts, triggerName);
92.595 + String alias = "";
92.596 + if (triggerName.indexOf('&') != -1) {
92.597 + alias = triggerName;
92.598 + }
92.599 + triggerName = getDefine(triggerName);
92.600 + Token<PlsqlTokenId> customStartToken = null;
92.601 +
92.602 + while (moveNext) {
92.603 + String image = tmp.text().toString();
92.604 + PlsqlTokenId tokenID = tmp.id();
92.605 +
92.606 + if ((tmp != null) && (!image.equals(";")) && (tmp.offset(tokenHierarchy) > endParse)) {
92.607 + break;
92.608 + }
92.609 +
92.610 + //We might have come to the end of the procedure/function declaration
92.611 + if ((tokenID == PlsqlTokenId.OPERATOR) && image.equals(";")) {
92.612 + //check whether previous Non white space token to the identifier is END
92.613 + int offset = ts.offset();
92.614 + getPreviousNonWhitespace(ts, true);
92.615 + Token<PlsqlTokenId> previousNWS = ts.token();
92.616 + String prevText = previousNWS.text().toString();
92.617 + getPreviousNonWhitespace(ts, true);
92.618 + previousNWS = ts.token();
92.619 + if (alias.equals("")) {
92.620 + if ((prevText.equalsIgnoreCase(triggerName)
92.621 + && previousNWS.text().toString().equalsIgnoreCase("END"))
92.622 + || prevText.equalsIgnoreCase("END")) {
92.623 + ts.move(offset);
92.624 + moveNext = ts.moveNext();
92.625 + moveNext = ts.moveNext();
92.626 + block = new PlsqlBlock(triggerBegin.offset(tokenHierarchy),
92.627 + ts.offset(), triggerName, alias, PlsqlBlockType.TRIGGER);
92.628 + checkPrefix(triggerBegin.offset(tokenHierarchy), ts, block);
92.629 + break;
92.630 + }
92.631 + } else {
92.632 + if ((prevText.equalsIgnoreCase(alias)
92.633 + && previousNWS.text().toString().equalsIgnoreCase("END"))
92.634 + || prevText.equalsIgnoreCase("END")) {
92.635 + ts.move(offset);
92.636 + moveNext = ts.moveNext();
92.637 + moveNext = ts.moveNext();
92.638 + block = new PlsqlBlock(triggerBegin.offset(tokenHierarchy),
92.639 + ts.offset(), triggerName, alias, PlsqlBlockType.TRIGGER);
92.640 + checkPrefix(triggerBegin.offset(tokenHierarchy), ts, block);
92.641 + break;
92.642 + }
92.643 + }
92.644 + ts.move(offset);
92.645 + moveNext = ts.moveNext();
92.646 + } else if (image.equalsIgnoreCase("TABLE")
92.647 + || image.equalsIgnoreCase("INDEX")
92.648 + || image.equalsIgnoreCase("SELECT")
92.649 + || image.equalsIgnoreCase("UPDATE")
92.650 + || image.equalsIgnoreCase("DELETE")
92.651 + || image.equalsIgnoreCase("INSERT")
92.652 + || image.equalsIgnoreCase("MERGE")
92.653 + || image.equalsIgnoreCase("DROP")
92.654 + || image.equalsIgnoreCase("SEQUENCE")) {
92.655 + if (!isNotBlockStart(tmp, ts)) {
92.656 + int offset = tmp.offset(tokenHierarchy);
92.657 + PlsqlBlock child = checkStatementBlock(tmp, ts, parentBlocks);
92.658 + if (child == null) {//If inner check seems to have failed need to continue this one
92.659 +
92.660 + ts.move(offset);
92.661 + ts.moveNext();
92.662 + } else {
92.663 + if (checkExisting(child, lstChild) == false) {
92.664 + lstChild.add(child);
92.665 + }
92.666 + }
92.667 + }
92.668 + } else if (image.equalsIgnoreCase("PROCEDURE")) {
92.669 + int beforeOff = tmp.offset(tokenHierarchy);
92.670 + PlsqlBlock child = checkMethod(tmp, ts, PlsqlBlockType.PROCEDURE_IMPL, lstChild);
92.671 + if (child == null) {//If inner check seems to have failed need to continue this one
92.672 + ts.move(beforeOff);
92.673 + ts.moveNext();
92.674 + } else {
92.675 + if (checkExisting(child, lstChild) == false) {
92.676 + lstChild.add(child);
92.677 + }
92.678 + }
92.679 + } //Inner procedure
92.680 + else if (image.equalsIgnoreCase("FUNCTION")) {
92.681 + int beforeOff = tmp.offset(tokenHierarchy);
92.682 + PlsqlBlock child = checkMethod(tmp, ts, PlsqlBlockType.FUNCTION_IMPL, lstChild);
92.683 + if (child == null) {//If inner check seems to have failed need to continue this one
92.684 +
92.685 + ts.move(beforeOff);
92.686 + ts.moveNext();
92.687 + } else {
92.688 + if (checkExisting(child, lstChild) == false) {
92.689 + lstChild.add(child);
92.690 + }
92.691 + }
92.692 + } else if (image.equalsIgnoreCase("CREATE")
92.693 + || image.equalsIgnoreCase("/")
92.694 + || image.equalsIgnoreCase("PACKAGE")) {
92.695 + break;
92.696 + } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.697 + //only single comment line
92.698 + if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.699 + customStartToken = tmp;
92.700 + } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.701 + if (customStartToken != null) {
92.702 + String name = customStartToken.text().toString();
92.703 + int index = name.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.704 + name = name.substring(index + 7).trim();
92.705 + if (ts.moveNext()) {
92.706 + tmp = ts.token();
92.707 + PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.708 + tmp.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.709 + customFoldBlocks.add(custom);
92.710 + }
92.711 + customStartToken = null;
92.712 + }
92.713 + } else {
92.714 + PlsqlBlock child = checkComment(tmp, ts);
92.715 + if (child != null) {
92.716 + if (checkExisting(child, lstChild) == false) {
92.717 + lstChild.add(child);
92.718 + }
92.719 + }
92.720 + }
92.721 + } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.722 + int start = tmp.offset(tokenHierarchy);
92.723 + PlsqlBlock child = new PlsqlBlock(start,
92.724 + start + tmp.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.725 + if (child != null) {
92.726 + if (checkExisting(child, lstChild) == false) {
92.727 + lstChild.add(child);
92.728 + }
92.729 + }
92.730 + }
92.731 +
92.732 + moveNext = ts.moveNext();
92.733 + tmp = ts.token();
92.734 + }
92.735 +
92.736 + if (block != null) {
92.737 + //add children
92.738 + addChildren(block, lstChild, parentBlocks);
92.739 + }
92.740 +
92.741 + return block;
92.742 + }
92.743 +
92.744 + /**
92.745 + * Method that will check the prefix of the given block and change the block values accordingly
92.746 + * @param startOffset
92.747 + * @param ts
92.748 + * @param begin
92.749 + */
92.750 + private void checkPrefix(int startOffset, TokenSequence<PlsqlTokenId> ts, PlsqlBlock block) {
92.751 + String prefix = "";
92.752 + int offset = ts.offset();
92.753 + ts.move(startOffset);
92.754 + ts.moveNext();
92.755 + Token<PlsqlTokenId> token = ts.token();
92.756 + int beginOffset = startOffset;
92.757 +
92.758 + while (ts.movePrevious()) {
92.759 token = ts.token();
92.760 String image = token.text().toString();
92.761 - PlsqlTokenId tokenID = token.id();
92.762 -
92.763 - if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.764 - //only single comment line
92.765 - if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.766 - //We have come to another start
92.767 - return;
92.768 - } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.769 - if (isTokenOk(token, immediateBlockHier, parent)) {
92.770 - String name = found.text().toString();
92.771 - int index = name.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.772 - name = name.substring(index + 7).trim();
92.773 - if (ts.moveNext()) {
92.774 - token = ts.token();
92.775 - PlsqlBlock custom = new PlsqlBlock(found.offset(tokenHierarchy),
92.776 - token.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.777 - customFoldBlocks.add(custom);
92.778 - }
92.779 - }
92.780 - //since we have found the other tag return
92.781 - return;
92.782 - }
92.783 +
92.784 + if (image.contains("\n") || (token.id() != PlsqlTokenId.KEYWORD && token.id() != PlsqlTokenId.WHITESPACE)) {
92.785 + break;
92.786 }
92.787 - }
92.788 - } else {
92.789 - ts.move(found.offset(tokenHierarchy));
92.790 - //We have to find the start fold token now
92.791 - while (ts.movePrevious()) {
92.792 +
92.793 + prefix = token.text().toString() + prefix;
92.794 + if (token.id() != PlsqlTokenId.WHITESPACE) {
92.795 + beginOffset = ts.offset();
92.796 + }
92.797 + }
92.798 +
92.799 + ts.move(offset);
92.800 + ts.moveNext();
92.801 + block.setStartOffset(beginOffset);
92.802 + block.setPrefix(prefix);
92.803 + }
92.804 +
92.805 + /**
92.806 + * Check whether there is a block existing with the given offset as the start offset
92.807 + * @param blockHierarchy
92.808 + * @param offset
92.809 + * @return
92.810 + */
92.811 + private boolean isBlockStartExisting(List<PlsqlBlock> blockHierarchy, int offset) {
92.812 + boolean isExisting = false;
92.813 + for (int i = blockHierarchy.size() - 1; i >= 0; i--) {
92.814 + PlsqlBlock tmp = blockHierarchy.get(i);
92.815 + if (tmp.getStartOffset() == offset) {
92.816 + isExisting = true;
92.817 + break;
92.818 + }
92.819 +
92.820 + if (!isExisting) {
92.821 + if (isBlockStartExisting(tmp.getChildBlocks(), offset)) {
92.822 + isExisting = true;
92.823 + break;
92.824 + }
92.825 + }
92.826 + }
92.827 +
92.828 + return isExisting;
92.829 + }
92.830 +
92.831 + private boolean isEqual(PlsqlBlock parent, PlsqlBlock block) {
92.832 + if ((parent == null) || (block == null)) {
92.833 + return false;
92.834 + }
92.835 + if ((parent.getStartOffset() == block.getStartOffset())
92.836 + || (parent.getEndOffset() == block.getEndOffset())
92.837 + || (parent.getName().equalsIgnoreCase(block.getName()))) {
92.838 + return true;
92.839 + }
92.840 + return false;
92.841 + }
92.842 +
92.843 + private String readLine(TokenSequence<PlsqlTokenId> ts, Token<PlsqlTokenId> token) {
92.844 + String line = token.toString();
92.845 + while (ts.moveNext()) {
92.846 + token = ts.token();
92.847 + if (token.id() == PlsqlTokenId.WHITESPACE && token.text().toString().contains("\n")) {
92.848 + ts.movePrevious();
92.849 + break;
92.850 + }
92.851 +
92.852 + line = line + token.toString();
92.853 + }
92.854 +
92.855 + return line;
92.856 + }
92.857 +
92.858 + /**
92.859 + * Method that will remove the begin block of this declare block if there
92.860 + * @param declareBlock
92.861 + */
92.862 + private void removeChildBegin(PlsqlBlock declareBlock) {
92.863 + //can check from the root hierarchies since begin/declare cannot be child blocks
92.864 + for (int i = blockHierarchy.size() - 1; i >= 0; i--) {
92.865 + PlsqlBlock tmp = blockHierarchy.get(i);
92.866 + if ((tmp.getStartOffset() > declareBlock.getStartOffset())
92.867 + && (tmp.getEndOffset() == declareBlock.getEndOffset())
92.868 + && (tmp.getType() == PlsqlBlockType.BEGIN_END)) {
92.869 + blockHierarchy.remove(tmp);
92.870 + }
92.871 + }
92.872 + }
92.873 +
92.874 + /**
92.875 + * Change offsets of the blocks below the area
92.876 + * @param blockHier
92.877 + * @param endParse
92.878 + * @param length
92.879 + */
92.880 + private void changeOffSet(List<PlsqlBlock> blockHier, int offset, int length, boolean add, boolean adjust) {
92.881 + int count = blockHier.size();
92.882 + int start = 0;
92.883 + int end = 0;
92.884 + for (int i = 0; i < count; i++) {
92.885 + PlsqlBlock temp = blockHier.get(i);
92.886 + start = temp.getStartOffset();
92.887 + end = temp.getEndOffset();
92.888 + if (temp.getStartOffset() >= offset) {
92.889 + if (temp.getPreviousStart() == -1) {
92.890 + temp.setPreviousStart(start);
92.891 + }
92.892 + if (start + length < 0) {
92.893 + temp.setStartOffset(0);
92.894 + } else {
92.895 + temp.setStartOffset(start + length);
92.896 + if (startParse == start && adjust) //changing offsets of toBeRemoved
92.897 + {
92.898 + startParse = start + length;
92.899 + }
92.900 + }
92.901 +
92.902 + if (temp.getPreviousEnd() == -1) {
92.903 + temp.setPreviousEnd(end);
92.904 + }
92.905 + if (end + length < 0) {
92.906 + temp.setEndOffset(0);
92.907 + } else {
92.908 + temp.setEndOffset(end + length);
92.909 + if (endParse == end && adjust) //changing offsets of toBeRemoved
92.910 + {
92.911 + endParse = end + length;
92.912 + }
92.913 + }
92.914 +
92.915 + if (add) {
92.916 + addToChangedBlocks(temp);
92.917 + }
92.918 + changeOffSet(temp.getChildBlocks(), offset, length, add, adjust);
92.919 + } else if (temp.getEndOffset() >= offset) {
92.920 + if (temp.getPreviousEnd() == -1) {
92.921 + temp.setPreviousEnd(end);
92.922 + }
92.923 + if (end + length < 0) {
92.924 + temp.setEndOffset(0);
92.925 + } else {
92.926 + temp.setEndOffset(end + length);
92.927 + if (endParse == end && adjust) //changing offsets of toBeRemoved
92.928 + {
92.929 + endParse = end + length;
92.930 + }
92.931 + }
92.932 +
92.933 + if (add) {
92.934 + addToChangedBlocks(temp);
92.935 + }
92.936 + changeOffSet(temp.getChildBlocks(), offset, length, add, adjust);
92.937 + }
92.938 + }
92.939 + }
92.940 +
92.941 + /**
92.942 + * Method that will check whether there are DEFINE statements in the affected area
92.943 + * @param doc
92.944 + * @param startOffset
92.945 + * @param endOffset
92.946 + */
92.947 + private void checkAffected(Document doc, int startOffset, int endOffset) throws BadLocationException {
92.948 + int length = endOffset - startOffset;
92.949 + String changedText = doc.getText(startOffset, length);
92.950 +
92.951 + if ((changedText.toUpperCase(Locale.ENGLISH).indexOf("DEFINE ") != -1)
92.952 + || (changedText.toUpperCase(Locale.ENGLISH).indexOf("DEFIN ") != -1)
92.953 + || (changedText.toUpperCase(Locale.ENGLISH).indexOf("DEFI ") != -1)
92.954 + || (changedText.toUpperCase(Locale.ENGLISH).indexOf("DEF ") != -1)) {
92.955 + isDefineChanged = true;
92.956 + }
92.957 + }
92.958 +
92.959 + /**
92.960 + * Method that will make CURSOR blocks
92.961 + * @param tempToken
92.962 + * @param ts
92.963 + * @param parentBlocks
92.964 + * @return
92.965 + */
92.966 + private PlsqlBlock checkCursor(Token<PlsqlTokenId> current, TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> parentBlocks) {
92.967 + Token<PlsqlTokenId> cursorBegin = current;
92.968 + Token<PlsqlTokenId> tmp = current;
92.969 + Token<PlsqlTokenId> cursorEnd = null;
92.970 + PlsqlBlock block = null;
92.971 + List<PlsqlBlock> lstChild = new ArrayList<PlsqlBlock>();
92.972 + boolean moveNext = false;
92.973 +
92.974 + //Check whether the beginning is in a SQL Plus command
92.975 + if (sqlPlusLine(ts)) {
92.976 + return null;
92.977 + }
92.978 +
92.979 + //Get next token which is the name
92.980 + int offset = ts.offset();
92.981 + moveNext = getNextNonWhitespace(ts, false);
92.982 + tmp = ts.token();
92.983 + if (moveNext == false) {
92.984 + ts.move(offset);
92.985 + ts.moveNext();
92.986 + return block;
92.987 + }
92.988 + String cursorName = tmp.text().toString();
92.989 + String alias = "";
92.990 + if (cursorName.indexOf('&') != -1) {
92.991 + alias = cursorName;
92.992 + }
92.993 + cursorName = getDefine(cursorName);
92.994 +
92.995 + //Next token has to be IS or ( if not leave
92.996 + moveNext = getNextNonWhitespace(ts, false);
92.997 + tmp = ts.token();
92.998 + boolean isFound = false;
92.999 + boolean parameter = false;
92.1000 + Token<PlsqlTokenId> customStartToken = null;
92.1001 +
92.1002 + while (moveNext) {
92.1003 + PlsqlTokenId tokenID = tmp.id();
92.1004 + String image = tmp.text().toString();
92.1005 +
92.1006 + if ((tmp != null) && (!image.equals(";")) && (tmp.offset(tokenHierarchy) > endParse)) {
92.1007 + break;
92.1008 + }
92.1009 +
92.1010 + //When we have come up to ';' stop
92.1011 + if ((tokenID == PlsqlTokenId.OPERATOR) && (image.equals(";"))) {
92.1012 + if (isFound) {
92.1013 + if (ts.moveNext()) {
92.1014 + tmp = ts.token();
92.1015 + }
92.1016 + cursorEnd = tmp;
92.1017 + break;
92.1018 + } else {
92.1019 + ts.move(offset);
92.1020 + ts.moveNext();
92.1021 + return null;
92.1022 + }
92.1023 + } else if ((tokenID == PlsqlTokenId.LPAREN) && (!isFound)) {
92.1024 + parameter = true;
92.1025 + } else if ((tokenID == PlsqlTokenId.RPAREN) && (!isFound)) {
92.1026 + parameter = false;
92.1027 + } else if (tokenID == PlsqlTokenId.KEYWORD) {
92.1028 + if (image.equalsIgnoreCase("IS")) {
92.1029 + isFound = true;
92.1030 + } else if ((!parameter) && //If this keyword is a parameter inside cursor ignore
92.1031 + ((image.equalsIgnoreCase("SUBTYPE"))
92.1032 + || (image.equalsIgnoreCase("CONSTANT"))
92.1033 + || (image.equalsIgnoreCase("NUMBER"))
92.1034 + || (image.equalsIgnoreCase("VARCHAR2")))) { //Avoid catching ';' of other statements
92.1035 +
92.1036 + return null;
92.1037 + } else if ((image.equalsIgnoreCase("VIEW"))
92.1038 + || (image.equalsIgnoreCase("PROCEDURE"))
92.1039 + || (image.equalsIgnoreCase("FUNCTION"))
92.1040 + || (image.equalsIgnoreCase("BEGIN"))
92.1041 + || (image.equalsIgnoreCase("DECLARE"))
92.1042 + || (image.equalsIgnoreCase("CREATE"))
92.1043 + || (image.equalsIgnoreCase("CURSOR"))
92.1044 + || (image.equalsIgnoreCase("EXCEPTION"))
92.1045 + || (image.equalsIgnoreCase("PRAGMA"))
92.1046 + || (image.equalsIgnoreCase("END"))
92.1047 + || (image.equalsIgnoreCase("COMMENT"))) { //Avoid catching ';' of other statements
92.1048 +
92.1049 + return null;
92.1050 + }
92.1051 + } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.1052 + //only single comment line
92.1053 + if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.1054 + customStartToken = tmp;
92.1055 + } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.1056 + if (customStartToken != null) {
92.1057 + String name = customStartToken.text().toString();
92.1058 + int index = name.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.1059 + name = name.substring(index + 7).trim();
92.1060 + if (ts.moveNext()) {
92.1061 + tmp = ts.token();
92.1062 + PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.1063 + tmp.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.1064 + customFoldBlocks.add(custom);
92.1065 + }
92.1066 + customStartToken = null;
92.1067 + }
92.1068 + } else {
92.1069 + PlsqlBlock child = checkComment(tmp, ts);
92.1070 + if (child != null) {
92.1071 + if (checkExisting(child, lstChild) == false) {
92.1072 + lstChild.add(child);
92.1073 + }
92.1074 + }
92.1075 + }
92.1076 + } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.1077 + int start = tmp.offset(tokenHierarchy);
92.1078 + PlsqlBlock child = new PlsqlBlock(start,
92.1079 + start + tmp.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.1080 + if (child != null) {
92.1081 + if (checkExisting(child, lstChild) == false) {
92.1082 + lstChild.add(child);
92.1083 + }
92.1084 + }
92.1085 + }
92.1086 +
92.1087 + moveNext = ts.moveNext();
92.1088 + tmp = ts.token();
92.1089 + }
92.1090 +
92.1091 + if (cursorEnd != null) {
92.1092 + block = new PlsqlBlock(cursorBegin.offset(tokenHierarchy), ts.offset(),
92.1093 + cursorName, alias, PlsqlBlockType.CURSOR);
92.1094 + }
92.1095 +
92.1096 + if (block != null) {
92.1097 + //add children
92.1098 + addChildren(block, lstChild, parentBlocks);
92.1099 + }
92.1100 +
92.1101 + return block;
92.1102 + }
92.1103 +
92.1104 + /**
92.1105 + * Check whether we have caught a begin of a declare block
92.1106 + * @param ts
92.1107 + * @param immediate
92.1108 + * @return
92.1109 + */
92.1110 + private boolean isDeclare(TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> immediate) {
92.1111 + int offset = ts.offset();
92.1112 + Token<PlsqlTokenId> token = ts.token();
92.1113 + Token<PlsqlTokenId> tokenPre = ts.token();
92.1114 +
92.1115 + while (ts.movePrevious()) {
92.1116 token = ts.token();
92.1117 String image = token.text().toString();
92.1118 - PlsqlTokenId tokenID = token.id();
92.1119 -
92.1120 - if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.1121 - //only single comment line
92.1122 - if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.1123 - if (isTokenOk(token, immediateBlockHier, parent)) {
92.1124 - String name = image;
92.1125 - int index = name.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.1126 - name = name.substring(index + 7).trim();
92.1127 - ts.move(found.offset(tokenHierarchy));
92.1128 - ts.moveNext();
92.1129 - if (ts.moveNext()) {
92.1130 - found = ts.token();
92.1131 - PlsqlBlock custom = new PlsqlBlock(token.offset(tokenHierarchy),
92.1132 - found.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.1133 - customFoldBlocks.add(custom);
92.1134 - }
92.1135 - }
92.1136 - //since we have found the other tag return
92.1137 - return;
92.1138 - } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.1139 - //We have come to another end
92.1140 - return;
92.1141 - }
92.1142 + if (image.equalsIgnoreCase("DECLARE") && (!isBlockStartExisting(immediate, ts.offset()))) {
92.1143 + PlsqlBlock block = checkDeclareBlock(token, ts, immediate);
92.1144 + if (block != null && (checkExisting(block, immediate) == false)) {//If inner check seems to have failed need to continue this one
92.1145 + immediate.add(block);
92.1146 + newBlocks.add(block);
92.1147 + } else {
92.1148 + //Since we have not found the block we have to avoid getting caught up in a loop
92.1149 + ts.move(offset);
92.1150 + ts.moveNext();
92.1151 + }
92.1152 + return true;
92.1153 + } else if ((image.equals("/")) || (image.equalsIgnoreCase("BEGIN"))
92.1154 + || ((image.equalsIgnoreCase("END")) && (tokenPre.text().toString().equals(";")))) {
92.1155 + break;
92.1156 }
92.1157 - }
92.1158 - }
92.1159 - }
92.1160 -
92.1161 - /**
92.1162 - * Method that will check for a Java Source block
92.1163 - * @param tempToken
92.1164 - * @param ts
92.1165 - * @param immediateBlockHier
92.1166 - * @return
92.1167 - */
92.1168 - private PlsqlBlock checkJavaSource(Token<PlsqlTokenId> tempToken, TokenSequence<PlsqlTokenId> ts) {
92.1169 - Token<PlsqlTokenId> begin = tempToken;
92.1170 - Token<PlsqlTokenId> tmp = tempToken;
92.1171 - PlsqlBlock block = null;
92.1172 -
92.1173 - //Check whether the beginning is in a SQL Plus command
92.1174 - if (sqlPlusLine(ts)) {
92.1175 - return null;
92.1176 - }
92.1177 -
92.1178 - while (ts.moveNext()) {
92.1179 - tmp = ts.token();
92.1180 - String image = tmp.text().toString();
92.1181 - PlsqlTokenId tokenID = tmp.id();
92.1182 -
92.1183 - if ((tmp != null) && (!image.equals("/")) && (tmp.offset(tokenHierarchy) > endParse)) {
92.1184 - break;
92.1185 - }
92.1186 -
92.1187 - //We might have come to the end of the procedure/function declaration
92.1188 - if ((tokenID == PlsqlTokenId.OPERATOR) && image.equals("/")) {
92.1189 - //check whether previous Non white space token to the identifier is END
92.1190 - int offset = ts.offset();
92.1191 - if (checkForOnlyChar(ts, offset)) {
92.1192 - ts.move(offset);
92.1193 - ts.moveNext();
92.1194 - ts.moveNext();
92.1195 - block = new PlsqlBlock(begin.offset(tokenHierarchy), offset, "", "", PlsqlBlockType.JAVA_SOURCE);
92.1196 - checkPrefix(begin.offset(tokenHierarchy), ts, block);
92.1197 - break;
92.1198 +
92.1199 + if ((token.id() != PlsqlTokenId.WHITESPACE)
92.1200 + && (token.id() != PlsqlTokenId.LINE_COMMENT)
92.1201 + && (token.id() != PlsqlTokenId.BLOCK_COMMENT)) {
92.1202 + tokenPre = token;
92.1203 }
92.1204 - }
92.1205 - }
92.1206 -
92.1207 - return block;
92.1208 - }
92.1209 -
92.1210 - /**
92.1211 - * Check whether this current token is the only token in this line
92.1212 - * @param ts
92.1213 - * @param offset
92.1214 - * @return
92.1215 - */
92.1216 - private boolean checkForOnlyChar(TokenSequence<PlsqlTokenId> ts, int offset) {
92.1217 - boolean isStartOk = true;
92.1218 - boolean isEndOk = true;
92.1219 - ts.move(offset);
92.1220 - Token<PlsqlTokenId> token = null;
92.1221 - while (ts.movePrevious()) {
92.1222 - token = ts.token();
92.1223 - if (token.id() == PlsqlTokenId.WHITESPACE) {
92.1224 - if (token.toString().contains("\n")) {
92.1225 - break;
92.1226 + }
92.1227 +
92.1228 + ts.move(offset);
92.1229 + ts.moveNext();
92.1230 + return false;
92.1231 + }
92.1232 +
92.1233 + /**
92.1234 + * Check whether the given block is already there in block hierachy
92.1235 + * @param block
92.1236 + * @param childList
92.1237 + * @return
92.1238 + */
92.1239 + private boolean checkExisting(PlsqlBlock block, List<PlsqlBlock> childList) {
92.1240 + boolean existing = false;
92.1241 + int count = childList.size();
92.1242 + for (int i = 0; i < count; i++) {
92.1243 + PlsqlBlock tmp = childList.get(i);
92.1244 + if ((tmp.getName().equals(block.getName()) && tmp.getEndOffset() == block.getEndOffset())
92.1245 + || (tmp.getName().equals(block.getName()) && tmp.getStartOffset() == block.getStartOffset())
92.1246 + || (tmp.getEndOffset() == block.getEndOffset() && tmp.getStartOffset() == block.getStartOffset())) {
92.1247 + existing = true;
92.1248 + break;
92.1249 }
92.1250 - } else if (token.id() == PlsqlTokenId.JAVA_SOUCE) {
92.1251 - break;
92.1252 - } else {
92.1253 - isStartOk = false;
92.1254 - break;
92.1255 - }
92.1256 - }
92.1257 -
92.1258 - ts.move(offset);
92.1259 - ts.moveNext(); //current token
92.1260 - while (ts.moveNext()) {
92.1261 - token = ts.token();
92.1262 - if (token.id() == PlsqlTokenId.WHITESPACE) {
92.1263 - if (token.toString().contains("\n")) {
92.1264 - break;
92.1265 + }
92.1266 +
92.1267 + return existing;
92.1268 + }
92.1269 +
92.1270 + /**
92.1271 + * Clear internal variables used in a parse
92.1272 + */
92.1273 + private void clear() {
92.1274 + isDefineChanged = false;
92.1275 + startParse = 0;
92.1276 + endParse = 0;
92.1277 + changedLength = 0;
92.1278 + newBlocks = new ArrayList<PlsqlBlock>();
92.1279 + toBeRemoved = new ArrayList<PlsqlBlock>();
92.1280 + changedBlocks = new ArrayList<PlsqlBlock>();
92.1281 + unsuccessBlocks = new HashSet<Integer>();
92.1282 + resetPreviousValues(blockHierarchy);
92.1283 + }
92.1284 +
92.1285 + private void resetPreviousValues(List<PlsqlBlock> blockList) {
92.1286 + for (PlsqlBlock block : blockList) {
92.1287 + block.setPreviousStart(-1);
92.1288 + block.setPreviousEnd(-1);
92.1289 + resetPreviousValues(block.getChildBlocks());
92.1290 + }
92.1291 + }
92.1292 +
92.1293 + public void beforeCaseChange() {
92.1294 + caseChangeInProgress = true;
92.1295 + }
92.1296 +
92.1297 + public void afterCaseChange() {
92.1298 + caseChangeInProgress = false;
92.1299 + }
92.1300 +
92.1301 + public void beforeSave(Document document) {
92.1302 + saveInProgress = true;
92.1303 + synchronized (updateLock) {
92.1304 + updateEvents.clear();
92.1305 + }
92.1306 + }
92.1307 +
92.1308 + public boolean isSaveInProgress() {
92.1309 + return saveInProgress || caseChangeInProgress;
92.1310 + }
92.1311 +
92.1312 + public synchronized void afterSave(Document document) {
92.1313 + setChanged();
92.1314 + //initHierarchy(document);
92.1315 + reParse(document);
92.1316 + parseAliases();
92.1317 + notifyObservers(document);
92.1318 + clearChanged();
92.1319 + saveInProgress = false;
92.1320 + }
92.1321 +
92.1322 + private EventProperties addNewEvent(DocumentEvent e, DocumentEvent.EventType mode) {
92.1323 + EventProperties eventProperties = new EventProperties(this);
92.1324 + eventProperties.document = e.getDocument();
92.1325 + eventProperties.offset = e.getOffset();
92.1326 + eventProperties.length = e.getLength();
92.1327 + eventProperties.mode = mode;
92.1328 + updateEvents.addLast(eventProperties);
92.1329 + return eventProperties;
92.1330 +
92.1331 + }
92.1332 +
92.1333 + private void removeBlock(PlsqlBlock block, List<PlsqlBlock> lstBlocks) {
92.1334 + boolean removed = false;
92.1335 + if (!lstBlocks.remove(block)) {
92.1336 + if (removeBlock(blockHierarchy, block)) {
92.1337 + toBeRemoved.add(block);
92.1338 + removed = true;
92.1339 }
92.1340 - } else {
92.1341 - isEndOk = false;
92.1342 - break;
92.1343 - }
92.1344 - }
92.1345 -
92.1346 - ts.move(offset);
92.1347 - ts.moveNext();
92.1348 -
92.1349 - if (isStartOk && isEndOk) {
92.1350 - return true;
92.1351 - }
92.1352 -
92.1353 - return false;
92.1354 - }
92.1355 -
92.1356 - /**
92.1357 - * Method that will check for statement blocks other than the CURSOR and VIEW
92.1358 - * @param tempToken
92.1359 - * @param ts
92.1360 - * @param immediateBlockHier
92.1361 - * @return
92.1362 - */
92.1363 - private PlsqlBlock checkStatementBlock(Token<PlsqlTokenId> current, TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> parentBlocks) {
92.1364 - Token<PlsqlTokenId> stmtBegin = null;
92.1365 - Token<PlsqlTokenId> token = null;
92.1366 - List<PlsqlBlock> lstChild = new ArrayList<PlsqlBlock>();
92.1367 - PlsqlBlock block = null;
92.1368 - boolean moveNext = false;
92.1369 -
92.1370 - //Check whether the beginning is in a SQL Plus command
92.1371 - if (sqlPlusLine(ts)) {
92.1372 - return null;
92.1373 - }
92.1374 -
92.1375 - moveNext = ts.moveNext();
92.1376 - token = ts.token();
92.1377 - stmtBegin = current;
92.1378 - boolean getName = true;
92.1379 - Token<PlsqlTokenId> customStartToken = null;
92.1380 - String name = current.text().toString();
92.1381 -
92.1382 - while (moveNext) {
92.1383 - String image = token.text().toString();
92.1384 - PlsqlTokenId tokenID = token.id();
92.1385 -
92.1386 - if ((token != null) && (!image.equals(";")) && (!image.equals("/")) && (token.offset(tokenHierarchy) > endParse)) {
92.1387 - break;
92.1388 - }
92.1389 -
92.1390 - if (image.equals(";") || (image.equals("/") && checkForOnlyChar(ts, ts.offset()))) {
92.1391 - block = new PlsqlBlock(stmtBegin.offset(tokenHierarchy), token.offset(tokenHierarchy), name.trim(), "", PlsqlBlockType.STATEMENT);
92.1392 - checkPrefix(stmtBegin.offset(tokenHierarchy), ts, block);
92.1393 - break;
92.1394 - } else if (image.equalsIgnoreCase("CREATE")
92.1395 - || image.equalsIgnoreCase("DECLARE")
92.1396 - || image.equalsIgnoreCase("BEGIN")
92.1397 - || image.equalsIgnoreCase("WHEN")
92.1398 - || image.equalsIgnoreCase("THEN")
92.1399 - || image.equalsIgnoreCase("IF")
92.1400 - || image.equalsIgnoreCase("END")
92.1401 - || image.equalsIgnoreCase("ELSE")
92.1402 - || image.equalsIgnoreCase("LOOP")) {
92.1403 - break;
92.1404 - } else if (image.equalsIgnoreCase("CASE")) {
92.1405 - int beforeOff = token.offset(tokenHierarchy);
92.1406 - List children = checkCaseBlock(token, ts, lstChild, true);
92.1407 - if (children == null || children.size() == 0) {//If inner check seems to have failed need to continue this one
92.1408 -
92.1409 - ts.move(beforeOff);
92.1410 - moveNext = ts.moveNext();
92.1411 - } else {
92.1412 - for (int i = 0; i < children.size(); i++) {
92.1413 - PlsqlBlock child = (PlsqlBlock) children.get(i);
92.1414 - if (checkExisting(child, lstChild) == false) {
92.1415 - lstChild.add(child);
92.1416 - }
92.1417 - }
92.1418 - }
92.1419 - } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.1420 - //only single comment line
92.1421 - if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.1422 - customStartToken = token;
92.1423 - } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.1424 - if (customStartToken != null) {
92.1425 - String fname = customStartToken.text().toString();
92.1426 - int index = fname.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.1427 - fname = fname.substring(index + 7).trim();
92.1428 - if (ts.moveNext()) {
92.1429 - token = ts.token();
92.1430 - PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.1431 - token.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.1432 - customFoldBlocks.add(custom);
92.1433 - }
92.1434 - customStartToken = null;
92.1435 - }
92.1436 - } else {
92.1437 - PlsqlBlock child = checkComment(token, ts);
92.1438 - if (child != null) {
92.1439 - if (checkExisting(child, lstChild) == false) {
92.1440 - lstChild.add(child);
92.1441 - }
92.1442 - }
92.1443 - }
92.1444 - } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.1445 - int start = token.offset(tokenHierarchy);
92.1446 - PlsqlBlock child = new PlsqlBlock(start,
92.1447 - start + token.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.1448 - if (child != null) {
92.1449 - if (checkExisting(child, lstChild) == false) {
92.1450 - lstChild.add(child);
92.1451 - }
92.1452 - }
92.1453 - } else if (tokenID == PlsqlTokenId.WHITESPACE && image.contains("\n")) {
92.1454 - getName = false;
92.1455 - } else if (getName) {
92.1456 - name = name + image;
92.1457 - }
92.1458 -
92.1459 - moveNext = ts.moveNext();
92.1460 - token = ts.token();
92.1461 - }
92.1462 -
92.1463 - if (block != null) {
92.1464 - //add children
92.1465 - addChildren(block, lstChild, parentBlocks);
92.1466 - }
92.1467 -
92.1468 - return block;
92.1469 - }
92.1470 -
92.1471 - /**
92.1472 - * Check whether the given token offest is inlcuded in any existing block
92.1473 - * @param token
92.1474 - * @param immediateBlockHier
92.1475 - * @param parent
92.1476 - * @return
92.1477 - */
92.1478 - private boolean isTokenOk(Token<PlsqlTokenId> token, List<PlsqlBlock> immediateBlockHier, PlsqlBlock parent) {
92.1479 - boolean isOk = true;
92.1480 - int offset = token.offset(tokenHierarchy);
92.1481 - for (int i = immediateBlockHier.size() - 1; i >= 0; i--) {
92.1482 - PlsqlBlock block = immediateBlockHier.get(i);
92.1483 - if ((block.getStartOffset() <= offset) && (block.getEndOffset() >= offset)) {
92.1484 - isOk = false;
92.1485 - break;
92.1486 - }
92.1487 - }
92.1488 -
92.1489 - if (isOk && parent != null) {
92.1490 - if (!((parent.getStartOffset() <= offset) && (parent.getEndOffset() >= offset))) {
92.1491 - isOk = false;
92.1492 - }
92.1493 - }
92.1494 - return isOk;
92.1495 - }
92.1496 -
92.1497 - /**
92.1498 - * Method that will look for trigger blocks
92.1499 - * @param tempToken
92.1500 - * @param ts
92.1501 - * @param parentBlocks
92.1502 - * @return
92.1503 - */
92.1504 - private PlsqlBlock checkTrigger(Token<PlsqlTokenId> tiggerToken, TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> parentBlocks) {
92.1505 - Token<PlsqlTokenId> triggerBegin = tiggerToken;
92.1506 - Token<PlsqlTokenId> tmp = tiggerToken;
92.1507 - PlsqlBlock block = null;
92.1508 - List<PlsqlBlock> lstChild = new ArrayList<PlsqlBlock>();
92.1509 -
92.1510 - String triggerName = "";
92.1511 - boolean moveNext = false;
92.1512 -
92.1513 - //Check whether the beginning is in a SQL Plus command
92.1514 - if (sqlPlusLine(ts)) {
92.1515 - return null;
92.1516 - }
92.1517 -
92.1518 - //Get procedure/function name which is the next non whitespace token
92.1519 - moveNext = getNextNonWhitespace(ts, true);
92.1520 - tmp = ts.token();
92.1521 - if (moveNext == false) {
92.1522 - return block;
92.1523 - }
92.1524 -
92.1525 - triggerName = tmp.text().toString();
92.1526 - triggerName = checkForOtherSchema(ts, triggerName);
92.1527 - String alias = "";
92.1528 - if (triggerName.indexOf('&') != -1) {
92.1529 - alias = triggerName;
92.1530 - }
92.1531 - triggerName = getDefine(triggerName);
92.1532 - Token<PlsqlTokenId> customStartToken = null;
92.1533 -
92.1534 - while (moveNext) {
92.1535 - String image = tmp.text().toString();
92.1536 - PlsqlTokenId tokenID = tmp.id();
92.1537 -
92.1538 - if ((tmp != null) && (!image.equals(";")) && (tmp.offset(tokenHierarchy) > endParse)) {
92.1539 - break;
92.1540 - }
92.1541 -
92.1542 - //We might have come to the end of the procedure/function declaration
92.1543 - if ((tokenID == PlsqlTokenId.OPERATOR) && image.equals(";")) {
92.1544 - //check whether previous Non white space token to the identifier is END
92.1545 - int offset = ts.offset();
92.1546 - getPreviousNonWhitespace(ts, true);
92.1547 - Token<PlsqlTokenId> previousNWS = ts.token();
92.1548 - String prevText = previousNWS.text().toString();
92.1549 - getPreviousNonWhitespace(ts, true);
92.1550 - previousNWS = ts.token();
92.1551 - if (alias.equals("")) {
92.1552 - if ((prevText.equalsIgnoreCase(triggerName)
92.1553 - && previousNWS.text().toString().equalsIgnoreCase("END"))
92.1554 - || prevText.equalsIgnoreCase("END")) {
92.1555 - ts.move(offset);
92.1556 - moveNext = ts.moveNext();
92.1557 - moveNext = ts.moveNext();
92.1558 - block = new PlsqlBlock(triggerBegin.offset(tokenHierarchy),
92.1559 - ts.offset(), triggerName, alias, PlsqlBlockType.TRIGGER);
92.1560 - checkPrefix(triggerBegin.offset(tokenHierarchy), ts, block);
92.1561 - break;
92.1562 - }
92.1563 - } else {
92.1564 - if ((prevText.equalsIgnoreCase(alias)
92.1565 - && previousNWS.text().toString().equalsIgnoreCase("END"))
92.1566 - || prevText.equalsIgnoreCase("END")) {
92.1567 - ts.move(offset);
92.1568 - moveNext = ts.moveNext();
92.1569 - moveNext = ts.moveNext();
92.1570 - block = new PlsqlBlock(triggerBegin.offset(tokenHierarchy),
92.1571 - ts.offset(), triggerName, alias, PlsqlBlockType.TRIGGER);
92.1572 - checkPrefix(triggerBegin.offset(tokenHierarchy), ts, block);
92.1573 - break;
92.1574 - }
92.1575 - }
92.1576 - ts.move(offset);
92.1577 - moveNext = ts.moveNext();
92.1578 - } else if (image.equalsIgnoreCase("TABLE")
92.1579 - || image.equalsIgnoreCase("INDEX")
92.1580 - || image.equalsIgnoreCase("SELECT")
92.1581 - || image.equalsIgnoreCase("UPDATE")
92.1582 - || image.equalsIgnoreCase("DELETE")
92.1583 - || image.equalsIgnoreCase("INSERT")
92.1584 - || image.equalsIgnoreCase("MERGE")
92.1585 - || image.equalsIgnoreCase("DROP")
92.1586 - || image.equalsIgnoreCase("SEQUENCE")) {
92.1587 - if (!isNotBlockStart(tmp, ts)) {
92.1588 - int offset = tmp.offset(tokenHierarchy);
92.1589 - PlsqlBlock child = checkStatementBlock(tmp, ts, parentBlocks);
92.1590 - if (child == null) {//If inner check seems to have failed need to continue this one
92.1591 -
92.1592 - ts.move(offset);
92.1593 - ts.moveNext();
92.1594 - } else {
92.1595 - if (checkExisting(child, lstChild) == false) {
92.1596 - lstChild.add(child);
92.1597 - }
92.1598 - }
92.1599 - }
92.1600 - } else if (image.equalsIgnoreCase("PROCEDURE")) {
92.1601 - int beforeOff = tmp.offset(tokenHierarchy);
92.1602 - PlsqlBlock child = checkMethod(tmp, ts, PlsqlBlockType.PROCEDURE_IMPL, lstChild);
92.1603 - if (child == null) {//If inner check seems to have failed need to continue this one
92.1604 - ts.move(beforeOff);
92.1605 - ts.moveNext();
92.1606 - } else {
92.1607 - if (checkExisting(child, lstChild) == false) {
92.1608 - lstChild.add(child);
92.1609 - }
92.1610 - }
92.1611 - } //Inner procedure
92.1612 - else if (image.equalsIgnoreCase("FUNCTION")) {
92.1613 - int beforeOff = tmp.offset(tokenHierarchy);
92.1614 - PlsqlBlock child = checkMethod(tmp, ts, PlsqlBlockType.FUNCTION_IMPL, lstChild);
92.1615 - if (child == null) {//If inner check seems to have failed need to continue this one
92.1616 -
92.1617 - ts.move(beforeOff);
92.1618 - ts.moveNext();
92.1619 - } else {
92.1620 - if (checkExisting(child, lstChild) == false) {
92.1621 - lstChild.add(child);
92.1622 - }
92.1623 - }
92.1624 - } else if (image.equalsIgnoreCase("CREATE")
92.1625 - || image.equalsIgnoreCase("/")
92.1626 - || image.equalsIgnoreCase("PACKAGE")) {
92.1627 - break;
92.1628 - } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.1629 - //only single comment line
92.1630 - if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.1631 - customStartToken = tmp;
92.1632 - } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.1633 - if (customStartToken != null) {
92.1634 - String name = customStartToken.text().toString();
92.1635 - int index = name.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.1636 - name = name.substring(index + 7).trim();
92.1637 - if (ts.moveNext()) {
92.1638 - tmp = ts.token();
92.1639 - PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.1640 - tmp.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.1641 - customFoldBlocks.add(custom);
92.1642 - }
92.1643 - customStartToken = null;
92.1644 - }
92.1645 - } else {
92.1646 - PlsqlBlock child = checkComment(tmp, ts);
92.1647 - if (child != null) {
92.1648 - if (checkExisting(child, lstChild) == false) {
92.1649 - lstChild.add(child);
92.1650 - }
92.1651 - }
92.1652 - }
92.1653 - } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.1654 - int start = tmp.offset(tokenHierarchy);
92.1655 - PlsqlBlock child = new PlsqlBlock(start,
92.1656 - start + tmp.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.1657 - if (child != null) {
92.1658 - if (checkExisting(child, lstChild) == false) {
92.1659 - lstChild.add(child);
92.1660 - }
92.1661 - }
92.1662 - }
92.1663 -
92.1664 - moveNext = ts.moveNext();
92.1665 - tmp = ts.token();
92.1666 - }
92.1667 -
92.1668 - if (block != null) {
92.1669 - //add children
92.1670 - addChildren(block, lstChild, parentBlocks);
92.1671 - }
92.1672 -
92.1673 - return block;
92.1674 - }
92.1675 -
92.1676 - /**
92.1677 - * Method that will check the prefix of the given block and change the block values accordingly
92.1678 - * @param startOffset
92.1679 - * @param ts
92.1680 - * @param begin
92.1681 - */
92.1682 - private void checkPrefix(int startOffset, TokenSequence<PlsqlTokenId> ts, PlsqlBlock block) {
92.1683 - String prefix = "";
92.1684 - int offset = ts.offset();
92.1685 - ts.move(startOffset);
92.1686 - ts.moveNext();
92.1687 - Token<PlsqlTokenId> token = ts.token();
92.1688 - int beginOffset = startOffset;
92.1689 -
92.1690 - while (ts.movePrevious()) {
92.1691 - token = ts.token();
92.1692 - String image = token.text().toString();
92.1693 -
92.1694 - if (image.contains("\n") || (token.id() != PlsqlTokenId.KEYWORD && token.id() != PlsqlTokenId.WHITESPACE)) {
92.1695 - break;
92.1696 - }
92.1697 -
92.1698 - prefix = token.text().toString() + prefix;
92.1699 - if (token.id() != PlsqlTokenId.WHITESPACE) {
92.1700 - beginOffset = ts.offset();
92.1701 - }
92.1702 - }
92.1703 -
92.1704 - ts.move(offset);
92.1705 - ts.moveNext();
92.1706 - block.setStartOffset(beginOffset);
92.1707 - block.setPrefix(prefix);
92.1708 - }
92.1709 -
92.1710 - /**
92.1711 - * Check whether there is a block existing with the given offset as the start offset
92.1712 - * @param blockHierarchy
92.1713 - * @param offset
92.1714 - * @return
92.1715 - */
92.1716 - private boolean isBlockStartExisting(List<PlsqlBlock> blockHierarchy, int offset) {
92.1717 - boolean isExisting = false;
92.1718 - for (int i = blockHierarchy.size() - 1; i >= 0; i--) {
92.1719 - PlsqlBlock tmp = blockHierarchy.get(i);
92.1720 - if (tmp.getStartOffset() == offset) {
92.1721 - isExisting = true;
92.1722 - break;
92.1723 - }
92.1724 -
92.1725 - if (!isExisting) {
92.1726 - if (isBlockStartExisting(tmp.getChildBlocks(), offset)) {
92.1727 - isExisting = true;
92.1728 - break;
92.1729 - }
92.1730 - }
92.1731 - }
92.1732 -
92.1733 - return isExisting;
92.1734 - }
92.1735 -
92.1736 - private boolean isEqual(PlsqlBlock parent, PlsqlBlock block) {
92.1737 - if ((parent == null) || (block == null)) {
92.1738 - return false;
92.1739 - }
92.1740 - if ((parent.getStartOffset() == block.getStartOffset())
92.1741 - || (parent.getEndOffset() == block.getEndOffset())
92.1742 - || (parent.getName().equalsIgnoreCase(block.getName()))) {
92.1743 - return true;
92.1744 - }
92.1745 - return false;
92.1746 - }
92.1747 -
92.1748 - private String readLine(TokenSequence<PlsqlTokenId> ts, Token<PlsqlTokenId> token) {
92.1749 - String line = token.toString();
92.1750 - while (ts.moveNext()) {
92.1751 - token = ts.token();
92.1752 - if (token.id() == PlsqlTokenId.WHITESPACE && token.text().toString().contains("\n")) {
92.1753 - ts.movePrevious();
92.1754 - break;
92.1755 - }
92.1756 -
92.1757 - line = line + token.toString();
92.1758 - }
92.1759 -
92.1760 - return line;
92.1761 - }
92.1762 -
92.1763 - /**
92.1764 - * Method that will remove the begin block of this declare block if there
92.1765 - * @param declareBlock
92.1766 - */
92.1767 - private void removeChildBegin(PlsqlBlock declareBlock) {
92.1768 - //can check from the root hierarchies since begin/declare cannot be child blocks
92.1769 - for (int i = blockHierarchy.size() - 1; i >= 0; i--) {
92.1770 - PlsqlBlock tmp = blockHierarchy.get(i);
92.1771 - if ((tmp.getStartOffset() > declareBlock.getStartOffset())
92.1772 - && (tmp.getEndOffset() == declareBlock.getEndOffset())
92.1773 - && (tmp.getType() == PlsqlBlockType.BEGIN_END)) {
92.1774 - blockHierarchy.remove(tmp);
92.1775 - }
92.1776 - }
92.1777 - }
92.1778 -
92.1779 - /**
92.1780 - * Change offsets of the blocks below the area
92.1781 - * @param blockHier
92.1782 - * @param endParse
92.1783 - * @param length
92.1784 - */
92.1785 - private void changeOffSet(List<PlsqlBlock> blockHier, int offset, int length, boolean add, boolean adjust) {
92.1786 - int count = blockHier.size();
92.1787 - int start = 0;
92.1788 - int end = 0;
92.1789 - for (int i = 0; i < count; i++) {
92.1790 - PlsqlBlock temp = blockHier.get(i);
92.1791 - start = temp.getStartOffset();
92.1792 - end = temp.getEndOffset();
92.1793 - if (temp.getStartOffset() >= offset) {
92.1794 - if (temp.getPreviousStart() == -1) {
92.1795 - temp.setPreviousStart(start);
92.1796 - }
92.1797 - if (start + length < 0) {
92.1798 - temp.setStartOffset(0);
92.1799 - } else {
92.1800 - temp.setStartOffset(start + length);
92.1801 - if (startParse == start && adjust) //changing offsets of toBeRemoved
92.1802 - {
92.1803 - startParse = start + length;
92.1804 - }
92.1805 - }
92.1806 -
92.1807 - if (temp.getPreviousEnd() == -1) {
92.1808 - temp.setPreviousEnd(end);
92.1809 - }
92.1810 - if (end + length < 0) {
92.1811 - temp.setEndOffset(0);
92.1812 - } else {
92.1813 - temp.setEndOffset(end + length);
92.1814 - if (endParse == end && adjust) //changing offsets of toBeRemoved
92.1815 - {
92.1816 - endParse = end + length;
92.1817 - }
92.1818 - }
92.1819 -
92.1820 - if (add) {
92.1821 - addToChangedBlocks(temp);
92.1822 - }
92.1823 - changeOffSet(temp.getChildBlocks(), offset, length, add, adjust);
92.1824 - } else if (temp.getEndOffset() >= offset) {
92.1825 - if (temp.getPreviousEnd() == -1) {
92.1826 - temp.setPreviousEnd(end);
92.1827 - }
92.1828 - if (end + length < 0) {
92.1829 - temp.setEndOffset(0);
92.1830 - } else {
92.1831 - temp.setEndOffset(end + length);
92.1832 - if (endParse == end && adjust) //changing offsets of toBeRemoved
92.1833 - {
92.1834 - endParse = end + length;
92.1835 - }
92.1836 - }
92.1837 -
92.1838 - if (add) {
92.1839 - addToChangedBlocks(temp);
92.1840 - }
92.1841 - changeOffSet(temp.getChildBlocks(), offset, length, add, adjust);
92.1842 - }
92.1843 - }
92.1844 - }
92.1845 -
92.1846 - /**
92.1847 - * Method that will check whether there are DEFINE statements in the affected area
92.1848 - * @param doc
92.1849 - * @param startOffset
92.1850 - * @param endOffset
92.1851 - */
92.1852 - private void checkAffected(Document doc, int startOffset, int endOffset) throws BadLocationException {
92.1853 - int length = endOffset - startOffset;
92.1854 - String changedText = doc.getText(startOffset, length);
92.1855 -
92.1856 - if ((changedText.toUpperCase(Locale.ENGLISH).indexOf("DEFINE ") != -1)
92.1857 - || (changedText.toUpperCase(Locale.ENGLISH).indexOf("DEFIN ") != -1)
92.1858 - || (changedText.toUpperCase(Locale.ENGLISH).indexOf("DEFI ") != -1)
92.1859 - || (changedText.toUpperCase(Locale.ENGLISH).indexOf("DEF ") != -1)) {
92.1860 - isDefineChanged = true;
92.1861 - }
92.1862 - }
92.1863 -
92.1864 - /**
92.1865 - * Method that will make CURSOR blocks
92.1866 - * @param tempToken
92.1867 - * @param ts
92.1868 - * @param parentBlocks
92.1869 - * @return
92.1870 - */
92.1871 - private PlsqlBlock checkCursor(Token<PlsqlTokenId> current, TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> parentBlocks) {
92.1872 - Token<PlsqlTokenId> cursorBegin = current;
92.1873 - Token<PlsqlTokenId> tmp = current;
92.1874 - Token<PlsqlTokenId> cursorEnd = null;
92.1875 - PlsqlBlock block = null;
92.1876 - List<PlsqlBlock> lstChild = new ArrayList<PlsqlBlock>();
92.1877 - boolean moveNext = false;
92.1878 -
92.1879 - //Check whether the beginning is in a SQL Plus command
92.1880 - if (sqlPlusLine(ts)) {
92.1881 - return null;
92.1882 - }
92.1883 -
92.1884 - //Get next token which is the name
92.1885 - int offset = ts.offset();
92.1886 - moveNext = getNextNonWhitespace(ts, false);
92.1887 - tmp = ts.token();
92.1888 - if (moveNext == false) {
92.1889 - ts.move(offset);
92.1890 - ts.moveNext();
92.1891 - return block;
92.1892 - }
92.1893 - String cursorName = tmp.text().toString();
92.1894 - String alias = "";
92.1895 - if (cursorName.indexOf('&') != -1) {
92.1896 - alias = cursorName;
92.1897 - }
92.1898 - cursorName = getDefine(cursorName);
92.1899 -
92.1900 - //Next token has to be IS or ( if not leave
92.1901 - moveNext = getNextNonWhitespace(ts, false);
92.1902 - tmp = ts.token();
92.1903 - boolean isFound = false;
92.1904 - boolean parameter = false;
92.1905 - Token<PlsqlTokenId> customStartToken = null;
92.1906 -
92.1907 - while (moveNext) {
92.1908 - PlsqlTokenId tokenID = tmp.id();
92.1909 - String image = tmp.text().toString();
92.1910 -
92.1911 - if ((tmp != null) && (!image.equals(";")) && (tmp.offset(tokenHierarchy) > endParse)) {
92.1912 - break;
92.1913 - }
92.1914 -
92.1915 - //When we have come up to ';' stop
92.1916 - if ((tokenID == PlsqlTokenId.OPERATOR) && (image.equals(";"))) {
92.1917 - if (isFound) {
92.1918 - if (ts.moveNext()) {
92.1919 - tmp = ts.token();
92.1920 - }
92.1921 - cursorEnd = tmp;
92.1922 - break;
92.1923 - } else {
92.1924 - ts.move(offset);
92.1925 - ts.moveNext();
92.1926 - return null;
92.1927 - }
92.1928 - } else if ((tokenID == PlsqlTokenId.LPAREN) && (!isFound)) {
92.1929 - parameter = true;
92.1930 - } else if ((tokenID == PlsqlTokenId.RPAREN) && (!isFound)) {
92.1931 - parameter = false;
92.1932 - } else if (tokenID == PlsqlTokenId.KEYWORD) {
92.1933 - if (image.equalsIgnoreCase("IS")) {
92.1934 - isFound = true;
92.1935 - } else if ((!parameter) && //If this keyword is a parameter inside cursor ignore
92.1936 - ((image.equalsIgnoreCase("SUBTYPE"))
92.1937 - || (image.equalsIgnoreCase("CONSTANT"))
92.1938 - || (image.equalsIgnoreCase("NUMBER"))
92.1939 - || (image.equalsIgnoreCase("VARCHAR2")))) { //Avoid catching ';' of other statements
92.1940 -
92.1941 - return null;
92.1942 - } else if ((image.equalsIgnoreCase("VIEW"))
92.1943 - || (image.equalsIgnoreCase("PROCEDURE"))
92.1944 - || (image.equalsIgnoreCase("FUNCTION"))
92.1945 - || (image.equalsIgnoreCase("BEGIN"))
92.1946 - || (image.equalsIgnoreCase("DECLARE"))
92.1947 - || (image.equalsIgnoreCase("CREATE"))
92.1948 - || (image.equalsIgnoreCase("CURSOR"))
92.1949 - || (image.equalsIgnoreCase("EXCEPTION"))
92.1950 - || (image.equalsIgnoreCase("PRAGMA"))
92.1951 - || (image.equalsIgnoreCase("END"))
92.1952 - || (image.equalsIgnoreCase("COMMENT"))) { //Avoid catching ';' of other statements
92.1953 -
92.1954 - return null;
92.1955 - }
92.1956 - } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.1957 - //only single comment line
92.1958 - if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.1959 - customStartToken = tmp;
92.1960 - } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.1961 - if (customStartToken != null) {
92.1962 - String name = customStartToken.text().toString();
92.1963 - int index = name.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.1964 - name = name.substring(index + 7).trim();
92.1965 - if (ts.moveNext()) {
92.1966 - tmp = ts.token();
92.1967 - PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.1968 - tmp.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.1969 - customFoldBlocks.add(custom);
92.1970 - }
92.1971 - customStartToken = null;
92.1972 - }
92.1973 - } else {
92.1974 - PlsqlBlock child = checkComment(tmp, ts);
92.1975 - if (child != null) {
92.1976 - if (checkExisting(child, lstChild) == false) {
92.1977 - lstChild.add(child);
92.1978 - }
92.1979 - }
92.1980 - }
92.1981 - } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.1982 - int start = tmp.offset(tokenHierarchy);
92.1983 - PlsqlBlock child = new PlsqlBlock(start,
92.1984 - start + tmp.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.1985 - if (child != null) {
92.1986 - if (checkExisting(child, lstChild) == false) {
92.1987 - lstChild.add(child);
92.1988 - }
92.1989 - }
92.1990 - }
92.1991 -
92.1992 - moveNext = ts.moveNext();
92.1993 - tmp = ts.token();
92.1994 - }
92.1995 -
92.1996 - if (cursorEnd != null) {
92.1997 - block = new PlsqlBlock(cursorBegin.offset(tokenHierarchy), ts.offset(),
92.1998 - cursorName, alias, PlsqlBlockType.CURSOR);
92.1999 - }
92.2000 -
92.2001 - if (block != null) {
92.2002 - //add children
92.2003 - addChildren(block, lstChild, parentBlocks);
92.2004 - }
92.2005 -
92.2006 - return block;
92.2007 - }
92.2008 -
92.2009 - /**
92.2010 - * Check whether we have caught a begin of a declare block
92.2011 - * @param ts
92.2012 - * @param immediate
92.2013 - * @return
92.2014 - */
92.2015 - private boolean isDeclare(TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> immediate) {
92.2016 - int offset = ts.offset();
92.2017 - Token<PlsqlTokenId> token = ts.token();
92.2018 - Token<PlsqlTokenId> tokenPre = ts.token();
92.2019 -
92.2020 - while (ts.movePrevious()) {
92.2021 - token = ts.token();
92.2022 - String image = token.text().toString();
92.2023 - if (image.equalsIgnoreCase("DECLARE") && (!isBlockStartExisting(immediate, ts.offset()))) {
92.2024 - PlsqlBlock block = checkDeclareBlock(token, ts, immediate);
92.2025 - if (block != null && (checkExisting(block, immediate) == false)) {//If inner check seems to have failed need to continue this one
92.2026 - immediate.add(block);
92.2027 - newBlocks.add(block);
92.2028 - } else {
92.2029 - //Since we have not found the block we have to avoid getting caught up in a loop
92.2030 - ts.move(offset);
92.2031 - ts.moveNext();
92.2032 - }
92.2033 - return true;
92.2034 - } else if ((image.equals("/")) || (image.equalsIgnoreCase("BEGIN"))
92.2035 - || ((image.equalsIgnoreCase("END")) && (tokenPre.text().toString().equals(";")))) {
92.2036 - break;
92.2037 - }
92.2038 -
92.2039 - if ((token.id() != PlsqlTokenId.WHITESPACE)
92.2040 - && (token.id() != PlsqlTokenId.LINE_COMMENT)
92.2041 - && (token.id() != PlsqlTokenId.BLOCK_COMMENT)) {
92.2042 - tokenPre = token;
92.2043 - }
92.2044 - }
92.2045 -
92.2046 - ts.move(offset);
92.2047 - ts.moveNext();
92.2048 - return false;
92.2049 - }
92.2050 -
92.2051 - /**
92.2052 - * Check whether the given block is already there in block hierachy
92.2053 - * @param block
92.2054 - * @param childList
92.2055 - * @return
92.2056 - */
92.2057 - private boolean checkExisting(PlsqlBlock block, List<PlsqlBlock> childList) {
92.2058 - boolean existing = false;
92.2059 - int count = childList.size();
92.2060 - for (int i = 0; i < count; i++) {
92.2061 - PlsqlBlock tmp = childList.get(i);
92.2062 - if ((tmp.getName().equals(block.getName()) && tmp.getEndOffset() == block.getEndOffset())
92.2063 - || (tmp.getName().equals(block.getName()) && tmp.getStartOffset() == block.getStartOffset())
92.2064 - || (tmp.getEndOffset() == block.getEndOffset() && tmp.getStartOffset() == block.getStartOffset())) {
92.2065 - existing = true;
92.2066 - break;
92.2067 - }
92.2068 - }
92.2069 -
92.2070 - return existing;
92.2071 - }
92.2072 -
92.2073 - /**
92.2074 - * Clear internal variables used in a parse
92.2075 - */
92.2076 - private void clear() {
92.2077 - isDefineChanged = false;
92.2078 - startParse = 0;
92.2079 - endParse = 0;
92.2080 - changedLength = 0;
92.2081 - newBlocks = new ArrayList<PlsqlBlock>();
92.2082 - toBeRemoved = new ArrayList<PlsqlBlock>();
92.2083 - changedBlocks = new ArrayList<PlsqlBlock>();
92.2084 - unsuccessBlocks = new HashSet<Integer>();
92.2085 - resetPreviousValues(blockHierarchy);
92.2086 - }
92.2087 -
92.2088 - private void resetPreviousValues(List<PlsqlBlock> blockList) {
92.2089 - for (PlsqlBlock block : blockList) {
92.2090 - block.setPreviousStart(-1);
92.2091 - block.setPreviousEnd(-1);
92.2092 - resetPreviousValues(block.getChildBlocks());
92.2093 - }
92.2094 - }
92.2095 -
92.2096 - public void beforeCaseChange() {
92.2097 - caseChangeInProgress = true;
92.2098 - }
92.2099 -
92.2100 - public void afterCaseChange() {
92.2101 - caseChangeInProgress = false;
92.2102 - }
92.2103 -
92.2104 - public void beforeSave(Document document) {
92.2105 - saveInProgress = true;
92.2106 - synchronized (updateLock) {
92.2107 - updateEvents.clear();
92.2108 - }
92.2109 - }
92.2110 -
92.2111 - public boolean isSaveInProgress() {
92.2112 - return saveInProgress || caseChangeInProgress;
92.2113 - }
92.2114 -
92.2115 - public synchronized void afterSave(Document document) {
92.2116 - setChanged();
92.2117 - //initHierarchy(document);
92.2118 - reParse(document);
92.2119 - parseAliases();
92.2120 - notifyObservers(document);
92.2121 - clearChanged();
92.2122 - saveInProgress = false;
92.2123 - }
92.2124 -
92.2125 - private EventProperties addNewEvent(DocumentEvent e, DocumentEvent.EventType mode) {
92.2126 - EventProperties eventProperties = new EventProperties(this);
92.2127 - eventProperties.document = e.getDocument();
92.2128 - eventProperties.offset = e.getOffset();
92.2129 - eventProperties.length = e.getLength();
92.2130 - eventProperties.mode = mode;
92.2131 - updateEvents.addLast(eventProperties);
92.2132 - return eventProperties;
92.2133 -
92.2134 - }
92.2135 -
92.2136 - private void removeBlock(PlsqlBlock block, List<PlsqlBlock> lstBlocks) {
92.2137 - boolean removed = false;
92.2138 - if (!lstBlocks.remove(block)) {
92.2139 - if (removeBlock(blockHierarchy, block)) {
92.2140 + } else {
92.2141 toBeRemoved.add(block);
92.2142 removed = true;
92.2143 - }
92.2144 - } else {
92.2145 - toBeRemoved.add(block);
92.2146 - removed = true;
92.2147 - }
92.2148 -
92.2149 - if (removed) {
92.2150 - //If this block is there in changed blocks remove it
92.2151 - removeBlock(changedBlocks, block);
92.2152 - if (startParse > block.getStartOffset()) {
92.2153 - startParse = block.getStartOffset();
92.2154 - }
92.2155 - if (endParse < block.getEndOffset()) {
92.2156 - endParse = block.getEndOffset();
92.2157 - }
92.2158 - }
92.2159 - }
92.2160 -
92.2161 - private void addToChangedBlocks(PlsqlBlock temp) {
92.2162 - int count = changedBlocks.size();
92.2163 - boolean found = false;
92.2164 - for (int i = 0; i < count; i++) {
92.2165 - PlsqlBlock tmp = changedBlocks.get(i);
92.2166 - if (tmp.getStartOffset() == temp.getStartOffset() && tmp.getEndOffset() == temp.getEndOffset()) {
92.2167 - found = true;
92.2168 - break;
92.2169 - }
92.2170 - }
92.2171 -
92.2172 - if (!found) {
92.2173 - changedBlocks.add(temp);
92.2174 - }
92.2175 - }
92.2176 -
92.2177 - private String checkForOtherSchema(TokenSequence<PlsqlTokenId> ts, String currentName) {
92.2178 - int offset = ts.offset();
92.2179 - if (ts.moveNext()) {
92.2180 - Token<PlsqlTokenId> token = ts.token();
92.2181 - if (token.id() == PlsqlTokenId.DOT) {
92.2182 - if (ts.moveNext()) {
92.2183 - token = ts.token();
92.2184 - if (token.id() == PlsqlTokenId.DOT) {
92.2185 - if (ts.moveNext()) {
92.2186 - return ts.token().toString();
92.2187 - }
92.2188 - } else {
92.2189 - return ts.token().toString();
92.2190 - }
92.2191 + }
92.2192 +
92.2193 + if (removed) {
92.2194 + //If this block is there in changed blocks remove it
92.2195 + removeBlock(changedBlocks, block);
92.2196 + if (startParse > block.getStartOffset()) {
92.2197 + startParse = block.getStartOffset();
92.2198 }
92.2199 - }
92.2200 - }
92.2201 -
92.2202 - //Reset the original location
92.2203 - ts.move(offset);
92.2204 - ts.moveNext();
92.2205 -
92.2206 - return currentName;
92.2207 - }
92.2208 -
92.2209 - private static class EventProperties {
92.2210 -
92.2211 - public int offset = -1;
92.2212 - public int length = -1;
92.2213 - public Document document = null;
92.2214 - DocumentEvent.EventType mode = null;
92.2215 - public PlsqlBlockFactory blockFactory = null;
92.2216 -
92.2217 - public EventProperties(PlsqlBlockFactory blockFactory) {
92.2218 - this.blockFactory = blockFactory;
92.2219 - }
92.2220 - }
92.2221 -
92.2222 - private static class UpdateBlocksThread implements Runnable {
92.2223 -
92.2224 - public UpdateBlocksThread() {
92.2225 - }
92.2226 -
92.2227 - public void run() {
92.2228 - synchronized (updateLock) {
92.2229 - while (updateEvents.size() > 0) {
92.2230 - EventProperties event = updateEvents.getFirst();
92.2231 - Document doc = event.document;
92.2232 - List<EventProperties> docList = new ArrayList<EventProperties>();
92.2233 -
92.2234 - while (event != null && event.document.equals(doc)) {
92.2235 - updateEvents.removeFirst();
92.2236 - docList.add(event);
92.2237 - event = null;
92.2238 - if (updateEvents.size() > 0) {
92.2239 - event = updateEvents.getFirst();
92.2240 - }
92.2241 - }
92.2242 -
92.2243 - docList.get(0).blockFactory.doUpdate(doc, docList);
92.2244 + if (endParse < block.getEndOffset()) {
92.2245 + endParse = block.getEndOffset();
92.2246 }
92.2247 - }
92.2248 - }
92.2249 - }
92.2250 -
92.2251 - private synchronized void doUpdate(final Document document, final List<EventProperties> docList) {
92.2252 -
92.2253 - //make sure that the updates are run in the Swing thread
92.2254 - SwingUtilities.invokeLater(new Runnable() {
92.2255 -
92.2256 - public void run() {
92.2257 - setChanged();
92.2258 - updateBlocks(document, docList);
92.2259 - parseAliases();
92.2260 - notifyObservers(document);
92.2261 - clearChanged();
92.2262 - }
92.2263 - });
92.2264 - }
92.2265 -
92.2266 - private void addUpdateEvent(DocumentEvent e, DocumentEvent.EventType mode) {
92.2267 - synchronized (updateLock) {
92.2268 - if (updateBlocksTask == null) {
92.2269 - updateBlocksTask = RequestProcessor.getDefault().create(new UpdateBlocksThread());
92.2270 - }
92.2271 - updateBlocksTask.schedule(DEFAULT_WAIT_TIME);
92.2272 - addNewEvent(e, mode);
92.2273 - }
92.2274 - }
92.2275 -
92.2276 - /**
92.2277 - * Event fired on insert
92.2278 - * @param e
92.2279 - */
92.2280 - public void insertUpdate(DocumentEvent e) {
92.2281 - if (isSaveInProgress()) {
92.2282 - return;
92.2283 - }
92.2284 -
92.2285 - addUpdateEvent(e, DocumentEvent.EventType.INSERT);
92.2286 - }
92.2287 -
92.2288 - /**
92.2289 - * Event fired in remove
92.2290 - * @param e
92.2291 - */
92.2292 - public void removeUpdate(DocumentEvent e) {
92.2293 - if (isSaveInProgress()) {
92.2294 - return;
92.2295 - }
92.2296 - addUpdateEvent(e, DocumentEvent.EventType.REMOVE);
92.2297 - }
92.2298 -
92.2299 - /**
92.2300 - * trigged when opening a different document
92.2301 - * @param e
92.2302 - */
92.2303 - public void changedUpdate(DocumentEvent e) {
92.2304 - //It seems we don't have to handle this case since initHierarchy
92.2305 - // will always be called before this
92.2306 - }
92.2307 -
92.2308 - /**
92.2309 - * Update block hierarchy on a document event
92.2310 - * @param e
92.2311 - * @param action
92.2312 - */
92.2313 - public synchronized void initHierarchy(Document doc) {
92.2314 - clear();
92.2315 -
92.2316 - if (doc == null) {
92.2317 - return;
92.2318 - }
92.2319 -
92.2320 - docStartOffset = doc.getStartPosition().getOffset();
92.2321 - docEndOffset = doc.getEndPosition().getOffset();
92.2322 - Object obj = doc.getProperty("Listener");
92.2323 -
92.2324 - if ((obj == null) || (!obj.equals("YES"))) {
92.2325 - startParse = docStartOffset;
92.2326 - endParse = docEndOffset - 1;
92.2327 -
92.2328 - //clean block hierarchy
92.2329 - blockHierarchy.clear();
92.2330 - customFoldBlocks.clear();
92.2331 - getAliases(doc);
92.2332 - generateBlocks(doc);
92.2333 - //This property is added only to ensure that document listener is added only once
92.2334 - doc.putProperty("Listener", "YES");
92.2335 - doc.addDocumentListener(this);
92.2336 - }
92.2337 - }
92.2338 -
92.2339 - /**
92.2340 - * Method that will return the block within the start & end parse
92.2341 - * @param start
92.2342 - * @param end
92.2343 - * @return
92.2344 - */
92.2345 - private PlsqlBlock getParentBlock(List<PlsqlBlock> lstBlock, int start, int end) {
92.2346 - PlsqlBlock parent = null;
92.2347 - int count = lstBlock.size();
92.2348 - for (int i = 0; i < count; i++) {
92.2349 - PlsqlBlock tmp = lstBlock.get(i);
92.2350 - if ((tmp.getStartOffset() < start) && (tmp.getEndOffset() > end)) {
92.2351 - PlsqlBlock child = getParentBlock(tmp.getChildBlocks(), start, end);
92.2352 + }
92.2353 + }
92.2354 +
92.2355 + private void addToChangedBlocks(PlsqlBlock temp) {
92.2356 + int count = changedBlocks.size();
92.2357 + boolean found = false;
92.2358 + for (int i = 0; i < count; i++) {
92.2359 + PlsqlBlock tmp = changedBlocks.get(i);
92.2360 + if (tmp.getStartOffset() == temp.getStartOffset() && tmp.getEndOffset() == temp.getEndOffset()) {
92.2361 + found = true;
92.2362 + break;
92.2363 + }
92.2364 + }
92.2365 +
92.2366 + if (!found) {
92.2367 + changedBlocks.add(temp);
92.2368 + }
92.2369 + }
92.2370 +
92.2371 + private String checkForOtherSchema(TokenSequence<PlsqlTokenId> ts, String currentName) {
92.2372 + int offset = ts.offset();
92.2373 + if (ts.moveNext()) {
92.2374 + Token<PlsqlTokenId> token = ts.token();
92.2375 + if (token.id() == PlsqlTokenId.DOT) {
92.2376 + if (ts.moveNext()) {
92.2377 + token = ts.token();
92.2378 + if (token.id() == PlsqlTokenId.DOT) {
92.2379 + if (ts.moveNext()) {
92.2380 + return ts.token().toString();
92.2381 + }
92.2382 + } else {
92.2383 + return ts.token().toString();
92.2384 + }
92.2385 + }
92.2386 + }
92.2387 + }
92.2388 +
92.2389 + //Reset the original location
92.2390 + ts.move(offset);
92.2391 + ts.moveNext();
92.2392 +
92.2393 + return currentName;
92.2394 + }
92.2395 +
92.2396 + private static class EventProperties {
92.2397 +
92.2398 + public int offset = -1;
92.2399 + public int length = -1;
92.2400 + public Document document = null;
92.2401 + DocumentEvent.EventType mode = null;
92.2402 + public PlsqlBlockFactory blockFactory = null;
92.2403 +
92.2404 + public EventProperties(PlsqlBlockFactory blockFactory) {
92.2405 + this.blockFactory = blockFactory;
92.2406 + }
92.2407 + }
92.2408 +
92.2409 + private static class UpdateBlocksThread implements Runnable {
92.2410 +
92.2411 + @Override
92.2412 + public void run() {
92.2413 + synchronized (updateLock) {
92.2414 + while (updateEvents.size() > 0) {
92.2415 + EventProperties event = updateEvents.getFirst();
92.2416 + Document doc = event.document;
92.2417 + List<EventProperties> docList = new ArrayList<EventProperties>();
92.2418 +
92.2419 + while (event != null && event.document.equals(doc)) {
92.2420 + updateEvents.removeFirst();
92.2421 + docList.add(event);
92.2422 + event = null;
92.2423 + if (updateEvents.size() > 0) {
92.2424 + event = updateEvents.getFirst();
92.2425 + }
92.2426 + }
92.2427 +
92.2428 + docList.get(0).blockFactory.doUpdate(doc, docList);
92.2429 + }
92.2430 + }
92.2431 + }
92.2432 + }
92.2433 +
92.2434 + private synchronized void doUpdate(final Document document, final List<EventProperties> docList) {
92.2435 +
92.2436 + //make sure that the updates are run in the Swing thread
92.2437 + SwingUtilities.invokeLater(new Runnable() {
92.2438 +
92.2439 + @Override
92.2440 + public void run() {
92.2441 + setChanged();
92.2442 + updateBlocks(document, docList);
92.2443 + parseAliases();
92.2444 + notifyObservers(document);
92.2445 + clearChanged();
92.2446 + }
92.2447 + });
92.2448 + }
92.2449 +
92.2450 + private void addUpdateEvent(DocumentEvent e, DocumentEvent.EventType mode) {
92.2451 + synchronized (updateLock) {
92.2452 + if (updateBlocksTask == null) {
92.2453 + updateBlocksTask = RP.create(new UpdateBlocksThread());
92.2454 + }
92.2455 + updateBlocksTask.schedule(DEFAULT_WAIT_TIME);
92.2456 + addNewEvent(e, mode);
92.2457 + }
92.2458 + }
92.2459 +
92.2460 + /**
92.2461 + * Event fired on insert
92.2462 + * @param e
92.2463 + */
92.2464 + @Override
92.2465 + public void insertUpdate(DocumentEvent e) {
92.2466 + if (isSaveInProgress()) {
92.2467 + return;
92.2468 + }
92.2469 +
92.2470 + addUpdateEvent(e, DocumentEvent.EventType.INSERT);
92.2471 + }
92.2472 +
92.2473 + /**
92.2474 + * Event fired in remove
92.2475 + * @param e
92.2476 + */
92.2477 + @Override
92.2478 + public void removeUpdate(DocumentEvent e) {
92.2479 + if (isSaveInProgress()) {
92.2480 + return;
92.2481 + }
92.2482 + addUpdateEvent(e, DocumentEvent.EventType.REMOVE);
92.2483 + }
92.2484 +
92.2485 + /**
92.2486 + * trigged when opening a different document
92.2487 + * @param e
92.2488 + */
92.2489 + @Override
92.2490 + public void changedUpdate(DocumentEvent e) {
92.2491 + //It seems we don't have to handle this case since initHierarchy
92.2492 + // will always be called before this
92.2493 + }
92.2494 +
92.2495 + /**
92.2496 + * Update block hierarchy on a document event
92.2497 + * @param e
92.2498 + * @param action
92.2499 + */
92.2500 + public synchronized void initHierarchy(Document doc) {
92.2501 + clear();
92.2502 +
92.2503 + if (doc == null) {
92.2504 + return;
92.2505 + }
92.2506 +
92.2507 + docStartOffset = doc.getStartPosition().getOffset();
92.2508 + docEndOffset = doc.getEndPosition().getOffset();
92.2509 + Object obj = doc.getProperty("Listener");
92.2510 +
92.2511 + if ((obj == null) || (!obj.equals("YES"))) {
92.2512 + startParse = docStartOffset;
92.2513 + endParse = docEndOffset - 1;
92.2514 +
92.2515 + //clean block hierarchy
92.2516 + blockHierarchy.clear();
92.2517 + customFoldBlocks.clear();
92.2518 + getAliases(doc);
92.2519 + generateBlocks(doc);
92.2520 + //This property is added only to ensure that document listener is added only once
92.2521 + doc.putProperty("Listener", "YES");
92.2522 + doc.addDocumentListener(this);
92.2523 + }
92.2524 + }
92.2525 +
92.2526 + /**
92.2527 + * Method that will return the block within the start & end parse
92.2528 + * @param start
92.2529 + * @param end
92.2530 + * @return
92.2531 + */
92.2532 + private PlsqlBlock getParentBlock(List<PlsqlBlock> lstBlock, int start, int end) {
92.2533 + PlsqlBlock parent = null;
92.2534 + int count = lstBlock.size();
92.2535 + for (int i = 0; i < count; i++) {
92.2536 + PlsqlBlock tmp = lstBlock.get(i);
92.2537 + if ((tmp.getStartOffset() < start) && (tmp.getEndOffset() > end)) {
92.2538 + PlsqlBlock child = getParentBlock(tmp.getChildBlocks(), start, end);
92.2539 + if (child != null) {
92.2540 + parent = child;
92.2541 + } else {
92.2542 + parent = tmp;
92.2543 + }
92.2544 +
92.2545 + break;
92.2546 + }
92.2547 + }
92.2548 +
92.2549 + return parent;
92.2550 + }
92.2551 +
92.2552 + /**
92.2553 + * Get the line offset of the beginning of this block end line
92.2554 + * @param doc
92.2555 + * @param parent
92.2556 + * @return
92.2557 + */
92.2558 + private int getPreLineOfBlockEnd(Document doc, PlsqlBlock parent) {
92.2559 + TokenHierarchy tokenHier = TokenHierarchy.get(doc);
92.2560 + @SuppressWarnings("unchecked")
92.2561 + TokenSequence<PlsqlTokenId> ts = tokenHier.tokenSequence(PlsqlTokenId.language());
92.2562 + if (ts == null) {
92.2563 + return parent.getEndOffset();
92.2564 + }
92.2565 + int preEnd = parent.getEndOffset();
92.2566 +
92.2567 + //go to the previous line break
92.2568 + ts.move(preEnd);
92.2569 + boolean movePrevious = ts.movePrevious();
92.2570 + Token<PlsqlTokenId> tokenPre = ts.token();
92.2571 +
92.2572 + while (movePrevious) {
92.2573 + if (tokenPre.text().toString().contains("\n")) {
92.2574 + preEnd = tokenPre.offset(tokenHier);
92.2575 + break;
92.2576 + }
92.2577 + movePrevious = ts.movePrevious();
92.2578 + tokenPre = ts.token();
92.2579 + }
92.2580 +
92.2581 + return preEnd;
92.2582 + }
92.2583 +
92.2584 + private boolean isNotBlockStart(Token<PlsqlTokenId> current, TokenSequence<PlsqlTokenId> ts) {
92.2585 + boolean isNotBlockStart = false;
92.2586 + int offset = current.offset(tokenHierarchy);
92.2587 + Token<PlsqlTokenId> token = current;
92.2588 + Token<PlsqlTokenId> tokenPre = current;
92.2589 + int loopCount = 0;
92.2590 + while (ts.movePrevious()) {
92.2591 + token = ts.token();
92.2592 +
92.2593 + if (loopCount == 0 && token.id() == PlsqlTokenId.DOT) {
92.2594 + isNotBlockStart = true;
92.2595 + break;
92.2596 + } else if (token.id() == PlsqlTokenId.WHITESPACE) {
92.2597 + String preText = tokenPre.text().toString();
92.2598 + if (token.text().toString().contains("\n")) {
92.2599 + if (preText.equalsIgnoreCase("TYPE")
92.2600 + || preText.equalsIgnoreCase("GRANT")) {
92.2601 + isNotBlockStart = true;
92.2602 + }
92.2603 + break;
92.2604 + }
92.2605 + } else if (token.text().toString().equalsIgnoreCase("TYPE")) {
92.2606 + isNotBlockStart = true;
92.2607 + break;
92.2608 + } else {
92.2609 + tokenPre = token;
92.2610 + }
92.2611 + loopCount++;
92.2612 + }
92.2613 +
92.2614 + if (token.text().toString().equalsIgnoreCase("TYPE")
92.2615 + || token.text().toString().equalsIgnoreCase("GRANT")) {
92.2616 + isNotBlockStart = true;
92.2617 + }
92.2618 +
92.2619 + ts.move(offset);
92.2620 + ts.moveNext();
92.2621 + return isNotBlockStart;
92.2622 + }
92.2623 +
92.2624 + /**
92.2625 + * Get the line offset of the second line of this block start
92.2626 + * @param doc
92.2627 + * @param parent
92.2628 + * @return
92.2629 + */
92.2630 + private int getSecondLineOfBlock(Document doc, PlsqlBlock parent) {
92.2631 + TokenHierarchy tokenHier = TokenHierarchy.get(doc);
92.2632 + @SuppressWarnings("unchecked")
92.2633 + TokenSequence<PlsqlTokenId> ts = tokenHier.tokenSequence(PlsqlTokenId.language());
92.2634 + if (ts == null) {
92.2635 + return parent.getStartOffset();
92.2636 + }
92.2637 + int preStart = parent.getStartOffset();
92.2638 + ts.move(preStart);
92.2639 + boolean moveNext = ts.moveNext();
92.2640 + Token<PlsqlTokenId> tokenNext = ts.token();
92.2641 +
92.2642 + while (moveNext) {
92.2643 + if (tokenNext.text().toString().contains("\n")) {
92.2644 + preStart = tokenNext.offset(tokenHier);
92.2645 + break;
92.2646 + }
92.2647 + moveNext = ts.moveNext();
92.2648 + tokenNext = ts.token();
92.2649 + }
92.2650 +
92.2651 + return preStart;
92.2652 + }
92.2653 +
92.2654 + /**
92.2655 + * If any defines are changed change the affected names
92.2656 + */
92.2657 + private void parseAliases() {
92.2658 + if (!isDefineChanged) {
92.2659 + return;
92.2660 + }
92.2661 +
92.2662 + int size = blockHierarchy.size();
92.2663 + for (int i = 0; i < size; i++) {
92.2664 + PlsqlBlock block = blockHierarchy.get(i);
92.2665 + evaluateBlock(block);
92.2666 + }
92.2667 + }
92.2668 +
92.2669 + public boolean isAliasesChanged() {
92.2670 + return isDefineChanged;
92.2671 + }
92.2672 +
92.2673 + /**
92.2674 + * Method that will evaluate the given block and
92.2675 + * decide whether the name has to be changed
92.2676 + * @param block
92.2677 + */
92.2678 + private void evaluateBlock(PlsqlBlock block) {
92.2679 + String alias = block.getAlias();
92.2680 + if (!alias.equals("")) {
92.2681 + block.setName(getDefine(alias));
92.2682 + }
92.2683 +
92.2684 + int childCount = block.getChildBlocks().size();
92.2685 + for (int i = 0; i < childCount; i++) {
92.2686 + PlsqlBlock child = block.getChildBlocks().get(i);
92.2687 + evaluateBlock(child);
92.2688 + }
92.2689 + }
92.2690 +
92.2691 + /**
92.2692 + * Remove given block from the hierarchy
92.2693 + * @param blockHier
92.2694 + * @param block
92.2695 + */
92.2696 + private boolean removeBlock(List<PlsqlBlock> blockHier, PlsqlBlock block) {
92.2697 + int count = blockHier.size();
92.2698 + boolean isFound = false;
92.2699 +
92.2700 + for (int i = 0; i < count; i++) {
92.2701 + PlsqlBlock temp = blockHier.get(i);
92.2702 +
92.2703 + if ((temp.getStartOffset() == block.getStartOffset())
92.2704 + && (temp.getEndOffset() == block.getEndOffset())) {
92.2705 + blockHier.remove(temp);
92.2706 + isFound = true;
92.2707 + break;
92.2708 + } else {
92.2709 + if ((temp.getStartOffset() < block.getStartOffset())
92.2710 + && (temp.getEndOffset() > block.getEndOffset())) { //block is a child
92.2711 +
92.2712 + if (removeBlock(temp.getChildBlocks(), block)) {
92.2713 + isFound = true;
92.2714 + break;
92.2715 + }
92.2716 + }
92.2717 + }
92.2718 + }
92.2719 +
92.2720 + return isFound;
92.2721 + }
92.2722 +
92.2723 + /**
92.2724 + * Add child blocks enclosed by the change area to the remove list (do not update the parse area here, done only in REMOVE)
92.2725 + * @param doc
92.2726 + * @param plsqlBlocks
92.2727 + * @param toBeRemoved
92.2728 + * @param startOffset
92.2729 + * @param endOffset
92.2730 + * @return
92.2731 + */
92.2732 + private void removeEnclosedBlocks(Document doc, List<PlsqlBlock> plsqlBlocks, int startOffset, int endOffset) {
92.2733 + int count = plsqlBlocks.size();
92.2734 +
92.2735 + for (int i = count - 1; i >= 0; i--) {
92.2736 + PlsqlBlock block = plsqlBlocks.get(i);
92.2737 +
92.2738 + if ((block.getEndOffset() <= endOffset)
92.2739 + && (block.getStartOffset() >= startOffset)) { //blocks which are enclosed by the affected area
92.2740 + removeBlock(block, plsqlBlocks);
92.2741 + } else {
92.2742 + removeEnclosedBlocks(doc, block.getChildBlocks(), startOffset, endOffset);
92.2743 + }
92.2744 + }
92.2745 + }
92.2746 +
92.2747 + /**
92.2748 + * Add child blocks affected by the change area to the remove list
92.2749 + * and update the parse area
92.2750 + * @param doc
92.2751 + * @param plsqlBlocks
92.2752 + * @param toBeRemoved
92.2753 + * @param startOffset
92.2754 + * @param endOffset
92.2755 + * @return
92.2756 + */
92.2757 + private boolean removeBlocksWithin(Document doc, List<PlsqlBlock> plsqlBlocks, int startOffset, int endOffset) {
92.2758 + boolean blockIsFound = false;
92.2759 +
92.2760 + int count = plsqlBlocks.size();
92.2761 +
92.2762 + for (int i = count - 1; i >= 0; i--) {
92.2763 + PlsqlBlock block = plsqlBlocks.get(i);
92.2764 + int blockStart = block.getStartOffset();
92.2765 + int blockEnd = block.getEndOffset();
92.2766 + //assumption on max length of a package/procedure/function first line
92.2767 + if ((Math.abs(blockEnd - endOffset) < 150) && (checkSameLine(doc, blockEnd, endOffset))) {
92.2768 + removeBlock(block, plsqlBlocks);
92.2769 + blockIsFound = true;
92.2770 + //assumption on max length of a package/procedure/function first line
92.2771 + } else if ((Math.abs(blockStart - startOffset) < 150) && (checkSameLine(doc, blockStart, startOffset))) {
92.2772 + removeBlock(block, plsqlBlocks);
92.2773 + blockIsFound = true;
92.2774 + } else if ((blockEnd < endOffset)
92.2775 + && (blockStart > startOffset)) { //blocks which are enclosed by the affected area
92.2776 + removeBlock(block, plsqlBlocks);
92.2777 + blockIsFound = true;
92.2778 + } else if ((blockEnd > endOffset) && (blockStart < startOffset)
92.2779 + && (block.getType() != PlsqlBlockType.PACKAGE && block.getType() != PlsqlBlockType.PACKAGE_BODY)) {
92.2780 + //affected area included in the block we need to remove the block.
92.2781 + //Idealy we should remove all types, but concerning on the performance did this
92.2782 + //comment might be removed here
92.2783 + removeBlock(block, plsqlBlocks);
92.2784 + blockIsFound = true;
92.2785 + } else {
92.2786 + boolean isFound = removeBlocksWithin(doc, block.getChildBlocks(), startOffset, endOffset);
92.2787 + if (!isFound) {
92.2788 + if ((blockStart >= startOffset)
92.2789 + && (blockStart <= endOffset)
92.2790 + && (blockEnd >= endOffset)) {//first part of the block enclosed
92.2791 + removeBlock(block, plsqlBlocks);
92.2792 + blockIsFound = true;
92.2793 + } else if ((blockEnd <= endOffset)
92.2794 + && (blockEnd >= startOffset)
92.2795 + && (blockStart <= startOffset)) {//end part of the block enclosed
92.2796 + removeBlock(block, plsqlBlocks);
92.2797 + blockIsFound = true;
92.2798 + } else if ((blockEnd < endOffset)
92.2799 + && (blockStart > startOffset)) { //blocks which are enclosed by the affected area
92.2800 + removeBlock(block, plsqlBlocks);
92.2801 + blockIsFound = true;
92.2802 + } else if ((blockEnd > endOffset) && (blockStart < startOffset)
92.2803 + && (block.getType() != PlsqlBlockType.PACKAGE && block.getType() != PlsqlBlockType.PACKAGE_BODY)) {
92.2804 + //affected area included in the block we need to remove the block.
92.2805 + //Idealy we should remove all types, but concerning on the performance did this
92.2806 + //comment might be removed here
92.2807 + removeBlock(block, plsqlBlocks);
92.2808 + blockIsFound = true;
92.2809 + }
92.2810 + }
92.2811 + }
92.2812 + }
92.2813 + return blockIsFound;
92.2814 + }
92.2815 +
92.2816 + /**
92.2817 + * Remove custom fold blocks that are there within the parse area
92.2818 + * @param customFoldBlocks
92.2819 + * @param startParse
92.2820 + * @param endParse
92.2821 + */
92.2822 + private void removeCustomBlocks(List<PlsqlBlock> customFoldBlocks, int startParse, int endParse) {
92.2823 + for (int i = customFoldBlocks.size() - 1; i >= 0; i--) {
92.2824 + PlsqlBlock block = customFoldBlocks.get(i);
92.2825 + if ((block.getStartOffset() >= startParse)
92.2826 + && (block.getEndOffset() <= endParse)) {
92.2827 + customFoldBlocks.remove(i);
92.2828 + } else if ((block.getEndOffset() <= endParse)
92.2829 + && (block.getEndOffset() >= startParse)
92.2830 + && (block.getStartOffset() <= startParse)) {
92.2831 + customFoldBlocks.remove(i);
92.2832 + } else if ((block.getStartOffset() >= startParse)
92.2833 + && (block.getStartOffset() <= endParse)
92.2834 + && (block.getEndOffset() >= endParse)) {
92.2835 + customFoldBlocks.remove(i);
92.2836 + }
92.2837 + }
92.2838 + }
92.2839 +
92.2840 + /**
92.2841 + * If given block exists in the hier delete
92.2842 + * @param child
92.2843 + * @param parentBlocks
92.2844 + */
92.2845 + private void removeFromParent(PlsqlBlock child, List<PlsqlBlock> parentBlocks) {
92.2846 + for (int i = 0; i < parentBlocks.size(); i++) {
92.2847 + PlsqlBlock tmp = parentBlocks.get(i);
92.2848 + if ((tmp.getEndOffset() == child.getEndOffset())
92.2849 + && (tmp.getStartOffset() == child.getStartOffset())) {
92.2850 + parentBlocks.remove(tmp);
92.2851 + break;
92.2852 + }
92.2853 + }
92.2854 + }
92.2855 +
92.2856 + private boolean sqlPlusLine(TokenSequence<PlsqlTokenId> ts) {
92.2857 + int offset = ts.offset();
92.2858 + boolean isSqlPlus = false;
92.2859 + Token<PlsqlTokenId> token = null;
92.2860 + Token<PlsqlTokenId> tokenPre = null;
92.2861 + while (ts.movePrevious()) {
92.2862 + token = ts.token();
92.2863 + if (token.id() == PlsqlTokenId.WHITESPACE && token.toString().contains("\n")) {
92.2864 + if (tokenPre != null && tokenPre.id() == PlsqlTokenId.SQL_PLUS) {
92.2865 + isSqlPlus = true;
92.2866 + }
92.2867 + break;
92.2868 + }
92.2869 +
92.2870 + if (token.id() != PlsqlTokenId.WHITESPACE) {
92.2871 + tokenPre = token;
92.2872 + }
92.2873 + }
92.2874 +
92.2875 + if (tokenPre != null && tokenPre.id() == PlsqlTokenId.SQL_PLUS) {
92.2876 + isSqlPlus = true;
92.2877 + }
92.2878 +
92.2879 + ts.move(offset);
92.2880 + ts.moveNext();
92.2881 + return isSqlPlus;
92.2882 + }
92.2883 +
92.2884 + /**
92.2885 + * Update block hierarchy based on the document event and the action
92.2886 + */
92.2887 + private synchronized void updateBlocks(Document doc, List<EventProperties> docList) {
92.2888 + clear();
92.2889 + try {
92.2890 + ((AbstractDocument) doc).readLock();
92.2891 +
92.2892 + docStartOffset = doc.getStartPosition().getOffset();
92.2893 + docEndOffset = doc.getEndPosition().getOffset();
92.2894 +
92.2895 + EventProperties event = docList.get(0);
92.2896 + //Area to be re parsed
92.2897 + startParse = event.offset;
92.2898 + endParse = event.offset + event.length;
92.2899 + if (event.mode == DocumentEvent.EventType.REMOVE) {
92.2900 + endParse = startParse;
92.2901 + }
92.2902 +
92.2903 + for (int x = 0; x < docList.size(); x++) {
92.2904 + event = docList.get(x);
92.2905 + int offset = event.offset;
92.2906 + int length = event.length;
92.2907 + DocumentEvent.EventType action = event.mode;
92.2908 +
92.2909 + //get the affected area
92.2910 + int startOffset = offset;
92.2911 + int endOffset = startOffset + length;
92.2912 + if (action == DocumentEvent.EventType.REMOVE) {
92.2913 + endOffset = startOffset;
92.2914 + }
92.2915 +
92.2916 + //If action is remove, remove code folds in the affected area and repass them
92.2917 + if (action == DocumentEvent.EventType.REMOVE || action == DocumentEvent.EventType.INSERT) {
92.2918 + if (action == DocumentEvent.EventType.REMOVE) {
92.2919 + //Rearrange the offsets of the blocks below the area
92.2920 + removeEnclosedBlocks(doc, blockHierarchy, startOffset, startOffset + length);
92.2921 + changeOffSet(blockHierarchy, startOffset, -length, true, false);
92.2922 + changeOffSet(customFoldBlocks, startOffset, -length, true, false);
92.2923 + changeOffSet(toBeRemoved, startOffset, -length, false, true);
92.2924 + changedLength = changedLength - length;
92.2925 + } else if (action == DocumentEvent.EventType.INSERT) {
92.2926 + //Rearrange the offsets of the blocks below the start of the area
92.2927 + changeOffSet(blockHierarchy, startOffset, length, true, false);
92.2928 + changeOffSet(customFoldBlocks, startOffset, length, true, false);
92.2929 + changeOffSet(toBeRemoved, startOffset, length, false, true);
92.2930 + changedLength = changedLength + length;
92.2931 + }
92.2932 + //adjust offsets according to the change
92.2933 + if (startParse > startOffset) {
92.2934 + startParse = startOffset;
92.2935 + }
92.2936 + if (endParse < endOffset) {
92.2937 + endParse = endOffset;
92.2938 + }
92.2939 +
92.2940 + int count = blockHierarchy.size();
92.2941 + removeBlocksWithin(doc, blockHierarchy, startOffset, endOffset);
92.2942 + //If action removeimmediately before block and after block
92.2943 + if (count == 0) {//If no blocks pass the whole root
92.2944 +
92.2945 + startParse = docStartOffset;
92.2946 + endParse = docEndOffset - 1;
92.2947 + } else {
92.2948 + if (startParse == startOffset) {//if start offset already adjusted no need to do again
92.2949 +
92.2950 + PlsqlBlock block = null;
92.2951 + block = getImmediateBefore(blockHierarchy, block, startOffset);
92.2952 + PlsqlBlock parent = getParentBlock(blockHierarchy, startParse, endParse);
92.2953 +
92.2954 + if ((parent != null) && (block != null)) {
92.2955 + if (parent.getStartOffset() > block.getStartOffset()) {
92.2956 + int newStart = getSecondLineOfBlock(doc, parent); // we are not going to remove the parent here
92.2957 + if (newStart < startParse) {
92.2958 + startParse = newStart;
92.2959 + }
92.2960 + } else {
92.2961 + removeBlock(block, parent.getChildBlocks());
92.2962 + }
92.2963 + } else {
92.2964 + if (block != null) {
92.2965 + removeBlock(block, blockHierarchy);
92.2966 + } else if (parent != null) { // we are not going to remove the parent here
92.2967 +
92.2968 + int newStart = getSecondLineOfBlock(doc, parent);
92.2969 + if (newStart < startParse) {
92.2970 + startParse = newStart;
92.2971 + }
92.2972 + } else {
92.2973 + startParse = docStartOffset;
92.2974 + }
92.2975 + }
92.2976 + }
92.2977 +
92.2978 + if (endParse == endOffset) {//if end offset already adjusted no need to do again
92.2979 +
92.2980 + PlsqlBlock block = null;
92.2981 + block = getImmediateAfter(blockHierarchy, block, endOffset);
92.2982 + PlsqlBlock parent = getParentBlock(blockHierarchy, startParse, endParse);
92.2983 +
92.2984 + if ((parent != null) && (block != null)) {
92.2985 + if (parent.getEndOffset() < block.getEndOffset()) {
92.2986 + int newEnd = getPreLineOfBlockEnd(doc, parent); // we are not going to remove the parent here
92.2987 + if (newEnd > endParse) {
92.2988 + endParse = newEnd;
92.2989 + }
92.2990 + } else {
92.2991 + removeBlock(block, parent.getChildBlocks());
92.2992 + }
92.2993 + } else {
92.2994 + if (block != null) {
92.2995 + removeBlock(block, blockHierarchy);
92.2996 + } else if (parent != null) { // we are not going to remove the parent here
92.2997 +
92.2998 + int newEnd = getPreLineOfBlockEnd(doc, parent);
92.2999 + if (newEnd > endParse) {
92.3000 + endParse = newEnd;
92.3001 + }
92.3002 + } else {
92.3003 + endParse = docEndOffset - 1;
92.3004 + }
92.3005 + }
92.3006 + }
92.3007 +
92.3008 + //Remove custom fold blocks that are there within the parse area
92.3009 + removeCustomBlocks(customFoldBlocks, startParse, endParse);
92.3010 +
92.3011 + //When files are deleted and written after opening once following can happen
92.3012 + if ((endParse < 0) || (endParse > docEndOffset - 1)) {
92.3013 + endParse = docEndOffset - 1;
92.3014 + }
92.3015 +
92.3016 + if (startParse < 0) {
92.3017 + startParse = docStartOffset;
92.3018 + }
92.3019 +
92.3020 + if (startParse > docEndOffset - 1) {
92.3021 + startParse = docEndOffset - 1;
92.3022 + }
92.3023 + }
92.3024 + } else { //UPDATE pass again
92.3025 +
92.3026 + startParse = docStartOffset;
92.3027 + endParse = docEndOffset - 1;
92.3028 +
92.3029 + //clean block hierarchy
92.3030 + blockHierarchy.clear();
92.3031 + customFoldBlocks.clear();
92.3032 +
92.3033 + //we are going for a reparse, remove all the events for this doc
92.3034 + docList.clear();
92.3035 + break;
92.3036 + }
92.3037 + }
92.3038 +
92.3039 + if (startParse >= endParse) //Can happen in removes
92.3040 + {
92.3041 + return;
92.3042 + }
92.3043 +
92.3044 + //Check whether defines are changed from the affected area
92.3045 + checkAffected(doc, startParse, endParse);
92.3046 +
92.3047 + if (isDefineChanged) {
92.3048 + getAliases(doc);
92.3049 + }
92.3050 +
92.3051 + //pass affected section again
92.3052 + generateBlocks(doc);
92.3053 +
92.3054 + } catch (Exception e) {
92.3055 + ErrorManager.getDefault().notify(e);
92.3056 + } finally {
92.3057 + ((AbstractDocument) doc).readUnlock();
92.3058 + }
92.3059 + }
92.3060 +
92.3061 + /**
92.3062 + * Get block which is immediately before the given offset
92.3063 + * @param blocks
92.3064 + * @param block
92.3065 + * @param offset
92.3066 + * @return
92.3067 + */
92.3068 + private PlsqlBlock getImmediateBefore(List blocks, PlsqlBlock block, int offset) {
92.3069 + int count = blocks.size();
92.3070 +
92.3071 + for (int i = 0; i < count; i++) {
92.3072 + PlsqlBlock temp = (PlsqlBlock) blocks.get(i);
92.3073 + //check from children
92.3074 + PlsqlBlock child = getImmediateBefore(temp.getChildBlocks(), block, offset);
92.3075 if (child != null) {
92.3076 - parent = child;
92.3077 - } else {
92.3078 - parent = tmp;
92.3079 + block = child;
92.3080 }
92.3081
92.3082 - break;
92.3083 - }
92.3084 - }
92.3085 -
92.3086 - return parent;
92.3087 - }
92.3088 -
92.3089 - /**
92.3090 - * Get the line offset of the beginning of this block end line
92.3091 - * @param doc
92.3092 - * @param parent
92.3093 - * @return
92.3094 - */
92.3095 - private int getPreLineOfBlockEnd(Document doc, PlsqlBlock parent) {
92.3096 - TokenHierarchy tokenHier = TokenHierarchy.get(doc);
92.3097 - @SuppressWarnings("unchecked")
92.3098 - TokenSequence<PlsqlTokenId> ts = tokenHier.tokenSequence(PlsqlTokenId.language());
92.3099 - if (ts == null) {
92.3100 - return parent.getEndOffset();
92.3101 - }
92.3102 - int preEnd = parent.getEndOffset();
92.3103 -
92.3104 - //go to the previous line break
92.3105 - ts.move(preEnd);
92.3106 - boolean movePrevious = ts.movePrevious();
92.3107 - Token<PlsqlTokenId> tokenPre = ts.token();
92.3108 -
92.3109 - while (movePrevious) {
92.3110 - if (tokenPre.text().toString().contains("\n")) {
92.3111 - preEnd = tokenPre.offset(tokenHier);
92.3112 - break;
92.3113 - }
92.3114 - movePrevious = ts.movePrevious();
92.3115 - tokenPre = ts.token();
92.3116 - }
92.3117 -
92.3118 - return preEnd;
92.3119 - }
92.3120 -
92.3121 - private boolean isNotBlockStart(Token<PlsqlTokenId> current, TokenSequence<PlsqlTokenId> ts) {
92.3122 - boolean isNotBlockStart = false;
92.3123 - int offset = current.offset(tokenHierarchy);
92.3124 - Token<PlsqlTokenId> token = current;
92.3125 - Token<PlsqlTokenId> tokenPre = current;
92.3126 - int loopCount = 0;
92.3127 - while (ts.movePrevious()) {
92.3128 - token = ts.token();
92.3129 -
92.3130 - if (loopCount == 0 && token.id() == PlsqlTokenId.DOT) {
92.3131 - isNotBlockStart = true;
92.3132 - break;
92.3133 - } else if (token.id() == PlsqlTokenId.WHITESPACE) {
92.3134 - String preText = tokenPre.text().toString();
92.3135 - if (token.text().toString().contains("\n")) {
92.3136 - if (preText.equalsIgnoreCase("TYPE")
92.3137 - || preText.equalsIgnoreCase("GRANT")) {
92.3138 - isNotBlockStart = true;
92.3139 - }
92.3140 - break;
92.3141 + if ((temp.getEndOffset() < offset)
92.3142 + && ((block == null) || (block.getEndOffset() < temp.getEndOffset()))) {
92.3143 + block = temp;
92.3144 }
92.3145 - } else if (token.text().toString().equalsIgnoreCase("TYPE")) {
92.3146 - isNotBlockStart = true;
92.3147 - break;
92.3148 - } else {
92.3149 - tokenPre = token;
92.3150 - }
92.3151 - loopCount++;
92.3152 - }
92.3153 -
92.3154 - if (token.text().toString().equalsIgnoreCase("TYPE")
92.3155 - || token.text().toString().equalsIgnoreCase("GRANT")) {
92.3156 - isNotBlockStart = true;
92.3157 - }
92.3158 -
92.3159 - ts.move(offset);
92.3160 - ts.moveNext();
92.3161 - return isNotBlockStart;
92.3162 - }
92.3163 -
92.3164 - /**
92.3165 - * Get the line offset of the second line of this block start
92.3166 - * @param doc
92.3167 - * @param parent
92.3168 - * @return
92.3169 - */
92.3170 - private int getSecondLineOfBlock(Document doc, PlsqlBlock parent) {
92.3171 - TokenHierarchy tokenHier = TokenHierarchy.get(doc);
92.3172 - @SuppressWarnings("unchecked")
92.3173 - TokenSequence<PlsqlTokenId> ts = tokenHier.tokenSequence(PlsqlTokenId.language());
92.3174 - if (ts == null) {
92.3175 - return parent.getStartOffset();
92.3176 - }
92.3177 - int preStart = parent.getStartOffset();
92.3178 - ts.move(preStart);
92.3179 - boolean moveNext = ts.moveNext();
92.3180 - Token<PlsqlTokenId> tokenNext = ts.token();
92.3181 -
92.3182 - while (moveNext) {
92.3183 - if (tokenNext.text().toString().contains("\n")) {
92.3184 - preStart = tokenNext.offset(tokenHier);
92.3185 - break;
92.3186 - }
92.3187 - moveNext = ts.moveNext();
92.3188 - tokenNext = ts.token();
92.3189 - }
92.3190 -
92.3191 - return preStart;
92.3192 - }
92.3193 -
92.3194 - /**
92.3195 - * If any defines are changed change the affected names
92.3196 - */
92.3197 - private void parseAliases() {
92.3198 - if (!isDefineChanged) {
92.3199 - return;
92.3200 - }
92.3201 -
92.3202 - int size = blockHierarchy.size();
92.3203 - for (int i = 0; i < size; i++) {
92.3204 - PlsqlBlock block = blockHierarchy.get(i);
92.3205 - evaluateBlock(block);
92.3206 - }
92.3207 - }
92.3208 -
92.3209 - public boolean isAliasesChanged() {
92.3210 - return isDefineChanged;
92.3211 - }
92.3212 -
92.3213 - /**
92.3214 - * Method that will evaluate the given block and
92.3215 - * decide whether the name has to be changed
92.3216 - * @param block
92.3217 - */
92.3218 - private void evaluateBlock(PlsqlBlock block) {
92.3219 - String alias = block.getAlias();
92.3220 - if (!alias.equals("")) {
92.3221 - block.setName(getDefine(alias));
92.3222 - }
92.3223 -
92.3224 - int childCount = block.getChildBlocks().size();
92.3225 - for (int i = 0; i < childCount; i++) {
92.3226 - PlsqlBlock child = block.getChildBlocks().get(i);
92.3227 - evaluateBlock(child);
92.3228 - }
92.3229 - }
92.3230 -
92.3231 - /**
92.3232 - * Remove given block from the hierarchy
92.3233 - * @param blockHier
92.3234 - * @param block
92.3235 - */
92.3236 - private boolean removeBlock(List<PlsqlBlock> blockHier, PlsqlBlock block) {
92.3237 - int count = blockHier.size();
92.3238 - boolean isFound = false;
92.3239 -
92.3240 - for (int i = 0; i < count; i++) {
92.3241 - PlsqlBlock temp = blockHier.get(i);
92.3242 -
92.3243 - if ((temp.getStartOffset() == block.getStartOffset())
92.3244 - && (temp.getEndOffset() == block.getEndOffset())) {
92.3245 - blockHier.remove(temp);
92.3246 - isFound = true;
92.3247 - break;
92.3248 - } else {
92.3249 - if ((temp.getStartOffset() < block.getStartOffset())
92.3250 - && (temp.getEndOffset() > block.getEndOffset())) { //block is a child
92.3251 -
92.3252 - if (removeBlock(temp.getChildBlocks(), block)) {
92.3253 - isFound = true;
92.3254 - break;
92.3255 - }
92.3256 + }
92.3257 +
92.3258 + return block;
92.3259 + }
92.3260 +
92.3261 + /**
92.3262 + * Get fold which is immediately after the given offset
92.3263 + * @param blocks
92.3264 + * @param block
92.3265 + * @param offset
92.3266 + * @return
92.3267 + */
92.3268 + private PlsqlBlock getImmediateAfter(List<PlsqlBlock> blocks, PlsqlBlock block, int offset) {
92.3269 + int count = blocks.size();
92.3270 +
92.3271 + for (int i = 0; i < count; i++) {
92.3272 + PlsqlBlock temp = blocks.get(i);
92.3273 + //check from children
92.3274 + PlsqlBlock child = getImmediateAfter(temp.getChildBlocks(), block, offset);
92.3275 + if (child != null) {
92.3276 + block = child;
92.3277 }
92.3278 - }
92.3279 - }
92.3280 -
92.3281 - return isFound;
92.3282 - }
92.3283 -
92.3284 - /**
92.3285 - * Add child blocks enclosed by the change area to the remove list (do not update the parse area here, done only in REMOVE)
92.3286 - * @param doc
92.3287 - * @param plsqlBlocks
92.3288 - * @param toBeRemoved
92.3289 - * @param startOffset
92.3290 - * @param endOffset
92.3291 - * @return
92.3292 - */
92.3293 - private void removeEnclosedBlocks(Document doc, List<PlsqlBlock> plsqlBlocks, int startOffset, int endOffset) {
92.3294 - int count = plsqlBlocks.size();
92.3295 -
92.3296 - for (int i = count - 1; i >= 0; i--) {
92.3297 - PlsqlBlock block = plsqlBlocks.get(i);
92.3298 -
92.3299 - if ((block.getEndOffset() <= endOffset)
92.3300 - && (block.getStartOffset() >= startOffset)) { //blocks which are enclosed by the affected area
92.3301 - removeBlock(block, plsqlBlocks);
92.3302 - } else {
92.3303 - removeEnclosedBlocks(doc, block.getChildBlocks(), startOffset, endOffset);
92.3304 - }
92.3305 - }
92.3306 - }
92.3307 -
92.3308 - /**
92.3309 - * Add child blocks affected by the change area to the remove list
92.3310 - * and update the parse area
92.3311 - * @param doc
92.3312 - * @param plsqlBlocks
92.3313 - * @param toBeRemoved
92.3314 - * @param startOffset
92.3315 - * @param endOffset
92.3316 - * @return
92.3317 - */
92.3318 - private boolean removeBlocksWithin(Document doc, List<PlsqlBlock> plsqlBlocks, int startOffset, int endOffset) {
92.3319 - boolean blockIsFound = false;
92.3320 -
92.3321 - int count = plsqlBlocks.size();
92.3322 -
92.3323 - for (int i = count - 1; i >= 0; i--) {
92.3324 - PlsqlBlock block = plsqlBlocks.get(i);
92.3325 - int blockStart = block.getStartOffset();
92.3326 - int blockEnd = block.getEndOffset();
92.3327 - //assumption on max length of a package/procedure/function first line
92.3328 - if ((Math.abs(blockEnd - endOffset) < 150) && (checkSameLine(doc, blockEnd, endOffset))) {
92.3329 - removeBlock(block, plsqlBlocks);
92.3330 - blockIsFound = true;
92.3331 - //assumption on max length of a package/procedure/function first line
92.3332 - } else if ((Math.abs(blockStart - startOffset) < 150) && (checkSameLine(doc, blockStart, startOffset))) {
92.3333 - removeBlock(block, plsqlBlocks);
92.3334 - blockIsFound = true;
92.3335 - } else if ((blockEnd < endOffset)
92.3336 - && (blockStart > startOffset)) { //blocks which are enclosed by the affected area
92.3337 - removeBlock(block, plsqlBlocks);
92.3338 - blockIsFound = true;
92.3339 - } else if ((blockEnd > endOffset) && (blockStart < startOffset)
92.3340 - && (block.getType() != PlsqlBlockType.PACKAGE && block.getType() != PlsqlBlockType.PACKAGE_BODY)) {
92.3341 - //affected area included in the block we need to remove the block.
92.3342 - //Idealy we should remove all types, but concerning on the performance did this
92.3343 - //comment might be removed here
92.3344 - removeBlock(block, plsqlBlocks);
92.3345 - blockIsFound = true;
92.3346 - } else {
92.3347 - boolean isFound = removeBlocksWithin(doc, block.getChildBlocks(), startOffset, endOffset);
92.3348 - if (!isFound) {
92.3349 - if ((blockStart >= startOffset)
92.3350 - && (blockStart <= endOffset)
92.3351 - && (blockEnd >= endOffset)) {//first part of the block enclosed
92.3352 - removeBlock(block, plsqlBlocks);
92.3353 - blockIsFound = true;
92.3354 - } else if ((blockEnd <= endOffset)
92.3355 - && (blockEnd >= startOffset)
92.3356 - && (blockStart <= startOffset)) {//end part of the block enclosed
92.3357 - removeBlock(block, plsqlBlocks);
92.3358 - blockIsFound = true;
92.3359 - } else if ((blockEnd < endOffset)
92.3360 - && (blockStart > startOffset)) { //blocks which are enclosed by the affected area
92.3361 - removeBlock(block, plsqlBlocks);
92.3362 - blockIsFound = true;
92.3363 - } else if ((blockEnd > endOffset) && (blockStart < startOffset)
92.3364 - && (block.getType() != PlsqlBlockType.PACKAGE && block.getType() != PlsqlBlockType.PACKAGE_BODY)) {
92.3365 - //affected area included in the block we need to remove the block.
92.3366 - //Idealy we should remove all types, but concerning on the performance did this
92.3367 - //comment might be removed here
92.3368 - removeBlock(block, plsqlBlocks);
92.3369 - blockIsFound = true;
92.3370 - }
92.3371 +
92.3372 + if ((temp.getStartOffset() > offset)
92.3373 + && ((block == null) || (block.getStartOffset() > temp.getStartOffset()))) {
92.3374 + block = temp;
92.3375 }
92.3376 - }
92.3377 - }
92.3378 - return blockIsFound;
92.3379 - }
92.3380 -
92.3381 - /**
92.3382 - * Remove custom fold blocks that are there within the parse area
92.3383 - * @param customFoldBlocks
92.3384 - * @param startParse
92.3385 - * @param endParse
92.3386 - */
92.3387 - private void removeCustomBlocks(List<PlsqlBlock> customFoldBlocks, int startParse, int endParse) {
92.3388 - for (int i = customFoldBlocks.size() - 1; i >= 0; i--) {
92.3389 - PlsqlBlock block = customFoldBlocks.get(i);
92.3390 - if ((block.getStartOffset() >= startParse)
92.3391 - && (block.getEndOffset() <= endParse)) {
92.3392 - customFoldBlocks.remove(i);
92.3393 - } else if ((block.getEndOffset() <= endParse)
92.3394 - && (block.getEndOffset() >= startParse)
92.3395 - && (block.getStartOffset() <= startParse)) {
92.3396 - customFoldBlocks.remove(i);
92.3397 - } else if ((block.getStartOffset() >= startParse)
92.3398 - && (block.getStartOffset() <= endParse)
92.3399 - && (block.getEndOffset() >= endParse)) {
92.3400 - customFoldBlocks.remove(i);
92.3401 - }
92.3402 - }
92.3403 - }
92.3404 -
92.3405 - /**
92.3406 - * If given block exists in the hier delete
92.3407 - * @param child
92.3408 - * @param parentBlocks
92.3409 - */
92.3410 - private void removeFromParent(PlsqlBlock child, List<PlsqlBlock> parentBlocks) {
92.3411 - for (int i = 0; i < parentBlocks.size(); i++) {
92.3412 - PlsqlBlock tmp = parentBlocks.get(i);
92.3413 - if ((tmp.getEndOffset() == child.getEndOffset())
92.3414 - && (tmp.getStartOffset() == child.getStartOffset())) {
92.3415 - parentBlocks.remove(tmp);
92.3416 - break;
92.3417 - }
92.3418 - }
92.3419 - }
92.3420 -
92.3421 - private boolean sqlPlusLine(TokenSequence<PlsqlTokenId> ts) {
92.3422 - int offset = ts.offset();
92.3423 - boolean isSqlPlus = false;
92.3424 - Token<PlsqlTokenId> token = null;
92.3425 - Token<PlsqlTokenId> tokenPre = null;
92.3426 - while (ts.movePrevious()) {
92.3427 - token = ts.token();
92.3428 - if (token.id() == PlsqlTokenId.WHITESPACE && token.toString().contains("\n")) {
92.3429 - if (tokenPre != null && tokenPre.id() == PlsqlTokenId.SQL_PLUS) {
92.3430 - isSqlPlus = true;
92.3431 - }
92.3432 - break;
92.3433 - }
92.3434 -
92.3435 - if (token.id() != PlsqlTokenId.WHITESPACE) {
92.3436 - tokenPre = token;
92.3437 - }
92.3438 - }
92.3439 -
92.3440 - if (tokenPre != null && tokenPre.id() == PlsqlTokenId.SQL_PLUS) {
92.3441 - isSqlPlus = true;
92.3442 - }
92.3443 -
92.3444 - ts.move(offset);
92.3445 - ts.moveNext();
92.3446 - return isSqlPlus;
92.3447 - }
92.3448 -
92.3449 - /**
92.3450 - * Update block hierarchy based on the document event and the action
92.3451 - */
92.3452 - private synchronized void updateBlocks(Document doc, List<EventProperties> docList) {
92.3453 - clear();
92.3454 - try {
92.3455 - ((AbstractDocument) doc).readLock();
92.3456 -
92.3457 - docStartOffset = doc.getStartPosition().getOffset();
92.3458 - docEndOffset = doc.getEndPosition().getOffset();
92.3459 -
92.3460 - EventProperties event = docList.get(0);
92.3461 - //Area to be re parsed
92.3462 - startParse = event.offset;
92.3463 - endParse = event.offset + event.length;
92.3464 - if (event.mode == DocumentEvent.EventType.REMOVE) {
92.3465 - endParse = startParse;
92.3466 - }
92.3467 -
92.3468 - for (int x = 0; x < docList.size(); x++) {
92.3469 - event = docList.get(x);
92.3470 - int offset = event.offset;
92.3471 - int length = event.length;
92.3472 - DocumentEvent.EventType action = event.mode;
92.3473 -
92.3474 - //get the affected area
92.3475 - int startOffset = offset;
92.3476 - int endOffset = startOffset + length;
92.3477 - if (action == DocumentEvent.EventType.REMOVE) {
92.3478 - endOffset = startOffset;
92.3479 - }
92.3480 -
92.3481 - //If action is remove, remove code folds in the affected area and repass them
92.3482 - if (action == DocumentEvent.EventType.REMOVE || action == DocumentEvent.EventType.INSERT) {
92.3483 - if (action == DocumentEvent.EventType.REMOVE) {
92.3484 - //Rearrange the offsets of the blocks below the area
92.3485 - removeEnclosedBlocks(doc, blockHierarchy, startOffset, startOffset + length);
92.3486 - changeOffSet(blockHierarchy, startOffset, -length, true, false);
92.3487 - changeOffSet(customFoldBlocks, startOffset, -length, true, false);
92.3488 - changeOffSet(toBeRemoved, startOffset, -length, false, true);
92.3489 - changedLength = changedLength - length;
92.3490 - } else if (action == DocumentEvent.EventType.INSERT) {
92.3491 - //Rearrange the offsets of the blocks below the start of the area
92.3492 - changeOffSet(blockHierarchy, startOffset, length, true, false);
92.3493 - changeOffSet(customFoldBlocks, startOffset, length, true, false);
92.3494 - changeOffSet(toBeRemoved, startOffset, length, false, true);
92.3495 - changedLength = changedLength + length;
92.3496 - }
92.3497 - //adjust offsets according to the change
92.3498 - if (startParse > startOffset) {
92.3499 - startParse = startOffset;
92.3500 - }
92.3501 - if (endParse < endOffset) {
92.3502 - endParse = endOffset;
92.3503 - }
92.3504 -
92.3505 - int count = blockHierarchy.size();
92.3506 - removeBlocksWithin(doc, blockHierarchy, startOffset, endOffset);
92.3507 - //If action removeimmediately before block and after block
92.3508 - if (count == 0) {//If no blocks pass the whole root
92.3509 -
92.3510 - startParse = docStartOffset;
92.3511 - endParse = docEndOffset - 1;
92.3512 - } else {
92.3513 - if (startParse == startOffset) {//if start offset already adjusted no need to do again
92.3514 -
92.3515 - PlsqlBlock block = null;
92.3516 - block = getImmediateBefore(blockHierarchy, block, startOffset);
92.3517 - PlsqlBlock parent = getParentBlock(blockHierarchy, startParse, endParse);
92.3518 -
92.3519 - if ((parent != null) && (block != null)) {
92.3520 - if (parent.getStartOffset() > block.getStartOffset()) {
92.3521 - int newStart = getSecondLineOfBlock(doc, parent); // we are not going to remove the parent here
92.3522 - if (newStart < startParse) {
92.3523 - startParse = newStart;
92.3524 - }
92.3525 + }
92.3526 +
92.3527 + return block;
92.3528 + }
92.3529 +
92.3530 + /**
92.3531 + * Method that will generate blocks of the given offset range
92.3532 + * @param startOffset
92.3533 + * @param endOffset
92.3534 + */
92.3535 + private synchronized void generateBlocks(Document doc) {
92.3536 + List<PlsqlBlock> immediateBlockHier;
92.3537 + tokenHierarchy = TokenHierarchy.get(doc);
92.3538 + @SuppressWarnings("unchecked")
92.3539 + TokenSequence<PlsqlTokenId> ts = tokenHierarchy.tokenSequence(PlsqlTokenId.language());
92.3540 +
92.3541 + PlsqlBlock parent = getParentBlock(blockHierarchy, startParse, endParse);
92.3542 + if (parent != null) {
92.3543 + immediateBlockHier = parent.getChildBlocks();
92.3544 + } else {
92.3545 + immediateBlockHier = blockHierarchy;
92.3546 + }
92.3547 +
92.3548 + if (ts != null) {
92.3549 + //move offset
92.3550 + ts.move(startParse);
92.3551 + Token<PlsqlTokenId> tempToken = null;
92.3552 + Token<PlsqlTokenId> customStartToken = null;
92.3553 + Token<PlsqlTokenId> customEndToken = null;
92.3554 +
92.3555 + //Go through all the available tokens
92.3556 + while (ts.moveNext()) {
92.3557 + tempToken = ts.token();
92.3558 + PlsqlTokenId tokenID = tempToken.id();
92.3559 + String image = tempToken.text().toString();
92.3560 +
92.3561 + //Check end offset and break (exception for colun which will mark end of some blocks)
92.3562 + if ((tempToken != null) && (!image.equals(";")) && (tempToken.offset(tokenHierarchy) > endParse)) {
92.3563 + break;
92.3564 + }
92.3565 +
92.3566 + if (tokenID == PlsqlTokenId.KEYWORD) {
92.3567 + if (image.equalsIgnoreCase("VIEW")) {
92.3568 + int offset = ts.offset();
92.3569 + PlsqlBlock block = null;
92.3570 + block = checkView(tempToken, ts, immediateBlockHier);
92.3571 + if (block == null) {
92.3572 + //pass from the immediate next token to get inner blocks
92.3573 + ts.move(offset);
92.3574 + ts.moveNext();
92.3575 } else {
92.3576 - removeBlock(block, parent.getChildBlocks());
92.3577 + checkAndAddNew(block, parent, immediateBlockHier);
92.3578 }
92.3579 - } else {
92.3580 - if (block != null) {
92.3581 - removeBlock(block, blockHierarchy);
92.3582 - } else if (parent != null) { // we are not going to remove the parent here
92.3583 -
92.3584 - int newStart = getSecondLineOfBlock(doc, parent);
92.3585 - if (newStart < startParse) {
92.3586 - startParse = newStart;
92.3587 - }
92.3588 + } else if (image.equalsIgnoreCase("FUNCTION")) {
92.3589 + int offset = ts.offset();
92.3590 + PlsqlBlock block = null;
92.3591 + block = checkMethod(tempToken, ts, PlsqlBlockType.FUNCTION_IMPL, immediateBlockHier);
92.3592 + if (block == null) {
92.3593 + //pass from the immediate next token to get inner blocks
92.3594 + ts.move(offset);
92.3595 + ts.moveNext();
92.3596 } else {
92.3597 - startParse = docStartOffset;
92.3598 + checkAndAddNew(block, parent, immediateBlockHier);
92.3599 }
92.3600 - }
92.3601 - }
92.3602 -
92.3603 - if (endParse == endOffset) {//if end offset already adjusted no need to do again
92.3604 -
92.3605 - PlsqlBlock block = null;
92.3606 - block = getImmediateAfter(blockHierarchy, block, endOffset);
92.3607 - PlsqlBlock parent = getParentBlock(blockHierarchy, startParse, endParse);
92.3608 -
92.3609 - if ((parent != null) && (block != null)) {
92.3610 - if (parent.getEndOffset() < block.getEndOffset()) {
92.3611 - int newEnd = getPreLineOfBlockEnd(doc, parent); // we are not going to remove the parent here
92.3612 - if (newEnd > endParse) {
92.3613 - endParse = newEnd;
92.3614 - }
92.3615 + } else if (image.equalsIgnoreCase("PROCEDURE")) {
92.3616 + int offset = ts.offset();
92.3617 + PlsqlBlock block = null;
92.3618 + block = checkMethod(tempToken, ts, PlsqlBlockType.PROCEDURE_IMPL, immediateBlockHier);
92.3619 + if (block == null) {
92.3620 + //pass from the immediate next token to get inner blocks
92.3621 + ts.move(offset);
92.3622 + ts.moveNext();
92.3623 } else {
92.3624 - removeBlock(block, parent.getChildBlocks());
92.3625 + checkAndAddNew(block, parent, immediateBlockHier);
92.3626 }
92.3627 - } else {
92.3628 - if (block != null) {
92.3629 - removeBlock(block, blockHierarchy);
92.3630 - } else if (parent != null) { // we are not going to remove the parent here
92.3631 -
92.3632 - int newEnd = getPreLineOfBlockEnd(doc, parent);
92.3633 - if (newEnd > endParse) {
92.3634 - endParse = newEnd;
92.3635 - }
92.3636 + } else if (image.equalsIgnoreCase("PACKAGE")) {
92.3637 + int offset = ts.offset();
92.3638 + PlsqlBlock block = null;
92.3639 + block = checkPackage(tempToken, ts, immediateBlockHier);
92.3640 + if (block == null) {
92.3641 + //pass from the immediate next token to get inner blocks
92.3642 + ts.move(offset);
92.3643 + ts.moveNext();
92.3644 } else {
92.3645 - endParse = docEndOffset - 1;
92.3646 + checkAndAddNew(block, parent, immediateBlockHier);
92.3647 }
92.3648 - }
92.3649 - }
92.3650 -
92.3651 - //Remove custom fold blocks that are there within the parse area
92.3652 - removeCustomBlocks(customFoldBlocks, startParse, endParse);
92.3653 -
92.3654 - //When files are deleted and written after opening once following can happen
92.3655 - if ((endParse < 0) || (endParse > docEndOffset - 1)) {
92.3656 - endParse = docEndOffset - 1;
92.3657 - }
92.3658 -
92.3659 - if (startParse < 0) {
92.3660 - startParse = docStartOffset;
92.3661 - }
92.3662 -
92.3663 - if (startParse > docEndOffset - 1) {
92.3664 - startParse = docEndOffset - 1;
92.3665 - }
92.3666 - }
92.3667 - } else { //UPDATE pass again
92.3668 -
92.3669 - startParse = docStartOffset;
92.3670 - endParse = docEndOffset - 1;
92.3671 -
92.3672 - //clean block hierarchy
92.3673 - blockHierarchy.clear();
92.3674 - customFoldBlocks.clear();
92.3675 -
92.3676 - //we are going for a reparse, remove all the events for this doc
92.3677 - docList.clear();
92.3678 - break;
92.3679 - }
92.3680 - }
92.3681 -
92.3682 - if (startParse >= endParse) //Can happen in removes
92.3683 - {
92.3684 - return;
92.3685 - }
92.3686 -
92.3687 - //Check whether defines are changed from the affected area
92.3688 - checkAffected(doc, startParse, endParse);
92.3689 -
92.3690 - if (isDefineChanged) {
92.3691 - getAliases(doc);
92.3692 - }
92.3693 -
92.3694 - //pass affected section again
92.3695 - generateBlocks(doc);
92.3696 -
92.3697 - } catch (Exception e) {
92.3698 - ErrorManager.getDefault().notify(e);
92.3699 - } finally {
92.3700 - ((AbstractDocument) doc).readUnlock();
92.3701 - }
92.3702 - }
92.3703 -
92.3704 - /**
92.3705 - * Get block which is immediately before the given offset
92.3706 - * @param blocks
92.3707 - * @param block
92.3708 - * @param offset
92.3709 - * @return
92.3710 - */
92.3711 - private PlsqlBlock getImmediateBefore(List blocks, PlsqlBlock block, int offset) {
92.3712 - int count = blocks.size();
92.3713 -
92.3714 - for (int i = 0; i < count; i++) {
92.3715 - PlsqlBlock temp = (PlsqlBlock) blocks.get(i);
92.3716 - //check from children
92.3717 - PlsqlBlock child = getImmediateBefore(temp.getChildBlocks(), block, offset);
92.3718 - if (child != null) {
92.3719 - block = child;
92.3720 - }
92.3721 -
92.3722 - if ((temp.getEndOffset() < offset)
92.3723 - && ((block == null) || (block.getEndOffset() < temp.getEndOffset()))) {
92.3724 - block = temp;
92.3725 - }
92.3726 - }
92.3727 -
92.3728 - return block;
92.3729 - }
92.3730 -
92.3731 - /**
92.3732 - * Get fold which is immediately after the given offset
92.3733 - * @param blocks
92.3734 - * @param block
92.3735 - * @param offset
92.3736 - * @return
92.3737 - */
92.3738 - private PlsqlBlock getImmediateAfter(List<PlsqlBlock> blocks, PlsqlBlock block, int offset) {
92.3739 - int count = blocks.size();
92.3740 -
92.3741 - for (int i = 0; i < count; i++) {
92.3742 - PlsqlBlock temp = blocks.get(i);
92.3743 - //check from children
92.3744 - PlsqlBlock child = getImmediateAfter(temp.getChildBlocks(), block, offset);
92.3745 - if (child != null) {
92.3746 - block = child;
92.3747 - }
92.3748 -
92.3749 - if ((temp.getStartOffset() > offset)
92.3750 - && ((block == null) || (block.getStartOffset() > temp.getStartOffset()))) {
92.3751 - block = temp;
92.3752 - }
92.3753 - }
92.3754 -
92.3755 - return block;
92.3756 - }
92.3757 -
92.3758 - /**
92.3759 - * Method that will generate blocks of the given offset range
92.3760 - * @param startOffset
92.3761 - * @param endOffset
92.3762 - */
92.3763 - private synchronized void generateBlocks(Document doc) {
92.3764 - List<PlsqlBlock> immediateBlockHier;
92.3765 - tokenHierarchy = TokenHierarchy.get(doc);
92.3766 - @SuppressWarnings("unchecked")
92.3767 - TokenSequence<PlsqlTokenId> ts = tokenHierarchy.tokenSequence(PlsqlTokenId.language());
92.3768 -
92.3769 - PlsqlBlock parent = getParentBlock(blockHierarchy, startParse, endParse);
92.3770 - if (parent != null) {
92.3771 - immediateBlockHier = parent.getChildBlocks();
92.3772 - } else {
92.3773 - immediateBlockHier = blockHierarchy;
92.3774 - }
92.3775 -
92.3776 - if (ts != null) {
92.3777 - //move offset
92.3778 - ts.move(startParse);
92.3779 - Token<PlsqlTokenId> tempToken = null;
92.3780 - Token<PlsqlTokenId> customStartToken = null;
92.3781 - Token<PlsqlTokenId> customEndToken = null;
92.3782 -
92.3783 - //Go through all the available tokens
92.3784 - while (ts.moveNext()) {
92.3785 - tempToken = ts.token();
92.3786 - PlsqlTokenId tokenID = tempToken.id();
92.3787 - String image = tempToken.text().toString();
92.3788 -
92.3789 - //Check end offset and break (exception for colun which will mark end of some blocks)
92.3790 - if ((tempToken != null) && (!image.equals(";")) && (tempToken.offset(tokenHierarchy) > endParse)) {
92.3791 - break;
92.3792 - }
92.3793 -
92.3794 - if (tokenID == PlsqlTokenId.KEYWORD) {
92.3795 - if (image.equalsIgnoreCase("VIEW")) {
92.3796 - int offset = ts.offset();
92.3797 - PlsqlBlock block = null;
92.3798 - block = checkView(tempToken, ts, immediateBlockHier);
92.3799 - if (block == null) {
92.3800 - //pass from the immediate next token to get inner blocks
92.3801 - ts.move(offset);
92.3802 - ts.moveNext();
92.3803 - } else {
92.3804 - checkAndAddNew(block, parent, immediateBlockHier);
92.3805 - }
92.3806 - } else if (image.equalsIgnoreCase("FUNCTION")) {
92.3807 - int offset = ts.offset();
92.3808 - PlsqlBlock block = null;
92.3809 - block = checkMethod(tempToken, ts, PlsqlBlockType.FUNCTION_IMPL, immediateBlockHier);
92.3810 - if (block == null) {
92.3811 - //pass from the immediate next token to get inner blocks
92.3812 - ts.move(offset);
92.3813 - ts.moveNext();
92.3814 - } else {
92.3815 - checkAndAddNew(block, parent, immediateBlockHier);
92.3816 - }
92.3817 - } else if (image.equalsIgnoreCase("PROCEDURE")) {
92.3818 - int offset = ts.offset();
92.3819 - PlsqlBlock block = null;
92.3820 - block = checkMethod(tempToken, ts, PlsqlBlockType.PROCEDURE_IMPL, immediateBlockHier);
92.3821 - if (block == null) {
92.3822 - //pass from the immediate next token to get inner blocks
92.3823 - ts.move(offset);
92.3824 - ts.moveNext();
92.3825 - } else {
92.3826 - checkAndAddNew(block, parent, immediateBlockHier);
92.3827 - }
92.3828 - } else if (image.equalsIgnoreCase("PACKAGE")) {
92.3829 - int offset = ts.offset();
92.3830 - PlsqlBlock block = null;
92.3831 - block = checkPackage(tempToken, ts, immediateBlockHier);
92.3832 - if (block == null) {
92.3833 - //pass from the immediate next token to get inner blocks
92.3834 - ts.move(offset);
92.3835 - ts.moveNext();
92.3836 - } else {
92.3837 - checkAndAddNew(block, parent, immediateBlockHier);
92.3838 - }
92.3839 - } else if (image.equalsIgnoreCase("CURSOR")) {
92.3840 - int offset = ts.offset();
92.3841 - PlsqlBlock block = null;
92.3842 - block = checkCursor(tempToken, ts, immediateBlockHier);
92.3843 - if (block == null) {
92.3844 - //pass from the immediate next token to get inner blocks
92.3845 - ts.move(offset);
92.3846 - ts.moveNext();
92.3847 - } else {
92.3848 - checkAndAddNew(block, parent, immediateBlockHier);
92.3849 - }
92.3850 - } else if (image.equalsIgnoreCase("TRIGGER")) {
92.3851 - int offset = ts.offset();
92.3852 - PlsqlBlock block = null;
92.3853 - block = checkTrigger(tempToken, ts, immediateBlockHier);
92.3854 - if (block == null) {
92.3855 - //pass from the immediate next token to get inner blocks
92.3856 - ts.move(offset);
92.3857 - ts.moveNext();
92.3858 - } else {
92.3859 - checkAndAddNew(block, parent, immediateBlockHier);
92.3860 - }
92.3861 - } else if (image.equalsIgnoreCase("COMMENT")) {
92.3862 - int offset = ts.offset();
92.3863 - PlsqlBlock block = null;
92.3864 - block = checkTblColComment(tempToken, ts, immediateBlockHier);
92.3865 - if (block == null) {
92.3866 - //pass from the immediate next token to get inner blocks
92.3867 - ts.move(offset);
92.3868 - ts.moveNext();
92.3869 - } else {
92.3870 - checkAndAddNew(block, parent, immediateBlockHier);
92.3871 - }
92.3872 - } else if (image.equalsIgnoreCase("DECLARE")) {
92.3873 - PlsqlBlock block = checkDeclareBlock(tempToken, ts, immediateBlockHier);
92.3874 - if (block != null) {//If inner check seems to have failed need to continue this one
92.3875 - checkAndAddNew(block, parent, immediateBlockHier);
92.3876 - }
92.3877 - } else if (image.equalsIgnoreCase("BEGIN")) {
92.3878 - if (!isDeclare(ts, immediateBlockHier)) {//We need to check whether the declare is isolated by a CURSOR block
92.3879 -
92.3880 - int offset = ts.offset();
92.3881 - PlsqlBlock block = checkBeginBlock(tempToken, ts, immediateBlockHier);
92.3882 - if (block == null) {//If inner check seems to have failed need to continue this one
92.3883 -
92.3884 + } else if (image.equalsIgnoreCase("CURSOR")) {
92.3885 + int offset = ts.offset();
92.3886 + PlsqlBlock block = null;
92.3887 + block = checkCursor(tempToken, ts, immediateBlockHier);
92.3888 + if (block == null) {
92.3889 + //pass from the immediate next token to get inner blocks
92.3890 + ts.move(offset);
92.3891 + ts.moveNext();
92.3892 + } else {
92.3893 + checkAndAddNew(block, parent, immediateBlockHier);
92.3894 + }
92.3895 + } else if (image.equalsIgnoreCase("TRIGGER")) {
92.3896 + int offset = ts.offset();
92.3897 + PlsqlBlock block = null;
92.3898 + block = checkTrigger(tempToken, ts, immediateBlockHier);
92.3899 + if (block == null) {
92.3900 + //pass from the immediate next token to get inner blocks
92.3901 + ts.move(offset);
92.3902 + ts.moveNext();
92.3903 + } else {
92.3904 + checkAndAddNew(block, parent, immediateBlockHier);
92.3905 + }
92.3906 + } else if (image.equalsIgnoreCase("COMMENT")) {
92.3907 + int offset = ts.offset();
92.3908 + PlsqlBlock block = null;
92.3909 + block = checkTblColComment(tempToken, ts, immediateBlockHier);
92.3910 + if (block == null) {
92.3911 + //pass from the immediate next token to get inner blocks
92.3912 + ts.move(offset);
92.3913 + ts.moveNext();
92.3914 + } else {
92.3915 + checkAndAddNew(block, parent, immediateBlockHier);
92.3916 + }
92.3917 + } else if (image.equalsIgnoreCase("DECLARE")) {
92.3918 + PlsqlBlock block = checkDeclareBlock(tempToken, ts, immediateBlockHier);
92.3919 + if (block != null) {//If inner check seems to have failed need to continue this one
92.3920 + checkAndAddNew(block, parent, immediateBlockHier);
92.3921 + }
92.3922 + } else if (image.equalsIgnoreCase("BEGIN")) {
92.3923 + if (!isDeclare(ts, immediateBlockHier)) {//We need to check whether the declare is isolated by a CURSOR block
92.3924 +
92.3925 + int offset = ts.offset();
92.3926 + PlsqlBlock block = checkBeginBlock(tempToken, ts, immediateBlockHier);
92.3927 + if (block == null) {//If inner check seems to have failed need to continue this one
92.3928 +
92.3929 + ts.move(offset);
92.3930 + ts.moveNext();
92.3931 + } else {
92.3932 + checkAndAddNew(block, parent, immediateBlockHier);
92.3933 + }
92.3934 + }
92.3935 + } else if (image.equalsIgnoreCase("IF")
92.3936 + || image.equalsIgnoreCase("ELSIF")) {
92.3937 + if (!isNotBlockStart(tempToken, ts)) {
92.3938 + int offset = tempToken.offset(tokenHierarchy);
92.3939 + List children = checkIfBlock(tempToken, ts, immediateBlockHier);
92.3940 + if (children == null || children.isEmpty()) {//If inner check seems to have failed need to continue this one
92.3941 +
92.3942 + ts.move(offset);
92.3943 + ts.moveNext();
92.3944 + } else {
92.3945 + for (int i = 0; i < children.size(); i++) {
92.3946 + PlsqlBlock child = (PlsqlBlock) children.get(i);
92.3947 + checkAndAddNew(child, parent, immediateBlockHier);
92.3948 + }
92.3949 + }
92.3950 + }
92.3951 + } else if (image.equalsIgnoreCase("ELSE")) {
92.3952 + if (!isNotBlockStart(tempToken, ts)) {
92.3953 + int offset = tempToken.offset(tokenHierarchy);
92.3954 + List children = checkIfBlock(tempToken, ts, immediateBlockHier);
92.3955 + if (children == null || children.isEmpty()) {
92.3956 + children = checkCaseBlock(tempToken, ts, immediateBlockHier, false);
92.3957 + }
92.3958 +
92.3959 + if (children == null || children.isEmpty()) {//If inner check seems to have failed need to continue this one
92.3960 +
92.3961 + ts.move(offset);
92.3962 + ts.moveNext();
92.3963 + } else {
92.3964 + for (int i = 0; i < children.size(); i++) {
92.3965 + PlsqlBlock child = (PlsqlBlock) children.get(i);
92.3966 + checkAndAddNew(child, parent, immediateBlockHier);
92.3967 + }
92.3968 + }
92.3969 + }
92.3970 + } else if (image.equalsIgnoreCase("CASE")
92.3971 + || image.equalsIgnoreCase("WHEN")) {
92.3972 + if (!isNotBlockStart(tempToken, ts)) {
92.3973 + int offset = tempToken.offset(tokenHierarchy);
92.3974 + List children = checkCaseBlock(tempToken, ts, immediateBlockHier, false);
92.3975 + if (children == null || children.isEmpty()) {//If inner check seems to have failed need to continue this one
92.3976 +
92.3977 + ts.move(offset);
92.3978 + ts.moveNext();
92.3979 + } else {
92.3980 + for (int i = 0; i < children.size(); i++) {
92.3981 + PlsqlBlock child = (PlsqlBlock) children.get(i);
92.3982 + checkAndAddNew(child, parent, immediateBlockHier);
92.3983 + }
92.3984 + }
92.3985 + }
92.3986 + } else if (image.equalsIgnoreCase("LOOP")
92.3987 + || image.equalsIgnoreCase("WHILE")
92.3988 + || image.equalsIgnoreCase("FOR")) {
92.3989 + if (!isNotBlockStart(tempToken, ts)) {
92.3990 + int offset = tempToken.offset(tokenHierarchy);
92.3991 + if (!unsuccessBlocks.contains(offset)) {
92.3992 + PlsqlBlock child = checkLoopBlock(tempToken, ts, immediateBlockHier);
92.3993 + if (child == null) {//If inner check seems to have failed need to continue this one
92.3994 + unsuccessBlocks.add(offset);
92.3995 + ts.move(offset);
92.3996 + ts.moveNext();
92.3997 + } else {
92.3998 + checkAndAddNew(child, parent, immediateBlockHier);
92.3999 + }
92.4000 + }
92.4001 + }
92.4002 + } else if (image.equalsIgnoreCase("TABLE")
92.4003 + || image.equalsIgnoreCase("INDEX")
92.4004 + || image.equalsIgnoreCase("SELECT")
92.4005 + || image.equalsIgnoreCase("UPDATE")
92.4006 + || image.equalsIgnoreCase("DELETE")
92.4007 + || image.equalsIgnoreCase("INSERT")
92.4008 + || image.equalsIgnoreCase("MERGE")
92.4009 + || image.equalsIgnoreCase("DROP")
92.4010 + || image.equalsIgnoreCase("SEQUENCE")) {
92.4011 + if (!isNotBlockStart(tempToken, ts)) {
92.4012 + int offset = tempToken.offset(tokenHierarchy);
92.4013 + PlsqlBlock child = checkStatementBlock(tempToken, ts, immediateBlockHier);
92.4014 + if (child == null) {//If inner check seems to have failed need to continue this one
92.4015 +
92.4016 + ts.move(offset);
92.4017 + ts.moveNext();
92.4018 + } else {
92.4019 + checkAndAddNew(child, parent, immediateBlockHier);
92.4020 + }
92.4021 + }
92.4022 + }
92.4023 + } else if (tokenID == PlsqlTokenId.JAVA_SOUCE) {
92.4024 + int offset = ts.offset();
92.4025 + PlsqlBlock block = null;
92.4026 + block = checkJavaSource(tempToken, ts);
92.4027 + if (block == null) {
92.4028 + //pass from the immediate next token to get inner blocks
92.4029 ts.move(offset);
92.4030 ts.moveNext();
92.4031 - } else {
92.4032 + } else {
92.4033 checkAndAddNew(block, parent, immediateBlockHier);
92.4034 - }
92.4035 - }
92.4036 - } else if (image.equalsIgnoreCase("IF")
92.4037 - || image.equalsIgnoreCase("ELSIF")) {
92.4038 - if (!isNotBlockStart(tempToken, ts)) {
92.4039 - int offset = tempToken.offset(tokenHierarchy);
92.4040 - List children = checkIfBlock(tempToken, ts, immediateBlockHier);
92.4041 - if (children == null || children.size() == 0) {//If inner check seems to have failed need to continue this one
92.4042 -
92.4043 - ts.move(offset);
92.4044 - ts.moveNext();
92.4045 - } else {
92.4046 - for (int i = 0; i < children.size(); i++) {
92.4047 - PlsqlBlock child = (PlsqlBlock) children.get(i);
92.4048 - checkAndAddNew(child, parent, immediateBlockHier);
92.4049 + }
92.4050 + } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.4051 + //only single comment line
92.4052 + if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.4053 + customStartToken = tempToken;
92.4054 + } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.4055 + if (customStartToken != null) {
92.4056 + String name = customStartToken.text().toString();
92.4057 + int index = name.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.4058 + name = name.substring(index + 7).trim();
92.4059 + if (ts.moveNext()) {
92.4060 + tempToken = ts.token();
92.4061 + PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.4062 + tempToken.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.4063 + customFoldBlocks.add(custom);
92.4064 + }
92.4065 + customStartToken = null;
92.4066 + } else {
92.4067 + customEndToken = tempToken;
92.4068 }
92.4069 - }
92.4070 - }
92.4071 - } else if (image.equalsIgnoreCase("ELSE")) {
92.4072 - if (!isNotBlockStart(tempToken, ts)) {
92.4073 - int offset = tempToken.offset(tokenHierarchy);
92.4074 - List children = checkIfBlock(tempToken, ts, immediateBlockHier);
92.4075 - if (children == null || children.size() == 0) {
92.4076 - children = checkCaseBlock(tempToken, ts, immediateBlockHier, false);
92.4077 - }
92.4078 -
92.4079 - if (children == null || children.size() == 0) {//If inner check seems to have failed need to continue this one
92.4080 -
92.4081 - ts.move(offset);
92.4082 - ts.moveNext();
92.4083 - } else {
92.4084 - for (int i = 0; i < children.size(); i++) {
92.4085 - PlsqlBlock child = (PlsqlBlock) children.get(i);
92.4086 - checkAndAddNew(child, parent, immediateBlockHier);
92.4087 + } else {
92.4088 + PlsqlBlock block = checkComment(tempToken, ts);
92.4089 + if (block != null) {
92.4090 + checkAndAddNew(block, parent, immediateBlockHier);
92.4091 }
92.4092 - }
92.4093 - }
92.4094 - } else if (image.equalsIgnoreCase("CASE")
92.4095 - || image.equalsIgnoreCase("WHEN")) {
92.4096 - if (!isNotBlockStart(tempToken, ts)) {
92.4097 - int offset = tempToken.offset(tokenHierarchy);
92.4098 - List children = checkCaseBlock(tempToken, ts, immediateBlockHier, false);
92.4099 - if (children == null || children.size() == 0) {//If inner check seems to have failed need to continue this one
92.4100 -
92.4101 - ts.move(offset);
92.4102 - ts.moveNext();
92.4103 - } else {
92.4104 - for (int i = 0; i < children.size(); i++) {
92.4105 - PlsqlBlock child = (PlsqlBlock) children.get(i);
92.4106 - checkAndAddNew(child, parent, immediateBlockHier);
92.4107 + }
92.4108 + } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.4109 + int start = tempToken.offset(tokenHierarchy);
92.4110 + PlsqlBlock block = new PlsqlBlock(start,
92.4111 + start + tempToken.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.4112 + if (block != null) {
92.4113 + checkAndAddNew(block, parent, immediateBlockHier);
92.4114 + }
92.4115 + } else if ((tokenID == PlsqlTokenId.OPERATOR) && (image.equals(";"))) {
92.4116 + PlsqlBlock block = checkEnd(tempToken, ts);
92.4117 + //check whether this is the parent can happen in a remove
92.4118 + if (block != null && (block.getType() != PlsqlBlockType.FUNCTION_IMPL && block.getType() != PlsqlBlockType.PROCEDURE_IMPL)) {
92.4119 + if (!isEqual(parent, block)) {
92.4120 + if ((block != null) && (checkExisting(block, immediateBlockHier) == false)) {
92.4121 + addImmediateChildren(block, immediateBlockHier);
92.4122 + immediateBlockHier.add(block);
92.4123 + newBlocks.add(block);
92.4124 + if (parent != null) {
92.4125 + block.setParent(parent);
92.4126 + }
92.4127 + }
92.4128 }
92.4129 - }
92.4130 - }
92.4131 - } else if (image.equalsIgnoreCase("LOOP")
92.4132 - || image.equalsIgnoreCase("WHILE")
92.4133 - || image.equalsIgnoreCase("FOR")) {
92.4134 - if (!isNotBlockStart(tempToken, ts)) {
92.4135 - int offset = tempToken.offset(tokenHierarchy);
92.4136 - if (!unsuccessBlocks.contains(offset)) {
92.4137 - PlsqlBlock child = checkLoopBlock(tempToken, ts, immediateBlockHier);
92.4138 - if (child == null) {//If inner check seems to have failed need to continue this one
92.4139 - unsuccessBlocks.add(offset);
92.4140 - ts.move(offset);
92.4141 - ts.moveNext();
92.4142 - } else {
92.4143 - checkAndAddNew(child, parent, immediateBlockHier);
92.4144 - }
92.4145 - }
92.4146 - }
92.4147 - } else if (image.equalsIgnoreCase("TABLE")
92.4148 - || image.equalsIgnoreCase("INDEX")
92.4149 - || image.equalsIgnoreCase("SELECT")
92.4150 - || image.equalsIgnoreCase("UPDATE")
92.4151 - || image.equalsIgnoreCase("DELETE")
92.4152 - || image.equalsIgnoreCase("INSERT")
92.4153 - || image.equalsIgnoreCase("MERGE")
92.4154 - || image.equalsIgnoreCase("DROP")
92.4155 - || image.equalsIgnoreCase("SEQUENCE")) {
92.4156 - if (!isNotBlockStart(tempToken, ts)) {
92.4157 - int offset = tempToken.offset(tokenHierarchy);
92.4158 - PlsqlBlock child = checkStatementBlock(tempToken, ts, immediateBlockHier);
92.4159 - if (child == null) {//If inner check seems to have failed need to continue this one
92.4160 -
92.4161 - ts.move(offset);
92.4162 - ts.moveNext();
92.4163 - } else {
92.4164 - checkAndAddNew(child, parent, immediateBlockHier);
92.4165 - }
92.4166 - }
92.4167 - }
92.4168 - } else if (tokenID == PlsqlTokenId.JAVA_SOUCE) {
92.4169 - int offset = ts.offset();
92.4170 - PlsqlBlock block = null;
92.4171 - block = checkJavaSource(tempToken, ts);
92.4172 - if (block == null) {
92.4173 - //pass from the immediate next token to get inner blocks
92.4174 - ts.move(offset);
92.4175 - ts.moveNext();
92.4176 - } else {
92.4177 - checkAndAddNew(block, parent, immediateBlockHier);
92.4178 - }
92.4179 - } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.4180 - //only single comment line
92.4181 - if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.4182 - customStartToken = tempToken;
92.4183 - } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.4184 - if (customStartToken != null) {
92.4185 - String name = customStartToken.text().toString();
92.4186 - int index = name.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.4187 - name = name.substring(index + 7).trim();
92.4188 - if (ts.moveNext()) {
92.4189 - tempToken = ts.token();
92.4190 - PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.4191 - tempToken.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.4192 - customFoldBlocks.add(custom);
92.4193 - }
92.4194 - customStartToken = null;
92.4195 - } else {
92.4196 - customEndToken = tempToken;
92.4197 - }
92.4198 - } else {
92.4199 - PlsqlBlock block = checkComment(tempToken, ts);
92.4200 - if (block != null) {
92.4201 - checkAndAddNew(block, parent, immediateBlockHier);
92.4202 - }
92.4203 - }
92.4204 - } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.4205 - int start = tempToken.offset(tokenHierarchy);
92.4206 - PlsqlBlock block = new PlsqlBlock(start,
92.4207 - start + tempToken.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.4208 - if (block != null) {
92.4209 - checkAndAddNew(block, parent, immediateBlockHier);
92.4210 - }
92.4211 - } else if ((tokenID == PlsqlTokenId.OPERATOR) && (image.equals(";"))) {
92.4212 - PlsqlBlock block = checkEnd(tempToken, ts);
92.4213 - //check whether this is the parent can happen in a remove
92.4214 - if (!isEqual(parent, block)) {
92.4215 - if ((block != null) && (checkExisting(block, immediateBlockHier) == false)) {
92.4216 - addImmediateChildren(block, immediateBlockHier);
92.4217 - immediateBlockHier.add(block);
92.4218 - newBlocks.add(block);
92.4219 - if (parent != null) {
92.4220 - block.setParent(parent);
92.4221 - }
92.4222 - }
92.4223 - }
92.4224 + }
92.4225 + }
92.4226 + } //we have come to the end now, check whether we have unmatched custom tokens
92.4227 +
92.4228 + if (customEndToken != null) {
92.4229 + checkCustom(customEndToken, ts, immediateBlockHier, parent, "END");
92.4230 + } else if (customStartToken != null) {
92.4231 + checkCustom(customStartToken, ts, immediateBlockHier, parent, "START");
92.4232 }
92.4233 - } //we have come to the end now, check whether we have unmatched custom tokens
92.4234 -
92.4235 - if (customEndToken != null) {
92.4236 - checkCustom(customEndToken, ts, immediateBlockHier, parent, "END");
92.4237 - } else if (customStartToken != null) {
92.4238 - checkCustom(customStartToken, ts, immediateBlockHier, parent, "START");
92.4239 - }
92.4240 - }
92.4241 - }
92.4242 -
92.4243 - private void checkAndAddNew(PlsqlBlock block, PlsqlBlock parent, List<PlsqlBlock> immediateBlockHier) {
92.4244 - if (checkExisting(block, immediateBlockHier) == false && !isEqual(parent, block)) {
92.4245 - immediateBlockHier.add(block);
92.4246 - newBlocks.add(block);
92.4247 - if (parent != null) {
92.4248 - block.setParent(parent);
92.4249 - }
92.4250 - }
92.4251 - }
92.4252 -
92.4253 - /**
92.4254 - * Check whether current ';' is the end of a function/procedure/view/package
92.4255 - * @param tempToken
92.4256 - * @param ts
92.4257 - */
92.4258 - private PlsqlBlock checkEnd(Token<PlsqlTokenId> endToken, TokenSequence<PlsqlTokenId> ts) {
92.4259 - Token<PlsqlTokenId> end = endToken; //means ';' here
92.4260 -
92.4261 - Token<PlsqlTokenId> begin = null;
92.4262 - String methodName = "";
92.4263 - int type = -1; //1 for FUNCTION/PROCEDURE/PACKAGE
92.4264 -
92.4265 - boolean moveBack = false;
92.4266 - PlsqlBlock block = null;
92.4267 - moveBack = getPreviousNonWhitespace(ts, true);
92.4268 - Token<PlsqlTokenId> tmp = ts.token();
92.4269 -
92.4270 - if (moveBack == false) {
92.4271 - ts.move(end.offset(tokenHierarchy));
92.4272 - ts.moveNext();
92.4273 - return block;
92.4274 - }
92.4275 -
92.4276 - //If this is a function/procedure end take the name
92.4277 - if ((tmp.id() == PlsqlTokenId.KEYWORD) && (tmp.text().toString().equalsIgnoreCase("END"))) {
92.4278 - type = 0;
92.4279 - } else if (tmp.id() == PlsqlTokenId.IDENTIFIER || tmp.id() == PlsqlTokenId.KEYWORD) {
92.4280 - methodName = tmp.text().toString();
92.4281 -
92.4282 - //Check whether this is an 'end <ide>;'
92.4283 - moveBack = getPreviousNonWhitespace(ts, true);
92.4284 - tmp = ts.token();
92.4285 -
92.4286 - if (moveBack == false) {
92.4287 + }
92.4288 + }
92.4289 +
92.4290 + private void checkAndAddNew(PlsqlBlock block, PlsqlBlock parent, List<PlsqlBlock> immediateBlockHier) {
92.4291 + if (checkExisting(block, immediateBlockHier) == false && !isEqual(parent, block)) {
92.4292 + immediateBlockHier.add(block);
92.4293 + newBlocks.add(block);
92.4294 + if (parent != null) {
92.4295 + block.setParent(parent);
92.4296 + }
92.4297 + }
92.4298 + }
92.4299 +
92.4300 + /**
92.4301 + * Check whether current ';' is the end of a function/procedure/view/package
92.4302 + * @param tempToken
92.4303 + * @param ts
92.4304 + */
92.4305 + private PlsqlBlock checkEnd(Token<PlsqlTokenId> endToken, TokenSequence<PlsqlTokenId> ts) {
92.4306 + Token<PlsqlTokenId> end = endToken; //means ';' here
92.4307 +
92.4308 + Token<PlsqlTokenId> begin = null;
92.4309 + String methodName = "";
92.4310 + int type = -1; //1 for FUNCTION/PROCEDURE/PACKAGE
92.4311 +
92.4312 + boolean moveBack = false;
92.4313 + PlsqlBlock block = null;
92.4314 + moveBack = getPreviousNonWhitespace(ts, true);
92.4315 + Token<PlsqlTokenId> tmp = ts.token();
92.4316 +
92.4317 + if (moveBack == false) {
92.4318 ts.move(end.offset(tokenHierarchy));
92.4319 ts.moveNext();
92.4320 return block;
92.4321 - }
92.4322 -
92.4323 - if ((tmp.id() == PlsqlTokenId.KEYWORD)
92.4324 - && (tmp.text().toString().equalsIgnoreCase("END"))) {
92.4325 - type = 1;
92.4326 - }
92.4327 -
92.4328 - }
92.4329 -
92.4330 - if (type == 1) {
92.4331 - begin = checkMethodBegin(ts, methodName);
92.4332 - } else if (type == 0) {
92.4333 - begin = checkMethodBegin(ts);
92.4334 -
92.4335 - Token<PlsqlTokenId> nameToken = begin;
92.4336 - //get name
92.4337 - if (getNextNonWhitespace(ts, true)) {
92.4338 - nameToken = ts.token();
92.4339 - if (!nameToken.text().toString().equalsIgnoreCase("BODY")) {
92.4340 - methodName = nameToken.text().toString();
92.4341 + }
92.4342 +
92.4343 + //If this is a function/procedure end take the name
92.4344 + if ((tmp.id() == PlsqlTokenId.KEYWORD) && (tmp.text().toString().equalsIgnoreCase("END"))) {
92.4345 + type = 0;
92.4346 + } else if (tmp.id() == PlsqlTokenId.IDENTIFIER || tmp.id() == PlsqlTokenId.KEYWORD) {
92.4347 + methodName = tmp.text().toString();
92.4348 +
92.4349 + //Check whether this is an 'end <ide>;'
92.4350 + moveBack = getPreviousNonWhitespace(ts, true);
92.4351 + tmp = ts.token();
92.4352 +
92.4353 + if (moveBack == false) {
92.4354 + ts.move(end.offset(tokenHierarchy));
92.4355 + ts.moveNext();
92.4356 + return block;
92.4357 + }
92.4358 +
92.4359 + if ((tmp.id() == PlsqlTokenId.KEYWORD)
92.4360 + && (tmp.text().toString().equalsIgnoreCase("END"))) {
92.4361 + type = 1;
92.4362 + }
92.4363 +
92.4364 + }
92.4365 +
92.4366 + if (type == 1) {
92.4367 + begin = checkMethodBegin(ts, methodName);
92.4368 + } else if (type == 0) {
92.4369 + begin = checkMethodBegin(ts);
92.4370 +
92.4371 + Token<PlsqlTokenId> nameToken = begin;
92.4372 + //get name
92.4373 + if (getNextNonWhitespace(ts, true)) {
92.4374 + nameToken = ts.token();
92.4375 + if (!nameToken.text().toString().equalsIgnoreCase("BODY")) {
92.4376 + methodName = nameToken.text().toString();
92.4377 + } else {
92.4378 + if (getNextNonWhitespace(ts, true)) {
92.4379 + nameToken = ts.token();
92.4380 + methodName = nameToken.text().toString();
92.4381 + }
92.4382 + }
92.4383 + }
92.4384 + }
92.4385 +
92.4386 + //Cold block is found
92.4387 + if (begin != null) {
92.4388 + String image = begin.text().toString();
92.4389 + String alias = "";
92.4390 + if (methodName.indexOf('&') != -1) {
92.4391 + alias = methodName;
92.4392 + }
92.4393 +
92.4394 + methodName = getDefine(methodName);
92.4395 +
92.4396 + //Get the token after the end token
92.4397 + ts.move(end.offset(tokenHierarchy));
92.4398 + ts.moveNext();
92.4399 + ts.moveNext();
92.4400 +
92.4401 + if (image.equalsIgnoreCase("PROCEDURE")) {
92.4402 + block = new PlsqlBlock(begin.offset(tokenHierarchy), ts.offset(),
92.4403 + methodName, alias, PlsqlBlockType.PROCEDURE_IMPL);
92.4404 + checkPrefix(begin.offset(tokenHierarchy), ts, block);
92.4405 + } else if (image.equalsIgnoreCase("PACKAGE")) {
92.4406 + //get next token & check
92.4407 + //find semicolon
92.4408 + int endPos = ts.offset();
92.4409 + ts.move(begin.offset(tokenHierarchy));
92.4410 + ts.moveNext();
92.4411 + boolean moveNext = false;
92.4412 + moveNext = getNextNonWhitespace(ts, true);
92.4413 + Token<PlsqlTokenId> next = ts.token();
92.4414 + PlsqlBlockType foldType = PlsqlBlockType.PACKAGE;
92.4415 + if ((moveNext != false) && (next.text().toString().equalsIgnoreCase("BODY"))) {
92.4416 + foldType = PlsqlBlockType.PACKAGE_BODY;
92.4417 + }
92.4418 +
92.4419 + block = new PlsqlBlock(begin.offset(tokenHierarchy), endPos,
92.4420 + methodName, alias, foldType);
92.4421 + checkPrefix(begin.offset(tokenHierarchy), ts, block);
92.4422 } else {
92.4423 - if (getNextNonWhitespace(ts, true)) {
92.4424 - nameToken = ts.token();
92.4425 - methodName = nameToken.text().toString();
92.4426 - }
92.4427 + block = new PlsqlBlock(begin.offset(tokenHierarchy), ts.offset(),
92.4428 + methodName, alias, PlsqlBlockType.FUNCTION_IMPL);
92.4429 + checkPrefix(begin.offset(tokenHierarchy), ts, block);
92.4430 }
92.4431 - }
92.4432 - }
92.4433 -
92.4434 - //Cold block is found
92.4435 - if (begin != null) {
92.4436 - String image = begin.text().toString();
92.4437 - String alias = "";
92.4438 - if (methodName.indexOf('&') != -1) {
92.4439 + }
92.4440 +
92.4441 + ts.move(end.offset(tokenHierarchy));
92.4442 + ts.moveNext();
92.4443 + return block;
92.4444 + }
92.4445 +
92.4446 + /**
92.4447 + * Check whether there is a function/procedure in this block
92.4448 + * @param ts
92.4449 + * @param methodName
92.4450 + * @return
92.4451 + */
92.4452 + private Token<PlsqlTokenId> checkMethodBegin(TokenSequence<PlsqlTokenId> ts, String methodName) {
92.4453 + Token<PlsqlTokenId> begin = null;
92.4454 + boolean moveBack = ts.movePrevious();
92.4455 + Token<PlsqlTokenId> tmp = ts.token();
92.4456 + int endCount = 0;
92.4457 +
92.4458 + while (moveBack) {
92.4459 + String image = tmp.text().toString();
92.4460 +
92.4461 + if (image.equalsIgnoreCase(methodName)) {
92.4462 + //Go to previous word
92.4463 + boolean move = getPreviousNonWhitespace(ts, true);
92.4464 + Token<PlsqlTokenId> token = ts.token();
92.4465 +
92.4466 + if ((move != false) && (token.id() == PlsqlTokenId.KEYWORD)) {
92.4467 + if ((token.text().toString().equalsIgnoreCase("FUNCTION"))
92.4468 + || (token.text().toString().equalsIgnoreCase("PROCEDURE"))) {
92.4469 + //if there were inner functions & procedures
92.4470 + if (endCount != 0) {
92.4471 + endCount--;
92.4472 + } else {
92.4473 + return token;
92.4474 + }
92.4475 + } else if (token.text().toString().equalsIgnoreCase("BODY")) {
92.4476 + boolean pre = getPreviousNonWhitespace(ts, true);
92.4477 + Token<PlsqlTokenId> previous = ts.token();
92.4478 + if ((pre != false) && (previous.text().toString().equalsIgnoreCase("PACKAGE"))) {
92.4479 + return previous;
92.4480 + }
92.4481 +
92.4482 + } else if (token.text().toString().equalsIgnoreCase("END")) {
92.4483 + ++endCount;
92.4484 + }
92.4485 + }
92.4486 + }
92.4487 + moveBack = getPreviousNonWhitespace(ts, true);
92.4488 + tmp = ts.token();
92.4489 + }
92.4490 +
92.4491 + return begin;
92.4492 + }
92.4493 +
92.4494 + /**
92.4495 + * Check whether there is a function/procedure in this block
92.4496 + * Method name is not there in the 'END;'
92.4497 + * @param ts
92.4498 + * @return
92.4499 + */
92.4500 + private Token<PlsqlTokenId> checkMethodBegin(TokenSequence<PlsqlTokenId> ts) {
92.4501 + Token<PlsqlTokenId> begin = null;
92.4502 + boolean moveBack = ts.movePrevious();
92.4503 + Token<PlsqlTokenId> tmp = ts.token();
92.4504 + int endCount = 0;
92.4505 +
92.4506 + while (moveBack) {
92.4507 + String image = tmp.text().toString();
92.4508 +
92.4509 + if (tmp.id() == PlsqlTokenId.KEYWORD) {
92.4510 + if ((image.equalsIgnoreCase("BEGIN"))) {
92.4511 + endCount--;
92.4512 + } else if ((image.equalsIgnoreCase("END"))) {
92.4513 + int off = ts.offset();
92.4514 + if (getNextNonWhitespace(ts, true)) {
92.4515 + tmp = ts.token();
92.4516 + }
92.4517 +
92.4518 + if ((tmp.text().toString().equals(";")) || (tmp.id() == PlsqlTokenId.IDENTIFIER)
92.4519 + || (tmp.id() == PlsqlTokenId.KEYWORD && (!tmp.toString().equalsIgnoreCase("IF")
92.4520 + && !tmp.toString().equalsIgnoreCase("CASE") && !tmp.toString().equalsIgnoreCase("LOOP")))) {
92.4521 + endCount++;
92.4522 + }
92.4523 +
92.4524 + ts.move(off);
92.4525 + ts.moveNext();
92.4526 + } else if ((endCount == 0) & (image.equalsIgnoreCase("PACKAGE"))) {
92.4527 + return tmp;
92.4528 + } else if ((endCount == -1) && ((image.equalsIgnoreCase("PROCEDURE"))
92.4529 + || (image.equalsIgnoreCase("FUNCTION")))) {
92.4530 + return tmp;
92.4531 + } else if ((endCount == 0) & (image.equalsIgnoreCase("BODY"))) {
92.4532 + boolean pre = getPreviousNonWhitespace(ts, true);
92.4533 + Token<PlsqlTokenId> previous = ts.token();
92.4534 + if ((pre != false) && (previous.text().toString().equalsIgnoreCase("PACKAGE"))) {
92.4535 + return previous;
92.4536 + }
92.4537 + }
92.4538 + }
92.4539 +
92.4540 + moveBack = getPreviousNonWhitespace(ts, true);
92.4541 + tmp = ts.token();
92.4542 + }
92.4543 +
92.4544 + return begin;
92.4545 + }
92.4546 +
92.4547 + /**
92.4548 + * Check whether this is a block comment, single line or multi lined comment
92.4549 + * @param current
92.4550 + * @param ts
92.4551 + * @return
92.4552 + */
92.4553 + private PlsqlBlock checkComment(Token<PlsqlTokenId> current, TokenSequence<PlsqlTokenId> ts) {
92.4554 + //If the line don't start with the comment ignore
92.4555 + String prefix = getPreceedingText(current.offset(tokenHierarchy), ts);
92.4556 + if (!prefix.trim().equals("")) {
92.4557 + return null;
92.4558 + }
92.4559 +
92.4560 + Token<PlsqlTokenId> commentBegin = current;
92.4561 + Token<PlsqlTokenId> tmp = current;
92.4562 + Token<PlsqlTokenId> commentEnd = current;
92.4563 + PlsqlBlock block = null;
92.4564 + String text = commentBegin.text().toString();
92.4565 + int offset = ts.offset();
92.4566 + boolean moveNext = getNextNonWhitespace(ts, false);
92.4567 + tmp = ts.token();
92.4568 + boolean takeDesc = true;
92.4569 + String desc = getCommentDescription(text);
92.4570 + if (!desc.equals("COMMENT...")) {
92.4571 + takeDesc = false;
92.4572 + }
92.4573 +
92.4574 + while (moveNext) {
92.4575 + PlsqlTokenId tokenID = tmp.id();
92.4576 +
92.4577 + //We have come to the end of the view declaration
92.4578 + if (tokenID != PlsqlTokenId.LINE_COMMENT) {
92.4579 + break;
92.4580 + } else {
92.4581 + commentEnd = tmp;
92.4582 + if (takeDesc) {
92.4583 + text = text + tmp.text().toString();
92.4584 + desc = getCommentDescription(text);
92.4585 + if (!desc.equals("COMMENT...")) {
92.4586 + takeDesc = false;
92.4587 + }
92.4588 + }
92.4589 + moveNext = getNextNonWhitespace(ts, false);
92.4590 + tmp = ts.token();
92.4591 + }
92.4592 + }
92.4593 +
92.4594 + offset = commentEnd.offset(tokenHierarchy);
92.4595 + ts.move(offset);
92.4596 + ts.moveNext();
92.4597 +
92.4598 + //Calculate end offset
92.4599 + int endOffset = commentEnd.offset(tokenHierarchy) + commentEnd.length();
92.4600 +
92.4601 + block = new PlsqlBlock(commentBegin.offset(tokenHierarchy),
92.4602 + endOffset, desc, "", PlsqlBlockType.COMMENT);
92.4603 +
92.4604 + return block;
92.4605 + }
92.4606 +
92.4607 + /**
92.4608 + * Method that will give the description of the comment fold
92.4609 + * @param text
92.4610 + * @return
92.4611 + */
92.4612 + private String getCommentDescription(String text) {
92.4613 + String description = "COMMENT...";
92.4614 +
92.4615 + //Get first -- character from begin to end
92.4616 + char[] textArr = text.toCharArray();
92.4617 + int begin = 0;
92.4618 + int end = 0;
92.4619 +
92.4620 + //Get the start character which is not -
92.4621 + int i = 0;
92.4622 + while (textArr.length > i) {
92.4623 + if ((textArr[i] != '-') && (textArr[i] != ' ')) {
92.4624 + begin = i;
92.4625 + break;
92.4626 + }
92.4627 + i++;
92.4628 + }
92.4629 +
92.4630 + //Get end character which is -
92.4631 + i++;
92.4632 + while (textArr.length > i) {
92.4633 + if (textArr[i] == '-') {
92.4634 + break;
92.4635 + }
92.4636 + i++;
92.4637 + }
92.4638 +
92.4639 + end = i;
92.4640 +
92.4641 + if (begin != 0) {
92.4642 + description = "-- " + text.substring(begin, end);
92.4643 + }
92.4644 +
92.4645 + return description;
92.4646 + }
92.4647 +
92.4648 + /**
92.4649 + * Check whether this is the start of a PROCEDURE/FUNCTION block
92.4650 + * @param methodToken
92.4651 + * @param ts
92.4652 + * @param type
92.4653 + * @return
92.4654 + */
92.4655 + private PlsqlBlock checkMethod(Token<PlsqlTokenId> methodToken, TokenSequence<PlsqlTokenId> ts, PlsqlBlockType type, List<PlsqlBlock> parentBlocks) {
92.4656 + Token<PlsqlTokenId> methodBegin = methodToken;
92.4657 + Token<PlsqlTokenId> tmp = methodToken;
92.4658 + PlsqlBlock block = null;
92.4659 + List<PlsqlBlock> lstChild = new ArrayList<PlsqlBlock>();
92.4660 + boolean isFound = false;
92.4661 + boolean pragmaFound = false;
92.4662 + int colunCount = 0;
92.4663 + String methodName = "";
92.4664 + boolean moveNext = false;
92.4665 + int beginCount = 0; //workaround to identify end of method...
92.4666 +
92.4667 + //Check whether the beginning is in a SQL Plus command
92.4668 + if (sqlPlusLine(ts)) {
92.4669 + return null;
92.4670 + }
92.4671 +
92.4672 + //Get procedure/function name which is the next non whitespace token
92.4673 + moveNext = getNextNonWhitespace(ts, true);
92.4674 + tmp = ts.token();
92.4675 + if (moveNext == false) {
92.4676 + return block;
92.4677 + }
92.4678 +
92.4679 + methodName = tmp.text().toString();
92.4680 + methodName = checkForOtherSchema(ts, methodName);
92.4681 + String alias = "";
92.4682 + if (methodName.indexOf('&') != -1) {
92.4683 alias = methodName;
92.4684 - }
92.4685 -
92.4686 - methodName = getDefine(methodName);
92.4687 -
92.4688 - //Get the token after the end token
92.4689 - ts.move(end.offset(tokenHierarchy));
92.4690 - ts.moveNext();
92.4691 - ts.moveNext();
92.4692 -
92.4693 - if (image.equalsIgnoreCase("PROCEDURE")) {
92.4694 - block = new PlsqlBlock(begin.offset(tokenHierarchy), ts.offset(),
92.4695 - methodName, alias, PlsqlBlockType.PROCEDURE_IMPL);
92.4696 - checkPrefix(begin.offset(tokenHierarchy), ts, block);
92.4697 - } else if (image.equalsIgnoreCase("PACKAGE")) {
92.4698 - //get next token & check
92.4699 - //find semicolon
92.4700 - int endPos = ts.offset();
92.4701 - ts.move(begin.offset(tokenHierarchy));
92.4702 - ts.moveNext();
92.4703 - boolean moveNext = false;
92.4704 - moveNext = getNextNonWhitespace(ts, true);
92.4705 - Token<PlsqlTokenId> next = ts.token();
92.4706 - PlsqlBlockType foldType = PlsqlBlockType.PACKAGE;
92.4707 - if ((moveNext != false) && (next.text().toString().equalsIgnoreCase("BODY"))) {
92.4708 - foldType = PlsqlBlockType.PACKAGE_BODY;
92.4709 + }
92.4710 +
92.4711 + methodName = getDefine(methodName);
92.4712 + Token<PlsqlTokenId> customStartToken = null;
92.4713 + Token<PlsqlTokenId> previous = tmp;
92.4714 +
92.4715 + //Check whether there is the keyword 'IS' before ';'
92.4716 + while (moveNext) {
92.4717 + String image = tmp.text().toString();
92.4718 + PlsqlTokenId tokenID = tmp.id();
92.4719 +
92.4720 + if ((tmp != null) && (!image.equals(";")) && (!image.equalsIgnoreCase("END")) && (!previous.toString().equalsIgnoreCase("END")) && (tmp.offset(tokenHierarchy) > endParse)) { //end is added here for the abnormal case in code templates
92.4721 + break;
92.4722 }
92.4723
92.4724 - block = new PlsqlBlock(begin.offset(tokenHierarchy), endPos,
92.4725 - methodName, alias, foldType);
92.4726 - checkPrefix(begin.offset(tokenHierarchy), ts, block);
92.4727 - } else {
92.4728 - block = new PlsqlBlock(begin.offset(tokenHierarchy), ts.offset(),
92.4729 - methodName, alias, PlsqlBlockType.FUNCTION_IMPL);
92.4730 - checkPrefix(begin.offset(tokenHierarchy), ts, block);
92.4731 - }
92.4732 - }
92.4733 -
92.4734 - ts.move(end.offset(tokenHierarchy));
92.4735 - ts.moveNext();
92.4736 - return block;
92.4737 - }
92.4738 -
92.4739 - /**
92.4740 - * Check whether there is a function/procedure in this block
92.4741 - * @param ts
92.4742 - * @param methodName
92.4743 - * @return
92.4744 - */
92.4745 - private Token<PlsqlTokenId> checkMethodBegin(TokenSequence<PlsqlTokenId> ts, String methodName) {
92.4746 - Token<PlsqlTokenId> begin = null;
92.4747 - boolean moveBack = ts.movePrevious();
92.4748 - Token<PlsqlTokenId> tmp = ts.token();
92.4749 - int endCount = 0;
92.4750 -
92.4751 - while (moveBack) {
92.4752 - String image = tmp.text().toString();
92.4753 -
92.4754 - if (image.equalsIgnoreCase(methodName)) {
92.4755 - //Go to previous word
92.4756 - boolean move = getPreviousNonWhitespace(ts, true);
92.4757 - Token<PlsqlTokenId> token = ts.token();
92.4758 -
92.4759 - if ((move != false) && (token.id() == PlsqlTokenId.KEYWORD)) {
92.4760 - if ((token.text().toString().equalsIgnoreCase("FUNCTION"))
92.4761 - || (token.text().toString().equalsIgnoreCase("PROCEDURE"))) {
92.4762 - //if there were inner functions & procedures
92.4763 - if (endCount != 0) {
92.4764 - endCount--;
92.4765 - } else {
92.4766 - return token;
92.4767 - }
92.4768 - } else if (token.text().toString().equalsIgnoreCase("BODY")) {
92.4769 - boolean pre = getPreviousNonWhitespace(ts, true);
92.4770 - Token<PlsqlTokenId> previous = ts.token();
92.4771 - if ((pre != false) && (previous.text().toString().equalsIgnoreCase("PACKAGE"))) {
92.4772 - return previous;
92.4773 - }
92.4774 -
92.4775 - } else if (token.text().toString().equalsIgnoreCase("END")) {
92.4776 - ++endCount;
92.4777 - }
92.4778 + //Increment colun count, if IS is not found before first break
92.4779 + if ((tokenID == PlsqlTokenId.OPERATOR) && image.equals(";")) {
92.4780 + ++colunCount;
92.4781 + boolean isEndFound = false;
92.4782 + int offset = ts.offset();
92.4783 + boolean preMove = false;
92.4784 + preMove = getPreviousNonWhitespace(ts, true);
92.4785 +
92.4786 + //workaround for issue with functions/procedures ending with End; (no name)
92.4787 + Token<PlsqlTokenId> previousNWS = ts.token();
92.4788 + PlsqlTokenId previd = previousNWS.id();
92.4789 + if ((preMove != false) && previousNWS.text().toString().equalsIgnoreCase("END")) {
92.4790 + if (beginCount < 1) {
92.4791 + isEndFound = true;
92.4792 + }
92.4793 + } else {
92.4794 + preMove = getPreviousNonWhitespace(ts, true);
92.4795 + previousNWS = ts.token();
92.4796 + if ((previd == PlsqlTokenId.IDENTIFIER || previd == PlsqlTokenId.KEYWORD)
92.4797 + && previousNWS.text().toString().equalsIgnoreCase("END")) {
92.4798 + isEndFound = true;
92.4799 + }
92.4800 + }
92.4801 +
92.4802 + ts.move(offset);
92.4803 + if ((colunCount == 1) && (!isFound) && (!pragmaFound) && (!isEndFound)) {
92.4804 + //Although we were looking for impl's we have found a def here
92.4805 + ts.moveNext();
92.4806 + ts.moveNext();
92.4807 + if (type == PlsqlBlockType.PROCEDURE_IMPL) {
92.4808 + block = new PlsqlBlock(methodBegin.offset(tokenHierarchy),
92.4809 + ts.offset(), methodName, alias, PlsqlBlockType.PROCEDURE_DEF);
92.4810 + } else {
92.4811 + block = new PlsqlBlock(methodBegin.offset(tokenHierarchy),
92.4812 + ts.offset(), methodName, alias, PlsqlBlockType.FUNCTION_DEF);
92.4813 + }
92.4814 +
92.4815 + return block;
92.4816 + }
92.4817 + ts.moveNext();
92.4818 }
92.4819 - }
92.4820 - moveBack = getPreviousNonWhitespace(ts, true);
92.4821 - tmp = ts.token();
92.4822 - }
92.4823 -
92.4824 - return begin;
92.4825 - }
92.4826 -
92.4827 - /**
92.4828 - * Check whether there is a function/procedure in this block
92.4829 - * Method name is not there in the 'END;'
92.4830 - * @param ts
92.4831 - * @return
92.4832 - */
92.4833 - private Token<PlsqlTokenId> checkMethodBegin(TokenSequence<PlsqlTokenId> ts) {
92.4834 - Token<PlsqlTokenId> begin = null;
92.4835 - boolean moveBack = ts.movePrevious();
92.4836 - Token<PlsqlTokenId> tmp = ts.token();
92.4837 - int endCount = 0;
92.4838 -
92.4839 - while (moveBack) {
92.4840 - String image = tmp.text().toString();
92.4841 -
92.4842 - if (tmp.id() == PlsqlTokenId.KEYWORD) {
92.4843 - if ((image.equalsIgnoreCase("BEGIN"))) {
92.4844 - endCount--;
92.4845 - } else if ((image.equalsIgnoreCase("END"))) {
92.4846 - int off = ts.offset();
92.4847 - if (getNextNonWhitespace(ts, true)) {
92.4848 - tmp = ts.token();
92.4849 - }
92.4850 -
92.4851 - if ((tmp.text().toString().equals(";")) || (tmp.id() == PlsqlTokenId.IDENTIFIER)
92.4852 - || (tmp.id() == PlsqlTokenId.KEYWORD && (!tmp.toString().equalsIgnoreCase("IF")
92.4853 - && !tmp.toString().equalsIgnoreCase("CASE") && !tmp.toString().equalsIgnoreCase("LOOP")))) {
92.4854 - endCount++;
92.4855 - }
92.4856 -
92.4857 - ts.move(off);
92.4858 - ts.moveNext();
92.4859 - } else if ((endCount == 0) & (image.equalsIgnoreCase("PACKAGE"))) {
92.4860 - return tmp;
92.4861 - } else if ((endCount == -1) && ((image.equalsIgnoreCase("PROCEDURE"))
92.4862 - || (image.equalsIgnoreCase("FUNCTION")))) {
92.4863 - return tmp;
92.4864 - } else if ((endCount == 0) & (image.equalsIgnoreCase("BODY"))) {
92.4865 - boolean pre = getPreviousNonWhitespace(ts, true);
92.4866 - Token<PlsqlTokenId> previous = ts.token();
92.4867 - if ((pre != false) && (previous.text().toString().equalsIgnoreCase("PACKAGE"))) {
92.4868 - return previous;
92.4869 - }
92.4870 +
92.4871 + //We might have come to the end of the procedure/function declaration
92.4872 + if (((tokenID == PlsqlTokenId.OPERATOR) && image.equals(";")) && isFound) {
92.4873 + //check whether previous Non white space token to the identifier is END
92.4874 + int offset = ts.offset();
92.4875 + boolean preMove = false;
92.4876 + preMove = getPreviousNonWhitespace(ts, true);
92.4877 + //workaround for issue with functions/procedures ending with End; (no name)
92.4878 + Token<PlsqlTokenId> previousNWS = ts.token();
92.4879 + String prevText = previousNWS.text().toString();
92.4880 + if ((preMove != false) && prevText.equalsIgnoreCase("END")) {
92.4881 + if (beginCount <= 0) {
92.4882 + ts.move(offset);
92.4883 + moveNext = ts.moveNext();
92.4884 + moveNext = ts.moveNext();
92.4885 + block = new PlsqlBlock(methodBegin.offset(tokenHierarchy),
92.4886 + ts.offset(), methodName, alias, type);
92.4887 + checkPrefix(methodBegin.offset(tokenHierarchy), ts, block);
92.4888 + break;
92.4889 + }
92.4890 + } else {
92.4891 + preMove = getPreviousNonWhitespace(ts, true);
92.4892 + previousNWS = ts.token();
92.4893 + if (previousNWS.text().toString().equalsIgnoreCase("END")) {
92.4894 + if (beginCount <= 0) {
92.4895 + ts.move(offset);
92.4896 + moveNext = ts.moveNext();
92.4897 + moveNext = ts.moveNext();
92.4898 + block = new PlsqlBlock(methodBegin.offset(tokenHierarchy),
92.4899 + ts.offset(), methodName, alias, type);
92.4900 + checkPrefix(methodBegin.offset(tokenHierarchy), ts, block);
92.4901 + break;
92.4902 + }
92.4903 + }
92.4904 + }
92.4905 + ts.move(offset);
92.4906 + moveNext = ts.moveNext();
92.4907 + } else if ((tokenID == PlsqlTokenId.KEYWORD)
92.4908 + && ((image.equalsIgnoreCase("PROCEDURE"))
92.4909 + || (image.equalsIgnoreCase("FUNCTION"))
92.4910 + || (image.equalsIgnoreCase("CURSOR")))) {
92.4911 + if (isFound && beginCount <= 0) {
92.4912 + int beforeOff = tmp.offset(tokenHierarchy);
92.4913 +
92.4914 + if (image.equalsIgnoreCase("PROCEDURE")) {
92.4915 + PlsqlBlock child = checkMethod(tmp, ts, PlsqlBlockType.PROCEDURE_IMPL, lstChild);
92.4916 + if (child == null) {//If inner check seems to have failed need to continue this one
92.4917 +
92.4918 + ts.move(beforeOff);
92.4919 + moveNext = ts.moveNext();
92.4920 + } else {
92.4921 + if (checkExisting(child, lstChild) == false) {
92.4922 + lstChild.add(child);
92.4923 + }
92.4924 + }
92.4925 + } //Inner procedure
92.4926 + else if (image.equalsIgnoreCase("FUNCTION")) {
92.4927 + PlsqlBlock child = checkMethod(tmp, ts, PlsqlBlockType.FUNCTION_IMPL, lstChild);
92.4928 + if (child == null) {//If inner check seems to have failed need to continue this one
92.4929 +
92.4930 + ts.move(beforeOff);
92.4931 + moveNext = ts.moveNext();
92.4932 + } else {
92.4933 + if (checkExisting(child, lstChild) == false) {
92.4934 + lstChild.add(child);
92.4935 + }
92.4936 + }
92.4937 + } //Inner function
92.4938 + else if (image.equalsIgnoreCase("CURSOR")) {
92.4939 + PlsqlBlock child = checkCursor(tmp, ts, lstChild);
92.4940 + if (child == null) {//If inner check seems to have failed need to continue this one
92.4941 +
92.4942 + ts.move(beforeOff);
92.4943 + moveNext = ts.moveNext();
92.4944 + } else {
92.4945 + if (checkExisting(child, lstChild) == false) {
92.4946 + lstChild.add(child);
92.4947 + }
92.4948 + }
92.4949 + } //Inner cursor
92.4950 + } else {
92.4951 + break;
92.4952 + }
92.4953 + } else if ((image.equalsIgnoreCase("IF")) && isFound) {
92.4954 + int beforeOff = tmp.offset(tokenHierarchy);
92.4955 + List children = checkIfBlock(tmp, ts, lstChild);
92.4956 + if (children == null || children.isEmpty()) {//If inner check seems to have failed need to continue this one
92.4957 +
92.4958 + ts.move(beforeOff);
92.4959 + moveNext =
92.4960 + ts.moveNext();
92.4961 + } else {
92.4962 + for (int i = 0; i
92.4963 + < children.size(); i++) {
92.4964 + PlsqlBlock child = (PlsqlBlock) children.get(i);
92.4965 + if (checkExisting(child, lstChild) == false) {
92.4966 + lstChild.add(child);
92.4967 + }
92.4968 + }
92.4969 + }
92.4970 + } //If block
92.4971 + else if ((image.equalsIgnoreCase("CASE")) && isFound) {
92.4972 + int beforeOff = tmp.offset(tokenHierarchy);
92.4973 + List children = checkCaseBlock(tmp, ts, lstChild, false);
92.4974 + if (children == null || children.isEmpty()) {//If inner check seems to have failed need to continue this one
92.4975 +
92.4976 + ts.move(beforeOff);
92.4977 + moveNext =
92.4978 + ts.moveNext();
92.4979 + } else {
92.4980 + for (int i = 0; i
92.4981 + < children.size(); i++) {
92.4982 + PlsqlBlock child = (PlsqlBlock) children.get(i);
92.4983 + if (checkExisting(child, lstChild) == false) {
92.4984 + lstChild.add(child);
92.4985 + }
92.4986 + }
92.4987 + }
92.4988 + } else if ((tokenID == PlsqlTokenId.KEYWORD)
92.4989 + && ((image.equalsIgnoreCase("LOOP"))
92.4990 + || (image.equalsIgnoreCase("WHILE"))
92.4991 + || (image.equalsIgnoreCase("FOR")))) {
92.4992 + if (isFound) {
92.4993 + int beforeOff = tmp.offset(tokenHierarchy);
92.4994 + if (!unsuccessBlocks.contains(beforeOff)) {
92.4995 + PlsqlBlock child = checkLoopBlock(tmp, ts, lstChild);
92.4996 + if (child == null) {//If inner check seems to have failed need to continue this one
92.4997 + unsuccessBlocks.add(beforeOff);
92.4998 + ts.move(beforeOff);
92.4999 + moveNext = ts.moveNext();
92.5000 + } else {
92.5001 + if (checkExisting(child, lstChild) == false) {
92.5002 + lstChild.add(child);
92.5003 + }
92.5004 + }
92.5005 + }
92.5006 + }
92.5007 + } else if ((tokenID == PlsqlTokenId.KEYWORD) && (image.equalsIgnoreCase("TABLE")
92.5008 + || image.equalsIgnoreCase("INDEX")
92.5009 + || image.equalsIgnoreCase("SELECT")
92.5010 + || image.equalsIgnoreCase("UPDATE")
92.5011 + || image.equalsIgnoreCase("DELETE")
92.5012 + || image.equalsIgnoreCase("INSERT")
92.5013 + || image.equalsIgnoreCase("MERGE")
92.5014 + || image.equalsIgnoreCase("DROP")
92.5015 + || image.equalsIgnoreCase("SEQUENCE"))) {
92.5016 + if (!isNotBlockStart(tmp, ts)) {
92.5017 + int offset = tmp.offset(tokenHierarchy);
92.5018 + PlsqlBlock child = checkStatementBlock(tmp, ts, parentBlocks);
92.5019 + if (child == null) {//If inner check seems to have failed need to continue this one
92.5020 +
92.5021 + ts.move(offset);
92.5022 + ts.moveNext();
92.5023 + } else {
92.5024 + if (checkExisting(child, lstChild) == false) {
92.5025 + lstChild.add(child);
92.5026 + }
92.5027 + }
92.5028 + }
92.5029 + } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.5030 + //only single comment line
92.5031 + if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.5032 + customStartToken = tmp;
92.5033 + } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.5034 + if (customStartToken != null) {
92.5035 + String name = customStartToken.text().toString();
92.5036 + int index = name.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.5037 + name =
92.5038 + name.substring(index + 7).trim();
92.5039 + if (ts.moveNext()) {
92.5040 + tmp = ts.token();
92.5041 + PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.5042 + tmp.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.5043 + customFoldBlocks.add(custom);
92.5044 + }
92.5045 + customStartToken = null;
92.5046 + }
92.5047 + } else {
92.5048 + PlsqlBlock child = checkComment(tmp, ts);
92.5049 + if ((child != null) && (checkExisting(child, lstChild) == false)) {
92.5050 + lstChild.add(child);
92.5051 + }
92.5052 + }
92.5053 + } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.5054 + int start = tmp.offset(tokenHierarchy);
92.5055 + PlsqlBlock child = new PlsqlBlock(start,
92.5056 + start + tmp.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.5057 + if ((child != null) && (checkExisting(child, lstChild) == false)) {
92.5058 + lstChild.add(child);
92.5059 + }
92.5060 + } else if (tokenID == PlsqlTokenId.KEYWORD && (image.equalsIgnoreCase("BEGIN"))) {
92.5061 + beginCount++;
92.5062 + } else if (tokenID == PlsqlTokenId.KEYWORD && image.equalsIgnoreCase("END")) {
92.5063 + int off = ts.offset();
92.5064 + if (getNextNonWhitespace(ts, true)) {
92.5065 + tmp = ts.token();
92.5066 + }
92.5067 +
92.5068 + if ((tmp.text().toString().equals(";")) || (tmp.id() == PlsqlTokenId.IDENTIFIER)
92.5069 + || (tmp.id() == PlsqlTokenId.KEYWORD && (!tmp.toString().equalsIgnoreCase("IF")
92.5070 + && !tmp.toString().equalsIgnoreCase("CASE") && !tmp.toString().equalsIgnoreCase("LOOP")))) {
92.5071 + beginCount--;
92.5072 + }
92.5073 +
92.5074 + ts.move(off);
92.5075 + ts.moveNext();
92.5076 + tmp = ts.token();
92.5077 + } else if (tokenID == PlsqlTokenId.KEYWORD && image.equalsIgnoreCase("PRAGMA")) {
92.5078 + pragmaFound = true;
92.5079 + } else {
92.5080 + //Mark when we come to 'IS'
92.5081 + if ((tokenID == PlsqlTokenId.KEYWORD)
92.5082 + && ((image.equalsIgnoreCase("IS")))) {
92.5083 + isFound = true;
92.5084 + }
92.5085 }
92.5086 - }
92.5087 -
92.5088 - moveBack = getPreviousNonWhitespace(ts, true);
92.5089 - tmp = ts.token();
92.5090 - }
92.5091 -
92.5092 - return begin;
92.5093 - }
92.5094 -
92.5095 - /**
92.5096 - * Check whether this is a block comment, single line or multi lined comment
92.5097 - * @param current
92.5098 - * @param ts
92.5099 - * @return
92.5100 - */
92.5101 - private PlsqlBlock checkComment(Token<PlsqlTokenId> current, TokenSequence<PlsqlTokenId> ts) {
92.5102 - //If the line don't start with the comment ignore
92.5103 - String prefix = getPreceedingText(current.offset(tokenHierarchy), ts);
92.5104 - if (!prefix.trim().equals("")) {
92.5105 - return null;
92.5106 - }
92.5107 -
92.5108 - Token<PlsqlTokenId> commentBegin = current;
92.5109 - Token<PlsqlTokenId> tmp = current;
92.5110 - Token<PlsqlTokenId> commentEnd = current;
92.5111 - PlsqlBlock block = null;
92.5112 - String text = commentBegin.text().toString();
92.5113 - int offset = ts.offset();
92.5114 - boolean moveNext = getNextNonWhitespace(ts, false);
92.5115 - tmp = ts.token();
92.5116 - boolean takeDesc = true;
92.5117 - String desc = getCommentDescription(text);
92.5118 - if (!desc.equals("COMMENT...")) {
92.5119 - takeDesc = false;
92.5120 - }
92.5121 -
92.5122 - while (moveNext) {
92.5123 - PlsqlTokenId tokenID = tmp.id();
92.5124 -
92.5125 - //We have come to the end of the view declaration
92.5126 - if (tokenID != PlsqlTokenId.LINE_COMMENT) {
92.5127 - break;
92.5128 - } else {
92.5129 - commentEnd = tmp;
92.5130 - if (takeDesc) {
92.5131 - text = text + tmp.text().toString();
92.5132 - desc = getCommentDescription(text);
92.5133 - if (!desc.equals("COMMENT...")) {
92.5134 - takeDesc = false;
92.5135 - }
92.5136 + if (tokenID != PlsqlTokenId.WHITESPACE) {
92.5137 + previous = tmp;
92.5138 }
92.5139 - moveNext = getNextNonWhitespace(ts, false);
92.5140 +
92.5141 + moveNext = ts.moveNext();
92.5142 tmp = ts.token();
92.5143 - }
92.5144 - }
92.5145 -
92.5146 - offset = commentEnd.offset(tokenHierarchy);
92.5147 - ts.move(offset);
92.5148 - ts.moveNext();
92.5149 -
92.5150 - //Calculate end offset
92.5151 - int endOffset = commentEnd.offset(tokenHierarchy) + commentEnd.length();
92.5152 -
92.5153 - block = new PlsqlBlock(commentBegin.offset(tokenHierarchy),
92.5154 - endOffset, desc, "", PlsqlBlockType.COMMENT);
92.5155 -
92.5156 - return block;
92.5157 - }
92.5158 -
92.5159 - /**
92.5160 - * Method that will give the description of the comment fold
92.5161 - * @param text
92.5162 - * @return
92.5163 - */
92.5164 - private String getCommentDescription(String text) {
92.5165 - String description = "COMMENT...";
92.5166 -
92.5167 - //Get first -- character from begin to end
92.5168 - char[] textArr = text.toCharArray();
92.5169 - int begin = 0;
92.5170 - int end = 0;
92.5171 -
92.5172 - //Get the start character which is not -
92.5173 - int i = 0;
92.5174 - while (textArr.length > i) {
92.5175 - if ((textArr[i] != '-') && (textArr[i] != ' ')) {
92.5176 - begin = i;
92.5177 - break;
92.5178 - }
92.5179 - i++;
92.5180 - }
92.5181 -
92.5182 - //Get end character which is -
92.5183 - i++;
92.5184 - while (textArr.length > i) {
92.5185 - if (textArr[i] == '-') {
92.5186 - break;
92.5187 - }
92.5188 - i++;
92.5189 - }
92.5190 -
92.5191 - end = i;
92.5192 -
92.5193 - if (begin != 0) {
92.5194 - description = "-- " + text.substring(begin, end);
92.5195 - }
92.5196 -
92.5197 - return description;
92.5198 - }
92.5199 -
92.5200 - /**
92.5201 - * Check whether this is the start of a PROCEDURE/FUNCTION block
92.5202 - * @param methodToken
92.5203 - * @param ts
92.5204 - * @param type
92.5205 - * @return
92.5206 - */
92.5207 - private PlsqlBlock checkMethod(Token<PlsqlTokenId> methodToken, TokenSequence<PlsqlTokenId> ts, PlsqlBlockType type, List<PlsqlBlock> parentBlocks) {
92.5208 - Token<PlsqlTokenId> methodBegin = methodToken;
92.5209 - Token<PlsqlTokenId> tmp = methodToken;
92.5210 - PlsqlBlock block = null;
92.5211 - List<PlsqlBlock> lstChild = new ArrayList<PlsqlBlock>();
92.5212 - boolean isFound = false;
92.5213 - boolean pragmaFound = false;
92.5214 - int colunCount = 0;
92.5215 - String methodName = "";
92.5216 - boolean moveNext = false;
92.5217 - int beginCount = 0; //workaround to identify end of method...
92.5218 -
92.5219 - //Check whether the beginning is in a SQL Plus command
92.5220 - if (sqlPlusLine(ts)) {
92.5221 - return null;
92.5222 - }
92.5223 -
92.5224 - //Get procedure/function name which is the next non whitespace token
92.5225 - moveNext = getNextNonWhitespace(ts, true);
92.5226 - tmp = ts.token();
92.5227 - if (moveNext == false) {
92.5228 - return block;
92.5229 - }
92.5230 -
92.5231 - methodName = tmp.text().toString();
92.5232 - methodName = checkForOtherSchema(ts, methodName);
92.5233 - String alias = "";
92.5234 - if (methodName.indexOf('&') != -1) {
92.5235 - alias = methodName;
92.5236 - }
92.5237 -
92.5238 - methodName = getDefine(methodName);
92.5239 - Token<PlsqlTokenId> customStartToken = null;
92.5240 - Token<PlsqlTokenId> previous = tmp;
92.5241 -
92.5242 - //Check whether there is the keyword 'IS' before ';'
92.5243 - while (moveNext) {
92.5244 - String image = tmp.text().toString();
92.5245 - PlsqlTokenId tokenID = tmp.id();
92.5246 -
92.5247 - if ((tmp != null) && (!image.equals(";")) && (!image.equalsIgnoreCase("END")) && (!previous.toString().equalsIgnoreCase("END")) && (tmp.offset(tokenHierarchy) > endParse)) { //end is added here for the abnormal case in code templates
92.5248 - break;
92.5249 - }
92.5250 -
92.5251 - //Increment colun count, if IS is not found before first break
92.5252 - if ((tokenID == PlsqlTokenId.OPERATOR) && image.equals(";")) {
92.5253 - ++colunCount;
92.5254 - boolean isEndFound = false;
92.5255 - int offset = ts.offset();
92.5256 - boolean preMove = false;
92.5257 - preMove = getPreviousNonWhitespace(ts, true);
92.5258 -
92.5259 - //workaround for issue with functions/procedures ending with End; (no name)
92.5260 - Token<PlsqlTokenId> previousNWS = ts.token();
92.5261 - PlsqlTokenId previd = previousNWS.id();
92.5262 - if ((preMove != false) && previousNWS.text().toString().equalsIgnoreCase("END")) {
92.5263 - if (beginCount < 1) {
92.5264 - isEndFound = true;
92.5265 - }
92.5266 - } else {
92.5267 - preMove = getPreviousNonWhitespace(ts, true);
92.5268 - previousNWS = ts.token();
92.5269 - if ((previd == PlsqlTokenId.IDENTIFIER || previd == PlsqlTokenId.KEYWORD)
92.5270 - && previousNWS.text().toString().equalsIgnoreCase("END")) {
92.5271 - isEndFound = true;
92.5272 - }
92.5273 + }
92.5274 +
92.5275 + if (block != null) {
92.5276 + //check whether there is a parent block
92.5277 + PlsqlBlock parent = getParentBlock(blockHierarchy, block.getStartOffset(), block.getEndOffset());
92.5278 + if ((parent != null) && (parent.getName().equals(block.getName()))) {
92.5279 + if (parent.getEndOffset() == block.getEndOffset()) {
92.5280 + return null;
92.5281 + }
92.5282 }
92.5283
92.5284 - ts.move(offset);
92.5285 - if ((colunCount == 1) && (!isFound) && (!pragmaFound) && (!isEndFound)) {
92.5286 - //Although we were looking for impl's we have found a def here
92.5287 - ts.moveNext();
92.5288 - ts.moveNext();
92.5289 - if (type == PlsqlBlockType.PROCEDURE_IMPL) {
92.5290 - block = new PlsqlBlock(methodBegin.offset(tokenHierarchy),
92.5291 - ts.offset(), methodName, alias, PlsqlBlockType.PROCEDURE_DEF);
92.5292 - } else {
92.5293 - block = new PlsqlBlock(methodBegin.offset(tokenHierarchy),
92.5294 - ts.offset(), methodName, alias, PlsqlBlockType.FUNCTION_DEF);
92.5295 - }
92.5296 -
92.5297 - return block;
92.5298 - }
92.5299 - ts.moveNext();
92.5300 - }
92.5301 -
92.5302 - //We might have come to the end of the procedure/function declaration
92.5303 - if (((tokenID == PlsqlTokenId.OPERATOR) && image.equals(";")) && isFound) {
92.5304 - //check whether previous Non white space token to the identifier is END
92.5305 - int offset = ts.offset();
92.5306 - boolean preMove = false;
92.5307 - preMove = getPreviousNonWhitespace(ts, true);
92.5308 - //workaround for issue with functions/procedures ending with End; (no name)
92.5309 - Token<PlsqlTokenId> previousNWS = ts.token();
92.5310 - String prevText = previousNWS.text().toString();
92.5311 - if ((preMove != false) && prevText.equalsIgnoreCase("END")) {
92.5312 - if (beginCount <= 0) {
92.5313 - ts.move(offset);
92.5314 - moveNext = ts.moveNext();
92.5315 - moveNext = ts.moveNext();
92.5316 - block = new PlsqlBlock(methodBegin.offset(tokenHierarchy),
92.5317 - ts.offset(), methodName, alias, type);
92.5318 - checkPrefix(methodBegin.offset(tokenHierarchy), ts, block);
92.5319 - break;
92.5320 - }
92.5321 - } else {
92.5322 - preMove = getPreviousNonWhitespace(ts, true);
92.5323 - previousNWS = ts.token();
92.5324 - if (previousNWS.text().toString().equalsIgnoreCase("END")) {
92.5325 - if (beginCount <= 0) {
92.5326 - ts.move(offset);
92.5327 - moveNext = ts.moveNext();
92.5328 - moveNext = ts.moveNext();
92.5329 - block = new PlsqlBlock(methodBegin.offset(tokenHierarchy),
92.5330 - ts.offset(), methodName, alias, type);
92.5331 - checkPrefix(methodBegin.offset(tokenHierarchy), ts, block);
92.5332 - break;
92.5333 - }
92.5334 - }
92.5335 - }
92.5336 - ts.move(offset);
92.5337 - moveNext = ts.moveNext();
92.5338 - } else if ((tokenID == PlsqlTokenId.KEYWORD)
92.5339 - && ((image.equalsIgnoreCase("PROCEDURE"))
92.5340 - || (image.equalsIgnoreCase("FUNCTION"))
92.5341 - || (image.equalsIgnoreCase("CURSOR")))) {
92.5342 - if (isFound && beginCount <= 0) {
92.5343 - int beforeOff = tmp.offset(tokenHierarchy);
92.5344 -
92.5345 - if (image.equalsIgnoreCase("PROCEDURE")) {
92.5346 - PlsqlBlock child = checkMethod(tmp, ts, PlsqlBlockType.PROCEDURE_IMPL, lstChild);
92.5347 - if (child == null) {//If inner check seems to have failed need to continue this one
92.5348 -
92.5349 - ts.move(beforeOff);
92.5350 - moveNext = ts.moveNext();
92.5351 - } else {
92.5352 - if (checkExisting(child, lstChild) == false) {
92.5353 - lstChild.add(child);
92.5354 - }
92.5355 - }
92.5356 - } //Inner procedure
92.5357 - else if (image.equalsIgnoreCase("FUNCTION")) {
92.5358 - PlsqlBlock child = checkMethod(tmp, ts, PlsqlBlockType.FUNCTION_IMPL, lstChild);
92.5359 - if (child == null) {//If inner check seems to have failed need to continue this one
92.5360 -
92.5361 - ts.move(beforeOff);
92.5362 - moveNext = ts.moveNext();
92.5363 - } else {
92.5364 - if (checkExisting(child, lstChild) == false) {
92.5365 - lstChild.add(child);
92.5366 - }
92.5367 - }
92.5368 - } //Inner function
92.5369 - else if (image.equalsIgnoreCase("CURSOR")) {
92.5370 - PlsqlBlock child = checkCursor(tmp, ts, lstChild);
92.5371 - if (child == null) {//If inner check seems to have failed need to continue this one
92.5372 -
92.5373 - ts.move(beforeOff);
92.5374 - moveNext = ts.moveNext();
92.5375 - } else {
92.5376 - if (checkExisting(child, lstChild) == false) {
92.5377 - lstChild.add(child);
92.5378 - }
92.5379 - }
92.5380 - } //Inner cursor
92.5381 - } else {
92.5382 - break;
92.5383 - }
92.5384 - } else if ((image.equalsIgnoreCase("IF")) && isFound) {
92.5385 - int beforeOff = tmp.offset(tokenHierarchy);
92.5386 - List children = checkIfBlock(tmp, ts, lstChild);
92.5387 - if (children == null || children.size() == 0) {//If inner check seems to have failed need to continue this one
92.5388 -
92.5389 - ts.move(beforeOff);
92.5390 - moveNext =
92.5391 - ts.moveNext();
92.5392 - } else {
92.5393 - for (int i = 0; i
92.5394 - < children.size(); i++) {
92.5395 - PlsqlBlock child = (PlsqlBlock) children.get(i);
92.5396 - if (checkExisting(child, lstChild) == false) {
92.5397 - lstChild.add(child);
92.5398 - }
92.5399 - }
92.5400 - }
92.5401 - } //If block
92.5402 - else if ((image.equalsIgnoreCase("CASE")) && isFound) {
92.5403 - int beforeOff = tmp.offset(tokenHierarchy);
92.5404 - List children = checkCaseBlock(tmp, ts, lstChild, false);
92.5405 - if (children == null || children.size() == 0) {//If inner check seems to have failed need to continue this one
92.5406 -
92.5407 - ts.move(beforeOff);
92.5408 - moveNext =
92.5409 - ts.moveNext();
92.5410 - } else {
92.5411 - for (int i = 0; i
92.5412 - < children.size(); i++) {
92.5413 - PlsqlBlock child = (PlsqlBlock) children.get(i);
92.5414 - if (checkExisting(child, lstChild) == false) {
92.5415 - lstChild.add(child);
92.5416 - }
92.5417 - }
92.5418 - }
92.5419 - } else if ((tokenID == PlsqlTokenId.KEYWORD)
92.5420 - && ((image.equalsIgnoreCase("LOOP"))
92.5421 - || (image.equalsIgnoreCase("WHILE"))
92.5422 - || (image.equalsIgnoreCase("FOR")))) {
92.5423 - if (isFound) {
92.5424 - int beforeOff = tmp.offset(tokenHierarchy);
92.5425 - if (!unsuccessBlocks.contains(beforeOff)) {
92.5426 - PlsqlBlock child = checkLoopBlock(tmp, ts, lstChild);
92.5427 - if (child == null) {//If inner check seems to have failed need to continue this one
92.5428 - unsuccessBlocks.add(beforeOff);
92.5429 - ts.move(beforeOff);
92.5430 - moveNext = ts.moveNext();
92.5431 - } else {
92.5432 - if (checkExisting(child, lstChild) == false) {
92.5433 - lstChild.add(child);
92.5434 - }
92.5435 - }
92.5436 - }
92.5437 - }
92.5438 - } else if ((tokenID == PlsqlTokenId.KEYWORD) && (image.equalsIgnoreCase("TABLE")
92.5439 - || image.equalsIgnoreCase("INDEX")
92.5440 - || image.equalsIgnoreCase("SELECT")
92.5441 - || image.equalsIgnoreCase("UPDATE")
92.5442 - || image.equalsIgnoreCase("DELETE")
92.5443 - || image.equalsIgnoreCase("INSERT")
92.5444 - || image.equalsIgnoreCase("MERGE")
92.5445 - || image.equalsIgnoreCase("DROP")
92.5446 - || image.equalsIgnoreCase("SEQUENCE"))) {
92.5447 - if (!isNotBlockStart(tmp, ts)) {
92.5448 - int offset = tmp.offset(tokenHierarchy);
92.5449 - PlsqlBlock child = checkStatementBlock(tmp, ts, parentBlocks);
92.5450 - if (child == null) {//If inner check seems to have failed need to continue this one
92.5451 -
92.5452 - ts.move(offset);
92.5453 - ts.moveNext();
92.5454 - } else {
92.5455 - if (checkExisting(child, lstChild) == false) {
92.5456 - lstChild.add(child);
92.5457 - }
92.5458 - }
92.5459 - }
92.5460 - } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.5461 - //only single comment line
92.5462 - if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.5463 - customStartToken = tmp;
92.5464 - } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.5465 - if (customStartToken != null) {
92.5466 - String name = customStartToken.text().toString();
92.5467 - int index = name.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.5468 - name =
92.5469 - name.substring(index + 7).trim();
92.5470 - if (ts.moveNext()) {
92.5471 - tmp = ts.token();
92.5472 - PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.5473 - tmp.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.5474 - customFoldBlocks.add(custom);
92.5475 - }
92.5476 - customStartToken = null;
92.5477 - }
92.5478 - } else {
92.5479 - PlsqlBlock child = checkComment(tmp, ts);
92.5480 - if ((child != null) && (checkExisting(child, lstChild) == false)) {
92.5481 - lstChild.add(child);
92.5482 - }
92.5483 - }
92.5484 - } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.5485 - int start = tmp.offset(tokenHierarchy);
92.5486 - PlsqlBlock child = new PlsqlBlock(start,
92.5487 - start + tmp.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.5488 - if ((child != null) && (checkExisting(child, lstChild) == false)) {
92.5489 - lstChild.add(child);
92.5490 - }
92.5491 - } else if (tokenID == PlsqlTokenId.KEYWORD && (image.equalsIgnoreCase("BEGIN"))) {
92.5492 - beginCount++;
92.5493 - } else if (tokenID == PlsqlTokenId.KEYWORD && image.equalsIgnoreCase("END")) {
92.5494 - int off = ts.offset();
92.5495 - if (getNextNonWhitespace(ts, true)) {
92.5496 - tmp = ts.token();
92.5497 - }
92.5498 -
92.5499 - if ((tmp.text().toString().equals(";")) || (tmp.id() == PlsqlTokenId.IDENTIFIER)
92.5500 - || (tmp.id() == PlsqlTokenId.KEYWORD && (!tmp.toString().equalsIgnoreCase("IF")
92.5501 - && !tmp.toString().equalsIgnoreCase("CASE") && !tmp.toString().equalsIgnoreCase("LOOP")))) {
92.5502 - beginCount--;
92.5503 - }
92.5504 -
92.5505 - ts.move(off);
92.5506 - ts.moveNext();
92.5507 - tmp = ts.token();
92.5508 - } else if (tokenID == PlsqlTokenId.KEYWORD && image.equalsIgnoreCase("PRAGMA")) {
92.5509 - pragmaFound = true;
92.5510 - } else {
92.5511 - //Mark when we come to 'IS'
92.5512 - if ((tokenID == PlsqlTokenId.KEYWORD)
92.5513 - && ((image.equalsIgnoreCase("IS")))) {
92.5514 - isFound = true;
92.5515 - }
92.5516 - }
92.5517 - if (tokenID != PlsqlTokenId.WHITESPACE) {
92.5518 - previous = tmp;
92.5519 - }
92.5520 -
92.5521 - moveNext = ts.moveNext();
92.5522 - tmp = ts.token();
92.5523 - }
92.5524 -
92.5525 - if (block != null) {
92.5526 - //check whether there is a parent block
92.5527 - PlsqlBlock parent = getParentBlock(blockHierarchy, block.getStartOffset(), block.getEndOffset());
92.5528 - if ((parent != null) && (parent.getName().equals(block.getName()))) {
92.5529 - if (parent.getEndOffset() == block.getEndOffset()) {
92.5530 - return null;
92.5531 - }
92.5532 - }
92.5533 -
92.5534 - //add children
92.5535 - addChildren(block, lstChild, parentBlocks);
92.5536 - }
92.5537 -
92.5538 - return block;
92.5539 - }
92.5540 -
92.5541 - /**
92.5542 - * Check whether this is the start of a PACKAGE block
92.5543 - * @param tempToken
92.5544 - * @param ts
92.5545 - * @return
92.5546 - */
92.5547 - private PlsqlBlock checkPackage(Token<PlsqlTokenId> packToken, TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> parentBlocks) {
92.5548 - Token<PlsqlTokenId> packBegin = packToken;
92.5549 - Token<PlsqlTokenId> tmp = packToken;
92.5550 - Token<PlsqlTokenId> tmpPre = packToken;
92.5551 - boolean isFound = false;
92.5552 - String packageName = "";
92.5553 - boolean isPackageBody = false;
92.5554 - boolean moveNext = false;
92.5555 - PlsqlBlock block = null;
92.5556 - List<PlsqlBlock> lstChild = new ArrayList<PlsqlBlock>();
92.5557 - int beginCount = 0;
92.5558 -
92.5559 - //Check whether the beginning is in a SQL Plus command
92.5560 - if (sqlPlusLine(ts)) {
92.5561 - return null;
92.5562 - }
92.5563 -
92.5564 - //Get package name which is the next non whitespace token in spec
92.5565 - moveNext = getNextNonWhitespace(ts, true);
92.5566 - tmp = ts.token();
92.5567 - if (moveNext == false) {
92.5568 - return block;
92.5569 - }
92.5570 -
92.5571 - if (tmp.text().toString().equalsIgnoreCase("BODY")) {
92.5572 - isPackageBody = true;
92.5573 - moveNext = getNextNonWhitespace(ts, true);
92.5574 - tmp = ts.token();
92.5575 - if (moveNext == false) {
92.5576 + //add children
92.5577 + addChildren(block, lstChild, parentBlocks);
92.5578 + }
92.5579 +
92.5580 + return block;
92.5581 + }
92.5582 +
92.5583 + /**
92.5584 + * Check whether this is the start of a PACKAGE block
92.5585 + * @param tempToken
92.5586 + * @param ts
92.5587 + * @return
92.5588 + */
92.5589 + private PlsqlBlock checkPackage(Token<PlsqlTokenId> packToken, TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> parentBlocks) {
92.5590 + Token<PlsqlTokenId> packBegin = packToken;
92.5591 + Token<PlsqlTokenId> tmp = packToken;
92.5592 + Token<PlsqlTokenId> tmpPre = packToken;
92.5593 + boolean isFound = false;
92.5594 + String packageName = "";
92.5595 + boolean isPackageBody = false;
92.5596 + boolean moveNext = false;
92.5597 + PlsqlBlock block = null;
92.5598 + List<PlsqlBlock> lstChild = new ArrayList<PlsqlBlock>();
92.5599 + int beginCount = 0;
92.5600 +
92.5601 + //Check whether the beginning is in a SQL Plus command
92.5602 + if (sqlPlusLine(ts)) {
92.5603 + return null;
92.5604 + }
92.5605 +
92.5606 + //Get package name which is the next non whitespace token in spec
92.5607 + moveNext = getNextNonWhitespace(ts, true);
92.5608 + tmp = ts.token();
92.5609 + if (moveNext == false) {
92.5610 return block;
92.5611 - }
92.5612 - }
92.5613 -
92.5614 - packageName = tmp.text().toString();
92.5615 - packageName = checkForOtherSchema(ts, packageName);
92.5616 - String alias = "";
92.5617 - if (packageName.indexOf('&') != -1) {
92.5618 - alias = packageName;
92.5619 - }
92.5620 - else if(hasDefineKey(packageName)){
92.5621 - alias = '&'+getDefineKey(packageName);
92.5622 - }
92.5623 -
92.5624 - packageName = getDefine(packageName);
92.5625 - Token<PlsqlTokenId> customStartToken = null;
92.5626 -
92.5627 - while (moveNext) {
92.5628 - String image = tmp.text().toString();
92.5629 - PlsqlTokenId tokenID = tmp.id();
92.5630 -
92.5631 - if ((tmp != null) && (!image.equals(";")) && (tmp.offset(tokenHierarchy) > endParse)) {
92.5632 - break;
92.5633 - }
92.5634 -
92.5635 - //We might have come to the end of the package
92.5636 - if (((tokenID == PlsqlTokenId.OPERATOR) && (image.equals(";") || (image.equals("/") && checkForOnlyChar(ts, ts.offset())))) && (isFound)
92.5637 - && ((tmpPre.text().toString().equalsIgnoreCase(packageName))
92.5638 - || ((!alias.equals("")) && (tmpPre.text().toString().equalsIgnoreCase(alias)))
92.5639 - || ((tmpPre.text().toString().equalsIgnoreCase("END")) && (beginCount < 0)))) {
92.5640 - boolean isPackage = false;
92.5641 - if (tmpPre.text().toString().equalsIgnoreCase(packageName)
92.5642 - || tmpPre.text().toString().equalsIgnoreCase(alias)) {
92.5643 - //check whether previous Non white space token to the identifier is END
92.5644 - int offset = ts.offset();
92.5645 - boolean preMove = false;
92.5646 - preMove = getPreviousNonWhitespace(ts, true);
92.5647 - preMove = getPreviousNonWhitespace(ts, true);
92.5648 - Token<PlsqlTokenId> previousNWS = ts.token();
92.5649 -
92.5650 - ts.move(offset);
92.5651 - ts.moveNext();
92.5652 -
92.5653 - if ((preMove != false)
92.5654 - && previousNWS.text().toString().equalsIgnoreCase("END")) {
92.5655 - isPackage = true;
92.5656 - }
92.5657 - } else if ((tmpPre.text().toString().equalsIgnoreCase("END")) && (beginCount < 0)) {
92.5658 - isPackage = true;
92.5659 - }
92.5660 -
92.5661 - //If this is a package end create the block
92.5662 - if (isPackage) {
92.5663 - PlsqlBlockType type = PlsqlBlockType.PACKAGE;
92.5664 -
92.5665 - if (isPackageBody) {
92.5666 - type = PlsqlBlockType.PACKAGE_BODY;
92.5667 - }
92.5668 -
92.5669 - ts.moveNext();
92.5670 -
92.5671 - block = new PlsqlBlock(packBegin.offset(tokenHierarchy),
92.5672 - ts.offset(), packageName, alias, type);
92.5673 - checkPrefix(packBegin.offset(tokenHierarchy), ts, block);
92.5674 - break;
92.5675 - }
92.5676 - } else if ((tokenID == PlsqlTokenId.KEYWORD)
92.5677 - && ((image.equalsIgnoreCase("PROCEDURE"))
92.5678 - || (image.equalsIgnoreCase("FUNCTION"))
92.5679 - || (image.equalsIgnoreCase("CURSOR")))) {
92.5680 - if (isFound) {
92.5681 - int beforeOff = tmp.offset(tokenHierarchy);
92.5682 -
92.5683 - if (image.equalsIgnoreCase("PROCEDURE")) {
92.5684 - PlsqlBlock child = checkMethod(tmp, ts, PlsqlBlockType.PROCEDURE_IMPL, lstChild);
92.5685 - if (child == null) {//If inner check seems to have failed need to continue this one
92.5686 -
92.5687 - ts.move(beforeOff);
92.5688 - ts.moveNext();
92.5689 - } else {
92.5690 - if (checkExisting(child, lstChild) == false) {
92.5691 - lstChild.add(child);
92.5692 - }
92.5693 - }
92.5694 - } //Inner procedure
92.5695 - else if (image.equalsIgnoreCase("FUNCTION")) {
92.5696 - PlsqlBlock child = checkMethod(tmp, ts, PlsqlBlockType.FUNCTION_IMPL, lstChild);
92.5697 - if (child == null) {//If inner check seems to have failed need to continue this one
92.5698 -
92.5699 - ts.move(beforeOff);
92.5700 - ts.moveNext();
92.5701 - } else {
92.5702 - if (checkExisting(child, lstChild) == false) {
92.5703 - lstChild.add(child);
92.5704 - }
92.5705 - }
92.5706 - } //Inner function
92.5707 - else if (image.equalsIgnoreCase("CURSOR")) {
92.5708 - PlsqlBlock child = checkCursor(tmp, ts, lstChild);
92.5709 - if (child == null) {//If inner check seems to have failed need to continue this one
92.5710 -
92.5711 - ts.move(beforeOff);
92.5712 - ts.moveNext();
92.5713 - } else {
92.5714 - if (checkExisting(child, lstChild) == false) {
92.5715 - lstChild.add(child);
92.5716 - }
92.5717 - }
92.5718 - } //Inner cursor
92.5719 -
92.5720 - } else {
92.5721 - break;
92.5722 - }
92.5723 - } else if (tokenID == PlsqlTokenId.KEYWORD && (image.equalsIgnoreCase("BEGIN"))) {
92.5724 - beginCount++;
92.5725 - } else if ((tokenID == PlsqlTokenId.KEYWORD)
92.5726 - && (image.equalsIgnoreCase("END"))) {
92.5727 - int off = ts.offset();
92.5728 - if (getNextNonWhitespace(ts, true)) {
92.5729 - tmp = ts.token();
92.5730 - }
92.5731 -
92.5732 - if ((tmp.text().toString().equals(";")) || (tmp.id() == PlsqlTokenId.IDENTIFIER)
92.5733 - || (tmp.id() == PlsqlTokenId.KEYWORD && (!tmp.toString().equalsIgnoreCase("IF")
92.5734 - && !tmp.toString().equalsIgnoreCase("CASE") && !tmp.toString().equalsIgnoreCase("LOOP")))) {
92.5735 - beginCount--;
92.5736 - }
92.5737 -
92.5738 - ts.move(off);
92.5739 - ts.moveNext();
92.5740 - tmp = ts.token();
92.5741 - } else if ((tokenID == PlsqlTokenId.KEYWORD)
92.5742 - && ((image.equalsIgnoreCase("CREATE")) || (image.equalsIgnoreCase("PACKAGE")))) {
92.5743 - return block;
92.5744 - } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.5745 - //only single comment line
92.5746 - if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.5747 - customStartToken = tmp;
92.5748 - } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.5749 - if (customStartToken != null) {
92.5750 - String name = customStartToken.text().toString();
92.5751 - int index = name.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.5752 - name = name.substring(index + 7).trim();
92.5753 - if (ts.moveNext()) {
92.5754 - tmp = ts.token();
92.5755 - PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.5756 - tmp.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.5757 - customFoldBlocks.add(custom);
92.5758 - }
92.5759 - customStartToken = null;
92.5760 - }
92.5761 - } else {
92.5762 - PlsqlBlock child = checkComment(tmp, ts);
92.5763 - if ((child != null) && (checkExisting(child, lstChild) == false)) {
92.5764 - lstChild.add(child);
92.5765 - }
92.5766 - }
92.5767 - } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.5768 - int start = tmp.offset(tokenHierarchy);
92.5769 - PlsqlBlock child = new PlsqlBlock(start,
92.5770 - start + tmp.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.5771 - if ((child != null) && (checkExisting(child, lstChild) == false)) {
92.5772 - lstChild.add(child);
92.5773 - }
92.5774 - } else {
92.5775 - //Mark when we come to 'IS'
92.5776 - if ((tokenID == PlsqlTokenId.KEYWORD)
92.5777 - && ((image.equalsIgnoreCase("IS")) || (image.equalsIgnoreCase("AS")))) {
92.5778 - isFound = true;
92.5779 - }
92.5780 - }
92.5781 -
92.5782 - if (tokenID != PlsqlTokenId.WHITESPACE) {//previous non whitespace token
92.5783 -
92.5784 - tmpPre = tmp;
92.5785 - }
92.5786 -
92.5787 - moveNext = ts.moveNext();
92.5788 - tmp = ts.token();
92.5789 - }
92.5790 -
92.5791 - if (block != null) {
92.5792 - //add children
92.5793 - addChildren(block, lstChild, parentBlocks);
92.5794 -
92.5795 - //Add immediate children
92.5796 - addImmediateChildren(block, parentBlocks);
92.5797 - }
92.5798 -
92.5799 - return block;
92.5800 - }
92.5801 -
92.5802 - /**
92.5803 - * Method that will check declare end blocks
92.5804 - * @param current
92.5805 - * @param ts
92.5806 - * @param parentBlocks
92.5807 - * @returns
92.5808 - */
92.5809 - private PlsqlBlock checkDeclareBlock(Token<PlsqlTokenId> current, TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> parentBlocks) {
92.5810 - Token<PlsqlTokenId> declareBegin;
92.5811 - Token<PlsqlTokenId> token = null;
92.5812 - boolean moveNext = false;
92.5813 - boolean isBeginFound = false;
92.5814 - List<PlsqlBlock> lstChild = new ArrayList<PlsqlBlock>();
92.5815 - PlsqlBlock block = null;
92.5816 -
92.5817 - //Check whether the beginning is in a SQL Plus command
92.5818 - if (sqlPlusLine(ts)) {
92.5819 - return null;
92.5820 - }
92.5821 -
92.5822 - moveNext = ts.moveNext();
92.5823 - token = ts.token();
92.5824 - declareBegin = current;
92.5825 - Token<PlsqlTokenId> customStartToken = null;
92.5826 -
92.5827 - while (moveNext) {
92.5828 - PlsqlTokenId tokenID = token.id();
92.5829 - String image = token.text().toString();
92.5830 -
92.5831 - if ((token != null) && (!image.equals(";")) && (token.offset(tokenHierarchy) > endParse)) {
92.5832 - break;
92.5833 - }
92.5834 -
92.5835 - //We have come to the end of the comment
92.5836 - if ((tokenID == PlsqlTokenId.OPERATOR) && ((image.equals("/") && checkForOnlyChar(ts, ts.offset())) || image.equals(";"))) {
92.5837 - //check whether its END; or END before /
92.5838 - boolean movePre = getPreviousNonWhitespace(ts, true);
92.5839 - Token<PlsqlTokenId> pre = ts.token();
92.5840 - if (!movePre) {
92.5841 - ts.move(token.offset(tokenHierarchy));
92.5842 - ts.moveNext();
92.5843 - }
92.5844 -
92.5845 - if (image.equals("/")) {
92.5846 - if (pre.toString().equals(";")) {
92.5847 - movePre = getPreviousNonWhitespace(ts, true);
92.5848 - pre = ts.token();
92.5849 - if ((movePre) && (pre.toString().equalsIgnoreCase("END"))) {
92.5850 - ts.move(token.offset(tokenHierarchy));
92.5851 - ts.moveNext();
92.5852 - ts.moveNext();
92.5853 - block = new PlsqlBlock(declareBegin.offset(tokenHierarchy),
92.5854 - ts.offset(), "", "", PlsqlBlockType.DECLARE_END);
92.5855 - removeChildBegin(block);
92.5856 - break;
92.5857 - }
92.5858 - } else {
92.5859 - //something has gone wrong '/' is a terminal
92.5860 - break;
92.5861 - }
92.5862 - } else {
92.5863 - if ((movePre) && (pre.toString().equalsIgnoreCase("END"))) {
92.5864 - ts.move(token.offset(tokenHierarchy));
92.5865 - ts.moveNext();
92.5866 - ts.moveNext();
92.5867 - block = new PlsqlBlock(declareBegin.offset(tokenHierarchy),
92.5868 - ts.offset(), "", "", PlsqlBlockType.DECLARE_END);
92.5869 - removeChildBegin(block);
92.5870 - break;
92.5871 - }
92.5872 - }
92.5873 - ts.move(token.offset(tokenHierarchy));
92.5874 - ts.moveNext();
92.5875 - } else if (image.equalsIgnoreCase("CURSOR")) {
92.5876 - int beforeOff = token.offset(tokenHierarchy);
92.5877 - PlsqlBlock child = checkCursor(token, ts, lstChild);
92.5878 - if (child == null) {//If inner check seems to have failed need to continue this one
92.5879 -
92.5880 - ts.move(beforeOff);
92.5881 - moveNext = ts.moveNext();
92.5882 - } else {
92.5883 - if (checkExisting(child, lstChild) == false) {
92.5884 - lstChild.add(child);
92.5885 - }
92.5886 - }
92.5887 - } else if (image.equalsIgnoreCase("PROCEDURE")) {
92.5888 - if (isBeginFound) {//Can be there only before begin in a declare block
92.5889 -
92.5890 - break;
92.5891 - }
92.5892 -
92.5893 - int beforeOff = token.offset(tokenHierarchy);
92.5894 - PlsqlBlock child = checkMethod(token, ts, PlsqlBlockType.PROCEDURE_IMPL, lstChild);
92.5895 - if (child == null) {//If inner check seems to have failed need to continue this one
92.5896 -
92.5897 - ts.move(beforeOff);
92.5898 - moveNext = ts.moveNext();
92.5899 - } else {
92.5900 - if (checkExisting(child, lstChild) == false) {
92.5901 - lstChild.add(child);
92.5902 - }
92.5903 - }
92.5904 - } else if (image.equalsIgnoreCase("FUNCTION")) {
92.5905 - if (isBeginFound) {//Can be there only before begin in a declare block
92.5906 -
92.5907 - break;
92.5908 - }
92.5909 -
92.5910 - int beforeOff = token.offset(tokenHierarchy);
92.5911 - PlsqlBlock child = checkMethod(token, ts, PlsqlBlockType.FUNCTION_IMPL, lstChild);
92.5912 - if (child == null) {//If inner check seems to have failed need to continue this one
92.5913 -
92.5914 - ts.move(beforeOff);
92.5915 - moveNext = ts.moveNext();
92.5916 - } else {
92.5917 - if (checkExisting(child, lstChild) == false) {
92.5918 - lstChild.add(child);
92.5919 - }
92.5920 - }
92.5921 - } else if (isBeginFound && image.equalsIgnoreCase("DECLARE")) {
92.5922 - int beforeOff = token.offset(tokenHierarchy);
92.5923 - PlsqlBlock child = checkDeclareBlock(token, ts, lstChild);
92.5924 - if (child != null) {//If inner check seems to have failed need to continue this one
92.5925 - if (checkExisting(child, lstChild) == false) {
92.5926 - lstChild.add(child);
92.5927 - }
92.5928 - }
92.5929 - } else if (image.equalsIgnoreCase("BEGIN")) {
92.5930 - if (isBeginFound) {
92.5931 - int beforeOff = token.offset(tokenHierarchy);
92.5932 - PlsqlBlock child = checkBeginBlock(token, ts, lstChild);
92.5933 - if (child == null) {//If inner check seems to have failed need to continue this one
92.5934 -
92.5935 - ts.move(beforeOff);
92.5936 - moveNext = ts.moveNext();
92.5937 - } else {
92.5938 - if (checkExisting(child, lstChild) == false) {
92.5939 - lstChild.add(child);
92.5940 - }
92.5941 - }
92.5942 - } else {
92.5943 - isBeginFound = true;
92.5944 - }
92.5945 - } else if (image.equalsIgnoreCase("IF")) {
92.5946 - int beforeOff = token.offset(tokenHierarchy);
92.5947 - List children = checkIfBlock(token, ts, lstChild);
92.5948 - if (children == null || children.size() == 0) {//If inner check seems to have failed need to continue this one
92.5949 -
92.5950 - ts.move(beforeOff);
92.5951 - moveNext = ts.moveNext();
92.5952 - } else {
92.5953 - for (int i = 0; i < children.size(); i++) {
92.5954 - PlsqlBlock child = (PlsqlBlock) children.get(i);
92.5955 - if (checkExisting(child, lstChild) == false) {
92.5956 - lstChild.add(child);
92.5957 - }
92.5958 - }
92.5959 - }
92.5960 - } else if (image.equalsIgnoreCase("CASE")) {
92.5961 - int beforeOff = token.offset(tokenHierarchy);
92.5962 - List children = checkCaseBlock(token, ts, lstChild, false);
92.5963 - if (children == null || children.size() == 0) {//If inner check seems to have failed need to continue this one
92.5964 -
92.5965 - ts.move(beforeOff);
92.5966 - moveNext = ts.moveNext();
92.5967 - } else {
92.5968 - for (int i = 0; i < children.size(); i++) {
92.5969 - PlsqlBlock child = (PlsqlBlock) children.get(i);
92.5970 - if (checkExisting(child, lstChild) == false) {
92.5971 - lstChild.add(child);
92.5972 - }
92.5973 - }
92.5974 - }
92.5975 - } else if (image.equalsIgnoreCase("LOOP")
92.5976 - || image.equalsIgnoreCase("WHILE")
92.5977 - || image.equalsIgnoreCase("FOR")) {
92.5978 - int beforeOff = token.offset(tokenHierarchy);
92.5979 - if (!unsuccessBlocks.contains(beforeOff)) {
92.5980 - PlsqlBlock child = checkLoopBlock(token, ts, lstChild);
92.5981 - if (child == null) {//If inner check seems to have failed need to continue this one
92.5982 - unsuccessBlocks.add(beforeOff);
92.5983 - ts.move(beforeOff);
92.5984 - moveNext = ts.moveNext();
92.5985 - } else {
92.5986 - if (checkExisting(child, lstChild) == false) {
92.5987 - lstChild.add(child);
92.5988 - }
92.5989 - }
92.5990 - }
92.5991 - } else if (image.equalsIgnoreCase("TABLE")
92.5992 - || image.equalsIgnoreCase("INDEX")
92.5993 - || image.equalsIgnoreCase("SELECT")
92.5994 - || image.equalsIgnoreCase("UPDATE")
92.5995 - || image.equalsIgnoreCase("DELETE")
92.5996 - || image.equalsIgnoreCase("INSERT")
92.5997 - || image.equalsIgnoreCase("MERGE")
92.5998 - || image.equalsIgnoreCase("DROP")
92.5999 - || image.equalsIgnoreCase("SEQUENCE")) {
92.6000 - if (!isNotBlockStart(token, ts)) {
92.6001 - int offset = token.offset(tokenHierarchy);
92.6002 - PlsqlBlock child = checkStatementBlock(token, ts, parentBlocks);
92.6003 - if (child == null) {//If inner check seems to have failed need to continue this one
92.6004 -
92.6005 - ts.move(offset);
92.6006 - ts.moveNext();
92.6007 - } else {
92.6008 - if (checkExisting(child, lstChild) == false) {
92.6009 - lstChild.add(child);
92.6010 - }
92.6011 - }
92.6012 - }
92.6013 - } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.6014 - //only single comment line
92.6015 - if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.6016 - customStartToken = token;
92.6017 - } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.6018 - if (customStartToken != null) {
92.6019 - String name = customStartToken.text().toString();
92.6020 - int index = name.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.6021 - name = name.substring(index + 7).trim();
92.6022 - if (ts.moveNext()) {
92.6023 - token = ts.token();
92.6024 - PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.6025 - token.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.6026 - customFoldBlocks.add(custom);
92.6027 - }
92.6028 -
92.6029 - customStartToken = null;
92.6030 - }
92.6031 - } else {
92.6032 - PlsqlBlock child = checkComment(token, ts);
92.6033 - if (child != null) {
92.6034 - if (checkExisting(child, lstChild) == false) {
92.6035 - lstChild.add(child);
92.6036 - }
92.6037 - }
92.6038 - }
92.6039 - } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.6040 - int start = token.offset(tokenHierarchy);
92.6041 - PlsqlBlock child = new PlsqlBlock(start,
92.6042 - start + token.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.6043 - if (child != null) {
92.6044 - if (checkExisting(child, lstChild) == false) {
92.6045 - lstChild.add(child);
92.6046 - }
92.6047 - }
92.6048 - }
92.6049 -
92.6050 - moveNext = ts.moveNext();
92.6051 - token = ts.token();
92.6052 - }
92.6053 -
92.6054 - if (block != null) {
92.6055 - //add children
92.6056 - addChildren(block, lstChild, parentBlocks);
92.6057 - } else {
92.6058 - if (moveNext) { //If have come to last return otherwise we will loop with begin
92.6059 - ts.move(declareBegin.offset(tokenHierarchy));
92.6060 - ts.moveNext();
92.6061 - }
92.6062 - }
92.6063 -
92.6064 - return block;
92.6065 - }
92.6066 -
92.6067 - /**
92.6068 - * Method that will check begin end blocks
92.6069 - * @param current
92.6070 - * @param ts
92.6071 - * @param parentBlocks
92.6072 - * @returns
92.6073 - */
92.6074 - private PlsqlBlock checkBeginBlock(Token<PlsqlTokenId> current, TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> parentBlocks) {
92.6075 - Token<PlsqlTokenId> begin;
92.6076 - Token<PlsqlTokenId> token = null;
92.6077 - PlsqlBlock block = null;
92.6078 - List<PlsqlBlock> lstChild = new ArrayList<PlsqlBlock>();
92.6079 - boolean moveNext = false;
92.6080 -
92.6081 - //Check whether the beginning is in a SQL Plus command
92.6082 - if (sqlPlusLine(ts)) {
92.6083 - return null;
92.6084 - }
92.6085 -
92.6086 - moveNext = ts.moveNext();
92.6087 - token = ts.token();
92.6088 - begin = current;
92.6089 - Token<PlsqlTokenId> customStartToken = null;
92.6090 -
92.6091 - while (moveNext) {
92.6092 - PlsqlTokenId tokenID = token.id();
92.6093 - String image = token.text().toString();
92.6094 -
92.6095 - if ((token != null) && (!image.equals(";")) && (token.offset(tokenHierarchy) > endParse)) {
92.6096 - break;
92.6097 - }
92.6098 -
92.6099 - //We have come to the end of the comment
92.6100 - if ((tokenID == PlsqlTokenId.OPERATOR) && ((image.equals("/") && checkForOnlyChar(ts, ts.offset())) || image.equals(";"))) {
92.6101 - //check whether its END; or END; before /
92.6102 - boolean movePre = getPreviousNonWhitespace(ts, true);
92.6103 - Token<PlsqlTokenId> pre = ts.token();
92.6104 - if (!movePre) {
92.6105 - ts.move(token.offset(tokenHierarchy));
92.6106 - ts.moveNext();
92.6107 - }
92.6108 -
92.6109 - if (image.equals("/")) {
92.6110 - if (pre.toString().equals(";")) {
92.6111 - movePre = getPreviousNonWhitespace(ts, true);
92.6112 - pre = ts.token();
92.6113 - if ((movePre) && (pre.toString().equalsIgnoreCase("END"))) {
92.6114 - //check whether there is a DECLARE_END parent block with the same offset
92.6115 - ts.move(token.offset(tokenHierarchy));
92.6116 - ts.moveNext();
92.6117 - ts.moveNext();
92.6118 - int start = begin.offset(tokenHierarchy);
92.6119 - int end = ts.offset();
92.6120 - PlsqlBlock parent = getParentBlock(blockHierarchy, start, end);
92.6121 - if ((parent == null) || (parent.getEndOffset() != end)) {
92.6122 - block = new PlsqlBlock(start, end, "", "", PlsqlBlockType.BEGIN_END);
92.6123 - }
92.6124 -
92.6125 - break;
92.6126 -
92.6127 - }
92.6128 - } else {
92.6129 - //something has gone wrong '/' is a terminal
92.6130 - break;
92.6131 - }
92.6132 - } else {
92.6133 - if ((movePre) && (pre.toString().equalsIgnoreCase("END"))) {
92.6134 - //check whether there is a DECLARE_END parent block with the same offset
92.6135 - ts.move(token.offset(tokenHierarchy));
92.6136 - ts.moveNext();
92.6137 - ts.moveNext();
92.6138 - int start = begin.offset(tokenHierarchy);
92.6139 - int end = ts.offset();
92.6140 - PlsqlBlock parent = getParentBlock(blockHierarchy, start, end);
92.6141 - if ((parent == null) || (parent.getEndOffset() != end)) {
92.6142 - block = new PlsqlBlock(start, end, "", "", PlsqlBlockType.BEGIN_END);
92.6143 - }
92.6144 -
92.6145 - break;
92.6146 - }
92.6147 - }
92.6148 - ts.move(token.offset(tokenHierarchy));
92.6149 - ts.moveNext();
92.6150 - } else if (tokenID == PlsqlTokenId.KEYWORD && image.equalsIgnoreCase("DECLARE")) {
92.6151 - int beforeOff = token.offset(tokenHierarchy);
92.6152 - PlsqlBlock child = checkDeclareBlock(token, ts, lstChild);
92.6153 - if (child != null) {//If inner check seems to have failed need to continue this one
92.6154 - if (checkExisting(child, lstChild) == false) {
92.6155 - lstChild.add(child);
92.6156 - }
92.6157 - }
92.6158 - } else if (tokenID == PlsqlTokenId.KEYWORD && (image.equalsIgnoreCase("BEGIN"))) {
92.6159 - int beforeOff = token.offset(tokenHierarchy);
92.6160 - PlsqlBlock child = checkBeginBlock(token, ts, lstChild);
92.6161 - if (child == null) {//If inner check seems to have failed need to continue this one
92.6162 -
92.6163 - ts.move(beforeOff);
92.6164 - moveNext = ts.moveNext();
92.6165 - } else {
92.6166 - if (checkExisting(child, lstChild) == false) {
92.6167 - lstChild.add(child);
92.6168 - }
92.6169 - }
92.6170 - } else if (image.equalsIgnoreCase("IF")) {
92.6171 - int beforeOff = token.offset(tokenHierarchy);
92.6172 - List children = checkIfBlock(token, ts, lstChild);
92.6173 - if (children == null || children.size() == 0) {//If inner check seems to have failed need to continue this one
92.6174 -
92.6175 - ts.move(beforeOff);
92.6176 - moveNext = ts.moveNext();
92.6177 - } else {
92.6178 - for (int i = 0; i < children.size(); i++) {
92.6179 - PlsqlBlock child = (PlsqlBlock) children.get(i);
92.6180 - if (checkExisting(child, lstChild) == false) {
92.6181 - lstChild.add(child);
92.6182 - }
92.6183 - }
92.6184 - }
92.6185 - } else if (image.equalsIgnoreCase("CASE")) {
92.6186 - int beforeOff = token.offset(tokenHierarchy);
92.6187 - List children = checkCaseBlock(token, ts, lstChild, false);
92.6188 - if (children == null || children.size() == 0) {//If inner check seems to have failed need to continue this one
92.6189 -
92.6190 - ts.move(beforeOff);
92.6191 - moveNext = ts.moveNext();
92.6192 - } else {
92.6193 - for (int i = 0; i < children.size(); i++) {
92.6194 - PlsqlBlock child = (PlsqlBlock) children.get(i);
92.6195 - if (checkExisting(child, lstChild) == false) {
92.6196 - lstChild.add(child);
92.6197 - }
92.6198 - }
92.6199 - }
92.6200 - } else if (image.equalsIgnoreCase("LOOP")
92.6201 - || image.equalsIgnoreCase("WHILE")
92.6202 - || image.equalsIgnoreCase("FOR")) {
92.6203 - int beforeOff = token.offset(tokenHierarchy);
92.6204 - if (!unsuccessBlocks.contains(beforeOff)) {
92.6205 - PlsqlBlock child = checkLoopBlock(token, ts, lstChild);
92.6206 - if (child == null) {//If inner check seems to have failed need to continue this one
92.6207 - unsuccessBlocks.add(beforeOff);
92.6208 - ts.move(beforeOff);
92.6209 - moveNext = ts.moveNext();
92.6210 - } else {
92.6211 - if (checkExisting(child, lstChild) == false) {
92.6212 - lstChild.add(child);
92.6213 - }
92.6214 - }
92.6215 - }
92.6216 - } else if (image.equalsIgnoreCase("TABLE")
92.6217 - || image.equalsIgnoreCase("INDEX")
92.6218 - || image.equalsIgnoreCase("SELECT")
92.6219 - || image.equalsIgnoreCase("UPDATE")
92.6220 - || image.equalsIgnoreCase("DELETE")
92.6221 - || image.equalsIgnoreCase("INSERT")
92.6222 - || image.equalsIgnoreCase("MERGE")
92.6223 - || image.equalsIgnoreCase("DROP")
92.6224 - || image.equalsIgnoreCase("SEQUENCE")) {
92.6225 - if (!isNotBlockStart(token, ts)) {
92.6226 - int offset = token.offset(tokenHierarchy);
92.6227 - PlsqlBlock child = checkStatementBlock(token, ts, parentBlocks);
92.6228 - if (child == null) {//If inner check seems to have failed need to continue this one
92.6229 -
92.6230 - ts.move(offset);
92.6231 - ts.moveNext();
92.6232 - } else {
92.6233 - if (checkExisting(child, lstChild) == false) {
92.6234 - lstChild.add(child);
92.6235 - }
92.6236 - }
92.6237 - }
92.6238 - } else if (image.equalsIgnoreCase("PROCEDURE")
92.6239 - || image.equalsIgnoreCase("FUNCTION")) {
92.6240 - break;
92.6241 - } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.6242 - //only single comment line
92.6243 - if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.6244 - customStartToken = token;
92.6245 - } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.6246 - if (customStartToken != null) {
92.6247 - String name = customStartToken.text().toString();
92.6248 - int index = name.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.6249 - name = name.substring(index + 7).trim();
92.6250 - if (ts.moveNext()) {
92.6251 - token = ts.token();
92.6252 - PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.6253 - token.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.6254 - customFoldBlocks.add(custom);
92.6255 - }
92.6256 -
92.6257 - customStartToken = null;
92.6258 - }
92.6259 - } else {
92.6260 - PlsqlBlock child = checkComment(token, ts);
92.6261 - if (child != null) {
92.6262 - if (checkExisting(child, lstChild) == false) {
92.6263 - lstChild.add(child);
92.6264 - }
92.6265 - }
92.6266 - }
92.6267 - } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.6268 - int start = token.offset(tokenHierarchy);
92.6269 - PlsqlBlock child = new PlsqlBlock(start,
92.6270 - start + token.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.6271 - if (child != null) {
92.6272 - if (checkExisting(child, lstChild) == false) {
92.6273 - lstChild.add(child);
92.6274 - }
92.6275 - }
92.6276 - }
92.6277 -
92.6278 - moveNext = ts.moveNext();
92.6279 - token = ts.token();
92.6280 - }
92.6281 -
92.6282 - if (block != null) {
92.6283 - //add children
92.6284 - addChildren(block, lstChild, parentBlocks);
92.6285 - }
92.6286 -
92.6287 - return block;
92.6288 - }
92.6289 -
92.6290 - /**
92.6291 - * Method to check table & column comments
92.6292 - * @param current
92.6293 - * @param ts
92.6294 - * @param parentBlocks
92.6295 - * @returns
92.6296 - */
92.6297 - private PlsqlBlock checkTblColComment(Token<PlsqlTokenId> current, TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> parentBlocks) {
92.6298 - Token<PlsqlTokenId> commentBegin = current;
92.6299 - Token<PlsqlTokenId> tmpPre = current;
92.6300 - PlsqlBlock block = null;
92.6301 - List<PlsqlBlock> lstChild = new ArrayList<PlsqlBlock>();
92.6302 -
92.6303 - //Check whether the beginning is in a SQL Plus command
92.6304 - if (sqlPlusLine(ts)) {
92.6305 - return null;
92.6306 - }
92.6307 -
92.6308 - int beginOffset = ts.offset();
92.6309 - boolean isTable = false;
92.6310 - boolean isEnd = false;
92.6311 - Token<PlsqlTokenId> previousBlock = null;
92.6312 - String tableName = "";
92.6313 - boolean moveNext = false;
92.6314 - moveNext = getNextNonWhitespace(ts, true);
92.6315 - String alias = "";
92.6316 - Token<PlsqlTokenId> customStartToken = null;
92.6317 -
92.6318 - //Check whether that is table/column comment
92.6319 - if (moveNext == false) {
92.6320 - return block;
92.6321 - }
92.6322 -
92.6323 - Token<PlsqlTokenId> tmp = ts.token(); //catching ON
92.6324 -
92.6325 - moveNext = getNextNonWhitespace(ts, true);
92.6326 - tmp = ts.token(); //TABLE OR VIEW
92.6327 -
92.6328 - if ((moveNext != false) && (tmp.id() == PlsqlTokenId.KEYWORD)) {
92.6329 - String image = tmp.text().toString();
92.6330 - if (image.equalsIgnoreCase("TABLE")) {
92.6331 - isTable = true;
92.6332 -
92.6333 + }
92.6334 +
92.6335 + if (tmp.text().toString().equalsIgnoreCase("BODY")) {
92.6336 + isPackageBody = true;
92.6337 moveNext = getNextNonWhitespace(ts, true);
92.6338 tmp = ts.token();
92.6339 -
92.6340 - if (moveNext != false) {
92.6341 - tableName = tmp.text().toString();
92.6342 - tableName = checkForOtherSchema(ts, tableName);
92.6343 - if (tableName.indexOf('&') != -1) {
92.6344 - alias = tableName;
92.6345 - }
92.6346 -
92.6347 - tableName = getDefine(tableName);
92.6348 - if (ts.moveNext()) {
92.6349 - tmp = ts.token();
92.6350 - if ((tmp.id() == PlsqlTokenId.DOT) && ts.moveNext()) {
92.6351 - tmp = ts.token();
92.6352 - }
92.6353 - }
92.6354 + if (moveNext == false) {
92.6355 + return block;
92.6356 }
92.6357 -
92.6358 - } else if (image.equalsIgnoreCase("COLUMN")) {
92.6359 - isTable = false;
92.6360 + }
92.6361 +
92.6362 + packageName = tmp.text().toString();
92.6363 + packageName = checkForOtherSchema(ts, packageName);
92.6364 + String alias = "";
92.6365 + if (packageName.indexOf('&') != -1) {
92.6366 + alias = packageName;
92.6367 + } else if (hasDefineKey(packageName)) {
92.6368 + alias = '&' + getDefineKey(packageName);
92.6369 + }
92.6370 +
92.6371 + packageName = getDefine(packageName);
92.6372 + Token<PlsqlTokenId> customStartToken = null;
92.6373 +
92.6374 + while (moveNext) {
92.6375 + String image = tmp.text().toString();
92.6376 + PlsqlTokenId tokenID = tmp.id();
92.6377 +
92.6378 + if ((tmp != null) && (!image.equals(";")) && (tmp.offset(tokenHierarchy) > endParse)) {
92.6379 + break;
92.6380 + }
92.6381 +
92.6382 + //We might have come to the end of the package
92.6383 + if (((tokenID == PlsqlTokenId.OPERATOR) && (image.equals(";") || (image.equals("/") && checkForOnlyChar(ts, ts.offset())))) && (isFound)
92.6384 + && ((tmpPre.text().toString().equalsIgnoreCase(packageName))
92.6385 + || ((!alias.equals("")) && (tmpPre.text().toString().equalsIgnoreCase(alias)))
92.6386 + || ((tmpPre.text().toString().equalsIgnoreCase("END")) && (beginCount < 0)))) {
92.6387 + boolean isPackage = false;
92.6388 + if (tmpPre.text().toString().equalsIgnoreCase(packageName)
92.6389 + || tmpPre.text().toString().equalsIgnoreCase(alias)) {
92.6390 + //check whether previous Non white space token to the identifier is END
92.6391 + int offset = ts.offset();
92.6392 + boolean preMove = false;
92.6393 + preMove = getPreviousNonWhitespace(ts, true);
92.6394 + preMove = getPreviousNonWhitespace(ts, true);
92.6395 + Token<PlsqlTokenId> previousNWS = ts.token();
92.6396 +
92.6397 + ts.move(offset);
92.6398 + ts.moveNext();
92.6399 +
92.6400 + if ((preMove != false)
92.6401 + && previousNWS.text().toString().equalsIgnoreCase("END")) {
92.6402 + isPackage = true;
92.6403 + }
92.6404 + } else if ((tmpPre.text().toString().equalsIgnoreCase("END")) && (beginCount < 0)) {
92.6405 + isPackage = true;
92.6406 + }
92.6407 +
92.6408 + //If this is a package end create the block
92.6409 + if (isPackage) {
92.6410 + PlsqlBlockType type = PlsqlBlockType.PACKAGE;
92.6411 +
92.6412 + if (isPackageBody) {
92.6413 + type = PlsqlBlockType.PACKAGE_BODY;
92.6414 + }
92.6415 +
92.6416 + ts.moveNext();
92.6417 +
92.6418 + block = new PlsqlBlock(packBegin.offset(tokenHierarchy),
92.6419 + ts.offset(), packageName, alias, type);
92.6420 + checkPrefix(packBegin.offset(tokenHierarchy), ts, block);
92.6421 + break;
92.6422 + }
92.6423 + } else if ((tokenID == PlsqlTokenId.KEYWORD)
92.6424 + && ((image.equalsIgnoreCase("PROCEDURE"))
92.6425 + || (image.equalsIgnoreCase("FUNCTION"))
92.6426 + || (image.equalsIgnoreCase("CURSOR")))) {
92.6427 + if (isFound) {
92.6428 + int beforeOff = tmp.offset(tokenHierarchy);
92.6429 +
92.6430 + if (image.equalsIgnoreCase("PROCEDURE")) {
92.6431 + PlsqlBlock child = checkMethod(tmp, ts, PlsqlBlockType.PROCEDURE_IMPL, lstChild);
92.6432 + if (child == null) {//If inner check seems to have failed need to continue this one
92.6433 +
92.6434 + ts.move(beforeOff);
92.6435 + ts.moveNext();
92.6436 + } else {
92.6437 + if (checkExisting(child, lstChild) == false) {
92.6438 + lstChild.add(child);
92.6439 + }
92.6440 + }
92.6441 + } //Inner procedure
92.6442 + else if (image.equalsIgnoreCase("FUNCTION")) {
92.6443 + PlsqlBlock child = checkMethod(tmp, ts, PlsqlBlockType.FUNCTION_IMPL, lstChild);
92.6444 + if (child == null) {//If inner check seems to have failed need to continue this one
92.6445 +
92.6446 + ts.move(beforeOff);
92.6447 + ts.moveNext();
92.6448 + } else {
92.6449 + if (checkExisting(child, lstChild) == false) {
92.6450 + lstChild.add(child);
92.6451 + }
92.6452 + }
92.6453 + } //Inner function
92.6454 + else if (image.equalsIgnoreCase("CURSOR")) {
92.6455 + PlsqlBlock child = checkCursor(tmp, ts, lstChild);
92.6456 + if (child == null) {//If inner check seems to have failed need to continue this one
92.6457 +
92.6458 + ts.move(beforeOff);
92.6459 + ts.moveNext();
92.6460 + } else {
92.6461 + if (checkExisting(child, lstChild) == false) {
92.6462 + lstChild.add(child);
92.6463 + }
92.6464 + }
92.6465 + } //Inner cursor
92.6466 +
92.6467 + } else {
92.6468 + break;
92.6469 + }
92.6470 + } else if (tokenID == PlsqlTokenId.KEYWORD && (image.equalsIgnoreCase("BEGIN"))) {
92.6471 + beginCount++;
92.6472 + } else if ((tokenID == PlsqlTokenId.KEYWORD)
92.6473 + && (image.equalsIgnoreCase("END"))) {
92.6474 + int off = ts.offset();
92.6475 + if (getNextNonWhitespace(ts, true)) {
92.6476 + tmp = ts.token();
92.6477 + }
92.6478 +
92.6479 + if ((tmp.text().toString().equals(";")) || (tmp.id() == PlsqlTokenId.IDENTIFIER)
92.6480 + || (tmp.id() == PlsqlTokenId.KEYWORD && (!tmp.toString().equalsIgnoreCase("IF")
92.6481 + && !tmp.toString().equalsIgnoreCase("CASE") && !tmp.toString().equalsIgnoreCase("LOOP")))) {
92.6482 + beginCount--;
92.6483 + }
92.6484 +
92.6485 + ts.move(off);
92.6486 + ts.moveNext();
92.6487 + tmp = ts.token();
92.6488 + } else if ((tokenID == PlsqlTokenId.KEYWORD)
92.6489 + && ((image.equalsIgnoreCase("CREATE")) || (image.equalsIgnoreCase("PACKAGE")))) {
92.6490 + return block;
92.6491 + } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.6492 + //only single comment line
92.6493 + if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.6494 + customStartToken = tmp;
92.6495 + } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.6496 + if (customStartToken != null) {
92.6497 + String name = customStartToken.text().toString();
92.6498 + int index = name.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.6499 + name = name.substring(index + 7).trim();
92.6500 + if (ts.moveNext()) {
92.6501 + tmp = ts.token();
92.6502 + PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.6503 + tmp.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.6504 + customFoldBlocks.add(custom);
92.6505 + }
92.6506 + customStartToken = null;
92.6507 + }
92.6508 + } else {
92.6509 + PlsqlBlock child = checkComment(tmp, ts);
92.6510 + if ((child != null) && (checkExisting(child, lstChild) == false)) {
92.6511 + lstChild.add(child);
92.6512 + }
92.6513 + }
92.6514 + } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.6515 + int start = tmp.offset(tokenHierarchy);
92.6516 + PlsqlBlock child = new PlsqlBlock(start,
92.6517 + start + tmp.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.6518 + if ((child != null) && (checkExisting(child, lstChild) == false)) {
92.6519 + lstChild.add(child);
92.6520 + }
92.6521 + } else {
92.6522 + //Mark when we come to 'IS'
92.6523 + if ((tokenID == PlsqlTokenId.KEYWORD)
92.6524 + && ((image.equalsIgnoreCase("IS")) || (image.equalsIgnoreCase("AS")))) {
92.6525 + isFound = true;
92.6526 + }
92.6527 + }
92.6528 +
92.6529 + if (tokenID != PlsqlTokenId.WHITESPACE) {//previous non whitespace token
92.6530 +
92.6531 + tmpPre = tmp;
92.6532 + }
92.6533 +
92.6534 + moveNext = ts.moveNext();
92.6535 + tmp = ts.token();
92.6536 + }
92.6537 +
92.6538 + if (block != null) {
92.6539 + //add children
92.6540 + addChildren(block, lstChild, parentBlocks);
92.6541 +
92.6542 + //Add immediate children
92.6543 + addImmediateChildren(block, parentBlocks);
92.6544 + }
92.6545 +
92.6546 + return block;
92.6547 + }
92.6548 +
92.6549 + /**
92.6550 + * Method that will check declare end blocks
92.6551 + * @param current
92.6552 + * @param ts
92.6553 + * @param parentBlocks
92.6554 + * @returns
92.6555 + */
92.6556 + private PlsqlBlock checkDeclareBlock(Token<PlsqlTokenId> current, TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> parentBlocks) {
92.6557 + Token<PlsqlTokenId> declareBegin;
92.6558 + Token<PlsqlTokenId> token = null;
92.6559 + boolean moveNext = false;
92.6560 + boolean isBeginFound = false;
92.6561 + List<PlsqlBlock> lstChild = new ArrayList<PlsqlBlock>();
92.6562 + PlsqlBlock block = null;
92.6563 +
92.6564 + //Check whether the beginning is in a SQL Plus command
92.6565 + if (sqlPlusLine(ts)) {
92.6566 + return null;
92.6567 + }
92.6568 +
92.6569 + moveNext = ts.moveNext();
92.6570 + token = ts.token();
92.6571 + declareBegin = current;
92.6572 + Token<PlsqlTokenId> customStartToken = null;
92.6573 +
92.6574 + while (moveNext) {
92.6575 + PlsqlTokenId tokenID = token.id();
92.6576 + String image = token.text().toString();
92.6577 +
92.6578 + if ((token != null) && (!image.equals(";")) && (token.offset(tokenHierarchy) > endParse)) {
92.6579 + break;
92.6580 + }
92.6581 +
92.6582 + //We have come to the end of the comment
92.6583 + if ((tokenID == PlsqlTokenId.OPERATOR) && ((image.equals("/") && checkForOnlyChar(ts, ts.offset())) || image.equals(";"))) {
92.6584 + //check whether its END; or END before /
92.6585 + boolean movePre = getPreviousNonWhitespace(ts, true);
92.6586 + Token<PlsqlTokenId> pre = ts.token();
92.6587 + if (!movePre) {
92.6588 + ts.move(token.offset(tokenHierarchy));
92.6589 + ts.moveNext();
92.6590 + }
92.6591 +
92.6592 + if (image.equals("/")) {
92.6593 + if (pre.toString().equals(";")) {
92.6594 + movePre = getPreviousNonWhitespace(ts, true);
92.6595 + pre = ts.token();
92.6596 + if ((movePre) && (pre.toString().equalsIgnoreCase("END"))) {
92.6597 + ts.move(token.offset(tokenHierarchy));
92.6598 + ts.moveNext();
92.6599 + ts.moveNext();
92.6600 + block = new PlsqlBlock(declareBegin.offset(tokenHierarchy),
92.6601 + ts.offset(), "", "", PlsqlBlockType.DECLARE_END);
92.6602 + removeChildBegin(block);
92.6603 + break;
92.6604 + }
92.6605 + } else {
92.6606 + //something has gone wrong '/' is a terminal
92.6607 + break;
92.6608 + }
92.6609 + } else {
92.6610 + if ((movePre) && (pre.toString().equalsIgnoreCase("END"))) {
92.6611 + ts.move(token.offset(tokenHierarchy));
92.6612 + ts.moveNext();
92.6613 + ts.moveNext();
92.6614 + block = new PlsqlBlock(declareBegin.offset(tokenHierarchy),
92.6615 + ts.offset(), "", "", PlsqlBlockType.DECLARE_END);
92.6616 + removeChildBegin(block);
92.6617 + break;
92.6618 + }
92.6619 + }
92.6620 + ts.move(token.offset(tokenHierarchy));
92.6621 + ts.moveNext();
92.6622 + } else if (image.equalsIgnoreCase("CURSOR")) {
92.6623 + int beforeOff = token.offset(tokenHierarchy);
92.6624 + PlsqlBlock child = checkCursor(token, ts, lstChild);
92.6625 + if (child == null) {//If inner check seems to have failed need to continue this one
92.6626 +
92.6627 + ts.move(beforeOff);
92.6628 + moveNext = ts.moveNext();
92.6629 + } else {
92.6630 + if (checkExisting(child, lstChild) == false) {
92.6631 + lstChild.add(child);
92.6632 + }
92.6633 + }
92.6634 + } else if (image.equalsIgnoreCase("PROCEDURE")) {
92.6635 + if (isBeginFound) {//Can be there only before begin in a declare block
92.6636 +
92.6637 + break;
92.6638 + }
92.6639 +
92.6640 + int beforeOff = token.offset(tokenHierarchy);
92.6641 + PlsqlBlock child = checkMethod(token, ts, PlsqlBlockType.PROCEDURE_IMPL, lstChild);
92.6642 + if (child == null) {//If inner check seems to have failed need to continue this one
92.6643 +
92.6644 + ts.move(beforeOff);
92.6645 + moveNext = ts.moveNext();
92.6646 + } else {
92.6647 + if (checkExisting(child, lstChild) == false) {
92.6648 + lstChild.add(child);
92.6649 + }
92.6650 + }
92.6651 + } else if (image.equalsIgnoreCase("FUNCTION")) {
92.6652 + if (isBeginFound) {//Can be there only before begin in a declare block
92.6653 +
92.6654 + break;
92.6655 + }
92.6656 +
92.6657 + int beforeOff = token.offset(tokenHierarchy);
92.6658 + PlsqlBlock child = checkMethod(token, ts, PlsqlBlockType.FUNCTION_IMPL, lstChild);
92.6659 + if (child == null) {//If inner check seems to have failed need to continue this one
92.6660 +
92.6661 + ts.move(beforeOff);
92.6662 + moveNext = ts.moveNext();
92.6663 + } else {
92.6664 + if (checkExisting(child, lstChild) == false) {
92.6665 + lstChild.add(child);
92.6666 + }
92.6667 + }
92.6668 + } else if (isBeginFound && image.equalsIgnoreCase("DECLARE")) {
92.6669 + int beforeOff = token.offset(tokenHierarchy);
92.6670 + PlsqlBlock child = checkDeclareBlock(token, ts, lstChild);
92.6671 + if (child != null) {//If inner check seems to have failed need to continue this one
92.6672 + if (checkExisting(child, lstChild) == false) {
92.6673 + lstChild.add(child);
92.6674 + }
92.6675 + }
92.6676 + } else if (image.equalsIgnoreCase("BEGIN")) {
92.6677 + if (isBeginFound) {
92.6678 + int beforeOff = token.offset(tokenHierarchy);
92.6679 + PlsqlBlock child = checkBeginBlock(token, ts, lstChild);
92.6680 + if (child == null) {//If inner check seems to have failed need to continue this one
92.6681 +
92.6682 + ts.move(beforeOff);
92.6683 + moveNext = ts.moveNext();
92.6684 + } else {
92.6685 + if (checkExisting(child, lstChild) == false) {
92.6686 + lstChild.add(child);
92.6687 + }
92.6688 + }
92.6689 + } else {
92.6690 + isBeginFound = true;
92.6691 + }
92.6692 + } else if (image.equalsIgnoreCase("IF")) {
92.6693 + int beforeOff = token.offset(tokenHierarchy);
92.6694 + List children = checkIfBlock(token, ts, lstChild);
92.6695 + if (children == null || children.isEmpty()) {//If inner check seems to have failed need to continue this one
92.6696 +
92.6697 + ts.move(beforeOff);
92.6698 + moveNext = ts.moveNext();
92.6699 + } else {
92.6700 + for (int i = 0; i < children.size(); i++) {
92.6701 + PlsqlBlock child = (PlsqlBlock) children.get(i);
92.6702 + if (checkExisting(child, lstChild) == false) {
92.6703 + lstChild.add(child);
92.6704 + }
92.6705 + }
92.6706 + }
92.6707 + } else if (image.equalsIgnoreCase("CASE")) {
92.6708 + int beforeOff = token.offset(tokenHierarchy);
92.6709 + List children = checkCaseBlock(token, ts, lstChild, false);
92.6710 + if (children == null || children.isEmpty()) {//If inner check seems to have failed need to continue this one
92.6711 +
92.6712 + ts.move(beforeOff);
92.6713 + moveNext = ts.moveNext();
92.6714 + } else {
92.6715 + for (int i = 0; i < children.size(); i++) {
92.6716 + PlsqlBlock child = (PlsqlBlock) children.get(i);
92.6717 + if (checkExisting(child, lstChild) == false) {
92.6718 + lstChild.add(child);
92.6719 + }
92.6720 + }
92.6721 + }
92.6722 + } else if (image.equalsIgnoreCase("LOOP")
92.6723 + || image.equalsIgnoreCase("WHILE")
92.6724 + || image.equalsIgnoreCase("FOR")) {
92.6725 + int beforeOff = token.offset(tokenHierarchy);
92.6726 + if (!unsuccessBlocks.contains(beforeOff)) {
92.6727 + PlsqlBlock child = checkLoopBlock(token, ts, lstChild);
92.6728 + if (child == null) {//If inner check seems to have failed need to continue this one
92.6729 + unsuccessBlocks.add(beforeOff);
92.6730 + ts.move(beforeOff);
92.6731 + moveNext = ts.moveNext();
92.6732 + } else {
92.6733 + if (checkExisting(child, lstChild) == false) {
92.6734 + lstChild.add(child);
92.6735 + }
92.6736 + }
92.6737 + }
92.6738 + } else if (image.equalsIgnoreCase("TABLE")
92.6739 + || image.equalsIgnoreCase("INDEX")
92.6740 + || image.equalsIgnoreCase("SELECT")
92.6741 + || image.equalsIgnoreCase("UPDATE")
92.6742 + || image.equalsIgnoreCase("DELETE")
92.6743 + || image.equalsIgnoreCase("INSERT")
92.6744 + || image.equalsIgnoreCase("MERGE")
92.6745 + || image.equalsIgnoreCase("DROP")
92.6746 + || image.equalsIgnoreCase("SEQUENCE")) {
92.6747 + if (!isNotBlockStart(token, ts)) {
92.6748 + int offset = token.offset(tokenHierarchy);
92.6749 + PlsqlBlock child = checkStatementBlock(token, ts, parentBlocks);
92.6750 + if (child == null) {//If inner check seems to have failed need to continue this one
92.6751 +
92.6752 + ts.move(offset);
92.6753 + ts.moveNext();
92.6754 + } else {
92.6755 + if (checkExisting(child, lstChild) == false) {
92.6756 + lstChild.add(child);
92.6757 + }
92.6758 + }
92.6759 + }
92.6760 + } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.6761 + //only single comment line
92.6762 + if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.6763 + customStartToken = token;
92.6764 + } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.6765 + if (customStartToken != null) {
92.6766 + String name = customStartToken.text().toString();
92.6767 + int index = name.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.6768 + name = name.substring(index + 7).trim();
92.6769 + if (ts.moveNext()) {
92.6770 + token = ts.token();
92.6771 + PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.6772 + token.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.6773 + customFoldBlocks.add(custom);
92.6774 + }
92.6775 +
92.6776 + customStartToken = null;
92.6777 + }
92.6778 + } else {
92.6779 + PlsqlBlock child = checkComment(token, ts);
92.6780 + if (child != null) {
92.6781 + if (checkExisting(child, lstChild) == false) {
92.6782 + lstChild.add(child);
92.6783 + }
92.6784 + }
92.6785 + }
92.6786 + } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.6787 + int start = token.offset(tokenHierarchy);
92.6788 + PlsqlBlock child = new PlsqlBlock(start,
92.6789 + start + token.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.6790 + if (child != null) {
92.6791 + if (checkExisting(child, lstChild) == false) {
92.6792 + lstChild.add(child);
92.6793 + }
92.6794 + }
92.6795 + }
92.6796 +
92.6797 + moveNext = ts.moveNext();
92.6798 + token = ts.token();
92.6799 + }
92.6800 +
92.6801 + if (block != null) {
92.6802 + //add children
92.6803 + addChildren(block, lstChild, parentBlocks);
92.6804 + } else {
92.6805 + if (moveNext) { //If have come to last return otherwise we will loop with begin
92.6806 + ts.move(declareBegin.offset(tokenHierarchy));
92.6807 + ts.moveNext();
92.6808 + }
92.6809 + }
92.6810 +
92.6811 + return block;
92.6812 + }
92.6813 +
92.6814 + /**
92.6815 + * Method that will check begin end blocks
92.6816 + * @param current
92.6817 + * @param ts
92.6818 + * @param parentBlocks
92.6819 + * @returns
92.6820 + */
92.6821 + private PlsqlBlock checkBeginBlock(Token<PlsqlTokenId> current, TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> parentBlocks) {
92.6822 + Token<PlsqlTokenId> begin;
92.6823 + Token<PlsqlTokenId> token = null;
92.6824 + PlsqlBlock block = null;
92.6825 + List<PlsqlBlock> lstChild = new ArrayList<PlsqlBlock>();
92.6826 + boolean moveNext = false;
92.6827 +
92.6828 + //Check whether the beginning is in a SQL Plus command
92.6829 + if (sqlPlusLine(ts)) {
92.6830 + return null;
92.6831 + }
92.6832 +
92.6833 + moveNext = ts.moveNext();
92.6834 + token = ts.token();
92.6835 + begin = current;
92.6836 + Token<PlsqlTokenId> customStartToken = null;
92.6837 +
92.6838 + while (moveNext) {
92.6839 + PlsqlTokenId tokenID = token.id();
92.6840 + String image = token.text().toString();
92.6841 +
92.6842 + if ((token != null) && (!image.equals(";")) && (token.offset(tokenHierarchy) > endParse)) {
92.6843 + break;
92.6844 + }
92.6845 +
92.6846 + //We have come to the end of the comment
92.6847 + if ((tokenID == PlsqlTokenId.OPERATOR) && ((image.equals("/") && checkForOnlyChar(ts, ts.offset())) || image.equals(";"))) {
92.6848 + //check whether its END; or END; before /
92.6849 + boolean movePre = getPreviousNonWhitespace(ts, true);
92.6850 + Token<PlsqlTokenId> pre = ts.token();
92.6851 + if (!movePre) {
92.6852 + ts.move(token.offset(tokenHierarchy));
92.6853 + ts.moveNext();
92.6854 + }
92.6855 +
92.6856 + if (image.equals("/")) {
92.6857 + if (pre.toString().equals(";")) {
92.6858 + movePre = getPreviousNonWhitespace(ts, true);
92.6859 + pre = ts.token();
92.6860 + if ((movePre) && (pre.toString().equalsIgnoreCase("END"))) {
92.6861 + //check whether there is a DECLARE_END parent block with the same offset
92.6862 + ts.move(token.offset(tokenHierarchy));
92.6863 + ts.moveNext();
92.6864 + ts.moveNext();
92.6865 + int start = begin.offset(tokenHierarchy);
92.6866 + int end = ts.offset();
92.6867 + PlsqlBlock parent = getParentBlock(blockHierarchy, start, end);
92.6868 + if ((parent == null) || (parent.getEndOffset() != end)) {
92.6869 + block = new PlsqlBlock(start, end, "", "", PlsqlBlockType.BEGIN_END);
92.6870 + }
92.6871 +
92.6872 + break;
92.6873 +
92.6874 + }
92.6875 + } else {
92.6876 + //something has gone wrong '/' is a terminal
92.6877 + break;
92.6878 + }
92.6879 + } else {
92.6880 + if ((movePre) && (pre.toString().equalsIgnoreCase("END"))) {
92.6881 + //check whether there is a DECLARE_END parent block with the same offset
92.6882 + ts.move(token.offset(tokenHierarchy));
92.6883 + ts.moveNext();
92.6884 + ts.moveNext();
92.6885 + int start = begin.offset(tokenHierarchy);
92.6886 + int end = ts.offset();
92.6887 + PlsqlBlock parent = getParentBlock(blockHierarchy, start, end);
92.6888 + if ((parent == null) || (parent.getEndOffset() != end)) {
92.6889 + block = new PlsqlBlock(start, end, "", "", PlsqlBlockType.BEGIN_END);
92.6890 + }
92.6891 +
92.6892 + break;
92.6893 + }
92.6894 + }
92.6895 + ts.move(token.offset(tokenHierarchy));
92.6896 + ts.moveNext();
92.6897 + } else if (tokenID == PlsqlTokenId.KEYWORD && image.equalsIgnoreCase("DECLARE")) {
92.6898 + int beforeOff = token.offset(tokenHierarchy);
92.6899 + PlsqlBlock child = checkDeclareBlock(token, ts, lstChild);
92.6900 + if (child != null) {//If inner check seems to have failed need to continue this one
92.6901 + if (checkExisting(child, lstChild) == false) {
92.6902 + lstChild.add(child);
92.6903 + }
92.6904 + }
92.6905 + } else if (tokenID == PlsqlTokenId.KEYWORD && (image.equalsIgnoreCase("BEGIN"))) {
92.6906 + int beforeOff = token.offset(tokenHierarchy);
92.6907 + PlsqlBlock child = checkBeginBlock(token, ts, lstChild);
92.6908 + if (child == null) {//If inner check seems to have failed need to continue this one
92.6909 +
92.6910 + ts.move(beforeOff);
92.6911 + moveNext = ts.moveNext();
92.6912 + } else {
92.6913 + if (checkExisting(child, lstChild) == false) {
92.6914 + lstChild.add(child);
92.6915 + }
92.6916 + }
92.6917 + } else if (image.equalsIgnoreCase("IF")) {
92.6918 + int beforeOff = token.offset(tokenHierarchy);
92.6919 + List children = checkIfBlock(token, ts, lstChild);
92.6920 + if (children == null || children.isEmpty()) {//If inner check seems to have failed need to continue this one
92.6921 +
92.6922 + ts.move(beforeOff);
92.6923 + moveNext = ts.moveNext();
92.6924 + } else {
92.6925 + for (int i = 0; i < children.size(); i++) {
92.6926 + PlsqlBlock child = (PlsqlBlock) children.get(i);
92.6927 + if (checkExisting(child, lstChild) == false) {
92.6928 + lstChild.add(child);
92.6929 + }
92.6930 + }
92.6931 + }
92.6932 + } else if (image.equalsIgnoreCase("CASE")) {
92.6933 + int beforeOff = token.offset(tokenHierarchy);
92.6934 + List children = checkCaseBlock(token, ts, lstChild, false);
92.6935 + if (children == null || children.isEmpty()) {//If inner check seems to have failed need to continue this one
92.6936 +
92.6937 + ts.move(beforeOff);
92.6938 + moveNext = ts.moveNext();
92.6939 + } else {
92.6940 + for (int i = 0; i < children.size(); i++) {
92.6941 + PlsqlBlock child = (PlsqlBlock) children.get(i);
92.6942 + if (checkExisting(child, lstChild) == false) {
92.6943 + lstChild.add(child);
92.6944 + }
92.6945 + }
92.6946 + }
92.6947 + } else if (image.equalsIgnoreCase("LOOP")
92.6948 + || image.equalsIgnoreCase("WHILE")
92.6949 + || image.equalsIgnoreCase("FOR")) {
92.6950 + int beforeOff = token.offset(tokenHierarchy);
92.6951 + if (!unsuccessBlocks.contains(beforeOff)) {
92.6952 + PlsqlBlock child = checkLoopBlock(token, ts, lstChild);
92.6953 + if (child == null) {//If inner check seems to have failed need to continue this one
92.6954 + unsuccessBlocks.add(beforeOff);
92.6955 + ts.move(beforeOff);
92.6956 + moveNext = ts.moveNext();
92.6957 + } else {
92.6958 + if (checkExisting(child, lstChild) == false) {
92.6959 + lstChild.add(child);
92.6960 + }
92.6961 + }
92.6962 + }
92.6963 + } else if (image.equalsIgnoreCase("TABLE")
92.6964 + || image.equalsIgnoreCase("INDEX")
92.6965 + || image.equalsIgnoreCase("SELECT")
92.6966 + || image.equalsIgnoreCase("UPDATE")
92.6967 + || image.equalsIgnoreCase("DELETE")
92.6968 + || image.equalsIgnoreCase("INSERT")
92.6969 + || image.equalsIgnoreCase("MERGE")
92.6970 + || image.equalsIgnoreCase("DROP")
92.6971 + || image.equalsIgnoreCase("SEQUENCE")) {
92.6972 + if (!isNotBlockStart(token, ts)) {
92.6973 + int offset = token.offset(tokenHierarchy);
92.6974 + PlsqlBlock child = checkStatementBlock(token, ts, parentBlocks);
92.6975 + if (child == null) {//If inner check seems to have failed need to continue this one
92.6976 +
92.6977 + ts.move(offset);
92.6978 + ts.moveNext();
92.6979 + } else {
92.6980 + if (checkExisting(child, lstChild) == false) {
92.6981 + lstChild.add(child);
92.6982 + }
92.6983 + }
92.6984 + }
92.6985 + } else if (image.equalsIgnoreCase("PROCEDURE")
92.6986 + || image.equalsIgnoreCase("FUNCTION")) {
92.6987 + break;
92.6988 + } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.6989 + //only single comment line
92.6990 + if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.6991 + customStartToken = token;
92.6992 + } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.6993 + if (customStartToken != null) {
92.6994 + String name = customStartToken.text().toString();
92.6995 + int index = name.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.6996 + name = name.substring(index + 7).trim();
92.6997 + if (ts.moveNext()) {
92.6998 + token = ts.token();
92.6999 + PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.7000 + token.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.7001 + customFoldBlocks.add(custom);
92.7002 + }
92.7003 +
92.7004 + customStartToken = null;
92.7005 + }
92.7006 + } else {
92.7007 + PlsqlBlock child = checkComment(token, ts);
92.7008 + if (child != null) {
92.7009 + if (checkExisting(child, lstChild) == false) {
92.7010 + lstChild.add(child);
92.7011 + }
92.7012 + }
92.7013 + }
92.7014 + } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.7015 + int start = token.offset(tokenHierarchy);
92.7016 + PlsqlBlock child = new PlsqlBlock(start,
92.7017 + start + token.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.7018 + if (child != null) {
92.7019 + if (checkExisting(child, lstChild) == false) {
92.7020 + lstChild.add(child);
92.7021 + }
92.7022 + }
92.7023 + }
92.7024 +
92.7025 + moveNext = ts.moveNext();
92.7026 + token = ts.token();
92.7027 + }
92.7028 +
92.7029 + if (block != null) {
92.7030 + //add children
92.7031 + addChildren(block, lstChild, parentBlocks);
92.7032 + }
92.7033 +
92.7034 + return block;
92.7035 + }
92.7036 +
92.7037 + /**
92.7038 + * Method to check table & column comments
92.7039 + * @param current
92.7040 + * @param ts
92.7041 + * @param parentBlocks
92.7042 + * @returns
92.7043 + */
92.7044 + private PlsqlBlock checkTblColComment(Token<PlsqlTokenId> current, TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> parentBlocks) {
92.7045 + Token<PlsqlTokenId> commentBegin = current;
92.7046 + Token<PlsqlTokenId> tmpPre = current;
92.7047 + PlsqlBlock block = null;
92.7048 + List<PlsqlBlock> lstChild = new ArrayList<PlsqlBlock>();
92.7049 +
92.7050 + //Check whether the beginning is in a SQL Plus command
92.7051 + if (sqlPlusLine(ts)) {
92.7052 + return null;
92.7053 + }
92.7054 +
92.7055 + int beginOffset = ts.offset();
92.7056 + boolean isTable = false;
92.7057 + boolean isEnd = false;
92.7058 + Token<PlsqlTokenId> previousBlock = null;
92.7059 + String tableName = "";
92.7060 + boolean moveNext = false;
92.7061 + moveNext = getNextNonWhitespace(ts, true);
92.7062 + String alias = "";
92.7063 + Token<PlsqlTokenId> customStartToken = null;
92.7064 +
92.7065 + //Check whether that is table/column comment
92.7066 + if (moveNext == false) {
92.7067 + return block;
92.7068 + }
92.7069 +
92.7070 + Token<PlsqlTokenId> tmp = ts.token(); //catching ON
92.7071 +
92.7072 + moveNext = getNextNonWhitespace(ts, true);
92.7073 + tmp = ts.token(); //TABLE OR VIEW
92.7074 +
92.7075 + if ((moveNext != false) && (tmp.id() == PlsqlTokenId.KEYWORD)) {
92.7076 + String image = tmp.text().toString();
92.7077 + if (image.equalsIgnoreCase("TABLE")) {
92.7078 + isTable = true;
92.7079 +
92.7080 + moveNext = getNextNonWhitespace(ts, true);
92.7081 + tmp = ts.token();
92.7082 +
92.7083 + if (moveNext != false) {
92.7084 + tableName = tmp.text().toString();
92.7085 + tableName = checkForOtherSchema(ts, tableName);
92.7086 + if (tableName.indexOf('&') != -1) {
92.7087 + alias = tableName;
92.7088 + }
92.7089 +
92.7090 + tableName = getDefine(tableName);
92.7091 + if (ts.moveNext()) {
92.7092 + tmp = ts.token();
92.7093 + if ((tmp.id() == PlsqlTokenId.DOT) && ts.moveNext()) {
92.7094 + tmp = ts.token();
92.7095 + }
92.7096 + }
92.7097 + }
92.7098 +
92.7099 + } else if (image.equalsIgnoreCase("COLUMN")) {
92.7100 + isTable = false;
92.7101 + moveNext = getNextNonWhitespace(ts, true);
92.7102 + tmp = ts.token();
92.7103 +
92.7104 + if (moveNext != false) {
92.7105 + tableName = tmp.text().toString();
92.7106 + if (tableName.indexOf('&') != -1) {
92.7107 + alias = tableName;
92.7108 + }
92.7109 +
92.7110 + tableName = getDefine(tableName);
92.7111 + if (ts.moveNext()) {
92.7112 + tmp = ts.token();
92.7113 + if ((tmp.id() == PlsqlTokenId.DOT) && ts.moveNext()) {
92.7114 + tmp = ts.token();
92.7115 + }
92.7116 + }
92.7117 + }
92.7118 + } else {
92.7119 + ts.move(beginOffset);
92.7120 + ts.moveNext();
92.7121 + ts.moveNext();
92.7122 + return block;
92.7123 + }
92.7124 + }
92.7125 +
92.7126 + while (moveNext) {
92.7127 + PlsqlTokenId tokenID = tmp.id();
92.7128 + String image = tmp.text().toString();
92.7129 +
92.7130 + //Check end offset and break (exception for colun which will mark end of some blocks)
92.7131 + if ((tmp != null) && (tmp.offset(tokenHierarchy) > endParse) && (!image.equals(";")) && (!(image.equals("/") && checkForOnlyChar(ts, ts.offset())))) {
92.7132 + ts.move(beginOffset);
92.7133 + ts.moveNext();
92.7134 + ts.moveNext();
92.7135 + break;
92.7136 + }
92.7137 +
92.7138 + //We have come to the end of the comment
92.7139 + if ((tokenID == PlsqlTokenId.OPERATOR)
92.7140 + && (image.equals(";") || (image.equals("/") && checkForOnlyChar(ts, ts.offset())))) {
92.7141 + isEnd = true;
92.7142 + previousBlock = tmp;
92.7143 + int offset = ts.offset();
92.7144 + boolean mNext = getNextNonWhitespace(ts, false); //after ';' dont ignore comments
92.7145 +
92.7146 + Token<PlsqlTokenId> next = ts.token();
92.7147 + ts.move(offset);
92.7148 + ts.moveNext();
92.7149 +
92.7150 + if ((mNext == false) || (!next.text().toString().equalsIgnoreCase("COMMENT"))
92.7151 + || ((next.text().toString().equalsIgnoreCase("COMMENT")) && (next.offset(tokenHierarchy) > endParse))) { //we have come to the end of the comments
92.7152 +
92.7153 + if (isTable) {
92.7154 + block = new PlsqlBlock(commentBegin.offset(tokenHierarchy),
92.7155 + previousBlock.offset(tokenHierarchy), tableName, alias, PlsqlBlockType.TABLE_COMMENT);
92.7156 + } else {
92.7157 + block = new PlsqlBlock(commentBegin.offset(tokenHierarchy),
92.7158 + previousBlock.offset(tokenHierarchy), tableName, alias, PlsqlBlockType.COLUMN_COMMENT);
92.7159 + }
92.7160 +
92.7161 + break;
92.7162 + }
92.7163 + } else if ((tokenID == PlsqlTokenId.KEYWORD)) {
92.7164 + if (image.equalsIgnoreCase("COLUMN")) {
92.7165 + if (isTable == true) {
92.7166 + isTable = false;
92.7167 +
92.7168 + if (previousBlock != null) {
92.7169 + //Create table comment fold
92.7170 + block = new PlsqlBlock(commentBegin.offset(tokenHierarchy),
92.7171 + previousBlock.offset(tokenHierarchy), tableName, alias, PlsqlBlockType.TABLE_COMMENT);
92.7172 + ts.move(tmpPre.offset(tokenHierarchy));
92.7173 + break;
92.7174 + }
92.7175 + }
92.7176 + } else if (image.equalsIgnoreCase("TABLE")) {
92.7177 + if (isTable == false) {
92.7178 + isTable = true;
92.7179 +
92.7180 + if (previousBlock != null) {
92.7181 + //Create column comment fold
92.7182 + block = new PlsqlBlock(commentBegin.offset(tokenHierarchy),
92.7183 + previousBlock.offset(tokenHierarchy), tableName, alias, PlsqlBlockType.COLUMN_COMMENT);
92.7184 + ts.move(tmpPre.offset(tokenHierarchy));
92.7185 + break;
92.7186 + }
92.7187 + }
92.7188 + } else if (image.equalsIgnoreCase("COMMENT")) {
92.7189 + tmpPre = tmp;
92.7190 + moveNext = getNextNonWhitespace(ts, true);
92.7191 + tmp = ts.token();
92.7192 + if (isEnd == false) {
92.7193 + commentBegin = tmpPre;
92.7194 + }
92.7195 + }
92.7196 + } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.7197 + //only single comment line
92.7198 + if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.7199 + customStartToken = tmp;
92.7200 + } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.7201 + if (customStartToken != null) {
92.7202 + String name = customStartToken.text().toString();
92.7203 + int index = name.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.7204 + name = name.substring(index + 7).trim();
92.7205 + if (ts.moveNext()) {
92.7206 + tmp = ts.token();
92.7207 + PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.7208 + tmp.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.7209 + customFoldBlocks.add(custom);
92.7210 + }
92.7211 +
92.7212 + customStartToken = null;
92.7213 + }
92.7214 + } else {
92.7215 + PlsqlBlock child = checkComment(tmp, ts);
92.7216 + if (child != null) {
92.7217 + if (checkExisting(child, lstChild) == false) {
92.7218 + lstChild.add(child);
92.7219 + }
92.7220 + }
92.7221 + }
92.7222 + } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.7223 + int start = tmp.offset(tokenHierarchy);
92.7224 + PlsqlBlock child = new PlsqlBlock(start,
92.7225 + start + tmp.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.7226 + if (child != null) {
92.7227 + if (checkExisting(child, lstChild) == false) {
92.7228 + lstChild.add(child);
92.7229 + }
92.7230 + }
92.7231 + }
92.7232 +
92.7233 moveNext = getNextNonWhitespace(ts, true);
92.7234 tmp = ts.token();
92.7235 -
92.7236 - if (moveNext != false) {
92.7237 - tableName = tmp.text().toString();
92.7238 - if (tableName.indexOf('&') != -1) {
92.7239 - alias = tableName;
92.7240 - }
92.7241 -
92.7242 - tableName = getDefine(tableName);
92.7243 - if (ts.moveNext()) {
92.7244 - tmp = ts.token();
92.7245 - if ((tmp.id() == PlsqlTokenId.DOT) && ts.moveNext()) {
92.7246 - tmp = ts.token();
92.7247 - }
92.7248 - }
92.7249 + }
92.7250 +
92.7251 + if (block != null) {
92.7252 + //add children
92.7253 + addChildren(block, lstChild, parentBlocks);
92.7254 + }
92.7255 +
92.7256 + return block;
92.7257 + }
92.7258 +
92.7259 + /**
92.7260 + * Get Return next non whitespace token
92.7261 + * @param ts
92.7262 + * @param ignoreComment: if true will ignore comments also
92.7263 + * @return
92.7264 + */
92.7265 + private boolean getNextNonWhitespace(TokenSequence<PlsqlTokenId> ts, boolean ignoreComment) {
92.7266 + boolean moveNext = ts.moveNext();
92.7267 + Token<PlsqlTokenId> tmp = ts.token();
92.7268 +
92.7269 +
92.7270 + while (moveNext) {
92.7271 + if (tmp.id() == PlsqlTokenId.WHITESPACE) {
92.7272 + moveNext = ts.moveNext();
92.7273 + tmp = ts.token();
92.7274 + } else {
92.7275 + if ((ignoreComment == true) && (tmp.id() == PlsqlTokenId.LINE_COMMENT
92.7276 + || tmp.id() == PlsqlTokenId.BLOCK_COMMENT)) {
92.7277 + moveNext = ts.moveNext();
92.7278 + tmp = ts.token();
92.7279 + } else {
92.7280 + break;
92.7281 + }
92.7282 }
92.7283 - } else {
92.7284 - ts.move(beginOffset);
92.7285 - ts.moveNext();
92.7286 + }
92.7287 +
92.7288 + return moveNext;
92.7289 + }
92.7290 +
92.7291 + /**
92.7292 + * Return previous non whitespace token
92.7293 + * @param ts
92.7294 + * @param ignoreComment
92.7295 + * @return
92.7296 + */
92.7297 + private boolean getPreviousNonWhitespace(TokenSequence<PlsqlTokenId> ts, boolean ignoreComment) {
92.7298 + boolean movePrevious = ts.movePrevious();
92.7299 + Token<PlsqlTokenId> tmp = ts.token();
92.7300 +
92.7301 + while (movePrevious) {
92.7302 + if (tmp.id() == PlsqlTokenId.WHITESPACE) {
92.7303 + movePrevious = ts.movePrevious();
92.7304 + tmp = ts.token();
92.7305 + } else {
92.7306 + if ((ignoreComment == true) && (tmp.id() == PlsqlTokenId.LINE_COMMENT
92.7307 + || tmp.id() == PlsqlTokenId.BLOCK_COMMENT)) {
92.7308 + movePrevious = ts.movePrevious();
92.7309 + tmp = ts.token();
92.7310 + } else {
92.7311 + break;
92.7312 + }
92.7313 + }
92.7314 + }
92.7315 + return movePrevious;
92.7316 + }
92.7317 +
92.7318 + /**
92.7319 + * Check whether this is the start of a VIEW block
92.7320 + * @param viewToken
92.7321 + * @param ts
92.7322 + * @param parentBlocks
92.7323 + * @return
92.7324 + */
92.7325 + private PlsqlBlock checkView(Token<PlsqlTokenId> viewToken, TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> parentBlocks) {
92.7326 + Token<PlsqlTokenId> viewBegin = viewToken;
92.7327 + Token<PlsqlTokenId> tmp = viewToken;
92.7328 + PlsqlBlock block = null;
92.7329 + List<PlsqlBlock> lstChild = new ArrayList<PlsqlBlock>();
92.7330 +
92.7331 + boolean moveNext = false;
92.7332 + String viewName = "";
92.7333 + int offset = ts.offset();
92.7334 +
92.7335 + //Check whether the beginning is in a SQL Plus command
92.7336 + if (sqlPlusLine(ts)) {
92.7337 + return null;
92.7338 + }
92.7339 +
92.7340 + //second non whitespace character should be the name
92.7341 + moveNext = getNextNonWhitespace(ts, true);
92.7342 + if (moveNext == false) {
92.7343 + ts.move(offset);
92.7344 ts.moveNext();
92.7345 return block;
92.7346 - }
92.7347 - }
92.7348 -
92.7349 - while (moveNext) {
92.7350 - PlsqlTokenId tokenID = tmp.id();
92.7351 - String image = tmp.text().toString();
92.7352 -
92.7353 - //Check end offset and break (exception for colun which will mark end of some blocks)
92.7354 - if ((tmp != null) && (tmp.offset(tokenHierarchy) > endParse) && (!image.equals(";")) && (!(image.equals("/") && checkForOnlyChar(ts, ts.offset())))) {
92.7355 - ts.move(beginOffset);
92.7356 - ts.moveNext();
92.7357 - ts.moveNext();
92.7358 - break;
92.7359 - }
92.7360 -
92.7361 - //We have come to the end of the comment
92.7362 - if ((tokenID == PlsqlTokenId.OPERATOR)
92.7363 - && (image.equals(";") || (image.equals("/") && checkForOnlyChar(ts, ts.offset())))) {
92.7364 - isEnd = true;
92.7365 - previousBlock = tmp;
92.7366 - int offset = ts.offset();
92.7367 - boolean mNext = getNextNonWhitespace(ts, false); //after ';' dont ignore comments
92.7368 -
92.7369 - Token<PlsqlTokenId> next = ts.token();
92.7370 - ts.move(offset);
92.7371 - ts.moveNext();
92.7372 -
92.7373 - if ((mNext == false) || (!next.text().toString().equalsIgnoreCase("COMMENT"))
92.7374 - || ((next.text().toString().equalsIgnoreCase("COMMENT")) && (next.offset(tokenHierarchy) > endParse))) { //we have come to the end of the comments
92.7375 -
92.7376 - if (isTable) {
92.7377 - block = new PlsqlBlock(commentBegin.offset(tokenHierarchy),
92.7378 - previousBlock.offset(tokenHierarchy), tableName, alias, PlsqlBlockType.TABLE_COMMENT);
92.7379 - } else {
92.7380 - block = new PlsqlBlock(commentBegin.offset(tokenHierarchy),
92.7381 - previousBlock.offset(tokenHierarchy), tableName, alias, PlsqlBlockType.COLUMN_COMMENT);
92.7382 - }
92.7383 -
92.7384 - break;
92.7385 - }
92.7386 - } else if ((tokenID == PlsqlTokenId.KEYWORD)) {
92.7387 - if (image.equalsIgnoreCase("COLUMN")) {
92.7388 - if (isTable == true) {
92.7389 - isTable = false;
92.7390 -
92.7391 - if (previousBlock != null) {
92.7392 - //Create table comment fold
92.7393 - block = new PlsqlBlock(commentBegin.offset(tokenHierarchy),
92.7394 - previousBlock.offset(tokenHierarchy), tableName, alias, PlsqlBlockType.TABLE_COMMENT);
92.7395 - ts.move(tmpPre.offset(tokenHierarchy));
92.7396 - break;
92.7397 - }
92.7398 - }
92.7399 - } else if (image.equalsIgnoreCase("TABLE")) {
92.7400 - if (isTable == false) {
92.7401 - isTable = true;
92.7402 -
92.7403 - if (previousBlock != null) {
92.7404 - //Create column comment fold
92.7405 - block = new PlsqlBlock(commentBegin.offset(tokenHierarchy),
92.7406 - previousBlock.offset(tokenHierarchy), tableName, alias, PlsqlBlockType.COLUMN_COMMENT);
92.7407 - ts.move(tmpPre.offset(tokenHierarchy));
92.7408 - break;
92.7409 - }
92.7410 - }
92.7411 - } else if (image.equalsIgnoreCase("COMMENT")) {
92.7412 - tmpPre = tmp;
92.7413 - moveNext = getNextNonWhitespace(ts, true);
92.7414 - tmp = ts.token();
92.7415 - if (isEnd == false) {
92.7416 - commentBegin = tmpPre;
92.7417 - }
92.7418 - }
92.7419 - } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.7420 - //only single comment line
92.7421 - if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.7422 - customStartToken = tmp;
92.7423 - } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.7424 - if (customStartToken != null) {
92.7425 - String name = customStartToken.text().toString();
92.7426 - int index = name.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.7427 - name = name.substring(index + 7).trim();
92.7428 - if (ts.moveNext()) {
92.7429 - tmp = ts.token();
92.7430 - PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.7431 - tmp.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.7432 - customFoldBlocks.add(custom);
92.7433 - }
92.7434 -
92.7435 - customStartToken = null;
92.7436 - }
92.7437 - } else {
92.7438 - PlsqlBlock child = checkComment(tmp, ts);
92.7439 - if (child != null) {
92.7440 - if (checkExisting(child, lstChild) == false) {
92.7441 - lstChild.add(child);
92.7442 - }
92.7443 - }
92.7444 - }
92.7445 - } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.7446 - int start = tmp.offset(tokenHierarchy);
92.7447 - PlsqlBlock child = new PlsqlBlock(start,
92.7448 - start + tmp.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.7449 - if (child != null) {
92.7450 - if (checkExisting(child, lstChild) == false) {
92.7451 - lstChild.add(child);
92.7452 - }
92.7453 - }
92.7454 - }
92.7455 -
92.7456 - moveNext = getNextNonWhitespace(ts, true);
92.7457 - tmp = ts.token();
92.7458 - }
92.7459 -
92.7460 - if (block != null) {
92.7461 - //add children
92.7462 - addChildren(block, lstChild, parentBlocks);
92.7463 - }
92.7464 -
92.7465 - return block;
92.7466 - }
92.7467 -
92.7468 - /**
92.7469 - * Get Return next non whitespace token
92.7470 - * @param ts
92.7471 - * @param ignoreComment: if true will ignore comments also
92.7472 - * @return
92.7473 - */
92.7474 - private boolean getNextNonWhitespace(TokenSequence<PlsqlTokenId> ts, boolean ignoreComment) {
92.7475 - boolean moveNext = ts.moveNext();
92.7476 - Token<PlsqlTokenId> tmp = ts.token();
92.7477 -
92.7478 -
92.7479 - while (moveNext) {
92.7480 - if (tmp.id() == PlsqlTokenId.WHITESPACE) {
92.7481 - moveNext = ts.moveNext();
92.7482 - tmp = ts.token();
92.7483 - } else {
92.7484 - if ((ignoreComment == true) && (tmp.id() == PlsqlTokenId.LINE_COMMENT
92.7485 - || tmp.id() == PlsqlTokenId.BLOCK_COMMENT)) {
92.7486 - moveNext = ts.moveNext();
92.7487 - tmp = ts.token();
92.7488 - } else {
92.7489 - break;
92.7490 - }
92.7491 - }
92.7492 - }
92.7493 -
92.7494 - return moveNext;
92.7495 - }
92.7496 -
92.7497 - /**
92.7498 - * Return previous non whitespace token
92.7499 - * @param ts
92.7500 - * @param ignoreComment
92.7501 - * @return
92.7502 - */
92.7503 - private boolean getPreviousNonWhitespace(TokenSequence<PlsqlTokenId> ts, boolean ignoreComment) {
92.7504 - boolean movePrevious = ts.movePrevious();
92.7505 - Token<PlsqlTokenId> tmp = ts.token();
92.7506 -
92.7507 - while (movePrevious) {
92.7508 - if (tmp.id() == PlsqlTokenId.WHITESPACE) {
92.7509 - movePrevious = ts.movePrevious();
92.7510 - tmp = ts.token();
92.7511 - } else {
92.7512 - if ((ignoreComment == true) && (tmp.id() == PlsqlTokenId.LINE_COMMENT
92.7513 - || tmp.id() == PlsqlTokenId.BLOCK_COMMENT)) {
92.7514 - movePrevious = ts.movePrevious();
92.7515 - tmp = ts.token();
92.7516 - } else {
92.7517 - break;
92.7518 - }
92.7519 - }
92.7520 - }
92.7521 - return movePrevious;
92.7522 - }
92.7523 -
92.7524 - /**
92.7525 - * Check whether this is the start of a VIEW block
92.7526 - * @param viewToken
92.7527 - * @param ts
92.7528 - * @param parentBlocks
92.7529 - * @return
92.7530 - */
92.7531 - private PlsqlBlock checkView(Token<PlsqlTokenId> viewToken, TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> parentBlocks) {
92.7532 - Token<PlsqlTokenId> viewBegin = viewToken;
92.7533 - Token<PlsqlTokenId> tmp = viewToken;
92.7534 - PlsqlBlock block = null;
92.7535 - List<PlsqlBlock> lstChild = new ArrayList<PlsqlBlock>();
92.7536 -
92.7537 - boolean moveNext = false;
92.7538 - String viewName = "";
92.7539 - int offset = ts.offset();
92.7540 -
92.7541 - //Check whether the beginning is in a SQL Plus command
92.7542 - if (sqlPlusLine(ts)) {
92.7543 - return null;
92.7544 - }
92.7545 -
92.7546 - //second non whitespace character should be the name
92.7547 - moveNext = getNextNonWhitespace(ts, true);
92.7548 - if (moveNext == false) {
92.7549 - ts.move(offset);
92.7550 - ts.moveNext();
92.7551 - return block;
92.7552 - }
92.7553 -
92.7554 - tmp = ts.token();
92.7555 -
92.7556 - //Second token is the view name
92.7557 - viewName = tmp.text().toString().trim();
92.7558 - viewName = checkForOtherSchema(ts, viewName);
92.7559 - String alias = "";
92.7560 - if (viewName.indexOf('&') != -1) {
92.7561 - alias = viewName;
92.7562 - viewName = getDefine(viewName);
92.7563 - }
92.7564 + }
92.7565 +
92.7566 + tmp = ts.token();
92.7567 +
92.7568 + //Second token is the view name
92.7569 + viewName = tmp.text().toString().trim();
92.7570 + viewName = checkForOtherSchema(ts, viewName);
92.7571 + String alias = "";
92.7572 + if (viewName.indexOf('&') != -1) {
92.7573 + alias = viewName;
92.7574 + viewName = getDefine(viewName);
92.7575 + }
92.7576 // if (ts.moveNext()) {
92.7577 // tmp = ts.token();
92.7578 // if ((tmp.id() == PlsqlTokenId.DOT) && ts.moveNext()) {
92.7579 @@ -3893,26 +3897,26 @@
92.7580 // }
92.7581 // }
92.7582
92.7583 - Token<PlsqlTokenId> customStartToken = null;
92.7584 - boolean isOk = false;
92.7585 -
92.7586 - while (moveNext) {
92.7587 - String image = tmp.text().toString();
92.7588 - PlsqlTokenId tokenID = tmp.id();
92.7589 -
92.7590 - //Check end offset and break(exception for colun which will mark end of some blocks)
92.7591 - if ((tmp != null) && (tmp.offset(tokenHierarchy) > endParse) && (!image.equals(";"))) {
92.7592 - break;
92.7593 - }
92.7594 -
92.7595 - if ((tokenID == PlsqlTokenId.KEYWORD) && (image.equalsIgnoreCase("AS"))) {
92.7596 - isOk = true;
92.7597 - }
92.7598 -
92.7599 - //We have come to the end of the view declaration
92.7600 - if ((tokenID == PlsqlTokenId.OPERATOR)
92.7601 - && (image.equals(";") || (image.equals("/") && checkForOnlyChar(ts, ts.offset())))) {
92.7602 - if (isOk) {
92.7603 + Token<PlsqlTokenId> customStartToken = null;
92.7604 + boolean isOk = false;
92.7605 +
92.7606 + while (moveNext) {
92.7607 + String image = tmp.text().toString();
92.7608 + PlsqlTokenId tokenID = tmp.id();
92.7609 +
92.7610 + //Check end offset and break(exception for colun which will mark end of some blocks)
92.7611 + if ((tmp != null) && (tmp.offset(tokenHierarchy) > endParse) && (!image.equals(";"))) {
92.7612 + break;
92.7613 + }
92.7614 +
92.7615 + if ((tokenID == PlsqlTokenId.KEYWORD) && (image.equalsIgnoreCase("AS"))) {
92.7616 + isOk = true;
92.7617 + }
92.7618 +
92.7619 + //We have come to the end of the view declaration
92.7620 + if ((tokenID == PlsqlTokenId.OPERATOR)
92.7621 + && (image.equals(";") || (image.equals("/") && checkForOnlyChar(ts, ts.offset())))) {
92.7622 + if (isOk) {
92.7623 // String alias = "";
92.7624 // if (viewName.indexOf('&') != -1) {
92.7625 // int dotIndex = viewName.indexOf('.');
92.7626 @@ -3926,999 +3930,1000 @@
92.7627 // }
92.7628 // }
92.7629
92.7630 - block = new PlsqlBlock(viewBegin.offset(tokenHierarchy),
92.7631 - tmp.offset(tokenHierarchy), viewName, alias, PlsqlBlockType.VIEW);
92.7632 - checkPrefix(viewBegin.offset(tokenHierarchy), ts, block);
92.7633 - break;
92.7634 + block = new PlsqlBlock(viewBegin.offset(tokenHierarchy),
92.7635 + tmp.offset(tokenHierarchy), viewName, alias, PlsqlBlockType.VIEW);
92.7636 + checkPrefix(viewBegin.offset(tokenHierarchy), ts, block);
92.7637 + break;
92.7638 + } else {
92.7639 + ts.move(offset);
92.7640 + ts.moveNext();
92.7641 + ts.moveNext(); // to avoid getting caught here again we have to move next
92.7642 + break;
92.7643 + }
92.7644 + } else if ((tokenID == PlsqlTokenId.KEYWORD)
92.7645 + && ((image.equalsIgnoreCase("COMMENT"))
92.7646 + || (image.equalsIgnoreCase("CREATE")))) { //Avoid catching ';' of other statements
92.7647 +
92.7648 + ts.move(offset);
92.7649 + ts.moveNext();
92.7650 + ts.moveNext(); // to avoid getting caught here again we have to move next
92.7651 +
92.7652 + break;
92.7653 +
92.7654 + } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.7655 + //only single comment line
92.7656 + if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.7657 + customStartToken = tmp;
92.7658 + } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.7659 + if (customStartToken != null) {
92.7660 + String name = customStartToken.text().toString();
92.7661 + int index = name.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.7662 + name = name.substring(index + 7).trim();
92.7663 + if (ts.moveNext()) {
92.7664 + tmp = ts.token();
92.7665 + PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.7666 + tmp.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.7667 + customFoldBlocks.add(custom);
92.7668 + }
92.7669 +
92.7670 + customStartToken = null;
92.7671 + }
92.7672 + } else {
92.7673 + PlsqlBlock child = checkComment(tmp, ts);
92.7674 + if (child != null) {
92.7675 + if (checkExisting(child, lstChild) == false) {
92.7676 + lstChild.add(child);
92.7677 + }
92.7678 + }
92.7679 + }
92.7680 + moveNext = ts.moveNext();
92.7681 + tmp = ts.token();
92.7682 + } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.7683 + int start = tmp.offset(tokenHierarchy);
92.7684 + PlsqlBlock child = new PlsqlBlock(start,
92.7685 + start + tmp.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.7686 + if (child != null) {
92.7687 + if (checkExisting(child, lstChild) == false) {
92.7688 + lstChild.add(child);
92.7689 + }
92.7690 + }
92.7691 + moveNext = ts.moveNext();
92.7692 + tmp = ts.token();
92.7693 } else {
92.7694 - ts.move(offset);
92.7695 - ts.moveNext();
92.7696 - ts.moveNext(); // to avoid getting caught here again we have to move next
92.7697 - break;
92.7698 + moveNext = ts.moveNext();
92.7699 + tmp = ts.token();
92.7700 }
92.7701 - } else if ((tokenID == PlsqlTokenId.KEYWORD)
92.7702 - && ((image.equalsIgnoreCase("COMMENT"))
92.7703 - || (image.equalsIgnoreCase("CREATE")))) { //Avoid catching ';' of other statements
92.7704 -
92.7705 - ts.move(offset);
92.7706 - ts.moveNext();
92.7707 - ts.moveNext(); // to avoid getting caught here again we have to move next
92.7708 -
92.7709 - break;
92.7710 -
92.7711 - } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.7712 - //only single comment line
92.7713 - if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.7714 - customStartToken = tmp;
92.7715 - } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.7716 - if (customStartToken != null) {
92.7717 - String name = customStartToken.text().toString();
92.7718 - int index = name.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.7719 - name = name.substring(index + 7).trim();
92.7720 - if (ts.moveNext()) {
92.7721 - tmp = ts.token();
92.7722 - PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.7723 - tmp.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.7724 - customFoldBlocks.add(custom);
92.7725 - }
92.7726 -
92.7727 - customStartToken = null;
92.7728 - }
92.7729 - } else {
92.7730 - PlsqlBlock child = checkComment(tmp, ts);
92.7731 - if (child != null) {
92.7732 - if (checkExisting(child, lstChild) == false) {
92.7733 - lstChild.add(child);
92.7734 - }
92.7735 - }
92.7736 + }
92.7737 +
92.7738 + if (block != null) {
92.7739 + //add children
92.7740 + addChildren(block, lstChild, parentBlocks);
92.7741 + }
92.7742 +
92.7743 + return block;
92.7744 + }
92.7745 +
92.7746 + /**
92.7747 + * Get the name defined by &Name
92.7748 + * @param inputName
92.7749 + * @return
92.7750 + */
92.7751 + public String getDefine(
92.7752 + String inputName) {
92.7753 + String name = inputName;
92.7754 +
92.7755 + if (name.indexOf('&', 0) != -1) {
92.7756 + String val = definesMap.get(name.substring(1).toUpperCase(Locale.ENGLISH));
92.7757 + if (val != null) {
92.7758 + name = val;
92.7759 }
92.7760 + }
92.7761 +
92.7762 + return name;
92.7763 + }
92.7764 +
92.7765 + /**
92.7766 + * Check &Name is in map as a key
92.7767 + * @param inputName
92.7768 + * @return
92.7769 + */
92.7770 + public boolean isDefine(String inputName) {
92.7771 + String name = inputName;
92.7772 +
92.7773 + if (name.indexOf('&', 0) != -1) {
92.7774 + return definesMap.containsKey(name.substring(1).toUpperCase(Locale.ENGLISH));
92.7775 + }
92.7776 +
92.7777 + return false;
92.7778 + }
92.7779 +
92.7780 + /**
92.7781 + * Check &Name is in map as a value
92.7782 + * @param inputName
92.7783 + * @return
92.7784 + */
92.7785 + public boolean hasDefineKey(String inputName) {
92.7786 + String name = inputName;
92.7787 + return definesMap.containsValue(name.toUpperCase(Locale.ENGLISH));
92.7788 + }
92.7789 +
92.7790 + /**
92.7791 + * Get the key of &Name
92.7792 + * @param inputName
92.7793 + * @return
92.7794 + */
92.7795 + public String getDefineKey(String inputName) {
92.7796 + for (Object o : definesMap.keySet()) {
92.7797 + if (definesMap.get(o).equals(inputName)) {
92.7798 + return o.toString();
92.7799 + }
92.7800 + }
92.7801 + return null;
92.7802 + }
92.7803 +
92.7804 + public Map<String, String> getDefines() {
92.7805 + return Collections.unmodifiableMap(definesMap);
92.7806 + }
92.7807 +
92.7808 + /**
92.7809 + * Method that will parse the document and initialize the aliases
92.7810 + * @param doc
92.7811 + */
92.7812 + private void getAliases(Document doc) {
92.7813 + TokenHierarchy tokenHier = TokenHierarchy.get(doc);
92.7814 + @SuppressWarnings("unchecked")
92.7815 + TokenSequence<PlsqlTokenId> ts = tokenHier.tokenSequence(PlsqlTokenId.language());
92.7816 + if (ts == null) {
92.7817 + return;
92.7818 + }
92.7819 +
92.7820 + //start to check aliases from the previous line end
92.7821 + ts.move(startParse);
92.7822 + Token<PlsqlTokenId> token = ts.token();
92.7823 +
92.7824 + //Get the difine by the name
92.7825 + while (ts.moveNext() && ts.offset() <= endParse) {
92.7826 + token = ts.token();
92.7827 + //Check whether this is DEFINE
92.7828 + if (token.id() == PlsqlTokenId.SQL_PLUS
92.7829 + && (token.toString().equalsIgnoreCase("DEF")
92.7830 + || token.toString().equalsIgnoreCase("DEFI")
92.7831 + || token.toString().equalsIgnoreCase("DEFIN")
92.7832 + || token.toString().equalsIgnoreCase("DEFINE"))) {
92.7833 + String tokenTxt = readLine(ts, token);
92.7834 + if (!tokenTxt.contains(" = ") && tokenTxt.contains("=")) {
92.7835 + tokenTxt = tokenTxt.substring(0, tokenTxt.indexOf("=")) + " = " + tokenTxt.substring(tokenTxt.indexOf("=") + 1);
92.7836 + }
92.7837 +
92.7838 + StringTokenizer tokenizer = new StringTokenizer(tokenTxt);
92.7839 + tokenizer.nextToken();
92.7840 + String alias;
92.7841 + String value = "";
92.7842 + boolean isNext = tokenizer.hasMoreTokens();
92.7843 +
92.7844 + //alias
92.7845 + if (isNext) {
92.7846 + alias = tokenizer.nextToken();
92.7847 + } else {
92.7848 + break;
92.7849 + }
92.7850 +
92.7851 + isNext = tokenizer.hasMoreTokens();
92.7852 +
92.7853 + if ((isNext) && (tokenizer.nextToken().equals("="))) {
92.7854 + boolean isComment = false;
92.7855 + while (tokenizer.hasMoreTokens() && !isComment) {
92.7856 + String temp = tokenizer.nextToken();
92.7857 + if (temp.startsWith("--") || temp.startsWith("/*")) {
92.7858 + isComment = true;
92.7859 + } else {
92.7860 + value = value + " " + temp;
92.7861 + }
92.7862 + }
92.7863 +
92.7864 + value = value.trim();
92.7865 +
92.7866 + if ((value.startsWith("\"") && value.endsWith("\""))
92.7867 + || (value.startsWith("\'") && value.endsWith("\'"))) {
92.7868 + value = value.substring(1, value.length() - 1);
92.7869 + }
92.7870 +
92.7871 + definesMap.put(alias.toUpperCase(Locale.ENGLISH), value);
92.7872 + }
92.7873 + }
92.7874 + }
92.7875 + }
92.7876 +
92.7877 + /**
92.7878 + * Replace exStr in the given text with newStr
92.7879 + * @param plsqlString
92.7880 + * @param exStr
92.7881 + * @param newStr
92.7882 + * @return
92.7883 + */
92.7884 + public String replaceText(
92.7885 + String plsqlString, String exStr, String newStr) {
92.7886 + if (plsqlString.indexOf(exStr) >= 0) {
92.7887 + plsqlString = plsqlString.replace(exStr, newStr);
92.7888 + }
92.7889 +
92.7890 + return plsqlString;
92.7891 + }
92.7892 +
92.7893 + /**
92.7894 + * Check whether the given offsets are in the same line
92.7895 + * @param doc
92.7896 + * @param offset1
92.7897 + * @param offset2
92.7898 + * @return
92.7899 + */
92.7900 + private boolean checkSameLine(Document doc, int offset1, int offset2) {
92.7901 + int startLine = offset2;
92.7902 + int endLine = offset2;
92.7903 +
92.7904 + TokenHierarchy tokenHier = TokenHierarchy.get(doc);
92.7905 + @SuppressWarnings("unchecked")
92.7906 + TokenSequence<PlsqlTokenId> ts = tokenHier.tokenSequence(PlsqlTokenId.language());
92.7907 + if (ts == null) {
92.7908 + return false;
92.7909 + }
92.7910 +
92.7911 + //go to the previous line break
92.7912 + ts.move(offset2);
92.7913 + boolean movePrevious = ts.movePrevious();
92.7914 + Token<PlsqlTokenId> tokenPre = ts.token();
92.7915 +
92.7916 + while (movePrevious) {
92.7917 + if (tokenPre.text().toString().contains("\n")) {
92.7918 + startLine = tokenPre.offset(tokenHier);
92.7919 + break;
92.7920 +
92.7921 + }
92.7922 + movePrevious = ts.movePrevious();
92.7923 + tokenPre = ts.token();
92.7924 + }
92.7925 +
92.7926 + //If cannot move previous and start line not set it is the document begin
92.7927 + if ((startLine == offset2) && (!movePrevious)) {
92.7928 + startLine = doc.getStartPosition().getOffset();
92.7929 + }
92.7930 +
92.7931 + //go to the next line break
92.7932 + ts.move(offset2);
92.7933 + boolean moveNext = ts.moveNext();
92.7934 + Token<PlsqlTokenId> tokenNext = ts.token();
92.7935 +
92.7936 + while (moveNext) {
92.7937 + if (tokenNext.text().toString().contains("\n")) {
92.7938 + endLine = tokenNext.offset(tokenHier);
92.7939 + break;
92.7940 + }
92.7941 +
92.7942 moveNext = ts.moveNext();
92.7943 - tmp = ts.token();
92.7944 - } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.7945 - int start = tmp.offset(tokenHierarchy);
92.7946 - PlsqlBlock child = new PlsqlBlock(start,
92.7947 - start + tmp.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.7948 - if (child != null) {
92.7949 - if (checkExisting(child, lstChild) == false) {
92.7950 - lstChild.add(child);
92.7951 - }
92.7952 + tokenNext = ts.token();
92.7953 + }
92.7954 +
92.7955 + //If cannot move next and end line not set it is the document end
92.7956 + if ((endLine == offset2) && (!moveNext)) {
92.7957 + endLine = doc.getEndPosition().getOffset();
92.7958 + }
92.7959 +
92.7960 + if ((offset1 >= startLine) && (offset1 <= endLine)) {
92.7961 + if ((offset2 >= startLine) && (offset2 <= endLine)) {
92.7962 + return true;
92.7963 }
92.7964 - moveNext = ts.moveNext();
92.7965 - tmp = ts.token();
92.7966 - } else {
92.7967 - moveNext = ts.moveNext();
92.7968 - tmp = ts.token();
92.7969 - }
92.7970 - }
92.7971 -
92.7972 - if (block != null) {
92.7973 - //add children
92.7974 - addChildren(block, lstChild, parentBlocks);
92.7975 - }
92.7976 -
92.7977 - return block;
92.7978 - }
92.7979 -
92.7980 - /**
92.7981 - * Get the name defined by &Name
92.7982 - * @param inputName
92.7983 - * @return
92.7984 - */
92.7985 - public String getDefine(
92.7986 - String inputName) {
92.7987 - String name = inputName;
92.7988 -
92.7989 - if (name.indexOf('&', 0) != -1) {
92.7990 - String val = definesMap.get(name.substring(1).toUpperCase(Locale.ENGLISH));
92.7991 - if (val != null) {
92.7992 - name = val;
92.7993 - }
92.7994 - }
92.7995 -
92.7996 - return name;
92.7997 - }
92.7998 -
92.7999 - /**
92.8000 - * Check &Name is in map as a key
92.8001 - * @param inputName
92.8002 - * @return
92.8003 - */
92.8004 - public boolean isDefine(String inputName) {
92.8005 - String name = inputName;
92.8006 -
92.8007 - if (name.indexOf('&', 0) != -1) {
92.8008 - return definesMap.containsKey(name.substring(1).toUpperCase(Locale.ENGLISH));
92.8009 - }
92.8010 -
92.8011 - return false;
92.8012 - }
92.8013 -
92.8014 - /**
92.8015 - * Check &Name is in map as a value
92.8016 - * @param inputName
92.8017 - * @return
92.8018 - */
92.8019 - public boolean hasDefineKey(String inputName) {
92.8020 - String name = inputName;
92.8021 - return definesMap.containsValue(name.toUpperCase(Locale.ENGLISH));
92.8022 - }
92.8023 -
92.8024 - /**
92.8025 - * Get the key of &Name
92.8026 - * @param inputName
92.8027 - * @return
92.8028 - */
92.8029 - public String getDefineKey(String inputName) {
92.8030 - for(Object o:definesMap.keySet()){
92.8031 - if(definesMap.get(o).equals(inputName))
92.8032 - return o.toString();
92.8033 - }
92.8034 - return null;
92.8035 - }
92.8036 -
92.8037 - public Map<String, String> getDefines() {
92.8038 - return Collections.unmodifiableMap(definesMap);
92.8039 - }
92.8040 -
92.8041 - /**
92.8042 - * Method that will parse the document and initialize the aliases
92.8043 - * @param doc
92.8044 - */
92.8045 - private void getAliases(Document doc) {
92.8046 - TokenHierarchy tokenHier = TokenHierarchy.get(doc);
92.8047 - @SuppressWarnings("unchecked")
92.8048 - TokenSequence<PlsqlTokenId> ts = tokenHier.tokenSequence(PlsqlTokenId.language());
92.8049 - if (ts == null) {
92.8050 - return;
92.8051 - }
92.8052 -
92.8053 - //start to check aliases from the previous line end
92.8054 - ts.move(startParse);
92.8055 - Token<PlsqlTokenId> token = ts.token();
92.8056 -
92.8057 - //Get the difine by the name
92.8058 - while (ts.moveNext() && ts.offset() <= endParse) {
92.8059 - token = ts.token();
92.8060 - //Check whether this is DEFINE
92.8061 - if (token.id() == PlsqlTokenId.SQL_PLUS
92.8062 - && (token.toString().equalsIgnoreCase("DEF")
92.8063 - || token.toString().equalsIgnoreCase("DEFI")
92.8064 - || token.toString().equalsIgnoreCase("DEFIN")
92.8065 - || token.toString().equalsIgnoreCase("DEFINE"))) {
92.8066 - String tokenTxt = readLine(ts, token);
92.8067 - if (!tokenTxt.contains(" = ") && tokenTxt.contains("=")) {
92.8068 - tokenTxt = tokenTxt.substring(0, tokenTxt.indexOf("=")) + " = " + tokenTxt.substring(tokenTxt.indexOf("=") + 1);
92.8069 + }
92.8070 +
92.8071 + return false;
92.8072 + }
92.8073 +
92.8074 + /**
92.8075 + * Method that will check if blocks
92.8076 + * @param current
92.8077 + * @param ts
92.8078 + * @param parentBlocks
92.8079 + * @return
92.8080 + */
92.8081 + private List<PlsqlBlock> checkIfBlock(Token<PlsqlTokenId> current, TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> parentBlocks) {
92.8082 + Token<PlsqlTokenId> ifBegin = null;
92.8083 + Token<PlsqlTokenId> token = null;
92.8084 + int preOffset = -1;
92.8085 + List<PlsqlBlock> ifBlocks = new ArrayList<PlsqlBlock>();
92.8086 + List<PlsqlBlock> lstChild = new ArrayList<PlsqlBlock>();
92.8087 + boolean moveNext = false;
92.8088 +
92.8089 + //Check whether the beginning is in a SQL Plus command
92.8090 + if (sqlPlusLine(ts)) {
92.8091 + return null;
92.8092 + }
92.8093 +
92.8094 + moveNext = ts.moveNext();
92.8095 + token = ts.token();
92.8096 + ifBegin = current;
92.8097 + String name = ifBegin.text().toString() + " ";
92.8098 + boolean isThen = false;
92.8099 + Token<PlsqlTokenId> customStartToken = null;
92.8100 + //If this is an else check we need to ignore then
92.8101 + if (name.trim().equalsIgnoreCase("ELSE")) {
92.8102 + isThen = true;
92.8103 + }
92.8104 + while (moveNext) {
92.8105 + String image = token.text().toString();
92.8106 + PlsqlTokenId tokenID = token.id();
92.8107 +
92.8108 + if ((token != null) && (!image.equals(";")) && (token.offset(tokenHierarchy) > endParse)) {
92.8109 + break;
92.8110 }
92.8111
92.8112 - StringTokenizer tokenizer = new StringTokenizer(tokenTxt);
92.8113 - tokenizer.nextToken();
92.8114 - String alias;
92.8115 - String value = "";
92.8116 - boolean isNext = tokenizer.hasMoreTokens();
92.8117 -
92.8118 - //alias
92.8119 - if (isNext) {
92.8120 - alias = tokenizer.nextToken();
92.8121 - } else {
92.8122 - break;
92.8123 - }
92.8124 -
92.8125 - isNext = tokenizer.hasMoreTokens();
92.8126 -
92.8127 - if ((isNext) && (tokenizer.nextToken().equals("="))) {
92.8128 - boolean isComment = false;
92.8129 - while (tokenizer.hasMoreTokens() && !isComment) {
92.8130 - String temp = tokenizer.nextToken();
92.8131 - if (temp.startsWith("--") || temp.startsWith("/*")) {
92.8132 - isComment = true;
92.8133 - } else {
92.8134 - value = value + " " + temp;
92.8135 - }
92.8136 - }
92.8137 -
92.8138 - value = value.trim();
92.8139 -
92.8140 - if ((value.startsWith("\"") && value.endsWith("\""))
92.8141 - || (value.startsWith("\'") && value.endsWith("\'"))) {
92.8142 - value = value.substring(1, value.length() - 1);
92.8143 - }
92.8144 -
92.8145 - definesMap.put(alias.toUpperCase(Locale.ENGLISH), value);
92.8146 - }
92.8147 - }
92.8148 - }
92.8149 - }
92.8150 -
92.8151 - /**
92.8152 - * Replace exStr in the given text with newStr
92.8153 - * @param plsqlString
92.8154 - * @param exStr
92.8155 - * @param newStr
92.8156 - * @return
92.8157 - */
92.8158 - public String replaceText(
92.8159 - String plsqlString, String exStr, String newStr) {
92.8160 - if (plsqlString.indexOf(exStr) >= 0) {
92.8161 - plsqlString = plsqlString.replace(exStr, newStr);
92.8162 - }
92.8163 -
92.8164 - return plsqlString;
92.8165 - }
92.8166 -
92.8167 - /**
92.8168 - * Check whether the given offsets are in the same line
92.8169 - * @param doc
92.8170 - * @param offset1
92.8171 - * @param offset2
92.8172 - * @return
92.8173 - */
92.8174 - private boolean checkSameLine(Document doc, int offset1, int offset2) {
92.8175 - int startLine = offset2;
92.8176 - int endLine = offset2;
92.8177 -
92.8178 - TokenHierarchy tokenHier = TokenHierarchy.get(doc);
92.8179 - @SuppressWarnings("unchecked")
92.8180 - TokenSequence<PlsqlTokenId> ts = tokenHier.tokenSequence(PlsqlTokenId.language());
92.8181 - if (ts == null) {
92.8182 - return false;
92.8183 - }
92.8184 -
92.8185 - //go to the previous line break
92.8186 - ts.move(offset2);
92.8187 - boolean movePrevious = ts.movePrevious();
92.8188 - Token<PlsqlTokenId> tokenPre = ts.token();
92.8189 -
92.8190 - while (movePrevious) {
92.8191 - if (tokenPre.text().toString().contains("\n")) {
92.8192 - startLine = tokenPre.offset(tokenHier);
92.8193 - break;
92.8194 -
92.8195 - }
92.8196 - movePrevious = ts.movePrevious();
92.8197 - tokenPre = ts.token();
92.8198 - }
92.8199 -
92.8200 - //If cannot move previous and start line not set it is the document begin
92.8201 - if ((startLine == offset2) && (!movePrevious)) {
92.8202 - startLine = doc.getStartPosition().getOffset();
92.8203 - }
92.8204 -
92.8205 - //go to the next line break
92.8206 - ts.move(offset2);
92.8207 - boolean moveNext = ts.moveNext();
92.8208 - Token<PlsqlTokenId> tokenNext = ts.token();
92.8209 -
92.8210 - while (moveNext) {
92.8211 - if (tokenNext.text().toString().contains("\n")) {
92.8212 - endLine = tokenNext.offset(tokenHier);
92.8213 - break;
92.8214 - }
92.8215 -
92.8216 - moveNext = ts.moveNext();
92.8217 - tokenNext = ts.token();
92.8218 - }
92.8219 -
92.8220 - //If cannot move next and end line not set it is the document end
92.8221 - if ((endLine == offset2) && (!moveNext)) {
92.8222 - endLine = doc.getEndPosition().getOffset();
92.8223 - }
92.8224 -
92.8225 - if ((offset1 >= startLine) && (offset1 <= endLine)) {
92.8226 - if ((offset2 >= startLine) && (offset2 <= endLine)) {
92.8227 - return true;
92.8228 - }
92.8229 - }
92.8230 -
92.8231 - return false;
92.8232 - }
92.8233 -
92.8234 - /**
92.8235 - * Method that will check if blocks
92.8236 - * @param current
92.8237 - * @param ts
92.8238 - * @param parentBlocks
92.8239 - * @return
92.8240 - */
92.8241 - private List<PlsqlBlock> checkIfBlock(Token<PlsqlTokenId> current, TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> parentBlocks) {
92.8242 - Token<PlsqlTokenId> ifBegin = null;
92.8243 - Token<PlsqlTokenId> token = null;
92.8244 - int preOffset = -1;
92.8245 - List<PlsqlBlock> ifBlocks = new ArrayList<PlsqlBlock>();
92.8246 - List<PlsqlBlock> lstChild = new ArrayList<PlsqlBlock>();
92.8247 - boolean moveNext = false;
92.8248 -
92.8249 - //Check whether the beginning is in a SQL Plus command
92.8250 - if (sqlPlusLine(ts)) {
92.8251 - return null;
92.8252 - }
92.8253 -
92.8254 - moveNext = ts.moveNext();
92.8255 - token = ts.token();
92.8256 - ifBegin = current;
92.8257 - String name = ifBegin.text().toString() + " ";
92.8258 - boolean isThen = false;
92.8259 - Token<PlsqlTokenId> customStartToken = null;
92.8260 - //If this is an else check we need to ignore then
92.8261 - if (name.trim().equalsIgnoreCase("ELSE")) {
92.8262 - isThen = true;
92.8263 - }
92.8264 - while (moveNext) {
92.8265 - String image = token.text().toString();
92.8266 - PlsqlTokenId tokenID = token.id();
92.8267 -
92.8268 - if ((token != null) && (!image.equals(";")) && (token.offset(tokenHierarchy) > endParse)) {
92.8269 - break;
92.8270 - }
92.8271 -
92.8272 - if (image.equalsIgnoreCase("ELSE")) {
92.8273 - if (isThen) {
92.8274 - PlsqlBlock block = new PlsqlBlock(ifBegin.offset(tokenHierarchy), preOffset, name.trim(), "", PlsqlBlockType.IF);
92.8275 - if (block != null) {
92.8276 - //add children
92.8277 - addChildren(block, lstChild, parentBlocks);
92.8278 - ifBlocks.add(block);
92.8279 - lstChild.clear();
92.8280 - }
92.8281 -
92.8282 - name = "ELSE";
92.8283 - ifBegin = token;
92.8284 - } else {
92.8285 - break;
92.8286 - }
92.8287 - } else if (image.equalsIgnoreCase("ELSIF")) {
92.8288 - if (isThen) {
92.8289 - PlsqlBlock block = new PlsqlBlock(ifBegin.offset(tokenHierarchy), preOffset, name.trim(), "", PlsqlBlockType.IF);
92.8290 - if (block != null) {
92.8291 - //add children
92.8292 - addChildren(block, lstChild, parentBlocks);
92.8293 - ifBlocks.add(block);
92.8294 - lstChild.clear();
92.8295 - }
92.8296 - //reset everything for ELSE IF
92.8297 - name = "ELSIF";
92.8298 - isThen = false;
92.8299 - ifBegin = token;
92.8300 - } else {
92.8301 - break;
92.8302 - }
92.8303 - } else if (image.equalsIgnoreCase("END")) {
92.8304 - if (isThen) {
92.8305 - boolean next = getNextNonWhitespace(ts, true);
92.8306 - Token<PlsqlTokenId> nextTok = ts.token();
92.8307 - if (next && nextTok.text().toString().equalsIgnoreCase("IF")) {
92.8308 - next = getNextNonWhitespace(ts, true);
92.8309 - nextTok = ts.token();
92.8310 - if (next && nextTok.text().toString().equalsIgnoreCase(";")) {
92.8311 - ts.moveNext();
92.8312 - PlsqlBlock block = new PlsqlBlock(ifBegin.offset(tokenHierarchy), ts.offset(), name.trim(), "", PlsqlBlockType.IF);
92.8313 - if (block != null) {
92.8314 + if (image.equalsIgnoreCase("ELSE")) {
92.8315 + if (isThen) {
92.8316 + PlsqlBlock block = new PlsqlBlock(ifBegin.offset(tokenHierarchy), preOffset, name.trim(), "", PlsqlBlockType.IF);
92.8317 + if (block != null) {
92.8318 //add children
92.8319 addChildren(block, lstChild, parentBlocks);
92.8320 ifBlocks.add(block);
92.8321 lstChild.clear();
92.8322 + }
92.8323 +
92.8324 + name = "ELSE";
92.8325 + ifBegin = token;
92.8326 + } else {
92.8327 + break;
92.8328 + }
92.8329 + } else if (image.equalsIgnoreCase("ELSIF")) {
92.8330 + if (isThen) {
92.8331 + PlsqlBlock block = new PlsqlBlock(ifBegin.offset(tokenHierarchy), preOffset, name.trim(), "", PlsqlBlockType.IF);
92.8332 + if (block != null) {
92.8333 + //add children
92.8334 + addChildren(block, lstChild, parentBlocks);
92.8335 + ifBlocks.add(block);
92.8336 + lstChild.clear();
92.8337 + }
92.8338 + //reset everything for ELSE IF
92.8339 + name = "ELSIF";
92.8340 + isThen = false;
92.8341 + ifBegin = token;
92.8342 + } else {
92.8343 + break;
92.8344 + }
92.8345 + } else if (image.equalsIgnoreCase("END")) {
92.8346 + if (isThen) {
92.8347 + boolean next = getNextNonWhitespace(ts, true);
92.8348 + Token<PlsqlTokenId> nextTok = ts.token();
92.8349 + if (next && nextTok.text().toString().equalsIgnoreCase("IF")) {
92.8350 + next = getNextNonWhitespace(ts, true);
92.8351 + nextTok = ts.token();
92.8352 + if (next && nextTok.text().toString().equalsIgnoreCase(";")) {
92.8353 + ts.moveNext();
92.8354 + PlsqlBlock block = new PlsqlBlock(ifBegin.offset(tokenHierarchy), ts.offset(), name.trim(), "", PlsqlBlockType.IF);
92.8355 + if (block != null) {
92.8356 + //add children
92.8357 + addChildren(block, lstChild, parentBlocks);
92.8358 + ifBlocks.add(block);
92.8359 + lstChild.clear();
92.8360 + break;
92.8361 + }
92.8362 + } else {
92.8363 + break;
92.8364 + }
92.8365 + }
92.8366 + } else {
92.8367 + break;
92.8368 + }
92.8369 + } else if (image.equalsIgnoreCase("THEN")) {
92.8370 + isThen = true;
92.8371 + } else if (image.equalsIgnoreCase("IF")) {
92.8372 + int beforeOff = token.offset(tokenHierarchy);
92.8373 + List children = checkIfBlock(token, ts, lstChild);
92.8374 + if (children == null || children.isEmpty()) {//If inner check seems to have failed need to continue this one
92.8375 +
92.8376 + ts.move(beforeOff);
92.8377 + moveNext = ts.moveNext();
92.8378 + } else {
92.8379 + for (int i = 0; i < children.size(); i++) {
92.8380 + PlsqlBlock child = (PlsqlBlock) children.get(i);
92.8381 + if (checkExisting(child, lstChild) == false) {
92.8382 + lstChild.add(child);
92.8383 + }
92.8384 + }
92.8385 + }
92.8386 + } else if (image.equalsIgnoreCase("CASE")) {
92.8387 + int beforeOff = token.offset(tokenHierarchy);
92.8388 + List children = checkCaseBlock(token, ts, lstChild, false);
92.8389 + if (children == null || children.isEmpty()) {//If inner check seems to have failed need to continue this one
92.8390 +
92.8391 + ts.move(beforeOff);
92.8392 + moveNext = ts.moveNext();
92.8393 + } else {
92.8394 + for (int i = 0; i < children.size(); i++) {
92.8395 + PlsqlBlock child = (PlsqlBlock) children.get(i);
92.8396 + if (checkExisting(child, lstChild) == false) {
92.8397 + lstChild.add(child);
92.8398 + }
92.8399 + }
92.8400 + }
92.8401 + } else if (tokenID == PlsqlTokenId.KEYWORD && image.equalsIgnoreCase("DECLARE")) {
92.8402 + PlsqlBlock child = checkDeclareBlock(token, ts, lstChild);
92.8403 + if (child != null) {//If inner check seems to have failed need to continue this one
92.8404 + if (checkExisting(child, lstChild) == false) {
92.8405 + lstChild.add(child);
92.8406 + }
92.8407 + }
92.8408 + } else if (tokenID == PlsqlTokenId.KEYWORD && (image.equalsIgnoreCase("BEGIN"))) {
92.8409 + int beforeOff = token.offset(tokenHierarchy);
92.8410 + PlsqlBlock child = checkBeginBlock(token, ts, lstChild);
92.8411 + if (child == null) {//If inner check seems to have failed need to continue this one
92.8412 +
92.8413 + ts.move(beforeOff);
92.8414 + moveNext = ts.moveNext();
92.8415 + } else {
92.8416 + if (checkExisting(child, lstChild) == false) {
92.8417 + lstChild.add(child);
92.8418 + }
92.8419 + }
92.8420 + } else if (image.equalsIgnoreCase("WHILE")
92.8421 + || image.equalsIgnoreCase("FOR")
92.8422 + || image.equalsIgnoreCase("LOOP")) {
92.8423 + int beforeOff = token.offset(tokenHierarchy);
92.8424 + if (!unsuccessBlocks.contains(beforeOff)) {
92.8425 + PlsqlBlock child = checkLoopBlock(token, ts, lstChild);
92.8426 + if (child == null) {//If inner check seems to have failed need to continue this one
92.8427 + unsuccessBlocks.add(beforeOff);
92.8428 + ts.move(beforeOff);
92.8429 + moveNext = ts.moveNext();
92.8430 + } else {
92.8431 + if (checkExisting(child, lstChild) == false) {
92.8432 + lstChild.add(child);
92.8433 + }
92.8434 + }
92.8435 + }
92.8436 + } else if (image.equalsIgnoreCase("TABLE")
92.8437 + || image.equalsIgnoreCase("INDEX")
92.8438 + || image.equalsIgnoreCase("SELECT")
92.8439 + || image.equalsIgnoreCase("UPDATE")
92.8440 + || image.equalsIgnoreCase("DELETE")
92.8441 + || image.equalsIgnoreCase("INSERT")
92.8442 + || image.equalsIgnoreCase("MERGE")
92.8443 + || image.equalsIgnoreCase("DROP")
92.8444 + || image.equalsIgnoreCase("SEQUENCE")) {
92.8445 + if (!isNotBlockStart(token, ts)) {
92.8446 + int offset = token.offset(tokenHierarchy);
92.8447 + PlsqlBlock child = checkStatementBlock(token, ts, parentBlocks);
92.8448 + if (child == null) {//If inner check seems to have failed need to continue this one
92.8449 +
92.8450 + ts.move(offset);
92.8451 + ts.moveNext();
92.8452 + } else {
92.8453 + if (checkExisting(child, lstChild) == false) {
92.8454 + lstChild.add(child);
92.8455 + }
92.8456 + }
92.8457 + }
92.8458 + } else if (image.equalsIgnoreCase("PROCEDURE")
92.8459 + || image.equalsIgnoreCase("FUNCTION")
92.8460 + || image.equalsIgnoreCase("CREATE")) {
92.8461 + break;
92.8462 + } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.8463 + //only single comment line
92.8464 + if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.8465 + customStartToken = token;
92.8466 + } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.8467 + if (customStartToken != null) {
92.8468 + String fname = customStartToken.text().toString();
92.8469 + int index = fname.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.8470 + fname = fname.substring(index + 7).trim();
92.8471 + if (ts.moveNext()) {
92.8472 + token = ts.token();
92.8473 + PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.8474 + token.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.8475 + customFoldBlocks.add(custom);
92.8476 + }
92.8477 + customStartToken = null;
92.8478 + }
92.8479 + } else {
92.8480 + PlsqlBlock child = checkComment(token, ts);
92.8481 + if (child != null) {
92.8482 + if (checkExisting(child, lstChild) == false) {
92.8483 + lstChild.add(child);
92.8484 + }
92.8485 + }
92.8486 + }
92.8487 + } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.8488 + int start = token.offset(tokenHierarchy);
92.8489 + PlsqlBlock child = new PlsqlBlock(start,
92.8490 + start + token.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.8491 + if (child != null) {
92.8492 + if (checkExisting(child, lstChild) == false) {
92.8493 + lstChild.add(child);
92.8494 + }
92.8495 + }
92.8496 + } else if (!isThen) {
92.8497 + name = name + image;
92.8498 + }
92.8499 +
92.8500 + preOffset = ts.offset();
92.8501 + moveNext = ts.moveNext();
92.8502 + token = ts.token();
92.8503 + }
92.8504 +
92.8505 + return ifBlocks;
92.8506 + }
92.8507 +
92.8508 + /**
92.8509 + * Method that will check case blocks
92.8510 + * @param current
92.8511 + * @param ts
92.8512 + * @param parentBlocks
92.8513 + * @return
92.8514 + */
92.8515 + private List<PlsqlBlock> checkCaseBlock(Token<PlsqlTokenId> current, TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> parentBlocks, boolean isStatement) {
92.8516 + Token<PlsqlTokenId> caseBegin = null;
92.8517 + Token<PlsqlTokenId> token = null;
92.8518 + int preOffset = -1;
92.8519 + List<PlsqlBlock> caseBlocks = new ArrayList<PlsqlBlock>();
92.8520 + List<PlsqlBlock> lstChild = new ArrayList<PlsqlBlock>();
92.8521 + boolean moveNext = false;
92.8522 +
92.8523 + //Check whether the beginning is in a SQL Plus command
92.8524 + if (!isStatement && sqlPlusLine(ts)) {
92.8525 + return null;
92.8526 + }
92.8527 +
92.8528 + moveNext = ts.moveNext();
92.8529 + token = ts.token();
92.8530 + caseBegin = current;
92.8531 + String name = caseBegin.text().toString() + " ";
92.8532 + boolean isThen = false;
92.8533 + Token<PlsqlTokenId> customStartToken = null;
92.8534 + //If this is an else check we need to ignore then
92.8535 + if (name.trim().equalsIgnoreCase("ELSE")) {
92.8536 + isThen = true;
92.8537 + }
92.8538 +
92.8539 + while (moveNext) {
92.8540 + String image = token.text().toString();
92.8541 + PlsqlTokenId tokenID = token.id();
92.8542 +
92.8543 + if ((token != null) && (!image.equals(";")) && (token.offset(tokenHierarchy) > endParse)) {
92.8544 + break;
92.8545 + }
92.8546 +
92.8547 + if (image.equalsIgnoreCase("ELSE")) {
92.8548 + if (isThen) {
92.8549 + PlsqlBlock block = new PlsqlBlock(caseBegin.offset(tokenHierarchy), preOffset, name.trim(), "", PlsqlBlockType.CASE);
92.8550 + if (block != null) {
92.8551 + //add children
92.8552 + addChildren(block, lstChild, parentBlocks);
92.8553 + caseBlocks.add(block);
92.8554 + lstChild.clear();
92.8555 + }
92.8556 +
92.8557 + name = "ELSE";
92.8558 + caseBegin = token;
92.8559 + } else {
92.8560 + break;
92.8561 + }
92.8562 + } else if (image.equalsIgnoreCase("WHEN")) {
92.8563 + if (isThen) {
92.8564 + PlsqlBlock block = new PlsqlBlock(caseBegin.offset(tokenHierarchy), preOffset, name.trim(), "", PlsqlBlockType.CASE);
92.8565 + if (block != null) {
92.8566 + //add children
92.8567 + addChildren(block, lstChild, parentBlocks);
92.8568 + caseBlocks.add(block);
92.8569 + lstChild.clear();
92.8570 + }
92.8571 + //reset everything for ELSE IF
92.8572 + name = "WHEN";
92.8573 + isThen = false;
92.8574 + caseBegin = token;
92.8575 + } else if (name.trim().startsWith("CASE")) { //first WHEN
92.8576 + name = name + image;
92.8577 + } else {
92.8578 + break;
92.8579 + }
92.8580 + } else if (image.equalsIgnoreCase("END")) {
92.8581 + if (isThen) {
92.8582 + boolean next = false;
92.8583 + Token<PlsqlTokenId> nextTok = token;
92.8584 + int offset = ts.offset();
92.8585 +
92.8586 + next = getNextNonWhitespace(ts, true);
92.8587 + nextTok = ts.token();
92.8588 + if (next && nextTok.text().toString().equalsIgnoreCase("CASE")) {
92.8589 + next = getNextNonWhitespace(ts, true);
92.8590 + nextTok = ts.token();
92.8591 + }
92.8592 + if (!(!isStatement && next && nextTok.text().toString().equalsIgnoreCase(";"))) {
92.8593 + ts.move(offset);
92.8594 + ts.moveNext();
92.8595 + }
92.8596 +
92.8597 + ts.moveNext();
92.8598 + PlsqlBlock block = new PlsqlBlock(caseBegin.offset(tokenHierarchy), ts.offset(), name.trim(), "", PlsqlBlockType.CASE);
92.8599 + if (block != null) {
92.8600 + //add children
92.8601 + addChildren(block, lstChild, parentBlocks);
92.8602 + caseBlocks.add(block);
92.8603 + lstChild.clear();
92.8604 + if (isStatement && ts.token().toString().equals(";")) {
92.8605 + ts.movePrevious();
92.8606 + }
92.8607 break;
92.8608 - }
92.8609 - } else {
92.8610 - break;
92.8611 - }
92.8612 - }
92.8613 - } else {
92.8614 - break;
92.8615 + }
92.8616 + } else {
92.8617 + break;
92.8618 + }
92.8619 + } else if (image.equalsIgnoreCase("THEN")) {
92.8620 + isThen = true;
92.8621 + } else if (image.equalsIgnoreCase("IF")) {
92.8622 + int beforeOff = token.offset(tokenHierarchy);
92.8623 + List children = checkIfBlock(token, ts, lstChild);
92.8624 + if (children == null || children.isEmpty()) {//If inner check seems to have failed need to continue this one
92.8625 +
92.8626 + ts.move(beforeOff);
92.8627 + moveNext = ts.moveNext();
92.8628 + } else {
92.8629 + for (int i = 0; i < children.size(); i++) {
92.8630 + PlsqlBlock child = (PlsqlBlock) children.get(i);
92.8631 + if (checkExisting(child, lstChild) == false) {
92.8632 + lstChild.add(child);
92.8633 + }
92.8634 + }
92.8635 + }
92.8636 + } else if (image.equalsIgnoreCase("CASE")) {
92.8637 + int beforeOff = token.offset(tokenHierarchy);
92.8638 + List children = checkCaseBlock(token, ts, lstChild, isStatement);
92.8639 + if (children == null || children.isEmpty()) {//If inner check seems to have failed need to continue this one
92.8640 +
92.8641 + ts.move(beforeOff);
92.8642 + moveNext = ts.moveNext();
92.8643 + } else {
92.8644 + for (int i = 0; i < children.size(); i++) {
92.8645 + PlsqlBlock child = (PlsqlBlock) children.get(i);
92.8646 + if (checkExisting(child, lstChild) == false) {
92.8647 + lstChild.add(child);
92.8648 + }
92.8649 + }
92.8650 + }
92.8651 + } else if (image.equalsIgnoreCase("WHILE")
92.8652 + || image.equalsIgnoreCase("FOR")
92.8653 + || image.equalsIgnoreCase("LOOP")) {
92.8654 + int beforeOff = token.offset(tokenHierarchy);
92.8655 + if (!unsuccessBlocks.contains(beforeOff)) {
92.8656 + PlsqlBlock child = checkLoopBlock(token, ts, lstChild);
92.8657 + if (child == null) {//If inner check seems to have failed need to continue this one
92.8658 + unsuccessBlocks.add(beforeOff);
92.8659 + ts.move(beforeOff);
92.8660 + moveNext = ts.moveNext();
92.8661 + } else {
92.8662 + if (checkExisting(child, lstChild) == false) {
92.8663 + lstChild.add(child);
92.8664 + }
92.8665 + }
92.8666 + }
92.8667 + } else if (tokenID == PlsqlTokenId.KEYWORD && (image.equalsIgnoreCase("BEGIN"))) {
92.8668 + int beforeOff = token.offset(tokenHierarchy);
92.8669 + PlsqlBlock child = checkBeginBlock(token, ts, lstChild);
92.8670 + if (child == null) {//If inner check seems to have failed need to continue this one
92.8671 +
92.8672 + ts.move(beforeOff);
92.8673 + moveNext = ts.moveNext();
92.8674 + } else {
92.8675 + if (checkExisting(child, lstChild) == false) {
92.8676 + lstChild.add(child);
92.8677 + }
92.8678 + }
92.8679 + } else if (image.equalsIgnoreCase("TABLE")
92.8680 + || image.equalsIgnoreCase("INDEX")
92.8681 + || image.equalsIgnoreCase("SELECT")
92.8682 + || image.equalsIgnoreCase("UPDATE")
92.8683 + || image.equalsIgnoreCase("DELETE")
92.8684 + || image.equalsIgnoreCase("INSERT")
92.8685 + || image.equalsIgnoreCase("MERGE")
92.8686 + || image.equalsIgnoreCase("DROP")
92.8687 + || image.equalsIgnoreCase("SEQUENCE")) {
92.8688 + if (!isNotBlockStart(token, ts)) {
92.8689 + int offset = token.offset(tokenHierarchy);
92.8690 + PlsqlBlock child = checkStatementBlock(token, ts, parentBlocks);
92.8691 + if (child == null) {//If inner check seems to have failed need to continue this one
92.8692 +
92.8693 + ts.move(offset);
92.8694 + ts.moveNext();
92.8695 + } else {
92.8696 + if (checkExisting(child, lstChild) == false) {
92.8697 + lstChild.add(child);
92.8698 + }
92.8699 + }
92.8700 + }
92.8701 + } else if (image.equalsIgnoreCase("PROCEDURE")
92.8702 + || image.equalsIgnoreCase("FUNCTION")
92.8703 + || image.equalsIgnoreCase("CREATE")) {
92.8704 + break;
92.8705 + } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.8706 + //only single comment line
92.8707 + if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.8708 + customStartToken = token;
92.8709 + } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.8710 + if (customStartToken != null) {
92.8711 + String fname = customStartToken.text().toString();
92.8712 + int index = fname.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.8713 + fname = fname.substring(index + 7).trim();
92.8714 + if (ts.moveNext()) {
92.8715 + token = ts.token();
92.8716 + PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.8717 + token.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.8718 + customFoldBlocks.add(custom);
92.8719 + }
92.8720 + customStartToken = null;
92.8721 + }
92.8722 + } else {
92.8723 + PlsqlBlock child = checkComment(token, ts);
92.8724 + if (child != null) {
92.8725 + if (checkExisting(child, lstChild) == false) {
92.8726 + lstChild.add(child);
92.8727 + }
92.8728 + }
92.8729 + }
92.8730 + } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.8731 + int start = token.offset(tokenHierarchy);
92.8732 + PlsqlBlock child = new PlsqlBlock(start,
92.8733 + start + token.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.8734 + if (child != null) {
92.8735 + if (checkExisting(child, lstChild) == false) {
92.8736 + lstChild.add(child);
92.8737 + }
92.8738 + }
92.8739 + } else if (!isThen) {
92.8740 + name = name + image;
92.8741 }
92.8742 - } else if (image.equalsIgnoreCase("THEN")) {
92.8743 - isThen = true;
92.8744 - } else if (image.equalsIgnoreCase("IF")) {
92.8745 - int beforeOff = token.offset(tokenHierarchy);
92.8746 - List children = checkIfBlock(token, ts, lstChild);
92.8747 - if (children == null || children.size() == 0) {//If inner check seems to have failed need to continue this one
92.8748 -
92.8749 - ts.move(beforeOff);
92.8750 - moveNext = ts.moveNext();
92.8751 - } else {
92.8752 - for (int i = 0; i < children.size(); i++) {
92.8753 - PlsqlBlock child = (PlsqlBlock) children.get(i);
92.8754 - if (checkExisting(child, lstChild) == false) {
92.8755 - lstChild.add(child);
92.8756 - }
92.8757 - }
92.8758 +
92.8759 + preOffset = ts.offset();
92.8760 + moveNext = ts.moveNext();
92.8761 + token = ts.token();
92.8762 + }
92.8763 +
92.8764 + return caseBlocks;
92.8765 + }
92.8766 +
92.8767 + /**
92.8768 + * Method that will return the prefix of the given block
92.8769 + * @param startOffset
92.8770 + * @param ts
92.8771 + * @return
92.8772 + */
92.8773 + private String getPreceedingText(int startOffset, TokenSequence<PlsqlTokenId> ts) {
92.8774 + String prefix = "";
92.8775 + int offset = ts.offset();
92.8776 + ts.move(startOffset);
92.8777 + ts.moveNext();
92.8778 + Token<PlsqlTokenId> token = ts.token();
92.8779 +
92.8780 + while (ts.movePrevious()) {
92.8781 + token = ts.token();
92.8782 + String image = token.text().toString();
92.8783 +
92.8784 + if (image.contains("\n")) {
92.8785 + break;
92.8786 }
92.8787 - } else if (image.equalsIgnoreCase("CASE")) {
92.8788 - int beforeOff = token.offset(tokenHierarchy);
92.8789 - List children = checkCaseBlock(token, ts, lstChild, false);
92.8790 - if (children == null || children.size() == 0) {//If inner check seems to have failed need to continue this one
92.8791 -
92.8792 - ts.move(beforeOff);
92.8793 - moveNext = ts.moveNext();
92.8794 - } else {
92.8795 - for (int i = 0; i < children.size(); i++) {
92.8796 - PlsqlBlock child = (PlsqlBlock) children.get(i);
92.8797 - if (checkExisting(child, lstChild) == false) {
92.8798 - lstChild.add(child);
92.8799 - }
92.8800 - }
92.8801 +
92.8802 + prefix = token.text().toString() + prefix;
92.8803 + }
92.8804 +
92.8805 + ts.move(offset);
92.8806 + ts.moveNext();
92.8807 + return prefix;
92.8808 + }
92.8809 +
92.8810 + /**
92.8811 + * Method that will check loop blocks
92.8812 + * @param current
92.8813 + * @param ts
92.8814 + * @param parentBlocks
92.8815 + * @return
92.8816 + */
92.8817 + private PlsqlBlock checkLoopBlock(Token<PlsqlTokenId> current, TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> parentBlocks) {
92.8818 + Token<PlsqlTokenId> loopBegin = null;
92.8819 + Token<PlsqlTokenId> token = null;
92.8820 + List<PlsqlBlock> lstChild = new ArrayList<PlsqlBlock>();
92.8821 + PlsqlBlock block = null;
92.8822 + boolean moveNext = false;
92.8823 +
92.8824 + //Check whether the beginning is in a SQL Plus command
92.8825 + if (sqlPlusLine(ts)) {
92.8826 + return null;
92.8827 + }
92.8828 +
92.8829 + moveNext = ts.moveNext();
92.8830 + token = ts.token();
92.8831 + loopBegin = current;
92.8832 + boolean isLoop = false;
92.8833 + Token<PlsqlTokenId> customStartToken = null;
92.8834 + PlsqlBlockType type = PlsqlBlockType.LOOP;
92.8835 + String name = "";
92.8836 + if (loopBegin.text().toString().equalsIgnoreCase("LOOP")) {
92.8837 + isLoop = true;
92.8838 + } else if (loopBegin.text().toString().equalsIgnoreCase("WHILE")) {
92.8839 + type = PlsqlBlockType.WHILE_LOOP;
92.8840 + } else if (loopBegin.text().toString().equalsIgnoreCase("FOR")) {
92.8841 + type = PlsqlBlockType.FOR_LOOP;
92.8842 + }
92.8843 +
92.8844 + while (moveNext) {
92.8845 + String image = token.text().toString();
92.8846 + PlsqlTokenId tokenID = token.id();
92.8847 +
92.8848 + if ((token != null) && (!image.equals(";")) && (token.offset(tokenHierarchy) > endParse)) {
92.8849 + break;
92.8850 }
92.8851 - } else if (tokenID == PlsqlTokenId.KEYWORD && image.equalsIgnoreCase("DECLARE")) {
92.8852 - PlsqlBlock child = checkDeclareBlock(token, ts, lstChild);
92.8853 - if (child != null) {//If inner check seems to have failed need to continue this one
92.8854 - if (checkExisting(child, lstChild) == false) {
92.8855 - lstChild.add(child);
92.8856 - }
92.8857 +
92.8858 + if (!isLoop && image.equalsIgnoreCase("LOOP")) {
92.8859 + isLoop = true;
92.8860 + } else if (image.equalsIgnoreCase("END")) {
92.8861 + if (isLoop) {
92.8862 + boolean next = getNextNonWhitespace(ts, true);
92.8863 + Token<PlsqlTokenId> nextTok = ts.token();
92.8864 + if (next && nextTok.text().toString().equalsIgnoreCase("LOOP")) {
92.8865 + next = getNextNonWhitespace(ts, true);
92.8866 + nextTok = ts.token();
92.8867 + if (next && nextTok.text().toString().equalsIgnoreCase(";")) {
92.8868 + ts.moveNext();
92.8869 + block = new PlsqlBlock(loopBegin.offset(tokenHierarchy), ts.offset(), name.trim(), "", type);
92.8870 + break;
92.8871 + } else {
92.8872 + break;
92.8873 + }
92.8874 + }
92.8875 + } else {
92.8876 + break;
92.8877 + }
92.8878 + } else if (image.equalsIgnoreCase("IF")) {
92.8879 + int beforeOff = token.offset(tokenHierarchy);
92.8880 + List<PlsqlBlock> children = checkIfBlock(token, ts, lstChild);
92.8881 + if (children == null || children.isEmpty()) {//If inner check seems to have failed need to continue this one
92.8882 +
92.8883 + ts.move(beforeOff);
92.8884 + moveNext = ts.moveNext();
92.8885 + } else {
92.8886 + for (int i = 0; i < children.size(); i++) {
92.8887 + PlsqlBlock child = children.get(i);
92.8888 + if (checkExisting(child, lstChild) == false) {
92.8889 + lstChild.add(child);
92.8890 + }
92.8891 + }
92.8892 + }
92.8893 + } else if (image.equalsIgnoreCase("CASE")) {
92.8894 + int beforeOff = token.offset(tokenHierarchy);
92.8895 + List<PlsqlBlock> children = checkCaseBlock(token, ts, lstChild, false);
92.8896 + if (children == null || children.isEmpty()) {//If inner check seems to have failed need to continue this one
92.8897 +
92.8898 + ts.move(beforeOff);
92.8899 + moveNext = ts.moveNext();
92.8900 + } else {
92.8901 + for (int i = 0; i < children.size(); i++) {
92.8902 + PlsqlBlock child = children.get(i);
92.8903 + if (checkExisting(child, lstChild) == false) {
92.8904 + lstChild.add(child);
92.8905 + }
92.8906 + }
92.8907 + }
92.8908 + } else if (image.equalsIgnoreCase("LOOP")
92.8909 + || image.equalsIgnoreCase("WHILE")
92.8910 + || image.equalsIgnoreCase("FOR")) {
92.8911 + int beforeOff = token.offset(tokenHierarchy);
92.8912 + if (!unsuccessBlocks.contains(beforeOff)) {
92.8913 + PlsqlBlock child = checkLoopBlock(token, ts, lstChild);
92.8914 + if (child == null) {//If inner check seems to have failed need to continue this one
92.8915 + unsuccessBlocks.add(beforeOff);
92.8916 + ts.move(beforeOff);
92.8917 + moveNext = ts.moveNext();
92.8918 + } else {
92.8919 + if (checkExisting(child, lstChild) == false) {
92.8920 + lstChild.add(child);
92.8921 + }
92.8922 + }
92.8923 + }
92.8924 + } else if (image.equalsIgnoreCase("TABLE")
92.8925 + || image.equalsIgnoreCase("INDEX")
92.8926 + || image.equalsIgnoreCase("SELECT")
92.8927 + || image.equalsIgnoreCase("UPDATE")
92.8928 + || image.equalsIgnoreCase("DELETE")
92.8929 + || image.equalsIgnoreCase("INSERT")
92.8930 + || image.equalsIgnoreCase("MERGE")
92.8931 + || image.equalsIgnoreCase("DROP")
92.8932 + || image.equalsIgnoreCase("SEQUENCE")) {
92.8933 + if (!isNotBlockStart(token, ts)) {
92.8934 + int offset = token.offset(tokenHierarchy);
92.8935 + PlsqlBlock child = checkStatementBlock(token, ts, parentBlocks);
92.8936 + if (child == null) {//If inner check seems to have failed need to continue this one
92.8937 +
92.8938 + ts.move(offset);
92.8939 + ts.moveNext();
92.8940 + } else {
92.8941 + if (checkExisting(child, lstChild) == false) {
92.8942 + lstChild.add(child);
92.8943 + }
92.8944 + }
92.8945 + }
92.8946 + } else if (image.equalsIgnoreCase("PROCEDURE")
92.8947 + || image.equalsIgnoreCase("FUNCTION")
92.8948 + || image.equalsIgnoreCase("CREATE")) {
92.8949 + break;
92.8950 + } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.8951 + //only single comment line
92.8952 + if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.8953 + customStartToken = token;
92.8954 + } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.8955 + if (customStartToken != null) {
92.8956 + String fname = customStartToken.text().toString();
92.8957 + int index = fname.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.8958 + fname = fname.substring(index + 7).trim();
92.8959 + if (ts.moveNext()) {
92.8960 + token = ts.token();
92.8961 + PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.8962 + token.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.8963 + customFoldBlocks.add(custom);
92.8964 + }
92.8965 +
92.8966 + customStartToken = null;
92.8967 + }
92.8968 + } else {
92.8969 + PlsqlBlock child = checkComment(token, ts);
92.8970 + if (child != null) {
92.8971 + if (checkExisting(child, lstChild) == false) {
92.8972 + lstChild.add(child);
92.8973 + }
92.8974 + }
92.8975 + }
92.8976 + } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.8977 + int start = token.offset(tokenHierarchy);
92.8978 + PlsqlBlock child = new PlsqlBlock(start,
92.8979 + start + token.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.8980 + if (child != null) {
92.8981 + if (checkExisting(child, lstChild) == false) {
92.8982 + lstChild.add(child);
92.8983 + }
92.8984 + }
92.8985 + } else if (!isLoop) {
92.8986 + name = name + image;
92.8987 }
92.8988 - } else if (tokenID == PlsqlTokenId.KEYWORD && (image.equalsIgnoreCase("BEGIN"))) {
92.8989 - int beforeOff = token.offset(tokenHierarchy);
92.8990 - PlsqlBlock child = checkBeginBlock(token, ts, lstChild);
92.8991 - if (child == null) {//If inner check seems to have failed need to continue this one
92.8992 -
92.8993 - ts.move(beforeOff);
92.8994 - moveNext = ts.moveNext();
92.8995 - } else {
92.8996 - if (checkExisting(child, lstChild) == false) {
92.8997 - lstChild.add(child);
92.8998 - }
92.8999 - }
92.9000 - } else if (image.equalsIgnoreCase("WHILE")
92.9001 - || image.equalsIgnoreCase("FOR")
92.9002 - || image.equalsIgnoreCase("LOOP")) {
92.9003 - int beforeOff = token.offset(tokenHierarchy);
92.9004 - if (!unsuccessBlocks.contains(beforeOff)) {
92.9005 - PlsqlBlock child = checkLoopBlock(token, ts, lstChild);
92.9006 - if (child == null) {//If inner check seems to have failed need to continue this one
92.9007 - unsuccessBlocks.add(beforeOff);
92.9008 - ts.move(beforeOff);
92.9009 - moveNext = ts.moveNext();
92.9010 - } else {
92.9011 - if (checkExisting(child, lstChild) == false) {
92.9012 - lstChild.add(child);
92.9013 - }
92.9014 - }
92.9015 - }
92.9016 - } else if (image.equalsIgnoreCase("TABLE")
92.9017 - || image.equalsIgnoreCase("INDEX")
92.9018 - || image.equalsIgnoreCase("SELECT")
92.9019 - || image.equalsIgnoreCase("UPDATE")
92.9020 - || image.equalsIgnoreCase("DELETE")
92.9021 - || image.equalsIgnoreCase("INSERT")
92.9022 - || image.equalsIgnoreCase("MERGE")
92.9023 - || image.equalsIgnoreCase("DROP")
92.9024 - || image.equalsIgnoreCase("SEQUENCE")) {
92.9025 - if (!isNotBlockStart(token, ts)) {
92.9026 - int offset = token.offset(tokenHierarchy);
92.9027 - PlsqlBlock child = checkStatementBlock(token, ts, parentBlocks);
92.9028 - if (child == null) {//If inner check seems to have failed need to continue this one
92.9029 -
92.9030 - ts.move(offset);
92.9031 - ts.moveNext();
92.9032 - } else {
92.9033 - if (checkExisting(child, lstChild) == false) {
92.9034 - lstChild.add(child);
92.9035 - }
92.9036 - }
92.9037 - }
92.9038 - } else if (image.equalsIgnoreCase("PROCEDURE")
92.9039 - || image.equalsIgnoreCase("FUNCTION")
92.9040 - || image.equalsIgnoreCase("CREATE")) {
92.9041 - break;
92.9042 - } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.9043 - //only single comment line
92.9044 - if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.9045 - customStartToken = token;
92.9046 - } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.9047 - if (customStartToken != null) {
92.9048 - String fname = customStartToken.text().toString();
92.9049 - int index = fname.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.9050 - fname = fname.substring(index + 7).trim();
92.9051 - if (ts.moveNext()) {
92.9052 - token = ts.token();
92.9053 - PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.9054 - token.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.9055 - customFoldBlocks.add(custom);
92.9056 - }
92.9057 - customStartToken = null;
92.9058 - }
92.9059 - } else {
92.9060 - PlsqlBlock child = checkComment(token, ts);
92.9061 - if (child != null) {
92.9062 - if (checkExisting(child, lstChild) == false) {
92.9063 - lstChild.add(child);
92.9064 - }
92.9065 - }
92.9066 - }
92.9067 - } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.9068 - int start = token.offset(tokenHierarchy);
92.9069 - PlsqlBlock child = new PlsqlBlock(start,
92.9070 - start + token.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.9071 - if (child != null) {
92.9072 - if (checkExisting(child, lstChild) == false) {
92.9073 - lstChild.add(child);
92.9074 - }
92.9075 - }
92.9076 - } else if (!isThen) {
92.9077 - name = name + image;
92.9078 - }
92.9079 -
92.9080 - preOffset = ts.offset();
92.9081 - moveNext = ts.moveNext();
92.9082 - token = ts.token();
92.9083 - }
92.9084 -
92.9085 - return ifBlocks;
92.9086 - }
92.9087 -
92.9088 - /**
92.9089 - * Method that will check case blocks
92.9090 - * @param current
92.9091 - * @param ts
92.9092 - * @param parentBlocks
92.9093 - * @return
92.9094 - */
92.9095 - private List<PlsqlBlock> checkCaseBlock(Token<PlsqlTokenId> current, TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> parentBlocks, boolean isStatement) {
92.9096 - Token<PlsqlTokenId> caseBegin = null;
92.9097 - Token<PlsqlTokenId> token = null;
92.9098 - int preOffset = -1;
92.9099 - List<PlsqlBlock> caseBlocks = new ArrayList<PlsqlBlock>();
92.9100 - List<PlsqlBlock> lstChild = new ArrayList<PlsqlBlock>();
92.9101 - boolean moveNext = false;
92.9102 -
92.9103 - //Check whether the beginning is in a SQL Plus command
92.9104 - if (!isStatement && sqlPlusLine(ts)) {
92.9105 - return null;
92.9106 - }
92.9107 -
92.9108 - moveNext = ts.moveNext();
92.9109 - token = ts.token();
92.9110 - caseBegin = current;
92.9111 - String name = caseBegin.text().toString() + " ";
92.9112 - boolean isThen = false;
92.9113 - Token<PlsqlTokenId> customStartToken = null;
92.9114 - //If this is an else check we need to ignore then
92.9115 - if (name.trim().equalsIgnoreCase("ELSE")) {
92.9116 - isThen = true;
92.9117 - }
92.9118 -
92.9119 - while (moveNext) {
92.9120 - String image = token.text().toString();
92.9121 - PlsqlTokenId tokenID = token.id();
92.9122 -
92.9123 - if ((token != null) && (!image.equals(";")) && (token.offset(tokenHierarchy) > endParse)) {
92.9124 - break;
92.9125 - }
92.9126 -
92.9127 - if (image.equalsIgnoreCase("ELSE")) {
92.9128 - if (isThen) {
92.9129 - PlsqlBlock block = new PlsqlBlock(caseBegin.offset(tokenHierarchy), preOffset, name.trim(), "", PlsqlBlockType.CASE);
92.9130 - if (block != null) {
92.9131 - //add children
92.9132 - addChildren(block, lstChild, parentBlocks);
92.9133 - caseBlocks.add(block);
92.9134 - lstChild.clear();
92.9135 - }
92.9136 -
92.9137 - name = "ELSE";
92.9138 - caseBegin = token;
92.9139 - } else {
92.9140 - break;
92.9141 - }
92.9142 - } else if (image.equalsIgnoreCase("WHEN")) {
92.9143 - if (isThen) {
92.9144 - PlsqlBlock block = new PlsqlBlock(caseBegin.offset(tokenHierarchy), preOffset, name.trim(), "", PlsqlBlockType.CASE);
92.9145 - if (block != null) {
92.9146 - //add children
92.9147 - addChildren(block, lstChild, parentBlocks);
92.9148 - caseBlocks.add(block);
92.9149 - lstChild.clear();
92.9150 - }
92.9151 - //reset everything for ELSE IF
92.9152 - name = "WHEN";
92.9153 - isThen = false;
92.9154 - caseBegin = token;
92.9155 - } else if (name.trim().startsWith("CASE")) { //first WHEN
92.9156 - name = name + image;
92.9157 - } else {
92.9158 - break;
92.9159 - }
92.9160 - } else if (image.equalsIgnoreCase("END")) {
92.9161 - if (isThen) {
92.9162 - boolean next = false;
92.9163 - Token<PlsqlTokenId> nextTok = token;
92.9164 - int offset = ts.offset();
92.9165 -
92.9166 - next = getNextNonWhitespace(ts, true);
92.9167 - nextTok = ts.token();
92.9168 - if (next && nextTok.text().toString().equalsIgnoreCase("CASE")) {
92.9169 - next = getNextNonWhitespace(ts, true);
92.9170 - nextTok = ts.token();
92.9171 - }
92.9172 - if (!(!isStatement && next && nextTok.text().toString().equalsIgnoreCase(";"))) {
92.9173 - ts.move(offset);
92.9174 - ts.moveNext();
92.9175 - }
92.9176 -
92.9177 - ts.moveNext();
92.9178 - PlsqlBlock block = new PlsqlBlock(caseBegin.offset(tokenHierarchy), ts.offset(), name.trim(), "", PlsqlBlockType.CASE);
92.9179 - if (block != null) {
92.9180 - //add children
92.9181 - addChildren(block, lstChild, parentBlocks);
92.9182 - caseBlocks.add(block);
92.9183 - lstChild.clear();
92.9184 - if (isStatement && ts.token().toString().equals(";")) {
92.9185 - ts.movePrevious();
92.9186 - }
92.9187 - break;
92.9188 - }
92.9189 - } else {
92.9190 - break;
92.9191 - }
92.9192 - } else if (image.equalsIgnoreCase("THEN")) {
92.9193 - isThen = true;
92.9194 - } else if (image.equalsIgnoreCase("IF")) {
92.9195 - int beforeOff = token.offset(tokenHierarchy);
92.9196 - List children = checkIfBlock(token, ts, lstChild);
92.9197 - if (children == null || children.size() == 0) {//If inner check seems to have failed need to continue this one
92.9198 -
92.9199 - ts.move(beforeOff);
92.9200 - moveNext = ts.moveNext();
92.9201 - } else {
92.9202 - for (int i = 0; i < children.size(); i++) {
92.9203 - PlsqlBlock child = (PlsqlBlock) children.get(i);
92.9204 - if (checkExisting(child, lstChild) == false) {
92.9205 - lstChild.add(child);
92.9206 - }
92.9207 - }
92.9208 - }
92.9209 - } else if (image.equalsIgnoreCase("CASE")) {
92.9210 - int beforeOff = token.offset(tokenHierarchy);
92.9211 - List children = checkCaseBlock(token, ts, lstChild, isStatement);
92.9212 - if (children == null || children.size() == 0) {//If inner check seems to have failed need to continue this one
92.9213 -
92.9214 - ts.move(beforeOff);
92.9215 - moveNext = ts.moveNext();
92.9216 - } else {
92.9217 - for (int i = 0; i < children.size(); i++) {
92.9218 - PlsqlBlock child = (PlsqlBlock) children.get(i);
92.9219 - if (checkExisting(child, lstChild) == false) {
92.9220 - lstChild.add(child);
92.9221 - }
92.9222 - }
92.9223 - }
92.9224 - } else if (image.equalsIgnoreCase("WHILE")
92.9225 - || image.equalsIgnoreCase("FOR")
92.9226 - || image.equalsIgnoreCase("LOOP")) {
92.9227 - int beforeOff = token.offset(tokenHierarchy);
92.9228 - if (!unsuccessBlocks.contains(beforeOff)) {
92.9229 - PlsqlBlock child = checkLoopBlock(token, ts, lstChild);
92.9230 - if (child == null) {//If inner check seems to have failed need to continue this one
92.9231 - unsuccessBlocks.add(beforeOff);
92.9232 - ts.move(beforeOff);
92.9233 - moveNext = ts.moveNext();
92.9234 - } else {
92.9235 - if (checkExisting(child, lstChild) == false) {
92.9236 - lstChild.add(child);
92.9237 - }
92.9238 - }
92.9239 - }
92.9240 - } else if (tokenID == PlsqlTokenId.KEYWORD && (image.equalsIgnoreCase("BEGIN"))) {
92.9241 - int beforeOff = token.offset(tokenHierarchy);
92.9242 - PlsqlBlock child = checkBeginBlock(token, ts, lstChild);
92.9243 - if (child == null) {//If inner check seems to have failed need to continue this one
92.9244 -
92.9245 - ts.move(beforeOff);
92.9246 - moveNext = ts.moveNext();
92.9247 - } else {
92.9248 - if (checkExisting(child, lstChild) == false) {
92.9249 - lstChild.add(child);
92.9250 - }
92.9251 - }
92.9252 - } else if (image.equalsIgnoreCase("TABLE")
92.9253 - || image.equalsIgnoreCase("INDEX")
92.9254 - || image.equalsIgnoreCase("SELECT")
92.9255 - || image.equalsIgnoreCase("UPDATE")
92.9256 - || image.equalsIgnoreCase("DELETE")
92.9257 - || image.equalsIgnoreCase("INSERT")
92.9258 - || image.equalsIgnoreCase("MERGE")
92.9259 - || image.equalsIgnoreCase("DROP")
92.9260 - || image.equalsIgnoreCase("SEQUENCE")) {
92.9261 - if (!isNotBlockStart(token, ts)) {
92.9262 - int offset = token.offset(tokenHierarchy);
92.9263 - PlsqlBlock child = checkStatementBlock(token, ts, parentBlocks);
92.9264 - if (child == null) {//If inner check seems to have failed need to continue this one
92.9265 -
92.9266 - ts.move(offset);
92.9267 - ts.moveNext();
92.9268 - } else {
92.9269 - if (checkExisting(child, lstChild) == false) {
92.9270 - lstChild.add(child);
92.9271 - }
92.9272 - }
92.9273 - }
92.9274 - } else if (image.equalsIgnoreCase("PROCEDURE")
92.9275 - || image.equalsIgnoreCase("FUNCTION")
92.9276 - || image.equalsIgnoreCase("CREATE")) {
92.9277 - break;
92.9278 - } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.9279 - //only single comment line
92.9280 - if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.9281 - customStartToken = token;
92.9282 - } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.9283 - if (customStartToken != null) {
92.9284 - String fname = customStartToken.text().toString();
92.9285 - int index = fname.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.9286 - fname = fname.substring(index + 7).trim();
92.9287 - if (ts.moveNext()) {
92.9288 - token = ts.token();
92.9289 - PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.9290 - token.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.9291 - customFoldBlocks.add(custom);
92.9292 - }
92.9293 - customStartToken = null;
92.9294 - }
92.9295 - } else {
92.9296 - PlsqlBlock child = checkComment(token, ts);
92.9297 - if (child != null) {
92.9298 - if (checkExisting(child, lstChild) == false) {
92.9299 - lstChild.add(child);
92.9300 - }
92.9301 - }
92.9302 - }
92.9303 - } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.9304 - int start = token.offset(tokenHierarchy);
92.9305 - PlsqlBlock child = new PlsqlBlock(start,
92.9306 - start + token.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.9307 - if (child != null) {
92.9308 - if (checkExisting(child, lstChild) == false) {
92.9309 - lstChild.add(child);
92.9310 - }
92.9311 - }
92.9312 - } else if (!isThen) {
92.9313 - name = name + image;
92.9314 - }
92.9315 -
92.9316 - preOffset = ts.offset();
92.9317 - moveNext = ts.moveNext();
92.9318 - token = ts.token();
92.9319 - }
92.9320 -
92.9321 - return caseBlocks;
92.9322 - }
92.9323 -
92.9324 - /**
92.9325 - * Method that will return the prefix of the given block
92.9326 - * @param startOffset
92.9327 - * @param ts
92.9328 - * @return
92.9329 - */
92.9330 - private String getPreceedingText(int startOffset, TokenSequence<PlsqlTokenId> ts) {
92.9331 - String prefix = "";
92.9332 - int offset = ts.offset();
92.9333 - ts.move(startOffset);
92.9334 - ts.moveNext();
92.9335 - Token<PlsqlTokenId> token = ts.token();
92.9336 -
92.9337 - while (ts.movePrevious()) {
92.9338 - token = ts.token();
92.9339 - String image = token.text().toString();
92.9340 -
92.9341 - if (image.contains("\n")) {
92.9342 - break;
92.9343 - }
92.9344 -
92.9345 - prefix = token.text().toString() + prefix;
92.9346 - }
92.9347 -
92.9348 - ts.move(offset);
92.9349 - ts.moveNext();
92.9350 - return prefix;
92.9351 - }
92.9352 -
92.9353 - /**
92.9354 - * Method that will check loop blocks
92.9355 - * @param current
92.9356 - * @param ts
92.9357 - * @param parentBlocks
92.9358 - * @return
92.9359 - */
92.9360 - private PlsqlBlock checkLoopBlock(Token<PlsqlTokenId> current, TokenSequence<PlsqlTokenId> ts, List<PlsqlBlock> parentBlocks) {
92.9361 - Token<PlsqlTokenId> loopBegin = null;
92.9362 - Token<PlsqlTokenId> token = null;
92.9363 - List<PlsqlBlock> lstChild = new ArrayList<PlsqlBlock>();
92.9364 - PlsqlBlock block = null;
92.9365 - boolean moveNext = false;
92.9366 -
92.9367 - //Check whether the beginning is in a SQL Plus command
92.9368 - if (sqlPlusLine(ts)) {
92.9369 - return null;
92.9370 - }
92.9371 -
92.9372 - moveNext = ts.moveNext();
92.9373 - token = ts.token();
92.9374 - loopBegin = current;
92.9375 - boolean isLoop = false;
92.9376 - Token<PlsqlTokenId> customStartToken = null;
92.9377 - PlsqlBlockType type = PlsqlBlockType.LOOP;
92.9378 - String name = "";
92.9379 - if (loopBegin.text().toString().equalsIgnoreCase("LOOP")) {
92.9380 - isLoop = true;
92.9381 - } else if (loopBegin.text().toString().equalsIgnoreCase("WHILE")) {
92.9382 - type = PlsqlBlockType.WHILE_LOOP;
92.9383 - } else if (loopBegin.text().toString().equalsIgnoreCase("FOR")) {
92.9384 - type = PlsqlBlockType.FOR_LOOP;
92.9385 - }
92.9386 -
92.9387 - while (moveNext) {
92.9388 - String image = token.text().toString();
92.9389 - PlsqlTokenId tokenID = token.id();
92.9390 -
92.9391 - if ((token != null) && (!image.equals(";")) && (token.offset(tokenHierarchy) > endParse)) {
92.9392 - break;
92.9393 - }
92.9394 -
92.9395 - if (!isLoop && image.equalsIgnoreCase("LOOP")) {
92.9396 - isLoop = true;
92.9397 - } else if (image.equalsIgnoreCase("END")) {
92.9398 - if (isLoop) {
92.9399 - boolean next = getNextNonWhitespace(ts, true);
92.9400 - Token<PlsqlTokenId> nextTok = ts.token();
92.9401 - if (next && nextTok.text().toString().equalsIgnoreCase("LOOP")) {
92.9402 - next = getNextNonWhitespace(ts, true);
92.9403 - nextTok = ts.token();
92.9404 - if (next && nextTok.text().toString().equalsIgnoreCase(";")) {
92.9405 - ts.moveNext();
92.9406 - block = new PlsqlBlock(loopBegin.offset(tokenHierarchy), ts.offset(), name.trim(), "", type);
92.9407 - break;
92.9408 - } else {
92.9409 - break;
92.9410 - }
92.9411 - }
92.9412 - } else {
92.9413 - break;
92.9414 - }
92.9415 - } else if (image.equalsIgnoreCase("IF")) {
92.9416 - int beforeOff = token.offset(tokenHierarchy);
92.9417 - List<PlsqlBlock> children = checkIfBlock(token, ts, lstChild);
92.9418 - if (children == null || children.size() == 0) {//If inner check seems to have failed need to continue this one
92.9419 -
92.9420 - ts.move(beforeOff);
92.9421 - moveNext = ts.moveNext();
92.9422 - } else {
92.9423 - for (int i = 0; i < children.size(); i++) {
92.9424 - PlsqlBlock child = children.get(i);
92.9425 - if (checkExisting(child, lstChild) == false) {
92.9426 - lstChild.add(child);
92.9427 - }
92.9428 - }
92.9429 - }
92.9430 - } else if (image.equalsIgnoreCase("CASE")) {
92.9431 - int beforeOff = token.offset(tokenHierarchy);
92.9432 - List<PlsqlBlock> children = checkCaseBlock(token, ts, lstChild, false);
92.9433 - if (children == null || children.size() == 0) {//If inner check seems to have failed need to continue this one
92.9434 -
92.9435 - ts.move(beforeOff);
92.9436 - moveNext = ts.moveNext();
92.9437 - } else {
92.9438 - for (int i = 0; i < children.size(); i++) {
92.9439 - PlsqlBlock child = children.get(i);
92.9440 - if (checkExisting(child, lstChild) == false) {
92.9441 - lstChild.add(child);
92.9442 - }
92.9443 - }
92.9444 - }
92.9445 - } else if (image.equalsIgnoreCase("LOOP")
92.9446 - || image.equalsIgnoreCase("WHILE")
92.9447 - || image.equalsIgnoreCase("FOR")) {
92.9448 - int beforeOff = token.offset(tokenHierarchy);
92.9449 - if (!unsuccessBlocks.contains(beforeOff)) {
92.9450 - PlsqlBlock child = checkLoopBlock(token, ts, lstChild);
92.9451 - if (child == null) {//If inner check seems to have failed need to continue this one
92.9452 - unsuccessBlocks.add(beforeOff);
92.9453 - ts.move(beforeOff);
92.9454 - moveNext = ts.moveNext();
92.9455 - } else {
92.9456 - if (checkExisting(child, lstChild) == false) {
92.9457 - lstChild.add(child);
92.9458 - }
92.9459 - }
92.9460 - }
92.9461 - } else if (image.equalsIgnoreCase("TABLE")
92.9462 - || image.equalsIgnoreCase("INDEX")
92.9463 - || image.equalsIgnoreCase("SELECT")
92.9464 - || image.equalsIgnoreCase("UPDATE")
92.9465 - || image.equalsIgnoreCase("DELETE")
92.9466 - || image.equalsIgnoreCase("INSERT")
92.9467 - || image.equalsIgnoreCase("MERGE")
92.9468 - || image.equalsIgnoreCase("DROP")
92.9469 - || image.equalsIgnoreCase("SEQUENCE")) {
92.9470 - if (!isNotBlockStart(token, ts)) {
92.9471 - int offset = token.offset(tokenHierarchy);
92.9472 - PlsqlBlock child = checkStatementBlock(token, ts, parentBlocks);
92.9473 - if (child == null) {//If inner check seems to have failed need to continue this one
92.9474 -
92.9475 - ts.move(offset);
92.9476 - ts.moveNext();
92.9477 - } else {
92.9478 - if (checkExisting(child, lstChild) == false) {
92.9479 - lstChild.add(child);
92.9480 - }
92.9481 - }
92.9482 - }
92.9483 - } else if (image.equalsIgnoreCase("PROCEDURE")
92.9484 - || image.equalsIgnoreCase("FUNCTION")
92.9485 - || image.equalsIgnoreCase("CREATE")) {
92.9486 - break;
92.9487 - } else if (tokenID == PlsqlTokenId.LINE_COMMENT) {
92.9488 - //only single comment line
92.9489 - if (image.toUpperCase(Locale.ENGLISH).contains("<FOLD>")) {
92.9490 - customStartToken = token;
92.9491 - } else if (image.toUpperCase(Locale.ENGLISH).contains("<END-FOLD>")) {
92.9492 - if (customStartToken != null) {
92.9493 - String fname = customStartToken.text().toString();
92.9494 - int index = fname.toUpperCase(Locale.ENGLISH).indexOf("<FOLD>");
92.9495 - fname = fname.substring(index + 7).trim();
92.9496 - if (ts.moveNext()) {
92.9497 - token = ts.token();
92.9498 - PlsqlBlock custom = new PlsqlBlock(customStartToken.offset(tokenHierarchy),
92.9499 - token.offset(tokenHierarchy), name, "", PlsqlBlockType.CUSTOM_FOLD);
92.9500 - customFoldBlocks.add(custom);
92.9501 - }
92.9502 -
92.9503 - customStartToken = null;
92.9504 - }
92.9505 - } else {
92.9506 - PlsqlBlock child = checkComment(token, ts);
92.9507 - if (child != null) {
92.9508 - if (checkExisting(child, lstChild) == false) {
92.9509 - lstChild.add(child);
92.9510 - }
92.9511 - }
92.9512 - }
92.9513 - } else if (tokenID == PlsqlTokenId.BLOCK_COMMENT) {
92.9514 - int start = token.offset(tokenHierarchy);
92.9515 - PlsqlBlock child = new PlsqlBlock(start,
92.9516 - start + token.length(), "BLOCK COMMENT", "", PlsqlBlockType.COMMENT);
92.9517 - if (child != null) {
92.9518 - if (checkExisting(child, lstChild) == false) {
92.9519 - lstChild.add(child);
92.9520 - }
92.9521 - }
92.9522 - } else if (!isLoop) {
92.9523 - name = name + image;
92.9524 - }
92.9525 -
92.9526 - moveNext = ts.moveNext();
92.9527 - token = ts.token();
92.9528 - }
92.9529 -
92.9530 - if (block != null) {
92.9531 - //add children
92.9532 - addChildren(block, lstChild, parentBlocks);
92.9533 - }
92.9534 -
92.9535 - return block;
92.9536 - }
92.9537 -
92.9538 - /**
92.9539 - * Method that will add the given child blocks to the block and
92.9540 - * remove from parent blocks if existing there
92.9541 - * @param block
92.9542 - * @param lstChild
92.9543 - * @param parentBlocks
92.9544 - */
92.9545 - private void addChildren(PlsqlBlock block, List<PlsqlBlock> lstChild, List<PlsqlBlock> parentBlocks) {
92.9546 - int size = lstChild.size();
92.9547 - for (int i = 0; i < size; i++) {
92.9548 - PlsqlBlock child = lstChild.get(i);
92.9549 - block.addChild(child);
92.9550 - removeFromParent(child, parentBlocks);
92.9551 - }
92.9552 - }
92.9553 -
92.9554 - public int getStartParse() {
92.9555 - return startParse;
92.9556 - }
92.9557 -
92.9558 - public int getEndParse() {
92.9559 - return endParse;
92.9560 - }
92.9561 -
92.9562 - public int getChangedLength() {
92.9563 - return changedLength;
92.9564 - }
92.9565 +
92.9566 + moveNext = ts.moveNext();
92.9567 + token = ts.token();
92.9568 + }
92.9569 +
92.9570 + if (block != null) {
92.9571 + //add children
92.9572 + addChildren(block, lstChild, parentBlocks);
92.9573 + }
92.9574 +
92.9575 + return block;
92.9576 + }
92.9577 +
92.9578 + /**
92.9579 + * Method that will add the given child blocks to the block and
92.9580 + * remove from parent blocks if existing there
92.9581 + * @param block
92.9582 + * @param lstChild
92.9583 + * @param parentBlocks
92.9584 + */
92.9585 + private void addChildren(PlsqlBlock block, List<PlsqlBlock> lstChild, List<PlsqlBlock> parentBlocks) {
92.9586 + int size = lstChild.size();
92.9587 + for (int i = 0; i < size; i++) {
92.9588 + PlsqlBlock child = lstChild.get(i);
92.9589 + block.addChild(child);
92.9590 + removeFromParent(child, parentBlocks);
92.9591 + }
92.9592 + }
92.9593 +
92.9594 + public int getStartParse() {
92.9595 + return startParse;
92.9596 + }
92.9597 +
92.9598 + public int getEndParse() {
92.9599 + return endParse;
92.9600 + }
92.9601 +
92.9602 + public int getChangedLength() {
92.9603 + return changedLength;
92.9604 + }
92.9605 }
93.1 --- a/PLSQL/Navigator/manifest.mf Tue Feb 14 17:36:37 2012 +0100
93.2 +++ b/PLSQL/Navigator/manifest.mf Wed Aug 15 20:45:01 2012 +0200
93.3 @@ -5,6 +5,6 @@
93.4 OpenIDE-Module-Layer: org/netbeans/modules/plsql/navigator/layer.xml
93.5 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/plsql/navigator
93.6 /Bundle.properties
93.7 -OpenIDE-Module-Specification-Version: 1.8.1
93.8 +OpenIDE-Module-Specification-Version: 1.8.4
93.9 AutoUpdate-Show-In-Client: false
93.10
94.1 --- a/PLSQL/Navigator/nbproject/project.properties Tue Feb 14 17:36:37 2012 +0100
94.2 +++ b/PLSQL/Navigator/nbproject/project.properties Wed Aug 15 20:45:01 2012 +0200
94.3 @@ -1,2 +1,9 @@
94.4 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
94.5 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=4
94.6 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=4
94.7 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
94.8 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=120
94.9 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
94.10 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
94.11 javac.source=1.6
94.12 javac.compilerargs=-Xlint -Xlint:-serial
95.1 --- a/PLSQL/Navigator/nbproject/project.xml Tue Feb 14 17:36:37 2012 +0100
95.2 +++ b/PLSQL/Navigator/nbproject/project.xml Wed Aug 15 20:45:01 2012 +0200
95.3 @@ -7,14 +7,6 @@
95.4 <suite-component/>
95.5 <module-dependencies>
95.6 <dependency>
95.7 - <code-name-base>org.netbeans.modules.plsql.lexer</code-name-base>
95.8 - <build-prerequisite/>
95.9 - <compile-dependency/>
95.10 - <run-dependency>
95.11 - <specification-version>1.0</specification-version>
95.12 - </run-dependency>
95.13 - </dependency>
95.14 - <dependency>
95.15 <code-name-base>org.jdesktop.layout</code-name-base>
95.16 <build-prerequisite/>
95.17 <compile-dependency/>
95.18 @@ -24,6 +16,15 @@
95.19 </run-dependency>
95.20 </dependency>
95.21 <dependency>
95.22 + <code-name-base>org.netbeans.modules.db</code-name-base>
95.23 + <build-prerequisite/>
95.24 + <compile-dependency/>
95.25 + <run-dependency>
95.26 + <release-version>1</release-version>
95.27 + <specification-version>1.44.1.30</specification-version>
95.28 + </run-dependency>
95.29 + </dependency>
95.30 + <dependency>
95.31 <code-name-base>org.netbeans.modules.editor</code-name-base>
95.32 <build-prerequisite/>
95.33 <compile-dependency/>
95.34 @@ -69,6 +70,56 @@
95.35 </run-dependency>
95.36 </dependency>
95.37 <dependency>
95.38 + <code-name-base>org.netbeans.modules.plsql.filetype</code-name-base>
95.39 + <build-prerequisite/>
95.40 + <compile-dependency/>
95.41 + <run-dependency>
95.42 + <specification-version>1.8.13</specification-version>
95.43 + </run-dependency>
95.44 + </dependency>
95.45 + <dependency>
95.46 + <code-name-base>org.netbeans.modules.plsql.lexer</code-name-base>
95.47 + <build-prerequisite/>
95.48 + <compile-dependency/>
95.49 + <run-dependency>
95.50 + <specification-version>1.0</specification-version>
95.51 + </run-dependency>
95.52 + </dependency>
95.53 + <dependency>
95.54 + <code-name-base>org.netbeans.modules.plsql.utilities</code-name-base>
95.55 + <build-prerequisite/>
95.56 + <compile-dependency/>
95.57 + <run-dependency>
95.58 + <specification-version>1.7.22</specification-version>
95.59 + </run-dependency>
95.60 + </dependency>
95.61 + <dependency>
95.62 + <code-name-base>org.netbeans.modules.plsqlsupport.db</code-name-base>
95.63 + <build-prerequisite/>
95.64 + <compile-dependency/>
95.65 + <run-dependency>
95.66 + <specification-version>1.8.23</specification-version>
95.67 + </run-dependency>
95.68 + </dependency>
95.69 + <dependency>
95.70 + <code-name-base>org.netbeans.modules.projectapi</code-name-base>
95.71 + <build-prerequisite/>
95.72 + <compile-dependency/>
95.73 + <run-dependency>
95.74 + <release-version>1</release-version>
95.75 + <specification-version>1.36.1</specification-version>
95.76 + </run-dependency>
95.77 + </dependency>
95.78 + <dependency>
95.79 + <code-name-base>org.netbeans.modules.projectuiapi</code-name-base>
95.80 + <build-prerequisite/>
95.81 + <compile-dependency/>
95.82 + <run-dependency>
95.83 + <release-version>1</release-version>
95.84 + <specification-version>1.51.2.8</specification-version>
95.85 + </run-dependency>
95.86 + </dependency>
95.87 + <dependency>
95.88 <code-name-base>org.netbeans.modules.settings</code-name-base>
95.89 <build-prerequisite/>
95.90 <compile-dependency/>
95.91 @@ -87,11 +138,27 @@
95.92 </run-dependency>
95.93 </dependency>
95.94 <dependency>
95.95 + <code-name-base>org.netbeans.spi.quicksearch</code-name-base>
95.96 + <build-prerequisite/>
95.97 + <compile-dependency/>
95.98 + <run-dependency>
95.99 + <specification-version>1.10.1</specification-version>
95.100 + </run-dependency>
95.101 + </dependency>
95.102 + <dependency>
95.103 + <code-name-base>org.openide.awt</code-name-base>
95.104 + <build-prerequisite/>
95.105 + <compile-dependency/>
95.106 + <run-dependency>
95.107 + <specification-version>7.31.2</specification-version>
95.108 + </run-dependency>
95.109 + </dependency>
95.110 + <dependency>
95.111 <code-name-base>org.openide.filesystems</code-name-base>
95.112 <build-prerequisite/>
95.113 <compile-dependency/>
95.114 <run-dependency>
95.115 - <specification-version>7.13.1.1.1</specification-version>
95.116 + <specification-version>7.47.1</specification-version>
95.117 </run-dependency>
95.118 </dependency>
95.119 <dependency>
96.1 --- a/PLSQL/Navigator/src/org/netbeans/modules/plsql/navigator/Bundle.properties Tue Feb 14 17:36:37 2012 +0100
96.2 +++ b/PLSQL/Navigator/src/org/netbeans/modules/plsql/navigator/Bundle.properties Wed Aug 15 20:45:01 2012 +0200
96.3 @@ -5,4 +5,5 @@
96.4 OpenIDE-sort-byAlpha=SORT_ALPHA
96.5
96.6 OpenIDE-toolTip-Sort-by-Source=Sort by Source
96.7 -OpenIDE-toolTip-sort-byAlpha=Sort by Name
96.8 \ No newline at end of file
96.9 +OpenIDE-toolTip-sort-byAlpha=Sort by Name
96.10 +QuickSearch/PL/SQL/org-netbeans-modules-plsql-navigator-PlsqlSearchProvider.instance=PL/SQL
97.1 --- a/PLSQL/Navigator/src/org/netbeans/modules/plsql/navigator/PlsqlNavigatorComponent.java Tue Feb 14 17:36:37 2012 +0100
97.2 +++ b/PLSQL/Navigator/src/org/netbeans/modules/plsql/navigator/PlsqlNavigatorComponent.java Wed Aug 15 20:45:01 2012 +0200
97.3 @@ -76,6 +76,7 @@
97.4 import org.openide.ErrorManager;
97.5 import org.openide.cookies.EditorCookie;
97.6 import org.openide.loaders.DataObject;
97.7 +import org.openide.util.Exceptions;
97.8 import org.openide.util.RequestProcessor;
97.9 import org.openide.windows.TopComponent;
97.10
97.11 @@ -85,6 +86,8 @@
97.12 */
97.13 public class PlsqlNavigatorComponent extends NavigatorTopComponent {
97.14
97.15 + private static final RequestProcessor RP = new RequestProcessor(PlsqlNavigatorComponent.class);
97.16 +
97.17 /**
97.18 * Setting up a MouseListner for the navigator. This activates when the
97.19 * user clicked on the navigator area.
97.20 @@ -105,8 +108,9 @@
97.21
97.22 if (getDocument() == null) {
97.23 JTextComponent component = Utilities.getFocusedComponent();
97.24 - if (component != null)
97.25 + if (component != null) {
97.26 setDocument(Utilities.getDocument(component));
97.27 + }
97.28 }
97.29
97.30 customizeIcon();
97.31 @@ -124,7 +128,6 @@
97.32 }
97.33 }
97.34
97.35 -
97.36 public void navigatorButtonListner() {
97.37 ActionListener al = new ActionListener() {
97.38
97.39 @@ -175,7 +178,7 @@
97.40 openAndFocusElement();
97.41 }
97.42 } catch (Exception ex) {
97.43 - ex.printStackTrace();
97.44 + Exceptions.printStackTrace(ex);
97.45 }
97.46 }
97.47 }
97.48 @@ -189,10 +192,10 @@
97.49 * @param blockFactory
97.50 */
97.51 public void update(PlsqlBlockFactory blockFactory) {
97.52 - final List<PlsqlBlock> newBlocks = new ArrayList<PlsqlBlock>(blockFactory.getNewBlocks());
97.53 - final List<PlsqlBlock> changedBlocks = new ArrayList<PlsqlBlock>(blockFactory.getChangedBlocks());
97.54 - final List<PlsqlBlock> removedBlocks = new ArrayList<PlsqlBlock>(blockFactory.getRemovedBlocks());
97.55 - loadAndExpandTree(root, treeModel, newBlocks, changedBlocks, removedBlocks);
97.56 + final List<PlsqlBlock> newBlocks = new ArrayList<PlsqlBlock>(blockFactory.getNewBlocks());
97.57 + final List<PlsqlBlock> changedBlocks = new ArrayList<PlsqlBlock>(blockFactory.getChangedBlocks());
97.58 + final List<PlsqlBlock> removedBlocks = new ArrayList<PlsqlBlock>(blockFactory.getRemovedBlocks());
97.59 + loadAndExpandTree(root, treeModel, newBlocks, changedBlocks, removedBlocks);
97.60 }
97.61
97.62 /**
97.63 @@ -206,7 +209,7 @@
97.64 setDocument(doc);
97.65 loadAndExpandInitialTree(root, treeModel, data, blocks);
97.66 } catch (Exception ex) {
97.67 - ex.printStackTrace();
97.68 + Exceptions.printStackTrace(ex);
97.69 }
97.70 }
97.71
97.72 @@ -233,7 +236,7 @@
97.73 */
97.74 private void addChildNode(DefaultMutableTreeNode parent, PlsqlBlock child, PlsqlBlockType parentType) {
97.75 PlsqlBlockType type = child.getType();
97.76 - int index = 0;
97.77 + int index = 0;
97.78 //We are looking for child blocks and adding now
97.79 if (type == PlsqlBlockType.FUNCTION_IMPL) { //Leaf node
97.80
97.81 @@ -262,20 +265,19 @@
97.82 }
97.83 }
97.84
97.85 -
97.86 - private void sortTreeModel(){
97.87 - int count = root.getChildCount();
97.88 + private void sortTreeModel() {
97.89 + int count = root.getChildCount();
97.90 if (count > 0) {
97.91 int i = 0;
97.92 ArrayList parent = Collections.list(root.children());
97.93 Collections.sort(parent, new CompareNodes(sortBySource));
97.94 // for main nodes
97.95 - while(i < count){
97.96 - treeModel.removeNodeFromParent((DefaultMutableTreeNode)root.getChildAt(0));
97.97 + while (i < count) {
97.98 + treeModel.removeNodeFromParent((DefaultMutableTreeNode) root.getChildAt(0));
97.99 i++;
97.100 }
97.101 // for child nodes
97.102 - i =0;
97.103 + i = 0;
97.104 while (i < count) {
97.105 DefaultMutableTreeNode child = (DefaultMutableTreeNode) parent.get(i);
97.106 if (child.getChildCount() > 1) {
97.107 @@ -296,11 +298,10 @@
97.108 i++;
97.109 }
97.110 }
97.111 - expandAll(jTree1, new TreePath(root), true);
97.112 + expandAll(jTree1, new TreePath(root), true);
97.113 jTree1.updateUI();
97.114 }
97.115
97.116 -
97.117 /**
97.118 * Get the parent node for the given block
97.119 * @param root
97.120 @@ -315,8 +316,8 @@
97.121 if (node.getUserObject() instanceof NodeInfo) {
97.122 NodeInfo nodeInfo = (NodeInfo) node.getUserObject();
97.123
97.124 - if ((nodeInfo.startOffset < block.getStartOffset()) &&
97.125 - (nodeInfo.endOffset > block.getEndOffset())) {
97.126 + if ((nodeInfo.startOffset < block.getStartOffset())
97.127 + && (nodeInfo.endOffset > block.getEndOffset())) {
97.128 parentNode = node;
97.129 break;
97.130 }
97.131 @@ -336,7 +337,7 @@
97.132 */
97.133 private synchronized void loadAndExpandInitialTree(DefaultMutableTreeNode root, DefaultTreeModel treeModel, DataObject dataObject, List<PlsqlBlock> blockhierarchy) {
97.134 List<PlsqlBlock> blocks = new ArrayList<PlsqlBlock>(blockhierarchy);
97.135 - Collections.sort(blocks, new CompareBlocks(sortBySource));
97.136 + Collections.sort(blocks, new CompareBlocks(sortBySource));
97.137 //Remove all the previous nodes
97.138 if (root.getChildCount() > 0) {
97.139 while (root.getChildCount() > 0) {
97.140 @@ -344,8 +345,9 @@
97.141 }
97.142 }
97.143
97.144 - if (!dataObject.isValid())
97.145 - return;
97.146 + if (!dataObject.isValid()) {
97.147 + return;
97.148 + }
97.149
97.150 //Set root name
97.151 String rootName = "Navigator Tree";
97.152 @@ -466,60 +468,62 @@
97.153 }
97.154
97.155 private boolean isBlockShownInNavigator(PlsqlBlock block, DefaultMutableTreeNode parentNode) {
97.156 - PlsqlBlockType parentType = null;
97.157 - if (parentNode!=null && parentNode.getUserObject() instanceof NodeInfo)
97.158 - parentType = ((NodeInfo)parentNode.getUserObject()).type;
97.159 - return (block.getType() == PlsqlBlockType.PACKAGE ||
97.160 - block.getType() == PlsqlBlockType.PACKAGE_BODY ||
97.161 - block.getType() == PlsqlBlockType.VIEW ||
97.162 - ((parentType==null || parentType == PlsqlBlockType.PACKAGE) &&
97.163 - (block.getType() == PlsqlBlockType.FUNCTION_DEF ||
97.164 - block.getType() == PlsqlBlockType.PROCEDURE_DEF)) ||
97.165 - ((parentType==null || parentType == PlsqlBlockType.PACKAGE_BODY) &&
97.166 - (block.getType() == PlsqlBlockType.FUNCTION_IMPL ||
97.167 - block.getType() == PlsqlBlockType.PROCEDURE_IMPL)));
97.168 + PlsqlBlockType parentType = null;
97.169 + if (parentNode != null && parentNode.getUserObject() instanceof NodeInfo) {
97.170 + parentType = ((NodeInfo) parentNode.getUserObject()).type;
97.171 + }
97.172 + return (block.getType() == PlsqlBlockType.PACKAGE
97.173 + || block.getType() == PlsqlBlockType.PACKAGE_BODY
97.174 + || block.getType() == PlsqlBlockType.VIEW
97.175 + || ((parentType == null || parentType == PlsqlBlockType.PACKAGE)
97.176 + && (block.getType() == PlsqlBlockType.FUNCTION_DEF
97.177 + || block.getType() == PlsqlBlockType.PROCEDURE_DEF))
97.178 + || ((parentType == null || parentType == PlsqlBlockType.PACKAGE_BODY)
97.179 + && (block.getType() == PlsqlBlockType.FUNCTION_IMPL
97.180 + || block.getType() == PlsqlBlockType.PROCEDURE_IMPL)));
97.181 }
97.182
97.183 + private static class CompareBlocks implements Comparator<PlsqlBlock> {
97.184
97.185 - private static class CompareBlocks implements Comparator<PlsqlBlock> {
97.186 - private boolean byPosition;
97.187 - public CompareBlocks(boolean byPosition) {
97.188 - this.byPosition = byPosition;
97.189 - }
97.190 + private boolean byPosition;
97.191
97.192 - public int compare(PlsqlBlock o1, PlsqlBlock o2) {
97.193 - //first sort by type
97.194 - int result = o1.getType().compareTo(o2.getType());
97.195 - if(result!=0 && !((o1.getType()==PlsqlBlockType.FUNCTION_DEF || o1.getType()==PlsqlBlockType.PROCEDURE_DEF ||
97.196 - o1.getType()==PlsqlBlockType.FUNCTION_IMPL || o1.getType()==PlsqlBlockType.PROCEDURE_IMPL) &&
97.197 - (o2.getType()==PlsqlBlockType.PROCEDURE_DEF || o2.getType()==PlsqlBlockType.FUNCTION_DEF ||
97.198 - o2.getType()==PlsqlBlockType.PROCEDURE_IMPL || o2.getType()==PlsqlBlockType.FUNCTION_IMPL)))
97.199 - return result;
97.200 + public CompareBlocks(boolean byPosition) {
97.201 + this.byPosition = byPosition;
97.202 + }
97.203
97.204 - if(byPosition) {
97.205 - Integer o1pos, o2pos;
97.206 - if(o1.getPreviousStart()>-1 && o2.getPreviousStart()>-1) {
97.207 - o1pos = new Integer(o1.getPreviousStart());
97.208 - o2pos = new Integer(o2.getPreviousStart());
97.209 - } else if(o1.getPreviousEnd()>-1 && o2.getPreviousEnd()>-1) {
97.210 - o1pos = new Integer(o1.getPreviousEnd());
97.211 - o2pos = new Integer(o2.getPreviousEnd());
97.212 - } else if(o1.getStartOffset()>-1 && o2.getStartOffset()>-1){
97.213 - o1pos = new Integer(o1.getStartOffset());
97.214 - o2pos = new Integer(o2.getStartOffset());
97.215 - } else {
97.216 - o1pos = new Integer(o1.getEndOffset());
97.217 - o2pos = new Integer(o2.getEndOffset());
97.218 + @Override
97.219 + public int compare(PlsqlBlock o1, PlsqlBlock o2) {
97.220 + //first sort by type
97.221 + int result = o1.getType().compareTo(o2.getType());
97.222 + if (result != 0 && !((o1.getType() == PlsqlBlockType.FUNCTION_DEF || o1.getType() == PlsqlBlockType.PROCEDURE_DEF
97.223 + || o1.getType() == PlsqlBlockType.FUNCTION_IMPL || o1.getType() == PlsqlBlockType.PROCEDURE_IMPL)
97.224 + && (o2.getType() == PlsqlBlockType.PROCEDURE_DEF || o2.getType() == PlsqlBlockType.FUNCTION_DEF
97.225 + || o2.getType() == PlsqlBlockType.PROCEDURE_IMPL || o2.getType() == PlsqlBlockType.FUNCTION_IMPL))) {
97.226 + return result;
97.227 }
97.228 - return o1pos.compareTo(o2pos);
97.229 - } else { //sort by name
97.230 - return o1.getName().compareToIgnoreCase(o2.getName());
97.231 - }
97.232 - }
97.233
97.234 - }
97.235 + if (byPosition) {
97.236 + Integer o1pos, o2pos;
97.237 + if (o1.getPreviousStart() > -1 && o2.getPreviousStart() > -1) {
97.238 + o1pos = new Integer(o1.getPreviousStart());
97.239 + o2pos = new Integer(o2.getPreviousStart());
97.240 + } else if (o1.getPreviousEnd() > -1 && o2.getPreviousEnd() > -1) {
97.241 + o1pos = new Integer(o1.getPreviousEnd());
97.242 + o2pos = new Integer(o2.getPreviousEnd());
97.243 + } else if (o1.getStartOffset() > -1 && o2.getStartOffset() > -1) {
97.244 + o1pos = new Integer(o1.getStartOffset());
97.245 + o2pos = new Integer(o2.getStartOffset());
97.246 + } else {
97.247 + o1pos = new Integer(o1.getEndOffset());
97.248 + o2pos = new Integer(o2.getEndOffset());
97.249 + }
97.250 + return o1pos.compareTo(o2pos);
97.251 + } else { //sort by name
97.252 + return o1.getName().compareToIgnoreCase(o2.getName());
97.253 + }
97.254 + }
97.255 + }
97.256
97.257 -
97.258 private static class CompareNodes implements Comparator<DefaultMutableTreeNode> {
97.259
97.260 private boolean byPosition;
97.261 @@ -528,6 +532,7 @@
97.262 this.byPosition = byPosition;
97.263 }
97.264
97.265 + @Override
97.266 public int compare(DefaultMutableTreeNode o1, DefaultMutableTreeNode o2) {
97.267
97.268 NodeInfo ni1;
97.269 @@ -575,229 +580,230 @@
97.270 }
97.271 }
97.272 }
97.273 -
97.274 +
97.275 /**
97.276 * Method that will be called to update the tree structure on document events
97.277 * @param root
97.278 * @param treeModel
97.279 * @param blockFactory
97.280 */
97.281 - private synchronized void loadAndExpandTree(DefaultMutableTreeNode root, DefaultTreeModel treeModel, List<PlsqlBlock> newBlocks, List<PlsqlBlock> changedBlocks, List<PlsqlBlock> removedBlocks) {
97.282 -
97.283 - Collections.sort(newBlocks, new CompareBlocks(sortBySource));
97.284 - Collections.sort(changedBlocks, new CompareBlocks(sortBySource));
97.285 - Collections.sort(removedBlocks, new CompareBlocks(sortBySource));
97.286 - //Update offsets of the changed blocksparentNodeparentNode
97.287 + private synchronized void loadAndExpandTree(DefaultMutableTreeNode root, DefaultTreeModel treeModel, List<PlsqlBlock> newBlocks, List<PlsqlBlock> changedBlocks, List<PlsqlBlock> removedBlocks) {
97.288
97.289 - Enumeration topLevelNodes = root.children();
97.290 - if (topLevelNodes.hasMoreElements()) {
97.291 - DefaultMutableTreeNode node = (DefaultMutableTreeNode)topLevelNodes.nextElement();
97.292 - Enumeration currentNodeList = topLevelNodes;
97.293 - DefaultMutableTreeNode parentNode = null;
97.294 - for (int i = 0; i < changedBlocks.size(); i++) {
97.295 - PlsqlBlock block = changedBlocks.get(i);
97.296 - if (isBlockShownInNavigator(block, parentNode)) {
97.297 - boolean childBlock = (block.getType() != PlsqlBlockType.PACKAGE) && (block.getType() != PlsqlBlockType.PACKAGE_BODY);
97.298 - boolean matchFound = false;
97.299 - boolean fromTheTop = false;
97.300 - while(node!=null && !matchFound) {
97.301 - if (node.getUserObject() instanceof NodeInfo) {
97.302 - NodeInfo nodeInfo = (NodeInfo) node.getUserObject();
97.303 - if ((nodeInfo.type == block.getType()) &&
97.304 - ((nodeInfo.type==PlsqlBlockType.PACKAGE_BODY && nodeInfo.name.equals(block.getName())) || //workaround for issue with packages... Should really be fixed in a different way...
97.305 - (((nodeInfo.startOffset != block.getStartOffset()) &&
97.306 - (nodeInfo.startOffset == block.getPreviousStart())) ||
97.307 - ((nodeInfo.endOffset != block.getEndOffset()) &&
97.308 - (nodeInfo.endOffset == block.getPreviousEnd()))))) {
97.309 - //we found the match
97.310 - nodeInfo.startOffset = block.getStartOffset();
97.311 - nodeInfo.endOffset = block.getEndOffset();
97.312 - nodeInfo.name = block.getName();
97.313 - nodeInfo.alias = block.getAlias();
97.314 - node.setUserObject(nodeInfo);
97.315 - matchFound = true;
97.316 - }
97.317 - }
97.318 - if (currentNodeList==topLevelNodes) {
97.319 - currentNodeList = node.children();
97.320 - parentNode = node;
97.321 - }
97.322 - if(!currentNodeList.hasMoreElements() || (!childBlock && !matchFound)) {
97.323 - currentNodeList=topLevelNodes;
97.324 - parentNode = null;
97.325 - }
97.326 - if(currentNodeList.hasMoreElements())
97.327 - node = (DefaultMutableTreeNode)currentNodeList.nextElement();
97.328 - else if(matchFound || fromTheTop)
97.329 - node = null;
97.330 - else {
97.331 - //this shouldn't happen if there are any remaining "changed" blocks. However, it could happen in some strange scenario so we'll try from the start again
97.332 - topLevelNodes = root.children();
97.333 - node = (DefaultMutableTreeNode)topLevelNodes.nextElement();
97.334 - currentNodeList = topLevelNodes;
97.335 - parentNode = null;
97.336 - fromTheTop=true;
97.337 - }
97.338 - }
97.339 + Collections.sort(newBlocks, new CompareBlocks(sortBySource));
97.340 + Collections.sort(changedBlocks, new CompareBlocks(sortBySource));
97.341 + Collections.sort(removedBlocks, new CompareBlocks(sortBySource));
97.342 + //Update offsets of the changed blocksparentNodeparentNode
97.343 +
97.344 + Enumeration topLevelNodes = root.children();
97.345 + if (topLevelNodes.hasMoreElements()) {
97.346 + DefaultMutableTreeNode node = (DefaultMutableTreeNode) topLevelNodes.nextElement();
97.347 + Enumeration currentNodeList = topLevelNodes;
97.348 + DefaultMutableTreeNode parentNode = null;
97.349 + for (int i = 0; i < changedBlocks.size(); i++) {
97.350 + PlsqlBlock block = changedBlocks.get(i);
97.351 + if (isBlockShownInNavigator(block, parentNode)) {
97.352 + boolean childBlock = (block.getType() != PlsqlBlockType.PACKAGE) && (block.getType() != PlsqlBlockType.PACKAGE_BODY);
97.353 + boolean matchFound = false;
97.354 + boolean fromTheTop = false;
97.355 + while (node != null && !matchFound) {
97.356 + if (node.getUserObject() instanceof NodeInfo) {
97.357 + NodeInfo nodeInfo = (NodeInfo) node.getUserObject();
97.358 + if ((nodeInfo.type == block.getType())
97.359 + && ((nodeInfo.type == PlsqlBlockType.PACKAGE_BODY && nodeInfo.name.equals(block.getName())) || //workaround for issue with packages... Should really be fixed in a different way...
97.360 + (((nodeInfo.startOffset != block.getStartOffset())
97.361 + && (nodeInfo.startOffset == block.getPreviousStart()))
97.362 + || ((nodeInfo.endOffset != block.getEndOffset())
97.363 + && (nodeInfo.endOffset == block.getPreviousEnd()))))) {
97.364 + //we found the match
97.365 + nodeInfo.startOffset = block.getStartOffset();
97.366 + nodeInfo.endOffset = block.getEndOffset();
97.367 + nodeInfo.name = block.getName();
97.368 + nodeInfo.alias = block.getAlias();
97.369 + node.setUserObject(nodeInfo);
97.370 + matchFound = true;
97.371 + }
97.372 + }
97.373 + if (currentNodeList == topLevelNodes) {
97.374 + currentNodeList = node.children();
97.375 + parentNode = node;
97.376 + }
97.377 + if (!currentNodeList.hasMoreElements() || (!childBlock && !matchFound)) {
97.378 + currentNodeList = topLevelNodes;
97.379 + parentNode = null;
97.380 + }
97.381 + if (currentNodeList.hasMoreElements()) {
97.382 + node = (DefaultMutableTreeNode) currentNodeList.nextElement();
97.383 + } else if (matchFound || fromTheTop) {
97.384 + node = null;
97.385 + } else {
97.386 + //this shouldn't happen if there are any remaining "changed" blocks. However, it could happen in some strange scenario so we'll try from the start again
97.387 + topLevelNodes = root.children();
97.388 + node = (DefaultMutableTreeNode) topLevelNodes.nextElement();
97.389 + currentNodeList = topLevelNodes;
97.390 + parentNode = null;
97.391 + fromTheTop = true;
97.392 + }
97.393 + }
97.394 + }
97.395 }
97.396 - }
97.397 - }
97.398 + }
97.399
97.400 - //find nodes to remove (but don't actually remove them...)
97.401 - topLevelNodes = root.children();
97.402 - List<DefaultMutableTreeNode> nodesToRemove = new ArrayList<DefaultMutableTreeNode>();
97.403 - if (topLevelNodes.hasMoreElements()) {
97.404 - DefaultMutableTreeNode node = (DefaultMutableTreeNode)topLevelNodes.nextElement();
97.405 - DefaultMutableTreeNode parentNode = null;
97.406 - Enumeration currentNodeList = topLevelNodes;
97.407 - for (int i = 0; i < removedBlocks.size(); i++) {
97.408 - PlsqlBlock block = removedBlocks.get(i);
97.409 - if (isBlockShownInNavigator(block, parentNode)) {
97.410 - boolean childBlock = (block.getType() != PlsqlBlockType.PACKAGE) && (block.getType() != PlsqlBlockType.PACKAGE_BODY);
97.411 - boolean matchFound = false;
97.412 - boolean fromTheTop = false;
97.413 - while(node!=null && !matchFound) {
97.414 - if (node.getUserObject() instanceof NodeInfo) {
97.415 - NodeInfo nodeInfo = (NodeInfo) node.getUserObject();
97.416 - if ((nodeInfo.type == block.getType()) &&
97.417 - (nodeInfo.name.equals(block.getName())) &&
97.418 - (nodeInfo.type==PlsqlBlockType.PACKAGE_BODY || //workaround for issue with packages... Should really be fixed in a different way...
97.419 - ((nodeInfo.startOffset == block.getStartOffset()) ||
97.420 - (nodeInfo.endOffset == block.getEndOffset()) ||
97.421 - (nodeInfo.startOffset == block.getPreviousStart()) ||
97.422 - (nodeInfo.endOffset == block.getPreviousEnd())))) {
97.423 - nodesToRemove.add(node);
97.424 - matchFound = true;
97.425 - }
97.426 - }
97.427 - //go to next candidate node
97.428 - if (currentNodeList==topLevelNodes) {
97.429 - currentNodeList = node.children();
97.430 - parentNode = node;
97.431 - }
97.432 - if(!currentNodeList.hasMoreElements() || (!childBlock && !matchFound)) {
97.433 - currentNodeList=topLevelNodes;
97.434 - parentNode = null;
97.435 - }
97.436 - if(currentNodeList.hasMoreElements())
97.437 - node = (DefaultMutableTreeNode)currentNodeList.nextElement();
97.438 - else if(matchFound || fromTheTop)
97.439 - node = null;
97.440 - else {
97.441 - //this shouldn't happen if there are any remaining "removed" blocks. However, it could happen in some strange scenario so we'll try from the start again
97.442 - topLevelNodes = root.children();
97.443 - node = (DefaultMutableTreeNode)topLevelNodes.nextElement();
97.444 - currentNodeList = topLevelNodes;
97.445 - parentNode = null;
97.446 - fromTheTop=true;
97.447 - }
97.448 - }
97.449 + //find nodes to remove (but don't actually remove them...)
97.450 + topLevelNodes = root.children();
97.451 + List<DefaultMutableTreeNode> nodesToRemove = new ArrayList<DefaultMutableTreeNode>();
97.452 + if (topLevelNodes.hasMoreElements()) {
97.453 + DefaultMutableTreeNode node = (DefaultMutableTreeNode) topLevelNodes.nextElement();
97.454 + DefaultMutableTreeNode parentNode = null;
97.455 + Enumeration currentNodeList = topLevelNodes;
97.456 + for (int i = 0; i < removedBlocks.size(); i++) {
97.457 + PlsqlBlock block = removedBlocks.get(i);
97.458 + if (isBlockShownInNavigator(block, parentNode)) {
97.459 + boolean childBlock = (block.getType() != PlsqlBlockType.PACKAGE) && (block.getType() != PlsqlBlockType.PACKAGE_BODY);
97.460 + boolean matchFound = false;
97.461 + boolean fromTheTop = false;
97.462 + while (node != null && !matchFound) {
97.463 + if (node.getUserObject() instanceof NodeInfo) {
97.464 + NodeInfo nodeInfo = (NodeInfo) node.getUserObject();
97.465 + if ((nodeInfo.type == block.getType())
97.466 + && (nodeInfo.name.equals(block.getName()))
97.467 + && (nodeInfo.type == PlsqlBlockType.PACKAGE_BODY || //workaround for issue with packages... Should really be fixed in a different way...
97.468 + ((nodeInfo.startOffset == block.getStartOffset())
97.469 + || (nodeInfo.endOffset == block.getEndOffset())
97.470 + || (nodeInfo.startOffset == block.getPreviousStart())
97.471 + || (nodeInfo.endOffset == block.getPreviousEnd())))) {
97.472 + nodesToRemove.add(node);
97.473 + matchFound = true;
97.474 + }
97.475 + }
97.476 + //go to next candidate node
97.477 + if (currentNodeList == topLevelNodes) {
97.478 + currentNodeList = node.children();
97.479 + parentNode = node;
97.480 + }
97.481 + if (!currentNodeList.hasMoreElements() || (!childBlock && !matchFound)) {
97.482 + currentNodeList = topLevelNodes;
97.483 + parentNode = null;
97.484 + }
97.485 + if (currentNodeList.hasMoreElements()) {
97.486 + node = (DefaultMutableTreeNode) currentNodeList.nextElement();
97.487 + } else if (matchFound || fromTheTop) {
97.488 + node = null;
97.489 + } else {
97.490 + //this shouldn't happen if there are any remaining "removed" blocks. However, it could happen in some strange scenario so we'll try from the start again
97.491 + topLevelNodes = root.children();
97.492 + node = (DefaultMutableTreeNode) topLevelNodes.nextElement();
97.493 + currentNodeList = topLevelNodes;
97.494 + parentNode = null;
97.495 + fromTheTop = true;
97.496 + }
97.497 + }
97.498 + }
97.499 }
97.500 - }
97.501 - }
97.502 - //actually remove the nodes
97.503 - for(DefaultMutableTreeNode node : nodesToRemove)
97.504 - treeModel.removeNodeFromParent(node);
97.505 + }
97.506 + //actually remove the nodes
97.507 + for (DefaultMutableTreeNode node : nodesToRemove) {
97.508 + treeModel.removeNodeFromParent(node);
97.509 + }
97.510
97.511 - //Now we can add new blocks with their children
97.512 - for (int i = 0; i < newBlocks.size(); i++) {
97.513 - PlsqlBlock temp = newBlocks.get(i);
97.514 - int lastInsertionIndex = 0;
97.515 - if (isBlockShownInNavigator(temp, null)) {
97.516 - DefaultMutableTreeNode parentNode = getParentNode(root, temp);
97.517 - if (parentNode != null) {
97.518 - //if this is a child of a leaf ignore
97.519 - DefaultMutableTreeNode leafParent = getParentNode(parentNode, temp);
97.520 - if (leafParent == null) {
97.521 - //add to parent
97.522 - boolean expand = parentNode.isLeaf();
97.523 - addChildNode(parentNode, temp, ((NodeInfo) parentNode.getUserObject()).type);
97.524 - if (expand) {
97.525 - expandAll(jTree1, new TreePath(treeModel.getPathToRoot(parentNode)), true);
97.526 - }
97.527 - }
97.528 - } else {
97.529 - //If a view add to views
97.530 - PlsqlBlockType type = temp.getType();
97.531 - if (type == PlsqlBlockType.VIEW) {
97.532 - boolean expand = false;
97.533 - DefaultMutableTreeNode viewsNode = null;
97.534 - int count = root.getChildCount();
97.535 - for (int x = 0; x < count; x++) {
97.536 - DefaultMutableTreeNode node = (DefaultMutableTreeNode) root.getChildAt(x);
97.537 - if (node.toString().equals("Views")) {
97.538 - viewsNode = node;
97.539 + //Now we can add new blocks with their children
97.540 + for (int i = 0; i < newBlocks.size(); i++) {
97.541 + PlsqlBlock temp = newBlocks.get(i);
97.542 + int lastInsertionIndex = 0;
97.543 + if (isBlockShownInNavigator(temp, null)) {
97.544 + DefaultMutableTreeNode parentNode = getParentNode(root, temp);
97.545 + if (parentNode != null) {
97.546 + //if this is a child of a leaf ignore
97.547 + DefaultMutableTreeNode leafParent = getParentNode(parentNode, temp);
97.548 + if (leafParent == null) {
97.549 + //add to parent
97.550 + boolean expand = parentNode.isLeaf();
97.551 + addChildNode(parentNode, temp, ((NodeInfo) parentNode.getUserObject()).type);
97.552 + if (expand) {
97.553 + expandAll(jTree1, new TreePath(treeModel.getPathToRoot(parentNode)), true);
97.554 + }
97.555 + }
97.556 + } else {
97.557 + //If a view add to views
97.558 + PlsqlBlockType type = temp.getType();
97.559 + if (type == PlsqlBlockType.VIEW) {
97.560 + boolean expand = false;
97.561 + DefaultMutableTreeNode viewsNode = null;
97.562 + int count = root.getChildCount();
97.563 + for (int x = 0; x < count; x++) {
97.564 + DefaultMutableTreeNode node = (DefaultMutableTreeNode) root.getChildAt(x);
97.565 + if (node.toString().equals("Views")) {
97.566 + viewsNode = node;
97.567
97.568 - //Check whether a leaf node
97.569 - if (viewsNode.isLeaf()) {
97.570 - expand = true;
97.571 + //Check whether a leaf node
97.572 + if (viewsNode.isLeaf()) {
97.573 + expand = true;
97.574 + }
97.575 + break;
97.576 + }
97.577 }
97.578 - break;
97.579 - }
97.580 - }
97.581
97.582 - if (viewsNode == null) {
97.583 - viewsNode = new DefaultMutableTreeNode("Views");
97.584 - treeModel.insertNodeInto(viewsNode, root, 0);
97.585 - expand = true;
97.586 - }
97.587 + if (viewsNode == null) {
97.588 + viewsNode = new DefaultMutableTreeNode("Views");
97.589 + treeModel.insertNodeInto(viewsNode, root, 0);
97.590 + expand = true;
97.591 + }
97.592
97.593 - NodeInfo nodeInfo = new NodeInfo(temp.getStartOffset(), temp.getEndOffset(),
97.594 - temp.getName(), temp.getAlias(), temp.getType());
97.595 - DefaultMutableTreeNode node = new DefaultMutableTreeNode(nodeInfo);
97.596 - treeModel.insertNodeInto(node, viewsNode, getChildIndex(viewsNode, node));
97.597 + NodeInfo nodeInfo = new NodeInfo(temp.getStartOffset(), temp.getEndOffset(),
97.598 + temp.getName(), temp.getAlias(), temp.getType());
97.599 + DefaultMutableTreeNode node = new DefaultMutableTreeNode(nodeInfo);
97.600 + treeModel.insertNodeInto(node, viewsNode, getChildIndex(viewsNode, node));
97.601
97.602 - //If the 'Views' node is newly added expand that
97.603 - if (expand) {
97.604 - expandAll(jTree1, new TreePath(treeModel.getPathToRoot(viewsNode)), true);
97.605 - }
97.606 - } else if (type == PlsqlBlockType.PACKAGE) { //Parent node
97.607 + //If the 'Views' node is newly added expand that
97.608 + if (expand) {
97.609 + expandAll(jTree1, new TreePath(treeModel.getPathToRoot(viewsNode)), true);
97.610 + }
97.611 + } else if (type == PlsqlBlockType.PACKAGE) { //Parent node
97.612
97.613 - NodeInfo nodeInfo = new NodeInfo(temp.getStartOffset(), temp.getEndOffset(),
97.614 - temp.getName(), temp.getAlias(), temp.getType());
97.615 - DefaultMutableTreeNode node = new DefaultMutableTreeNode(nodeInfo);
97.616 - lastInsertionIndex = getRootIndex(root, node, lastInsertionIndex);
97.617 - treeModel.insertNodeInto(node, root, lastInsertionIndex);
97.618 + NodeInfo nodeInfo = new NodeInfo(temp.getStartOffset(), temp.getEndOffset(),
97.619 + temp.getName(), temp.getAlias(), temp.getType());
97.620 + DefaultMutableTreeNode node = new DefaultMutableTreeNode(nodeInfo);
97.621 + lastInsertionIndex = getRootIndex(root, node, lastInsertionIndex);
97.622 + treeModel.insertNodeInto(node, root, lastInsertionIndex);
97.623
97.624 - //Remove child nodes if there are in the parent level first
97.625 + //Remove child nodes if there are in the parent level first
97.626 // removeChildNodes(root, temp.getChildBlocks());
97.627 - //Add child nodes and expand the node
97.628 - addChildNodes(node, temp.getChildBlocks(), temp.getType());
97.629 - expandAll(jTree1, new TreePath(treeModel.getPathToRoot(node)), true);
97.630 - } else if (type == PlsqlBlockType.PACKAGE_BODY) { //Parent node
97.631 + //Add child nodes and expand the node
97.632 + addChildNodes(node, temp.getChildBlocks(), temp.getType());
97.633 + expandAll(jTree1, new TreePath(treeModel.getPathToRoot(node)), true);
97.634 + } else if (type == PlsqlBlockType.PACKAGE_BODY) { //Parent node
97.635
97.636 - NodeInfo nodeInfo = new NodeInfo(temp.getStartOffset(), temp.getEndOffset(),
97.637 - temp.getName(), temp.getAlias(), temp.getType());
97.638 - DefaultMutableTreeNode node = new DefaultMutableTreeNode(nodeInfo);
97.639 - lastInsertionIndex = getRootIndex(root, node, lastInsertionIndex);
97.640 - treeModel.insertNodeInto(node, root, lastInsertionIndex);
97.641 + NodeInfo nodeInfo = new NodeInfo(temp.getStartOffset(), temp.getEndOffset(),
97.642 + temp.getName(), temp.getAlias(), temp.getType());
97.643 + DefaultMutableTreeNode node = new DefaultMutableTreeNode(nodeInfo);
97.644 + lastInsertionIndex = getRootIndex(root, node, lastInsertionIndex);
97.645 + treeModel.insertNodeInto(node, root, lastInsertionIndex);
97.646
97.647 - //Remove child nodes if there are in the parent level first
97.648 + //Remove child nodes if there are in the parent level first
97.649 // removeChildNodes(root, temp.getChildBlocks());
97.650 - //Add child nodes and expand the node
97.651 - addChildNodes(node, temp.getChildBlocks(), temp.getType());
97.652 - expandAll(jTree1, new TreePath(treeModel.getPathToRoot(node)), true);
97.653 - } else if (type == PlsqlBlockType.FUNCTION_IMPL) { //Leaf node
97.654 + //Add child nodes and expand the node
97.655 + addChildNodes(node, temp.getChildBlocks(), temp.getType());
97.656 + expandAll(jTree1, new TreePath(treeModel.getPathToRoot(node)), true);
97.657 + } else if (type == PlsqlBlockType.FUNCTION_IMPL) { //Leaf node
97.658
97.659 - NodeInfo nodeInfo = new NodeInfo(temp.getStartOffset(), temp.getEndOffset(),
97.660 - temp.getName(), temp.getAlias(), temp.getType());
97.661 - DefaultMutableTreeNode node = new DefaultMutableTreeNode(nodeInfo);
97.662 - lastInsertionIndex = getRootIndex(root, node, lastInsertionIndex);
97.663 - treeModel.insertNodeInto(node, root, lastInsertionIndex);
97.664 - } else if (type == PlsqlBlockType.PROCEDURE_IMPL) { //Leaf node
97.665 + NodeInfo nodeInfo = new NodeInfo(temp.getStartOffset(), temp.getEndOffset(),
97.666 + temp.getName(), temp.getAlias(), temp.getType());
97.667 + DefaultMutableTreeNode node = new DefaultMutableTreeNode(nodeInfo);
97.668 + lastInsertionIndex = getRootIndex(root, node, lastInsertionIndex);
97.669 + treeModel.insertNodeInto(node, root, lastInsertionIndex);
97.670 + } else if (type == PlsqlBlockType.PROCEDURE_IMPL) { //Leaf node
97.671
97.672 - NodeInfo nodeInfo = new NodeInfo(temp.getStartOffset(), temp.getEndOffset(),
97.673 - temp.getName(), temp.getAlias(), temp.getType());
97.674 - DefaultMutableTreeNode node = new DefaultMutableTreeNode(nodeInfo);
97.675 - lastInsertionIndex = getRootIndex(root, node, lastInsertionIndex);
97.676 - treeModel.insertNodeInto(node, root, lastInsertionIndex);
97.677 - }
97.678 + NodeInfo nodeInfo = new NodeInfo(temp.getStartOffset(), temp.getEndOffset(),
97.679 + temp.getName(), temp.getAlias(), temp.getType());
97.680 + DefaultMutableTreeNode node = new DefaultMutableTreeNode(nodeInfo);
97.681 + lastInsertionIndex = getRootIndex(root, node, lastInsertionIndex);
97.682 + treeModel.insertNodeInto(node, root, lastInsertionIndex);
97.683 + }
97.684 + }
97.685 }
97.686 - }
97.687 - }
97.688 + }
97.689
97.690 // jTree1.updateUI();
97.691 - }
97.692 + }
97.693
97.694 /**
97.695 * Opens and focusses on the appropriate location of the document when the
97.696 @@ -820,6 +826,7 @@
97.697 }
97.698 SwingUtilities.invokeLater(new Runnable() {
97.699
97.700 + @Override
97.701 public void run() {
97.702 JEditorPane[] panes = ec.getOpenedPanes();
97.703 if (panes != null && panes.length > 0) {
97.704 @@ -857,9 +864,9 @@
97.705 DefaultMutableTreeNode node = (DefaultMutableTreeNode) parentNode.getChildAt(i);
97.706 if (node.getUserObject() instanceof NodeInfo) {
97.707 NodeInfo nodeInfo = (NodeInfo) node.getUserObject();
97.708 - if ((nodeInfo.name.equals(block.getName())) &&
97.709 - (nodeInfo.startOffset == block.getStartOffset()) &&
97.710 - (nodeInfo.endOffset == block.getEndOffset())) {
97.711 + if ((nodeInfo.name.equals(block.getName()))
97.712 + && (nodeInfo.startOffset == block.getStartOffset())
97.713 + && (nodeInfo.endOffset == block.getEndOffset())) {
97.714 //we found the match
97.715 treeModel.removeNodeFromParent(node);
97.716 return true;
97.717 @@ -896,14 +903,15 @@
97.718 * @param pane The the editor pane which the document exists.
97.719 */
97.720 private void selectElementInPane(final JEditorPane pane) {
97.721 - RequestProcessor.getDefault().post(new Runnable() {
97.722 + RP.post(new Runnable() {
97.723
97.724 + @Override
97.725 public void run() {
97.726 BaseDocument bdoc = (BaseDocument) getDocument();
97.727 try {
97.728 pane.setCaretPosition(Utilities.getRowStart(bdoc, startOffset));
97.729 } catch (BadLocationException ex) {
97.730 - ex.printStackTrace();
97.731 + Exceptions.printStackTrace(ex);
97.732 }
97.733 }
97.734 });
97.735 @@ -961,10 +969,10 @@
97.736 }
97.737
97.738 if ((userObj instanceof NodeInfo) && (childUserObj instanceof NodeInfo)) {
97.739 - if ((((NodeInfo) userObj).type == PlsqlBlockType.PACKAGE) ||
97.740 - (((NodeInfo) userObj).type == PlsqlBlockType.PACKAGE_BODY)) {
97.741 - if ((((NodeInfo) childUserObj).type != PlsqlBlockType.PACKAGE) &&
97.742 - (((NodeInfo) childUserObj).type != PlsqlBlockType.PACKAGE_BODY)) {
97.743 + if ((((NodeInfo) userObj).type == PlsqlBlockType.PACKAGE)
97.744 + || (((NodeInfo) userObj).type == PlsqlBlockType.PACKAGE_BODY)) {
97.745 + if ((((NodeInfo) childUserObj).type != PlsqlBlockType.PACKAGE)
97.746 + && (((NodeInfo) childUserObj).type != PlsqlBlockType.PACKAGE_BODY)) {
97.747 continue;
97.748 }
97.749 }
97.750 @@ -1010,10 +1018,10 @@
97.751 NodeInfo block = (NodeInfo) (node.getUserObject());
97.752 if (PlsqlBlockType.VIEW == block.type) {
97.753 return viewIcon;
97.754 - } else if ((PlsqlBlockType.PROCEDURE_IMPL == block.type) ||
97.755 - (PlsqlBlockType.FUNCTION_IMPL == block.type) ||
97.756 - (PlsqlBlockType.FUNCTION_DEF == block.type) ||
97.757 - (PlsqlBlockType.PROCEDURE_DEF == block.type)) {
97.758 + } else if ((PlsqlBlockType.PROCEDURE_IMPL == block.type)
97.759 + || (PlsqlBlockType.FUNCTION_IMPL == block.type)
97.760 + || (PlsqlBlockType.FUNCTION_DEF == block.type)
97.761 + || (PlsqlBlockType.PROCEDURE_DEF == block.type)) {
97.762 if (block.name.endsWith("___")) {
97.763 return implementationMethodIcon;
97.764 } else if (block.name.endsWith("___")) {
97.765 @@ -1025,8 +1033,8 @@
97.766 } else {
97.767 return publicMethodIcon;
97.768 }
97.769 - } else if (PlsqlBlockType.PACKAGE == block.type ||
97.770 - PlsqlBlockType.PACKAGE_BODY == block.type) {
97.771 + } else if (PlsqlBlockType.PACKAGE == block.type
97.772 + || PlsqlBlockType.PACKAGE_BODY == block.type) {
97.773 return pkgIcon;
97.774 }
97.775 }
98.1 --- a/PLSQL/Navigator/src/org/netbeans/modules/plsql/navigator/PlsqlNavigatorImpl.java Tue Feb 14 17:36:37 2012 +0100
98.2 +++ b/PLSQL/Navigator/src/org/netbeans/modules/plsql/navigator/PlsqlNavigatorImpl.java Wed Aug 15 20:45:01 2012 +0200
98.3 @@ -175,7 +175,7 @@
98.4 editorDocument = ec.openDocument();
98.5 blockFactory.initHierarchy(editorDocument);
98.6 } catch (IOException ex) {
98.7 - ex.printStackTrace();
98.8 + Exceptions.printStackTrace(ex);
98.9 }
98.10
98.11 if (oldObserver != null) {
99.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
99.2 +++ b/PLSQL/Navigator/src/org/netbeans/modules/plsql/navigator/PlsqlSearchProvider.java Wed Aug 15 20:45:01 2012 +0200
99.3 @@ -0,0 +1,136 @@
99.4 +/*
99.5 + * To change this template, choose Tools | Templates
99.6 + * and open the template in the editor.
99.7 + */
99.8 +package org.netbeans.modules.plsql.navigator;
99.9 +
99.10 +import java.io.File;
99.11 +import java.util.*;
99.12 +import java.util.regex.Pattern;
99.13 +import org.netbeans.api.db.explorer.DatabaseConnection;
99.14 +import org.netbeans.api.project.Project;
99.15 +import org.netbeans.api.project.ui.OpenProjects;
99.16 +import org.netbeans.modules.plsql.lexer.PlsqlBlockType;
99.17 +import org.netbeans.modules.plsql.utilities.NotConnectedToDbException;
99.18 +import org.netbeans.modules.plsql.utilities.PlsqlFileLocatorService;
99.19 +import org.netbeans.modules.plsql.utilities.PlsqlFileUtil;
99.20 +import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
99.21 +import org.netbeans.modules.plsqlsupport.db.DatabaseContentManager;
99.22 +import org.netbeans.spi.quicksearch.SearchProvider;
99.23 +import org.netbeans.spi.quicksearch.SearchRequest;
99.24 +import org.netbeans.spi.quicksearch.SearchResponse;
99.25 +import org.openide.cookies.OpenCookie;
99.26 +import org.openide.loaders.DataObject;
99.27 +import org.openide.util.Exceptions;
99.28 +import org.openide.util.Lookup;
99.29 +
99.30 +public class PlsqlSearchProvider implements SearchProvider {
99.31 +
99.32 + final static String MODEL_DIRECTORY_PATH = "#COMPONENT#" + File.separator + "database" + File.separator + "#COMPONENT#";
99.33 + private final PlsqlFileLocatorService locatorService = Lookup.getDefault().lookup(PlsqlFileLocatorService.class);
99.34 +
99.35 + /**
99.36 + * Method is called by infrastructure when search operation was requested. Implementors should evaluate given
99.37 + * request and fill response object with appropriate results
99.38 + *
99.39 + * @param request Search request object that contains information what to search for
99.40 + * @param response Search response object that stores search results. Note that it's important to react to return
99.41 + * value of SearchResponse.addResult(...) method and stop computation if false value is returned.
99.42 + */
99.43 + @Override
99.44 + public void evaluate(SearchRequest request, SearchResponse response) {
99.45 + Project[] projects = OpenProjects.getDefault().getOpenProjects();
99.46 +
99.47 + String query = request.getText().toLowerCase();
99.48 + boolean useRegExp = query.contains("*");
99.49 + if (useRegExp) {
99.50 + query = query.replaceAll("\\.", "\\.");
99.51 + query = query.replaceAll("\\*", ".*");
99.52 + }
99.53 +
99.54 + for (Project project : projects) {
99.55 + //For Local Files
99.56 + Collection<File> allObjects = locatorService.getAllPlsqlFiles(project);
99.57 + if (allObjects != null) {
99.58 + for (File fileObj : allObjects) {
99.59 + String name = fileObj.getName().toLowerCase().substring(0, fileObj.getName().indexOf("."));
99.60 + boolean match = useRegExp ? Pattern.matches(query, name) : name.contains(query);
99.61 + if (match) {
99.62 + if (!response.addResult(new OpenLocalPlsqlFile(fileObj.getPath()), fileObj.getName() + "(" + project.getProjectDirectory().getName() + ")")) {
99.63 + return;
99.64 + }
99.65 + }
99.66 + }
99.67 + }
99.68 +
99.69 + //for Package files in DB. Do not consider tables, views, etc
99.70 + Set<String> DBFiles = getPlsqlFilesFromDB(project);
99.71 + for (String DBFile : DBFiles) {
99.72 + boolean match = useRegExp ? Pattern.matches(query, DBFile.toLowerCase()) : DBFile.toLowerCase().contains(query);
99.73 + if (match) {
99.74 + if (!response.addResult(new OpenPlsqlFileFromDB(DBFile, project), DBFile.toLowerCase() + " (" + project.getProjectDirectory().getName() + ")")) {
99.75 + return;
99.76 + }
99.77 + }
99.78 + }
99.79 + }
99.80 + }
99.81 +
99.82 + private Set<String> getPlsqlFilesFromDB(Project project) {
99.83 + Set<String> allPackages = new HashSet<String>();
99.84 + DatabaseConnectionManager connectionProvider = project.getLookup().lookup(DatabaseConnectionManager.class);
99.85 + if (connectionProvider != null) {
99.86 + DatabaseContentManager cache = DatabaseContentManager.getInstance(connectionProvider.getTemplateConnection());
99.87 + if (cache != null) {
99.88 + allPackages = (Set<String>) cache.getAllPackages();
99.89 + }
99.90 + }
99.91 + return allPackages;
99.92 + }
99.93 +
99.94 + private static class OpenLocalPlsqlFile implements Runnable {
99.95 +
99.96 + String filePath;
99.97 +
99.98 + public OpenLocalPlsqlFile(String filePath_) {
99.99 + filePath = filePath_;
99.100 + }
99.101 +
99.102 + @Override
99.103 + public void run() {
99.104 + DataObject dataObj = PlsqlFileUtil.getDataObject(filePath);
99.105 + if (dataObj != null) {
99.106 + OpenCookie openCookie = dataObj.getCookie(OpenCookie.class);
99.107 + openCookie.open();
99.108 + }
99.109 + }
99.110 + }
99.111 +
99.112 + private static class OpenPlsqlFileFromDB implements Runnable {
99.113 +
99.114 + String packageName;
99.115 + Project project;
99.116 +
99.117 + public OpenPlsqlFileFromDB(String packageName_, Project project_) {
99.118 + packageName = packageName_;
99.119 + project = project_;
99.120 + }
99.121 +
99.122 + @Override
99.123 + public void run() {
99.124 + final DatabaseConnectionManager connectionProvider = DatabaseConnectionManager.getInstance(project);
99.125 + DatabaseConnection databaseConnection = connectionProvider.getPooledDatabaseConnection(false);
99.126 + DataObject dataObj;
99.127 + try {
99.128 + dataObj = PlsqlFileUtil.fetchAsTempFile(packageName, PlsqlBlockType.PACKAGE_BODY, databaseConnection, project, null);
99.129 +
99.130 + if (dataObj != null) {
99.131 + OpenCookie openCookie = dataObj.getCookie(OpenCookie.class);
99.132 + openCookie.open();
99.133 + }
99.134 + } catch (NotConnectedToDbException ex) {
99.135 + Exceptions.printStackTrace(ex);
99.136 + }
99.137 + }
99.138 + }
99.139 +}
100.1 --- a/PLSQL/Navigator/src/org/netbeans/modules/plsql/navigator/layer.xml Tue Feb 14 17:36:37 2012 +0100
100.2 +++ b/PLSQL/Navigator/src/org/netbeans/modules/plsql/navigator/layer.xml Wed Aug 15 20:45:01 2012 +0200
100.3 @@ -1,5 +1,5 @@
100.4 <?xml version="1.0" encoding="UTF-8"?>
100.5 -<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
100.6 +<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
100.7 <filesystem>
100.8 <folder name="Navigator">
100.9 <folder name="Panels">
100.10 @@ -10,4 +10,15 @@
100.11 </folder>
100.12 </folder>
100.13 </folder>
100.14 + <folder name="QuickSearch">
100.15 + <folder name="Database Files">
100.16 + <folder name="SQL">
100.17 + <attr name="command" stringvalue="nb"/>
100.18 + <attr name="position" intvalue="0"/>
100.19 + <file name="org-netbeans-modules-plsql-navigator-PlsqlSearchProvider.instance">
100.20 + <attr name="displayName" bundlevalue="org.netbeans.modules.plsql.navigator.Bundle#QuickSearch/PL/SQL/org-netbeans-modules-plsql-navigator-PlsqlSearchProvider.instance"/>
100.21 + </file>
100.22 + </folder>
100.23 + </folder>
100.24 + </folder>
100.25 </filesystem>
101.1 --- a/PLSQL/Palette/manifest.mf Tue Feb 14 17:36:37 2012 +0100
101.2 +++ b/PLSQL/Palette/manifest.mf Wed Aug 15 20:45:01 2012 +0200
101.3 @@ -7,6 +7,6 @@
101.4 OpenIDE-Module-Layer: org/netbeans/modules/plsql/palette/layer.xml
101.5 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/plsql/palette/B
101.6 undle.properties
101.7 -OpenIDE-Module-Specification-Version: 1.8.9
101.8 +OpenIDE-Module-Specification-Version: 1.8.10
101.9 AutoUpdate-Show-In-Client: false
101.10
102.1 --- a/PLSQL/Palette/nbproject/project.properties Tue Feb 14 17:36:37 2012 +0100
102.2 +++ b/PLSQL/Palette/nbproject/project.properties Wed Aug 15 20:45:01 2012 +0200
102.3 @@ -1,2 +1,9 @@
102.4 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
102.5 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=4
102.6 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=4
102.7 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
102.8 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=120
102.9 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
102.10 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
102.11 javac.source=1.6
102.12 javac.compilerargs=-Xlint -Xlint:-serial
103.1 --- a/PLSQL/Palette/src/org/netbeans/modules/plsql/palette/PlsqlPaletteUtilities.java Tue Feb 14 17:36:37 2012 +0100
103.2 +++ b/PLSQL/Palette/src/org/netbeans/modules/plsql/palette/PlsqlPaletteUtilities.java Wed Aug 15 20:45:01 2012 +0200
103.3 @@ -48,6 +48,7 @@
103.4 import org.netbeans.editor.BaseDocument;
103.5 import org.netbeans.lib.editor.codetemplates.api.CodeTemplate;
103.6 import org.netbeans.lib.editor.codetemplates.api.CodeTemplateManager;
103.7 +import org.openide.util.Exceptions;
103.8
103.9
103.10 /*
103.11 @@ -95,11 +96,12 @@
103.12 if (doc instanceof BaseDocument) {
103.13 ((BaseDocument) doc).runAtomic(new Runnable() {
103.14
103.15 + @Override
103.16 public void run() {
103.17 try {
103.18 insert(s, target, doc);
103.19 } catch (BadLocationException ex) {
103.20 - ex.printStackTrace();
103.21 + Exceptions.printStackTrace(ex);
103.22 }
103.23 }
103.24 });
103.25 @@ -125,16 +127,16 @@
103.26 int p1 = Math.max(caret.getDot(), caret.getMark());
103.27 doc.remove(p0, p1 - p0);
103.28 start = caret.getDot();
103.29 -
103.30 +
103.31 //Insert the text as a code template
103.32 if (target != null) {
103.33 CodeTemplate ct = CodeTemplateManager.get(target.getDocument()).createTemporary(s);
103.34 - ct.insert(target);
103.35 - }
103.36 + ct.insert(target);
103.37 + }
103.38 } catch (BadLocationException ble) {
103.39 - ble.printStackTrace();
103.40 + Exceptions.printStackTrace(ble);
103.41 }
103.42
103.43 return start;
103.44 - }
103.45 + }
103.46 }
104.1 --- a/PLSQL/Project/manifest.mf Tue Feb 14 17:36:37 2012 +0100
104.2 +++ b/PLSQL/Project/manifest.mf Wed Aug 15 20:45:01 2012 +0200
104.3 @@ -5,5 +5,5 @@
104.4 OpenIDE-Module: org.netbeans.modules.plsqlsupport.db.project
104.5 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/plsqlsupport/db
104.6 /project/Bundle.properties
104.7 -OpenIDE-Module-Specification-Version: 1.0.1
104.8 +OpenIDE-Module-Specification-Version: 1.0.2
104.9
105.1 --- a/PLSQL/Project/nbproject/project.properties Tue Feb 14 17:36:37 2012 +0100
105.2 +++ b/PLSQL/Project/nbproject/project.properties Wed Aug 15 20:45:01 2012 +0200
105.3 @@ -1,2 +1,9 @@
105.4 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
105.5 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=4
105.6 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=4
105.7 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
105.8 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=120
105.9 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
105.10 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
105.11 javac.source=1.6
105.12 javac.compilerargs=-Xlint -Xlint:-serial
106.1 --- a/PLSQL/Project/src/org/netbeans/modules/plsqlsupport/db/project/DatabasePanel.java Tue Feb 14 17:36:37 2012 +0100
106.2 +++ b/PLSQL/Project/src/org/netbeans/modules/plsqlsupport/db/project/DatabasePanel.java Wed Aug 15 20:45:01 2012 +0200
106.3 @@ -66,76 +66,78 @@
106.4
106.5 public class DatabasePanel extends JPanel {
106.6
106.7 - public static final String DATA_VALID = "dataValid";
106.8 + public static final String DATA_VALID = "dataValid";
106.9 + private Category category;
106.10 + private DefaultTableModel connectionTableModel;
106.11 + private DatabaseConnection mainConnection;
106.12 + private boolean valid = true;
106.13 + private ValidationInvoker validationInvoker = new ValidationInvoker();
106.14
106.15 - private Category category;
106.16 - private DefaultTableModel connectionTableModel;
106.17 - private DatabaseConnection mainConnection;
106.18 + public DatabasePanel(Category category) {
106.19 + this.category = category;
106.20 + initComponents();
106.21 + connectionTableModel = (DefaultTableModel) connectionTable.getModel();
106.22 + TableColumn connectionTableColumn = connectionTable.getColumnModel().getColumn(0);
106.23 + connectionTableColumn.setCellEditor(new CellEditor());
106.24 + connectionTableColumn.setCellRenderer(new CellRenderer());
106.25 + connectionTable.setRowHeight(connectionTable.getRowHeight() + 4);
106.26 + connectionTableModel.addTableModelListener(validationInvoker);
106.27 + connectionTable.getColumnModel().getSelectionModel().addListSelectionListener(validationInvoker);
106.28 + performValidation();
106.29 + }
106.30
106.31 - private boolean valid = true;
106.32 - private ValidationInvoker validationInvoker = new ValidationInvoker();
106.33 + public List<DatabaseConnection> getDatabaseConnections() {
106.34 + List<DatabaseConnection> connections = new ArrayList<DatabaseConnection>();
106.35 + if (mainConnection != null) {
106.36 + connections.add(mainConnection);
106.37 + }
106.38 + for (int i = 0; i < connectionTableModel.getRowCount(); i++) {
106.39 + Object item = connectionTableModel.getValueAt(i, 0);
106.40 + if (item instanceof DatabaseConnection) {
106.41 + DatabaseConnection connection = (DatabaseConnection) item;
106.42 + if (!connections.contains(connection)) {
106.43 + connections.add(connection);
106.44 + }
106.45 + }
106.46 + }
106.47 + return connections;
106.48 + }
106.49
106.50 - public DatabasePanel(Category category) {
106.51 - this.category = category;
106.52 - initComponents();
106.53 - connectionTableModel = (DefaultTableModel)connectionTable.getModel();
106.54 - TableColumn connectionTableColumn = connectionTable.getColumnModel().getColumn(0);
106.55 - connectionTableColumn.setCellEditor(new CellEditor());
106.56 - connectionTableColumn.setCellRenderer(new CellRenderer());
106.57 - connectionTable.setRowHeight(connectionTable.getRowHeight() + 4);
106.58 - connectionTableModel.addTableModelListener(validationInvoker);
106.59 - connectionTable.getColumnModel().getSelectionModel().addListSelectionListener(validationInvoker);
106.60 - performValidation();
106.61 - }
106.62 + public void setDatabaseConnections(List<DatabaseConnection> connections) {
106.63 + connectionTableModel.setRowCount(0);
106.64 + for (DatabaseConnection connection : connections) {
106.65 + connectionTableModel.addRow(new Object[]{connection});
106.66 + }
106.67 + if (!connections.isEmpty()) {
106.68 + mainConnection = connections.get(0);
106.69 + }
106.70 + }
106.71
106.72 - public DatabaseConnection[] getDatabaseConnections() {
106.73 - List<DatabaseConnection> connections = new ArrayList<DatabaseConnection>();
106.74 - if (mainConnection != null)
106.75 - connections.add(mainConnection);
106.76 - for (int i = 0; i < connectionTableModel.getRowCount(); i++) {
106.77 - Object item = connectionTableModel.getValueAt(i, 0);
106.78 - if (item instanceof DatabaseConnection) {
106.79 - DatabaseConnection connection = (DatabaseConnection)item;
106.80 - if (!connections.contains(connection))
106.81 - connections.add(connection);
106.82 - }
106.83 - }
106.84 - return connections.toArray(new DatabaseConnection[connections.size()]);
106.85 - }
106.86 + private void performValidation() {
106.87 + int row = connectionTable.getSelectedRow();
106.88 + boolean hasSelection = row != -1;
106.89 + boolean hasSelectedConnection = hasSelection && connectionTableModel.getRowCount() > row
106.90 + && connectionTableModel.getValueAt(row, 0) instanceof DatabaseConnection;
106.91 + btnRemove.setEnabled(hasSelection);
106.92 + btnSetAsMain.setEnabled(hasSelectedConnection);
106.93
106.94 - public void setDatabaseConnections(DatabaseConnection[] connections) {
106.95 - connectionTableModel.setRowCount(0);
106.96 - for (DatabaseConnection connection : connections)
106.97 - connectionTableModel.addRow(new Object[] {connection});
106.98 - if (connections.length > 0)
106.99 - mainConnection = connections[0];
106.100 - }
106.101 + String errorMessage = "";
106.102
106.103 - private void performValidation() {
106.104 - int row = connectionTable.getSelectedRow();
106.105 - boolean hasSelection = row != -1;
106.106 - boolean hasSelectedConnection = hasSelection && connectionTableModel.getRowCount() > row
106.107 - && connectionTableModel.getValueAt(row, 0) instanceof DatabaseConnection;
106.108 - btnRemove.setEnabled(hasSelection);
106.109 - btnSetAsMain.setEnabled(hasSelectedConnection);
106.110 + for (DatabaseConnection connection : getDatabaseConnections()) {
106.111 + if (!connection.getDriverClass().equals(DatabaseConnectionManager.ORACLE_DRIVER_CLASS_NAME)) {
106.112 + errorMessage += NbBundle.getMessage(getClass(), "MSG_NonOracleDatabaseChosen");
106.113 + break;
106.114 + }
106.115 + }
106.116
106.117 - String errorMessage = "";
106.118 + boolean wasValid = valid;
106.119 + valid = errorMessage.equals("");
106.120 + category.setValid(valid);
106.121 + category.setErrorMessage(errorMessage);
106.122 + firePropertyChange(DATA_VALID, wasValid, valid);
106.123 + }
106.124
106.125 - DatabaseConnection[] connections = getDatabaseConnections();
106.126 - for (DatabaseConnection connection : connections)
106.127 - if (!connection.getDriverClass().equals(DatabaseConnectionManager.ORACLE_DRIVER_CLASS_NAME)) {
106.128 - errorMessage += NbBundle.getMessage(getClass(), "MSG_NonOracleDatabaseChosen");
106.129 - break;
106.130 - }
106.131 -
106.132 - boolean wasValid = valid;
106.133 - valid = errorMessage.equals("");
106.134 - category.setValid(valid);
106.135 - category.setErrorMessage(errorMessage);
106.136 - firePropertyChange(DATA_VALID, wasValid, valid);
106.137 - }
106.138 -
106.139 - @SuppressWarnings("unchecked")
106.140 + @SuppressWarnings("unchecked")
106.141 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
106.142 private void initComponents() {
106.143
106.144 @@ -215,35 +217,37 @@
106.145 }// </editor-fold>//GEN-END:initComponents
106.146
106.147 private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddActionPerformed
106.148 - connectionTableModel.addRow((Object[])null);
106.149 - connectionTable.editCellAt(connectionTableModel.getRowCount() - 1, 0);
106.150 + connectionTableModel.addRow((Object[]) null);
106.151 + connectionTable.editCellAt(connectionTableModel.getRowCount() - 1, 0);
106.152 }//GEN-LAST:event_btnAddActionPerformed
106.153
106.154 private void btnRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveActionPerformed
106.155 - int row = connectionTable.getSelectedRow();
106.156 - assert row != -1;
106.157 - TableCellEditor editor = connectionTable.getCellEditor();
106.158 - if (editor != null)
106.159 - editor.stopCellEditing();
106.160 - DatabaseConnection connection = (DatabaseConnection)connectionTableModel.getValueAt(row, 0);
106.161 - if (connection == mainConnection)
106.162 - mainConnection = null;
106.163 - connectionTableModel.removeRow(row);
106.164 + int row = connectionTable.getSelectedRow();
106.165 + assert row != -1;
106.166 + TableCellEditor editor = connectionTable.getCellEditor();
106.167 + if (editor != null) {
106.168 + editor.stopCellEditing();
106.169 + }
106.170 + DatabaseConnection connection = (DatabaseConnection) connectionTableModel.getValueAt(row, 0);
106.171 + if (connection == mainConnection) {
106.172 + mainConnection = null;
106.173 + }
106.174 + connectionTableModel.removeRow(row);
106.175 }//GEN-LAST:event_btnRemoveActionPerformed
106.176
106.177 private void btnSetAsMainActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSetAsMainActionPerformed
106.178 - int row = connectionTable.getSelectedRow();
106.179 - assert row != -1;
106.180 - Object item = connectionTableModel.getValueAt(row, 0);
106.181 - if (item instanceof DatabaseConnection) {
106.182 - mainConnection = (DatabaseConnection)item;
106.183 - connectionTableModel.fireTableDataChanged();
106.184 - TableCellEditor cellEditor = connectionTable.getCellEditor();
106.185 - if(cellEditor!=null)
106.186 - cellEditor.stopCellEditing();
106.187 - }
106.188 + int row = connectionTable.getSelectedRow();
106.189 + assert row != -1;
106.190 + Object item = connectionTableModel.getValueAt(row, 0);
106.191 + if (item instanceof DatabaseConnection) {
106.192 + mainConnection = (DatabaseConnection) item;
106.193 + connectionTableModel.fireTableDataChanged();
106.194 + TableCellEditor cellEditor = connectionTable.getCellEditor();
106.195 + if (cellEditor != null) {
106.196 + cellEditor.stopCellEditing();
106.197 + }
106.198 + }
106.199 }//GEN-LAST:event_btnSetAsMainActionPerformed
106.200 -
106.201 // Variables declaration - do not modify//GEN-BEGIN:variables
106.202 private javax.swing.JButton btnAdd;
106.203 private javax.swing.JButton btnRemove;
106.204 @@ -253,47 +257,52 @@
106.205 private javax.swing.JLabel databaseConnectionLabel;
106.206 // End of variables declaration//GEN-END:variables
106.207
106.208 - private class ValidationInvoker implements TableModelListener, ListSelectionListener {
106.209 + private class ValidationInvoker implements TableModelListener, ListSelectionListener {
106.210
106.211 - public ValidationInvoker() {}
106.212 + public ValidationInvoker() {
106.213 + }
106.214
106.215 - public void tableChanged(TableModelEvent e) {
106.216 - performValidation();
106.217 - }
106.218 + @Override
106.219 + public void tableChanged(TableModelEvent e) {
106.220 + performValidation();
106.221 + }
106.222
106.223 - public void valueChanged(ListSelectionEvent e) {
106.224 - performValidation();
106.225 - }
106.226 - }
106.227 + @Override
106.228 + public void valueChanged(ListSelectionEvent e) {
106.229 + performValidation();
106.230 + }
106.231 + }
106.232
106.233 - private static class CellEditor extends DefaultCellEditor {
106.234 + private static class CellEditor extends DefaultCellEditor {
106.235
106.236 - public CellEditor() {
106.237 - super(new JComboBox());
106.238 - DatabaseExplorerUIs.connect((JComboBox)editorComponent, ConnectionManager.getDefault());
106.239 - }
106.240 + public CellEditor() {
106.241 + super(new JComboBox());
106.242 + DatabaseExplorerUIs.connect((JComboBox) editorComponent, ConnectionManager.getDefault());
106.243 + }
106.244
106.245 - @Override
106.246 - public Object getCellEditorValue() {
106.247 - Object item = ((JComboBox)editorComponent).getSelectedItem();
106.248 - return item instanceof DatabaseConnection ? (DatabaseConnection)item : null;
106.249 - }
106.250 - }
106.251 + @Override
106.252 + public Object getCellEditorValue() {
106.253 + Object item = ((JComboBox) editorComponent).getSelectedItem();
106.254 + return item instanceof DatabaseConnection ? (DatabaseConnection) item : null;
106.255 + }
106.256 + }
106.257
106.258 - private class CellRenderer extends DefaultTableCellRenderer {
106.259 + private class CellRenderer extends DefaultTableCellRenderer {
106.260
106.261 - public CellRenderer() {}
106.262 + public CellRenderer() {
106.263 + }
106.264
106.265 - @Override
106.266 - public Component getTableCellRendererComponent(JTable table, Object value,
106.267 - boolean selected, boolean hasFocus, int row, int column) {
106.268 - super.getTableCellRendererComponent(table, value, selected, hasFocus, row, column);
106.269 - if (value != null) {
106.270 - setText(((DatabaseConnection)value).getName());
106.271 - if (value == mainConnection)
106.272 - setFont(getFont().deriveFont(Font.BOLD));
106.273 - }
106.274 - return this;
106.275 - }
106.276 - }
106.277 + @Override
106.278 + public Component getTableCellRendererComponent(JTable table, Object value,
106.279 + boolean selected, boolean hasFocus, int row, int column) {
106.280 + super.getTableCellRendererComponent(table, value, selected, hasFocus, row, column);
106.281 + if (value != null) {
106.282 + setText(((DatabaseConnection) value).getName());
106.283 + if (value == mainConnection) {
106.284 + setFont(getFont().deriveFont(Font.BOLD));
106.285 + }
106.286 + }
106.287 + return this;
106.288 + }
106.289 + }
106.290 }
107.1 --- a/PLSQL/Project/src/org/netbeans/modules/plsqlsupport/db/project/DatabasePropertiesPersister.java Tue Feb 14 17:36:37 2012 +0100
107.2 +++ b/PLSQL/Project/src/org/netbeans/modules/plsqlsupport/db/project/DatabasePropertiesPersister.java Wed Aug 15 20:45:01 2012 +0200
107.3 @@ -73,9 +73,9 @@
107.4 if (fields.length == 4) {
107.5 DatabaseConnection connection = null;
107.6 for (DatabaseConnection c : ConnectionManager.getDefault().getConnections()) {
107.7 - if (c.getDatabaseURL().equalsIgnoreCase(fields[0]) &&
107.8 - c.getUser().equalsIgnoreCase(fields[1]) &&
107.9 - c.getSchema().equalsIgnoreCase(fields[3])) {
107.10 + if (c.getDatabaseURL().equalsIgnoreCase(fields[0])
107.11 + && c.getUser().equalsIgnoreCase(fields[1])
107.12 + && c.getSchema().equalsIgnoreCase(fields[3])) {
107.13 connection = c;
107.14 }
107.15 }
107.16 @@ -98,16 +98,16 @@
107.17 }
107.18 }
107.19 }
107.20 - manager.setDatabaseConnections(connections.toArray(new DatabaseConnection[connections.size()]));
107.21 + manager.setDatabaseConnections(connections);
107.22 }
107.23
107.24 @Override
107.25 protected void storeProperties(EditableProperties properties) {
107.26 - DatabaseConnection[] connections = manager.getDatabaseConnections();
107.27 - String[] connectionStrings = new String[connections.length];
107.28 - for (int i = 0; i < connections.length; i++) {
107.29 + List<DatabaseConnection> connections = manager.getDatabaseConnections();
107.30 + String[] connectionStrings = new String[connections.size()];
107.31 + for (int i = 0; i < connections.size(); i++) {
107.32 StringBuilder builder = new StringBuilder();
107.33 - DatabaseConnection connection = connections[i];
107.34 + DatabaseConnection connection = connections.get(i);
107.35 if (connection.getDatabaseURL() != null) {
107.36 builder.append(connection.getDatabaseURL());
107.37 }
107.38 @@ -123,13 +123,13 @@
107.39 if (connection.getSchema() != null) {
107.40 builder.append(connection.getSchema());
107.41 }
107.42 - connectionStrings[i] = builder.toString();
107.43 + connectionStrings[i] = builder.toString();
107.44 }
107.45 setProperty(properties, CONNECTIONS_KEY, connectionStrings);
107.46 //get appowner of main DB (i.e. the first connection)
107.47 String appowner = "";
107.48 - if (connections.length > 0){
107.49 - appowner = connections[0].getSchema();
107.50 + if (!connections.isEmpty()) {
107.51 + appowner = connections.get(0).getSchema();
107.52 }
107.53 setProperty(properties, DB_APPOWNER_KEY, appowner);
107.54 }
108.1 --- a/PLSQL/Utilities/manifest.mf Tue Feb 14 17:36:37 2012 +0100
108.2 +++ b/PLSQL/Utilities/manifest.mf Wed Aug 15 20:45:01 2012 +0200
108.3 @@ -5,5 +5,5 @@
108.4 OpenIDE-Module: org.netbeans.modules.plsql.utilities
108.5 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/plsql/utilities
108.6 /Bundle.properties
108.7 -OpenIDE-Module-Specification-Version: 1.7.20
108.8 +OpenIDE-Module-Specification-Version: 8.72.0.8
108.9
109.1 --- a/PLSQL/Utilities/nbproject/project.properties Tue Feb 14 17:36:37 2012 +0100
109.2 +++ b/PLSQL/Utilities/nbproject/project.properties Wed Aug 15 20:45:01 2012 +0200
109.3 @@ -1,2 +1,9 @@
109.4 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
109.5 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=4
109.6 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=4
109.7 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
109.8 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=120
109.9 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
109.10 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
109.11 javac.source=1.6
109.12 javac.compilerargs=-Xlint -Xlint:-serial
110.1 --- a/PLSQL/Utilities/src/org/netbeans/modules/plsql/utilities/Bundle.properties Tue Feb 14 17:36:37 2012 +0100
110.2 +++ b/PLSQL/Utilities/src/org/netbeans/modules/plsql/utilities/Bundle.properties Wed Aug 15 20:45:01 2012 +0200
110.3 @@ -1,2 +1,5 @@
110.4 OpenIDE-Module-Display-Category=PL/SQL Support
110.5 OpenIDE-Module-Name=PL/SQL Utilities
110.6 +SelectMethodDialog.jLabel1.text=Available Methods
110.7 +SelectMethodDialog.btnOk.text=OK
110.8 +SelectMethodDialog.title=Select Method
111.1 --- a/PLSQL/Utilities/src/org/netbeans/modules/plsql/utilities/PlsqlFileLocatorService.java Tue Feb 14 17:36:37 2012 +0100
111.2 +++ b/PLSQL/Utilities/src/org/netbeans/modules/plsql/utilities/PlsqlFileLocatorService.java Wed Aug 15 20:45:01 2012 +0200
111.3 @@ -41,8 +41,10 @@
111.4 */
111.5 package org.netbeans.modules.plsql.utilities;
111.6
111.7 +import java.io.File;
111.8 import org.netbeans.modules.plsql.lexer.PlsqlBlockType;
111.9 import java.io.IOException;
111.10 +import java.util.Collection;
111.11 import org.netbeans.api.project.Project;
111.12 import org.openide.filesystems.FileObject;
111.13 import org.openide.loaders.DataObject;
111.14 @@ -92,4 +94,10 @@
111.15 public void addFileToCache(Project project, FileObject fileObject) throws IOException;
111.16
111.17 public void rebuildCache(Project project);
111.18 +
111.19 + /**
111.20 + * Give all objects in a project.
111.21 + * @param project
111.22 + */
111.23 + public Collection<File> getAllPlsqlFiles(Project project);
111.24 }
112.1 --- a/PLSQL/Utilities/src/org/netbeans/modules/plsql/utilities/PlsqlFileUtil.java Tue Feb 14 17:36:37 2012 +0100
112.2 +++ b/PLSQL/Utilities/src/org/netbeans/modules/plsql/utilities/PlsqlFileUtil.java Wed Aug 15 20:45:01 2012 +0200
112.3 @@ -286,6 +286,9 @@
112.4 }
112.5
112.6 public static boolean fileChanged(final File tmpFile, final long lastModified) {
112.7 + if (lastModified == -1) {
112.8 + return false;
112.9 + }
112.10 if (tmpFile.exists()) {
112.11 if (lastModified == -1) {
112.12 return false;
113.1 --- a/PLSQL/Utilities/src/org/netbeans/modules/plsql/utilities/PlsqlParserUtil.java Tue Feb 14 17:36:37 2012 +0100
113.2 +++ b/PLSQL/Utilities/src/org/netbeans/modules/plsql/utilities/PlsqlParserUtil.java Wed Aug 15 20:45:01 2012 +0200
113.3 @@ -88,6 +88,73 @@
113.4 } else {
113.5 usageParams = fetchMethodDefParamTypes(source, startOffset);
113.6 }
113.7 +
113.8 + if (packageName == null || packageName.equals("")) {
113.9 + packageName = getPackageName(getBlockFactory(source), startOffset);
113.10 + }
113.11 +
113.12 + //Take PlsqlBlock one by one and compare the parameters
113.13 + for (int x = 0; x < matchList.size(); x++) {
113.14 + PlsqlBlock block = matchList.get(x);
113.15 + if (!(block.getParent() != null ? block.getParent().getName().equalsIgnoreCase(packageName) : true)) {
113.16 + continue; //If the parent block name is not the same this is not a match
113.17 + }
113.18 +
113.19 + List<String> params = fetchMethodDefParamTypes(dest, block.getStartOffset());
113.20 + int defaultNo = fetchDefaultParams(dest, block.getStartOffset());
113.21 + if (compareParameters(usageParams, params, defaultNo)) {
113.22 + match = block;
113.23 + break;
113.24 + }
113.25 + }
113.26 + //get method from user
113.27 + if(match == null && findBestMatch && matchList.size() > 0){
113.28 + if(matchList.size()==1){
113.29 + match = matchList.get(0);
113.30 + }
113.31 + else{
113.32 + match = getMethodFromUser(dest,matchList);
113.33 + }
113.34 + }
113.35 +
113.36 + return (match == null && findBestMatch && matchList.size() > 0) ? null : match;
113.37 + }
113.38 +
113.39 + private static PlsqlBlock getMethodFromUser(Document doc, List<PlsqlBlock> blocks) {
113.40 + SelectMethodDialog dialog = new SelectMethodDialog(null, true, doc, blocks);
113.41 + dialog.setVisible(true);
113.42 + return dialog.getSelectedPlsqlBlock();
113.43 + }
113.44 +
113.45 + /**
113.46 + * Method that will find & return list of matching FUNCTION/ PROCEDURE of the body file
113.47 + * @param blockHier
113.48 + * @param source
113.49 + * @param dest
113.50 + * @param name
113.51 + * @param startOffset
113.52 + * @param isUsage whether this is method usage
113.53 + * @param isImpl
113.54 + * @param findBestMatch whether best match is OK
113.55 + * @return
113.56 + */
113.57 + public static List<PlsqlBlock> findMatchingBlocks(final List<PlsqlBlock> blockHier, final Document source,
113.58 + final Document dest, final String name, String packageName, final int startOffset, final boolean isUsage, final boolean isImpl, final boolean findBestMatch) {
113.59 + PlsqlBlock match = null;
113.60 + final List<PlsqlBlock> matchList = new ArrayList<PlsqlBlock>();
113.61 + if (isImpl) {
113.62 + findMatchingImplBlocks(blockHier, name, matchList);
113.63 + } else {
113.64 + findMatchingDefBlocks(blockHier, name, matchList);
113.65 + }
113.66 +
113.67 + //There are several methods with the same name. Have to check the signature
113.68 + List<String> usageParams;
113.69 + if (isUsage) {
113.70 + usageParams = fetchMethodParamTypes(source, startOffset);
113.71 + } else {
113.72 + usageParams = fetchMethodDefParamTypes(source, startOffset);
113.73 + }
113.74
113.75 if (packageName == null || packageName.equals("")) {
113.76 packageName = getPackageName(getBlockFactory(source), startOffset);
113.77 @@ -107,9 +174,38 @@
113.78 break;
113.79 }
113.80 }
113.81 + if (match == null && findBestMatch) {
113.82 + List<PlsqlBlock> similarParaCountList = new ArrayList<PlsqlBlock>();
113.83 + int usageCount = fetchMethodParamsCount(source, startOffset);
113.84 + for (int x = 0; x < matchList.size(); x++) {
113.85 + PlsqlBlock block = matchList.get(x);
113.86 + if (!(block.getParent() != null ? block.getParent().getName().equalsIgnoreCase(packageName) : true)) {
113.87 + continue; //If the parent block name is not the same this is not a match
113.88 + }
113.89
113.90 - return (match == null && findBestMatch && matchList.size() > 0) ? null : match;
113.91 - }
113.92 + int count = fetchMethodParamsCount(dest, block.getStartOffset());
113.93 +
113.94 + if (usageCount == count) {
113.95 + similarParaCountList.add(block);
113.96 + }
113.97 + }
113.98 + if (similarParaCountList.size() > 0) {
113.99 + if (similarParaCountList.size() == 1) {
113.100 + match = similarParaCountList.get(0);
113.101 + } else {
113.102 + return similarParaCountList;
113.103 + }
113.104 + }
113.105 + if (match == null && matchList.size() > 0) {
113.106 + return matchList;
113.107 + }
113.108 + }
113.109 + List<PlsqlBlock> returnList = new ArrayList<PlsqlBlock>();
113.110 + if (match != null) {
113.111 + returnList.add(match);
113.112 + }
113.113 + return (match == null && findBestMatch && matchList.size() > 0) ? null : returnList;
113.114 + }
113.115
113.116 /**
113.117 * Compare given parameter lists
113.118 @@ -257,6 +353,50 @@
113.119 }
113.120 return params;
113.121 }
113.122 +
113.123 + private static int fetchMethodParamsCount(final Document doc, final int start) {
113.124 + int noOfParams = 0;
113.125 + final TokenHierarchy tokenHierarchy = TokenHierarchy.get(doc);
113.126 + @SuppressWarnings("unchecked")
113.127 + final TokenSequence<PlsqlTokenId> ts = tokenHierarchy.tokenSequence(PlsqlTokenId.language());
113.128 +
113.129 + if (ts != null) {
113.130 + ts.move(start);
113.131 + Token<PlsqlTokenId> token = ts.token();
113.132 + HashSet<String> keywords = new HashSet<String>();
113.133 + while (ts.moveNext()) {
113.134 + token = ts.token();
113.135 + if ((token.text().toString().equals(",")) || (token.text().toString().equals(")"))) {
113.136 + noOfParams++;
113.137 + }
113.138 +
113.139 + if ((token.text().toString().equalsIgnoreCase("IS")) || (token.text().toString().equals(")")) || (token.text().toString().equals(";"))) {
113.140 + break;
113.141 + }
113.142 + }
113.143 + }
113.144 + return noOfParams;
113.145 + }
113.146 +
113.147 + public static String fetchMethodHeader(final Document doc, final int start) {
113.148 + String header = "";
113.149 + final TokenHierarchy tokenHierarchy = TokenHierarchy.get(doc);
113.150 + @SuppressWarnings("unchecked")
113.151 + final TokenSequence<PlsqlTokenId> ts = tokenHierarchy.tokenSequence(PlsqlTokenId.language());
113.152 +
113.153 + if (ts != null) {
113.154 + ts.move(start);
113.155 + Token<PlsqlTokenId> token = ts.token();
113.156 + while (ts.moveNext()) {
113.157 + token = ts.token();
113.158 + header += token;
113.159 + if ((token.text().toString().equalsIgnoreCase("IS")) || (token.text().toString().equals(")")) || (token.text().toString().equals(";"))) {
113.160 + break;
113.161 + }
113.162 + }
113.163 + }
113.164 + return header;
113.165 + }
113.166
113.167 /**
113.168 * Method that will access the parameter types of the function/procedure definition
114.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
114.2 +++ b/PLSQL/Utilities/src/org/netbeans/modules/plsql/utilities/SelectMethodDialog.form Wed Aug 15 20:45:01 2012 +0200
114.3 @@ -0,0 +1,101 @@
114.4 +<?xml version="1.1" encoding="UTF-8" ?>
114.5 +
114.6 +<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
114.7 + <Properties>
114.8 + <Property name="defaultCloseOperation" type="int" value="2"/>
114.9 + <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
114.10 + <ResourceString bundle="org/netbeans/modules/plsql/utilities/Bundle.properties" key="SelectMethodDialog.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
114.11 + </Property>
114.12 + <Property name="locationByPlatform" type="boolean" value="true"/>
114.13 + </Properties>
114.14 + <SyntheticProperties>
114.15 + <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
114.16 + </SyntheticProperties>
114.17 + <AuxValues>
114.18 + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
114.19 + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
114.20 + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
114.21 + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
114.22 + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
114.23 + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
114.24 + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
114.25 + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
114.26 + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
114.27 + </AuxValues>
114.28 +
114.29 + <Layout>
114.30 + <DimensionLayout dim="0">
114.31 + <Group type="103" groupAlignment="0" attributes="0">
114.32 + <Group type="102" alignment="0" attributes="0">
114.33 + <EmptySpace max="-2" attributes="0"/>
114.34 + <Group type="103" groupAlignment="0" attributes="0">
114.35 + <Component id="jScrollPane1" alignment="0" min="-2" pref="463" max="-2" attributes="0"/>
114.36 + <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
114.37 + </Group>
114.38 + <EmptySpace max="-2" attributes="0"/>
114.39 + </Group>
114.40 + <Group type="102" alignment="1" attributes="0">
114.41 + <EmptySpace pref="274" max="32767" attributes="0"/>
114.42 + <Component id="btnOk" min="-2" max="-2" attributes="0"/>
114.43 + <EmptySpace max="-2" attributes="0"/>
114.44 + </Group>
114.45 + </Group>
114.46 + </DimensionLayout>
114.47 + <DimensionLayout dim="1">
114.48 + <Group type="103" groupAlignment="0" attributes="0">
114.49 + <Group type="102" alignment="0" attributes="0">
114.50 + <EmptySpace max="-2" attributes="0"/>
114.51 + <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
114.52 + <EmptySpace max="-2" attributes="0"/>
114.53 + <Component id="jScrollPane1" min="-2" pref="151" max="-2" attributes="0"/>
114.54 + <EmptySpace max="-2" attributes="0"/>
114.55 + <Component id="btnOk" min="-2" max="-2" attributes="0"/>
114.56 + <EmptySpace max="32767" attributes="0"/>
114.57 + </Group>
114.58 + </Group>
114.59 + </DimensionLayout>
114.60 + </Layout>
114.61 + <SubComponents>
114.62 + <Component class="javax.swing.JLabel" name="jLabel1">
114.63 + <Properties>
114.64 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
114.65 + <ResourceString bundle="org/netbeans/modules/plsql/utilities/Bundle.properties" key="SelectMethodDialog.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
114.66 + </Property>
114.67 + </Properties>
114.68 + </Component>
114.69 + <Container class="javax.swing.JScrollPane" name="jScrollPane1">
114.70 + <AuxValues>
114.71 + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
114.72 + </AuxValues>
114.73 +
114.74 + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
114.75 + <SubComponents>
114.76 + <Component class="javax.swing.JList" name="lstMethods">
114.77 + <Properties>
114.78 + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
114.79 + <StringArray count="5">
114.80 + <StringItem index="0" value="Item 1"/>
114.81 + <StringItem index="1" value="Item 2"/>
114.82 + <StringItem index="2" value="Item 3"/>
114.83 + <StringItem index="3" value="Item 4"/>
114.84 + <StringItem index="4" value="Item 5"/>
114.85 + </StringArray>
114.86 + </Property>
114.87 + <Property name="selectionMode" type="int" value="0"/>
114.88 + </Properties>
114.89 + </Component>
114.90 + </SubComponents>
114.91 + </Container>
114.92 + <Component class="javax.swing.JButton" name="btnOk">
114.93 + <Properties>
114.94 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
114.95 + <ResourceString bundle="org/netbeans/modules/plsql/utilities/Bundle.properties" key="SelectMethodDialog.btnOk.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
114.96 + </Property>
114.97 + <Property name="enabled" type="boolean" value="false"/>
114.98 + </Properties>
114.99 + <Events>
114.100 + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnOkActionPerformed"/>
114.101 + </Events>
114.102 + </Component>
114.103 + </SubComponents>
114.104 +</Form>
115.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
115.2 +++ b/PLSQL/Utilities/src/org/netbeans/modules/plsql/utilities/SelectMethodDialog.java Wed Aug 15 20:45:01 2012 +0200
115.3 @@ -0,0 +1,162 @@
115.4 +/*
115.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
115.6 + *
115.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
115.8 + *
115.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
115.10 + * Other names may be trademarks of their respective owners.
115.11 + *
115.12 + * The contents of this file are subject to the terms of either the GNU
115.13 + * General Public License Version 2 only ("GPL") or the Common
115.14 + * Development and Distribution License("CDDL") (collectively, the
115.15 + * "License"). You may not use this file except in compliance with the
115.16 + * License. You can obtain a copy of the License at
115.17 + * http://www.netbeans.org/cddl-gplv2.html
115.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
115.19 + * specific language governing permissions and limitations under the
115.20 + * License. When distributing the software, include this License Header
115.21 + * Notice in each file and include the License file at
115.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
115.23 + * particular file as subject to the "Classpath" exception as provided
115.24 + * by Oracle in the GPL Version 2 section of the License file that
115.25 + * accompanied this code. If applicable, add the following below the
115.26 + * License Header, with the fields enclosed by brackets [] replaced by
115.27 + * your own identifying information:
115.28 + * "Portions Copyrighted [year] [name of copyright owner]"
115.29 + *
115.30 + * If you wish your version of this file to be governed by only the CDDL
115.31 + * or only the GPL Version 2, indicate your decision by adding
115.32 + * "[Contributor] elects to include this software in this distribution
115.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
115.34 + * single choice of license, a recipient has the option to distribute
115.35 + * your version of this file under either the CDDL, the GPL Version 2 or
115.36 + * to extend the choice of license to its licensees as provided above.
115.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
115.38 + * Version 2 license, then the option applies only if the new code is
115.39 + * made subject to such option by the copyright holder.
115.40 + *
115.41 + * Contributor(s):
115.42 + *
115.43 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
115.44 + */
115.45 +package org.netbeans.modules.plsql.utilities;
115.46 +
115.47 +import java.util.ArrayList;
115.48 +import java.util.List;
115.49 +import javax.swing.event.ListSelectionEvent;
115.50 +import javax.swing.event.ListSelectionListener;
115.51 +import javax.swing.text.Document;
115.52 +import org.netbeans.modules.plsql.lexer.PlsqlBlock;
115.53 +
115.54 +/**
115.55 + *
115.56 + * @author shaalk
115.57 + */
115.58 +public class SelectMethodDialog extends javax.swing.JDialog {
115.59 +
115.60 + private List<PlsqlBlock> blocks = null;
115.61 +
115.62 + /** Creates new form SelectMethodDialog */
115.63 + public SelectMethodDialog(java.awt.Frame parent, boolean modal, Document doc, List<PlsqlBlock> blocks) {
115.64 + super(parent, modal);
115.65 + initComponents();
115.66 + this.blocks = blocks;
115.67 + lstMethods.removeAll();
115.68 + ArrayList<String> items = new ArrayList<String>();
115.69 + for (PlsqlBlock block : blocks) {
115.70 + items.add(PlsqlParserUtil.fetchMethodHeader(doc, block.getStartOffset()));
115.71 + }
115.72 + lstMethods.setListData(items.toArray());
115.73 + lstMethods.addListSelectionListener(new ListSelectionListener() {
115.74 +
115.75 + @Override
115.76 + public void valueChanged(ListSelectionEvent e) {
115.77 + if (!lstMethods.isSelectionEmpty()) {
115.78 + btnOk.setEnabled(true);
115.79 + }
115.80 + }
115.81 + });
115.82 + }
115.83 +
115.84 + public PlsqlBlock getSelectedPlsqlBlock() {
115.85 + return blocks.get(lstMethods.getSelectedIndex());
115.86 + }
115.87 +
115.88 + /** This method is called from within the constructor to
115.89 + * initialize the form.
115.90 + * WARNING: Do NOT modify this code. The content of this method is
115.91 + * always regenerated by the Form Editor.
115.92 + */
115.93 + @SuppressWarnings("unchecked")
115.94 + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
115.95 + private void initComponents() {
115.96 +
115.97 + jLabel1 = new javax.swing.JLabel();
115.98 + jScrollPane1 = new javax.swing.JScrollPane();
115.99 + lstMethods = new javax.swing.JList();
115.100 + btnOk = new javax.swing.JButton();
115.101 +
115.102 + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
115.103 + setTitle(org.openide.util.NbBundle.getMessage(SelectMethodDialog.class, "SelectMethodDialog.title")); // NOI18N
115.104 + setLocationByPlatform(true);
115.105 +
115.106 + jLabel1.setText(org.openide.util.NbBundle.getMessage(SelectMethodDialog.class, "SelectMethodDialog.jLabel1.text")); // NOI18N
115.107 +
115.108 + lstMethods.setModel(new javax.swing.AbstractListModel() {
115.109 + String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
115.110 + public int getSize() { return strings.length; }
115.111 + public Object getElementAt(int i) { return strings[i]; }
115.112 + });
115.113 + lstMethods.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
115.114 + jScrollPane1.setViewportView(lstMethods);
115.115 +
115.116 + btnOk.setText(org.openide.util.NbBundle.getMessage(SelectMethodDialog.class, "SelectMethodDialog.btnOk.text")); // NOI18N
115.117 + btnOk.setEnabled(false);
115.118 + btnOk.addActionListener(new java.awt.event.ActionListener() {
115.119 + public void actionPerformed(java.awt.event.ActionEvent evt) {
115.120 + btnOkActionPerformed(evt);
115.121 + }
115.122 + });
115.123 +
115.124 + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
115.125 + getContentPane().setLayout(layout);
115.126 + layout.setHorizontalGroup(
115.127 + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
115.128 + .addGroup(layout.createSequentialGroup()
115.129 + .addContainerGap()
115.130 + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
115.131 + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 463, javax.swing.GroupLayout.PREFERRED_SIZE)
115.132 + .addComponent(jLabel1))
115.133 + .addContainerGap())
115.134 + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
115.135 + .addContainerGap(274, Short.MAX_VALUE)
115.136 + .addComponent(btnOk)
115.137 + .addContainerGap())
115.138 + );
115.139 + layout.setVerticalGroup(
115.140 + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
115.141 + .addGroup(layout.createSequentialGroup()
115.142 + .addContainerGap()
115.143 + .addComponent(jLabel1)
115.144 + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
115.145 + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE)
115.146 + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
115.147 + .addComponent(btnOk)
115.148 + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
115.149 + );
115.150 +
115.151 + pack();
115.152 + }// </editor-fold>//GEN-END:initComponents
115.153 +
115.154 +private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
115.155 + this.setVisible(false);
115.156 +}//GEN-LAST:event_btnOkActionPerformed
115.157 +
115.158 +
115.159 + // Variables declaration - do not modify//GEN-BEGIN:variables
115.160 + private javax.swing.JButton btnOk;
115.161 + private javax.swing.JLabel jLabel1;
115.162 + private javax.swing.JScrollPane jScrollPane1;
115.163 + private javax.swing.JList lstMethods;
115.164 + // End of variables declaration//GEN-END:variables
115.165 +}
116.1 --- a/PLSQL/Utilities/src/org/netbeans/modules/plsql/utilities/localization/PlsqlFileLocatorServiceImpl.java Tue Feb 14 17:36:37 2012 +0100
116.2 +++ b/PLSQL/Utilities/src/org/netbeans/modules/plsql/utilities/localization/PlsqlFileLocatorServiceImpl.java Wed Aug 15 20:45:01 2012 +0200
116.3 @@ -41,6 +41,7 @@
116.4 */
116.5 package org.netbeans.modules.plsql.utilities.localization;
116.6
116.7 +import java.util.Collection;
116.8 import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
116.9 import org.netbeans.modules.plsql.lexer.PlsqlBlockType;
116.10 import org.netbeans.modules.plsql.utilities.PlsqlFileLocatorService;
116.11 @@ -179,4 +180,17 @@
116.12 }
116.13 }
116.14 }
116.15 +
116.16 + @Override
116.17 + public Collection<File> getAllPlsqlFiles(Project project) {
116.18 + Collection<File> allPlsqlFiles = null;
116.19 + if (project != null) {
116.20 + PlsqlProjectFileCacheManager fileCache = cachePerProject.get(getProjectName(project));
116.21 + if (fileCache != null) {
116.22 + allPlsqlFiles = fileCache.getAllPlsqlObjects();
116.23 + return allPlsqlFiles;
116.24 + }
116.25 + }
116.26 + return allPlsqlFiles;
116.27 + }
116.28 }
117.1 --- a/PLSQL/Utilities/src/org/netbeans/modules/plsql/utilities/localization/PlsqlProjectFileCacheManager.java Tue Feb 14 17:36:37 2012 +0100
117.2 +++ b/PLSQL/Utilities/src/org/netbeans/modules/plsql/utilities/localization/PlsqlProjectFileCacheManager.java Wed Aug 15 20:45:01 2012 +0200
117.3 @@ -106,6 +106,12 @@
117.4 FileObject get(final PlsqlSearchObject searchObject) {
117.5 return cache.get(searchObject);
117.6 }
117.7 +
117.8 + Collection<File> getAllPlsqlObjects(){
117.9 + final PlsqlFileFinder scanner = new PlsqlFileFinder(rootFolder);
117.10 + final Collection<File> listFiles = scanner.findPlsqlFiles();
117.11 + return listFiles;
117.12 + }
117.13
117.14 int numberPlsqlObjects() {
117.15 return cache.numberPlsqlObjects();
118.1 --- a/Utilities/Oracle/manifest.mf Tue Feb 14 17:36:37 2012 +0100
118.2 +++ b/Utilities/Oracle/manifest.mf Wed Aug 15 20:45:01 2012 +0200
118.3 @@ -5,6 +5,6 @@
118.4 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/plsqlsupport/db
118.5 /Bundle.properties
118.6 OpenIDE-Module-Layer: org/netbeans/modules/plsqlsupport/db/layer.xml
118.7 -OpenIDE-Module-Specification-Version: 1.8.19
118.8 +OpenIDE-Module-Specification-Version: 1.8.23
118.9 AutoUpdate-Show-In-Client: false
118.10
119.1 --- a/Utilities/Oracle/nbproject/project.properties Tue Feb 14 17:36:37 2012 +0100
119.2 +++ b/Utilities/Oracle/nbproject/project.properties Wed Aug 15 20:45:01 2012 +0200
119.3 @@ -1,2 +1,9 @@
119.4 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
119.5 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=4
119.6 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=4
119.7 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
119.8 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=120
119.9 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
119.10 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
119.11 javac.source=1.6
119.12 javac.compilerargs=-Xlint -Xlint:-serial
120.1 --- a/Utilities/Oracle/src/org/netbeans/modules/plsqlsupport/db/DatabaseConnectionManager.java Tue Feb 14 17:36:37 2012 +0100
120.2 +++ b/Utilities/Oracle/src/org/netbeans/modules/plsqlsupport/db/DatabaseConnectionManager.java Wed Aug 15 20:45:01 2012 +0200
120.3 @@ -53,7 +53,9 @@
120.4 import java.sql.ResultSet;
120.5 import java.sql.SQLException;
120.6 import java.sql.Statement;
120.7 +import java.util.ArrayList;
120.8 import java.util.HashMap;
120.9 +import java.util.List;
120.10 import java.util.Map;
120.11 import java.util.Properties;
120.12 import java.util.Stack;
120.13 @@ -80,8 +82,9 @@
120.14 public static final String PROP_DATABASE_CONNECTIONS = "databaseConnections";
120.15 public static final String PROP_CW_DATABASE_CONNECTIONS = "commandWindowDatabaseConnections";
120.16 public static final String PROP_ONLINE = "online";
120.17 + private static final String REVERSE_DATABASE_KEY = "reverse.engineering.database";
120.18 private static Map<FileObject, DatabaseConnectionManager> instances = new HashMap<FileObject, DatabaseConnectionManager>();
120.19 - private DatabaseConnection[] connections = new DatabaseConnection[]{};
120.20 + private List<DatabaseConnection> connections = new ArrayList<DatabaseConnection>();
120.21 private final Stack<DatabaseConnection> connectionPool = new Stack<DatabaseConnection>();
120.22 private DatabaseConnection templateConnection;
120.23 private Connection debugConnection = null;
120.24 @@ -92,6 +95,8 @@
120.25 private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
120.26 private static FileObject tempFolder = null;
120.27 private static final Logger logger = Logger.getLogger(DatabaseConnectionManager.class.getName());
120.28 + private static final RequestProcessor RP = new RequestProcessor(DatabaseConnectionManager.class);
120.29 + private DatabaseConnection reverseConnection;
120.30
120.31 static {
120.32 String tempDir = System.getProperty("java.io.tmpdir");
120.33 @@ -162,7 +167,7 @@
120.34 return templateConnection != null && templateConnection.getJDBCConnection() != null;
120.35 }
120.36
120.37 - public DatabaseConnection[] getDatabaseConnections() {
120.38 + public List<DatabaseConnection> getDatabaseConnections() {
120.39 return connections;
120.40 }
120.41
120.42 @@ -173,16 +178,16 @@
120.43 */
120.44 public String getPrimaryConnectionURL() {
120.45 String result = "";
120.46 - if (connections.length > 0) {
120.47 - result = connections[0].getDatabaseURL();
120.48 + if (!connections.isEmpty()) {
120.49 + result = connections.get(0).getDatabaseURL();
120.50 }
120.51 return result;
120.52 }
120.53
120.54 public boolean isDefaultDatabase(DatabaseConnection connection) {
120.55 - return databaseConnectionsAreEqual(connection, templateConnection);
120.56 + return databaseConnectionsAreEqual(connection, templateConnection);
120.57 }
120.58 -
120.59 +
120.60 private boolean databaseConnectionsAreEqual(DatabaseConnection a, DatabaseConnection b) {
120.61 return (a != null && b != null
120.62 && a.getDatabaseURL().equals(b.getDatabaseURL())
120.63 @@ -217,10 +222,10 @@
120.64 synchronized (connectionPool) {
120.65 //if main database is still the same add the connection to the connection pool. Otherwise close and discard.
120.66 if (databaseConnectionsAreEqual(connection, this.templateConnection)) {
120.67 - if(!connectionPool.contains(connection)) {
120.68 - connectionPool.push(connection);
120.69 - logger.log(Level.FINEST, "Returning connection {0} to cache. Number of pooled connections={1}", new Object[]{connection.hashCode(), connectionPool.size()});
120.70 - }
120.71 + if (!connectionPool.contains(connection)) {
120.72 + connectionPool.push(connection);
120.73 + logger.log(Level.FINEST, "Returning connection {0} to cache. Number of pooled connections={1}", new Object[]{connection.hashCode(), connectionPool.size()});
120.74 + }
120.75 } else {
120.76 if (connection != null) {
120.77 logger.log(Level.FINEST, "Returning connection {0} to cache. Discard because connected to different database", connection.hashCode());
120.78 @@ -248,18 +253,18 @@
120.79 }
120.80 }
120.81
120.82 - /**
120.83 + /**
120.84 *
120.85 * @return True if there in on going transactions for a command window.
120.86 */
120.87 - public boolean hasDataToCommit(DatabaseConnection connection) {
120.88 + public boolean hasDataToCommit(DatabaseConnection connection) {
120.89 ResultSet rs = null;
120.90 PreparedStatement stmt = null;
120.91 String commitData = null;
120.92 if (connection == null || connection.getJDBCConnection() == null) {
120.93 return false;
120.94 }
120.95 -
120.96 +
120.97 try {
120.98 String sqlSelect = " SELECT taddr FROM v$session WHERE AUDsid=userenv('SESSIONID')";
120.99 stmt = connection.getJDBCConnection().prepareStatement(sqlSelect);
120.100 @@ -269,14 +274,14 @@
120.101 }
120.102 if (commitData != null) {
120.103 return true;
120.104 - }else{
120.105 + } else {
120.106 return false;
120.107 }
120.108 } catch (SQLException ex) {
120.109 Exceptions.printStackTrace(ex);
120.110 }
120.111 - return false;
120.112 - }
120.113 + return false;
120.114 + }
120.115
120.116 private void clearConnectionPool() {
120.117 synchronized (connectionPool) {
120.118 @@ -335,8 +340,9 @@
120.119 if (prompt) {
120.120 if (templateConnection == null) {
120.121 templateConnection = new DatabaseConnectionPanel().showDialog();
120.122 - connections = templateConnection != null ? new DatabaseConnection[]{templateConnection} : new DatabaseConnection[]{};
120.123 + connections.clear();
120.124 if (templateConnection != null) {
120.125 + connections.add(templateConnection);
120.126 usagesEnabled = isFindUsagesEnabled();
120.127 DatabaseContentManager contentManager = DatabaseContentManager.getInstance(templateConnection);
120.128 contentManager.addExceptionListener(connectionErrorListener);
120.129 @@ -354,8 +360,8 @@
120.130 DatabaseConnection connection = templateConnection;
120.131 if (useConnectionPool) {
120.132 connection = getDatabaseConnectionFromPool();
120.133 - if(connection!=null && connection.getJDBCConnection()==null) {
120.134 - connect(connection);
120.135 + if (connection != null && connection.getJDBCConnection() == null) {
120.136 + connect(connection);
120.137 }
120.138 }
120.139
120.140 @@ -423,13 +429,17 @@
120.141 return debugConnection;
120.142 }
120.143
120.144 - public void setDatabaseConnections(DatabaseConnection[] connections) {
120.145 - DatabaseConnection[] oldConnections = this.connections;
120.146 - this.connections = connections;
120.147 + public void setDatabaseConnections(List<DatabaseConnection> newConnections) {
120.148 +// List<DatabaseConnection> oldConnections = new ArrayList<DatabaseConnection>(connections.size());
120.149 +// Collections.copy(oldConnections, connections);
120.150 +// this.connections.clear();
120.151 +// this.connections.addAll(newConnections);
120.152 + List<DatabaseConnection> oldConnections = connections;
120.153 + connections = newConnections;
120.154 if (templateConnection != null) {
120.155 DatabaseContentManager.getInstance(templateConnection).removeExceptionListener(connectionErrorListener);
120.156 }
120.157 - templateConnection = connections.length > 0 ? connections[0] : null;
120.158 + templateConnection = !newConnections.isEmpty() ? newConnections.get(0) : null;
120.159 if (templateConnection != null) {
120.160 DatabaseContentManager.getInstance(templateConnection).addExceptionListener(connectionErrorListener);
120.161 }
120.162 @@ -437,7 +447,7 @@
120.163 //clear the connection pool and the debug connection when the main database changes
120.164 clearConnectionPool();
120.165 this.debugConnection = null;
120.166 - changeSupport.firePropertyChange(PROP_DATABASE_CONNECTIONS, oldConnections, connections);
120.167 + changeSupport.firePropertyChange(PROP_DATABASE_CONNECTIONS, oldConnections, newConnections);
120.168 }
120.169
120.170 public synchronized void connect(final DatabaseConnection connection) {
120.171 @@ -455,55 +465,55 @@
120.172 }
120.173 return;
120.174 } else {
120.175 - if (SwingUtilities.isEventDispatchThread()) {
120.176 - try {
120.177 - ConnectionManager.getDefault().showConnectionDialog(connection);
120.178 - } catch (NullPointerException e) {
120.179 - failed = true;
120.180 - } catch (IllegalStateException e) {
120.181 - failed = true;
120.182 - }
120.183 - } else {
120.184 - try {
120.185 - SwingUtilities.invokeAndWait(new Runnable() {
120.186 + if (SwingUtilities.isEventDispatchThread()) {
120.187 + try {
120.188 + ConnectionManager.getDefault().showConnectionDialog(connection);
120.189 + } catch (NullPointerException e) {
120.190 + failed = true;
120.191 + } catch (IllegalStateException e) {
120.192 + failed = true;
120.193 + }
120.194 + } else {
120.195 + try {
120.196 + SwingUtilities.invokeAndWait(new Runnable() {
120.197
120.198 - @Override
120.199 - public void run() {
120.200 - ConnectionManager.getDefault().showConnectionDialog(connection);
120.201 + @Override
120.202 + public void run() {
120.203 + ConnectionManager.getDefault().showConnectionDialog(connection);
120.204 + }
120.205 + });
120.206 + } catch (InterruptedException e) {
120.207 + failed = true;
120.208 + } catch (InvocationTargetException e) {
120.209 + failed = true;
120.210 + }
120.211 + }
120.212 + if ((connection.getJDBCConnection() == null || connection.getJDBCConnection().isClosed())) {
120.213 + if (SwingUtilities.isEventDispatchThread()) {
120.214 + Task request = RP.post(new Runnable() {
120.215 +
120.216 + @Override
120.217 + public void run() {
120.218 + try {
120.219 + ConnectionManager.getDefault().connect(connection);
120.220 + } catch (DatabaseException ex) {
120.221 + }
120.222 + }
120.223 + });
120.224 + try {
120.225 + request.waitFinished(10000);
120.226 + } catch (InterruptedException ex) {
120.227 + Exceptions.printStackTrace(ex);
120.228 }
120.229 - });
120.230 - } catch (InterruptedException e) {
120.231 - failed = true;
120.232 - } catch (InvocationTargetException e) {
120.233 - failed = true;
120.234 - }
120.235 - }
120.236 - if ((connection.getJDBCConnection() == null || connection.getJDBCConnection().isClosed())) {
120.237 - if (SwingUtilities.isEventDispatchThread()) {
120.238 - Task request = RequestProcessor.getDefault().post(new Runnable() {
120.239 -
120.240 - @Override
120.241 - public void run() {
120.242 - try {
120.243 - ConnectionManager.getDefault().connect(connection);
120.244 - } catch (DatabaseException ex) {
120.245 - }
120.246 - }
120.247 - });
120.248 - try {
120.249 - request.waitFinished(10000);
120.250 - } catch (InterruptedException ex) {
120.251 - Exceptions.printStackTrace(ex);
120.252 + } else {
120.253 + try {
120.254 + ConnectionManager.getDefault().connect(connection);
120.255 + } catch (DatabaseException ex) {
120.256 + failed = true;
120.257 + }
120.258 }
120.259 - } else {
120.260 - try {
120.261 - ConnectionManager.getDefault().connect(connection);
120.262 - } catch (DatabaseException ex) {
120.263 - failed = true;
120.264 - }
120.265 - }
120.266 - }
120.267 - }
120.268 + }
120.269 + }
120.270 } catch (SQLException ex) {
120.271 failed = true;
120.272 }
120.273 @@ -535,9 +545,9 @@
120.274 templateConnection = DatabaseConnection.create(templateConnection.getJDBCDriver(), templateConnection.getDatabaseURL(), templateConnection.getUser(), templateConnection.getSchema(), templateConnection.getPassword(), true, templateConnection.getDisplayName());
120.275 clearConnectionPool();
120.276 this.debugConnection = null;
120.277 - DatabaseConnection[] oldConnections = new DatabaseConnection[connections.length];
120.278 - System.arraycopy(connections, 0, oldConnections, 0, connections.length);
120.279 - connections[0] = templateConnection;
120.280 + List<DatabaseConnection> oldConnections = new ArrayList<DatabaseConnection>(connections.size());
120.281 + oldConnections.addAll(connections);
120.282 + connections.set(0, templateConnection);
120.283 changeSupport.firePropertyChange(PROP_DATABASE_CONNECTIONS, oldConnections, connections);
120.284 }
120.285 this.online = online;
120.286 @@ -546,12 +556,25 @@
120.287 }
120.288
120.289 public void addPropertyChangeListener(PropertyChangeListener listener) {
120.290 - PropertyChangeListener[] listeners = changeSupport.getPropertyChangeListeners();
120.291 - for(int i = 0; i<listeners.length; i++) {
120.292 - if(listeners[i]==listener) //don't register the same listener more than once
120.293 - return;
120.294 - }
120.295 - changeSupport.addPropertyChangeListener(listener);
120.296 + PropertyChangeListener[] listeners = changeSupport.getPropertyChangeListeners();
120.297 + for (int i = 0; i < listeners.length; i++) {
120.298 + //don't register the same listener more than once
120.299 + if (listeners[i] == listener) {
120.300 + return;
120.301 + }
120.302 + }
120.303 + changeSupport.addPropertyChangeListener(listener);
120.304 + }
120.305 +
120.306 + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
120.307 + PropertyChangeListener[] listeners = changeSupport.getPropertyChangeListeners();
120.308 + for (int i = 0; i < listeners.length; i++) {
120.309 + if (listeners[i] == listener) //don't register the same listener more than once
120.310 + {
120.311 + return;
120.312 + }
120.313 + }
120.314 + changeSupport.addPropertyChangeListener(propertyName, listener);
120.315 }
120.316
120.317 public void removePropertyChangeListener(PropertyChangeListener listener) {
120.318 @@ -575,6 +598,45 @@
120.319 }
120.320 }
120.321
120.322 + /**
120.323 + * Set Reverse Engineering DatabaseConnection
120.324 + * @param newConnection
120.325 + */
120.326 + public void setReverseConnection(DatabaseConnection newConnection) {
120.327 + DatabaseConnection oldConnection = this.reverseConnection;
120.328 + this.reverseConnection = newConnection;
120.329 + changeSupport.firePropertyChange(REVERSE_DATABASE_KEY, oldConnection, newConnection);
120.330 + }
120.331 +
120.332 + /**
120.333 + * Returns Reverse Engineering DatabaseConnection
120.334 + * @return
120.335 + */
120.336 + public DatabaseConnection getReverseConnection() {
120.337 + return reverseConnection;
120.338 + }
120.339 +
120.340 + /**
120.341 + * Returns true is Reverse Engineering DatabaseConnection has been set.
120.342 + * @return
120.343 + */
120.344 + public boolean hasReverseConnection() {
120.345 + return reverseConnection != null;
120.346 + }
120.347 +
120.348 + /**
120.349 + * Returns true is Reverse Engineering DatabaseConnection is online.
120.350 + * @return
120.351 + */
120.352 + public boolean isReverseOnline() {
120.353 + try {
120.354 + return hasReverseConnection() && reverseConnection.getJDBCConnection() != null && reverseConnection.getJDBCConnection().isValid(1000);
120.355 + } catch (SQLException ex) {
120.356 + Exceptions.printStackTrace(ex);
120.357 + }
120.358 + return false;
120.359 + }
120.360 +
120.361 private class ConnectionErrorListener implements ExceptionListener {
120.362
120.363 public ConnectionErrorListener() {
121.1 --- a/Utilities/Oracle/src/org/netbeans/modules/plsqlsupport/db/DatabaseContentUtilities.java Tue Feb 14 17:36:37 2012 +0100
121.2 +++ b/Utilities/Oracle/src/org/netbeans/modules/plsqlsupport/db/DatabaseContentUtilities.java Wed Aug 15 20:45:01 2012 +0200
121.3 @@ -1446,131 +1446,136 @@
121.4 return null;
121.5 }
121.6
121.7 - /**
121.8 - * Get model
121.9 - * @param objectName
121.10 - * @param type
121.11 - * @param connection
121.12 - * @return
121.13 - */
121.14 - public static DatabaseModelObjectInfo getModelObject(String objectName, String type, DatabaseConnection connection) throws SQLException {
121.15 - PreparedStatement stmt = null;
121.16 - DatabaseModelObjectInfo modelObject = null;
121.17 - //FETCH MODEL
121.18 - String query = "SELECT COMPONENT, MODEL_FILE FROM " + connection.getSchema() + ".FNDBAS_MODEL_OBJECT_TAB WHERE OBJECT_TYPE=? AND OBJECT_NAME=?";
121.19 - try {
121.20 - if (connection != null) {
121.21 - stmt = connection.getJDBCConnection().prepareStatement(query);
121.22 - stmt.setString(1, type);
121.23 - stmt.setString(2, objectName);
121.24 - ResultSet rs = stmt.executeQuery();
121.25 - while (rs.next()) {
121.26 - modelObject = new DatabaseModelObjectInfo(objectName, rs.getString(1), type, rs.getBytes(2));
121.27 - }
121.28 - rs.close();
121.29 - stmt.close();
121.30 - }
121.31 - } catch (SQLException ex) {
121.32 - return null; //work around for non-ifs databases
121.33 - } finally {
121.34 - if (stmt != null) {
121.35 - stmt.close();
121.36 - }
121.37 - }
121.38 - return modelObject;
121.39 - }
121.40 -
121.41 - /**
121.42 - * Get models updated after lastFetchDate
121.43 - * @param lastFetchDate
121.44 - * @param type
121.45 - * @param models
121.46 - * @param connection
121.47 - * @return lastImportFileDate
121.48 - */
121.49 - public static String getModelNames(String lastFetchDate, Map<String, Set<String>> models, DatabaseConnection connection) throws SQLException {
121.50 - PreparedStatement stmt = null;
121.51 -
121.52 - //FETCH MODEL NAMES
121.53 - String query = "SELECT object_name, object_type, to_char(import_file_stamp, " + TIMESTAMP_FORMAT + ") import_file_stamp "
121.54 - + "FROM " + connection.getSchema() + ".fndbas_model_object_tab "
121.55 - + "WHERE import_file_stamp > to_date(?, " + TIMESTAMP_FORMAT + ") "
121.56 - + "ORDER BY import_file_stamp DESC";
121.57 - try {
121.58 - String timestamp = null;
121.59 - if (connection != null) {
121.60 - stmt = connection.getJDBCConnection().prepareStatement(query);
121.61 - stmt.setString(1, lastFetchDate);
121.62 - ResultSet rs = stmt.executeQuery();
121.63 - while (rs.next()) {
121.64 - Set<String> modelList = models.get(rs.getString(2));
121.65 - if (modelList == null) {
121.66 - modelList = new HashSet<String>();
121.67 - models.put(rs.getString(2), modelList);
121.68 - }
121.69 - modelList.add(rs.getString(1));
121.70 - if (timestamp == null) {
121.71 - timestamp = rs.getString(3);
121.72 - }
121.73 - }
121.74 - rs.close();
121.75 - stmt.close();
121.76 - }
121.77 - return timestamp != null ? timestamp : lastFetchDate;
121.78 - } catch (SQLException ex) {
121.79 - return null; //work around for non-ifs databases
121.80 - } finally {
121.81 - if (stmt != null) {
121.82 - stmt.close();
121.83 - }
121.84 - }
121.85 - }
121.86 -
121.87 - /**
121.88 - * Method that will return the last modified time of the given model object
121.89 - * @param name
121.90 - * @param type
121.91 - * @param connection
121.92 - * @return
121.93 - */
121.94 - public static long getLastModifiedTime(String name, String type, DatabaseConnection connection) throws SQLException {
121.95 - {
121.96 - Date timeStamp = null;
121.97 - DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
121.98 -
121.99 - if (connection != null) {
121.100 - try {
121.101 - List<String> objList = new ArrayList<String>();
121.102 - ResultSet objSet = null;
121.103 -
121.104 - String query = "SELECT FILE_TIME_STAMP FROM FNDBAS_MODEL_OBJECT_TAB A WHERE OBJECT_TYPE = ? AND OBJECT_NAME= ?";
121.105 - PreparedStatement stmt = null;
121.106 - try {
121.107 - stmt = connection.getJDBCConnection().prepareStatement(query);
121.108 - stmt.setString(1, type);
121.109 - stmt.setString(2, name);
121.110 - objSet = stmt.executeQuery();
121.111 - while (objSet.next()) {
121.112 - objList.add(objSet.getString("FILE_TIME_STAMP"));
121.113 - }
121.114 - } finally {
121.115 - if (stmt != null) {
121.116 - stmt.close();
121.117 - }
121.118 - }
121.119 - if (objList.size() > 0) {
121.120 - timeStamp = dfm.parse(objList.get(0));
121.121 - }
121.122 - } catch (ParseException ex) {
121.123 - Exceptions.printStackTrace(ex);
121.124 - }
121.125 - }
121.126 -
121.127 - if (timeStamp == null) {
121.128 - return -1;
121.129 - } else {
121.130 - return timeStamp.getTime();
121.131 - }
121.132 - }
121.133 - }
121.134 +// /**
121.135 +// * Get model
121.136 +// * @param objectName
121.137 +// * @param type
121.138 +// * @param connection
121.139 +// * @return
121.140 +// */
121.141 +// public static DatabaseModelObjectInfo getModelObject(String objectName, String type, DatabaseConnection connection) throws SQLException {
121.142 +// return getModelObject(objectName, type, connection.getSchema(), connection.getJDBCConnection());
121.143 +// }
121.144 +//
121.145 +//
121.146 +// public static DatabaseModelObjectInfo getModelObject(String objectName, String type, String schema, Connection connection) throws SQLException {
121.147 +// PreparedStatement stmt = null;
121.148 +// DatabaseModelObjectInfo modelObject = null;
121.149 +// //FETCH MODEL
121.150 +// String query = "SELECT COMPONENT, MODEL_FILE FROM " + schema + ".FNDBAS_MODEL_OBJECT_TAB WHERE OBJECT_TYPE=? AND OBJECT_NAME=?";
121.151 +// try {
121.152 +// if (connection != null) {
121.153 +// stmt = connection.prepareStatement(query);
121.154 +// stmt.setString(1, type);
121.155 +// stmt.setString(2, objectName);
121.156 +// ResultSet rs = stmt.executeQuery();
121.157 +// while (rs.next()) {
121.158 +// modelObject = new DatabaseModelObjectInfo(objectName, rs.getString(1), type, rs.getBytes(2));
121.159 +// }
121.160 +// rs.close();
121.161 +// stmt.close();
121.162 +// }
121.163 +// } catch (SQLException ex) {
121.164 +// return null; //work around for non-ifs databases
121.165 +// } finally {
121.166 +// if (stmt != null) {
121.167 +// stmt.close();
121.168 +// }
121.169 +// }
121.170 +// return modelObject;
121.171 +// }
121.172 +//
121.173 +// /**
121.174 +// * Get models updated after lastFetchDate
121.175 +// * @param lastFetchDate
121.176 +// * @param type
121.177 +// * @param models
121.178 +// * @param connection
121.179 +// * @return lastImportFileDate
121.180 +// */
121.181 +// public static String getModelNames(String lastFetchDate, Map<String, Set<String>> models, DatabaseConnection connection) throws SQLException {
121.182 +// PreparedStatement stmt = null;
121.183 +//
121.184 +// //FETCH MODEL NAMES
121.185 +// String query = "SELECT object_name, object_type, to_char(import_file_stamp, " + TIMESTAMP_FORMAT + ") import_file_stamp "
121.186 +// + "FROM " + connection.getSchema() + ".fndbas_model_object_tab "
121.187 +// + "WHERE import_file_stamp > to_date(?, " + TIMESTAMP_FORMAT + ") "
121.188 +// + "ORDER BY import_file_stamp DESC";
121.189 +// try {
121.190 +// String timestamp = null;
121.191 +// if (connection != null) {
121.192 +// stmt = connection.getJDBCConnection().prepareStatement(query);
121.193 +// stmt.setString(1, lastFetchDate);
121.194 +// ResultSet rs = stmt.executeQuery();
121.195 +// while (rs.next()) {
121.196 +// Set<String> modelList = models.get(rs.getString(2));
121.197 +// if (modelList == null) {
121.198 +// modelList = new HashSet<String>();
121.199 +// models.put(rs.getString(2), modelList);
121.200 +// }
121.201 +// modelList.add(rs.getString(1));
121.202 +// if (timestamp == null) {
121.203 +// timestamp = rs.getString(3);
121.204 +// }
121.205 +// }
121.206 +// rs.close();
121.207 +// stmt.close();
121.208 +// }
121.209 +// return timestamp != null ? timestamp : lastFetchDate;
121.210 +// } catch (SQLException ex) {
121.211 +// return null; //work around for non-ifs databases
121.212 +// } finally {
121.213 +// if (stmt != null) {
121.214 +// stmt.close();
121.215 +// }
121.216 +// }
121.217 +// }
121.218 +//
121.219 +// /**
121.220 +// * Method that will return the last modified time of the given model object
121.221 +// * @param name
121.222 +// * @param type
121.223 +// * @param connection
121.224 +// * @return
121.225 +// */
121.226 +// public static long getLastModifiedTime(String name, String type, DatabaseConnection connection) throws SQLException {
121.227 +// {
121.228 +// Date timeStamp = null;
121.229 +// DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
121.230 +//
121.231 +// if (connection != null) {
121.232 +// try {
121.233 +// List<String> objList = new ArrayList<String>();
121.234 +// ResultSet objSet = null;
121.235 +//
121.236 +// String query = "SELECT FILE_TIME_STAMP FROM FNDBAS_MODEL_OBJECT_TAB A WHERE OBJECT_TYPE = ? AND OBJECT_NAME= ?";
121.237 +// PreparedStatement stmt = null;
121.238 +// try {
121.239 +// stmt = connection.getJDBCConnection().prepareStatement(query);
121.240 +// stmt.setString(1, type);
121.241 +// stmt.setString(2, name);
121.242 +// objSet = stmt.executeQuery();
121.243 +// while (objSet.next()) {
121.244 +// objList.add(objSet.getString("FILE_TIME_STAMP"));
121.245 +// }
121.246 +// } finally {
121.247 +// if (stmt != null) {
121.248 +// stmt.close();
121.249 +// }
121.250 +// }
121.251 +// if (objList.size() > 0) {
121.252 +// timeStamp = dfm.parse(objList.get(0));
121.253 +// }
121.254 +// } catch (ParseException ex) {
121.255 +// Exceptions.printStackTrace(ex);
121.256 +// }
121.257 +// }
121.258 +//
121.259 +// if (timeStamp == null) {
121.260 +// return -1;
121.261 +// } else {
121.262 +// return timeStamp.getTime();
121.263 +// }
121.264 +// }
121.265 +// }
121.266 }
122.1 --- a/Utilities/Oracle/src/org/netbeans/modules/plsqlsupport/db/DatabaseModelObjectInfo.java Tue Feb 14 17:36:37 2012 +0100
122.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
122.3 @@ -1,75 +0,0 @@
122.4 -/*
122.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
122.6 - *
122.7 - * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
122.8 - *
122.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
122.10 - * Other names may be trademarks of their respective owners.
122.11 - *
122.12 - * The contents of this file are subject to the terms of either the GNU
122.13 - * General Public License Version 2 only ("GPL") or the Common
122.14 - * Development and Distribution License("CDDL") (collectively, the
122.15 - * "License"). You may not use this file except in compliance with the
122.16 - * License. You can obtain a copy of the License at
122.17 - * http://www.netbeans.org/cddl-gplv2.html
122.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
122.19 - * specific language governing permissions and limitations under the
122.20 - * License. When distributing the software, include this License Header
122.21 - * Notice in each file and include the License file at
122.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
122.23 - * particular file as subject to the "Classpath" exception as provided
122.24 - * by Oracle in the GPL Version 2 section of the License file that
122.25 - * accompanied this code. If applicable, add the following below the
122.26 - * License Header, with the fields enclosed by brackets [] replaced by
122.27 - * your own identifying information:
122.28 - * "Portions Copyrighted [year] [name of copyright owner]"
122.29 - *
122.30 - * If you wish your version of this file to be governed by only the CDDL
122.31 - * or only the GPL Version 2, indicate your decision by adding
122.32 - * "[Contributor] elects to include this software in this distribution
122.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
122.34 - * single choice of license, a recipient has the option to distribute
122.35 - * your version of this file under either the CDDL, the GPL Version 2 or
122.36 - * to extend the choice of license to its licensees as provided above.
122.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
122.38 - * Version 2 license, then the option applies only if the new code is
122.39 - * made subject to such option by the copyright holder.
122.40 - *
122.41 - * Contributor(s):
122.42 - *
122.43 - * Portions Copyrighted 2011 Sun Microsystems, Inc.
122.44 - */
122.45 -package org.netbeans.modules.plsqlsupport.db;
122.46 -
122.47 -public class DatabaseModelObjectInfo {
122.48 -
122.49 - private String objectName;
122.50 - private String component;
122.51 - private String type;
122.52 - private byte[] data;
122.53 -
122.54 - // Use to store the query results of model data from Model Cache Table in Database
122.55 - public DatabaseModelObjectInfo(String objectName, String component, String type, byte[] data) {
122.56 - this.objectName = objectName;
122.57 - this.component = component;
122.58 - this.type = type;
122.59 - this.data = data;
122.60 - }
122.61 -
122.62 - public String getName() {
122.63 - return objectName;
122.64 - }
122.65 -
122.66 - public String getComponent() {
122.67 - return component;
122.68 - }
122.69 -
122.70 - public String getType() {
122.71 - return type;
122.72 - }
122.73 -
122.74 - public byte[] getData() {
122.75 - return data;
122.76 - }
122.77 -
122.78 -}
123.1 --- a/Utilities/Oracle/src/org/netbeans/modules/plsqlsupport/db/ui/DatabaseNode.java Tue Feb 14 17:36:37 2012 +0100
123.2 +++ b/Utilities/Oracle/src/org/netbeans/modules/plsqlsupport/db/ui/DatabaseNode.java Wed Aug 15 20:45:01 2012 +0200
123.3 @@ -63,102 +63,109 @@
123.4
123.5 public class DatabaseNode extends AbstractNode {
123.6
123.7 - private static final Image ONLINE_ICON = ImageUtilities.loadImage("org/netbeans/modules/plsqlsupport/db/ui/resources/database_online.gif");
123.8 - private static final Image OFFLINE_ICON = ImageUtilities.loadImage("org/netbeans/modules/plsqlsupport/db/ui/resources/database_offline.gif");
123.9 - private static final Image NO_CONNECTION_ICON = ImageUtilities.loadImage("org/netbeans/modules/plsqlsupport/db/ui/resources/database_notconnected.gif");
123.10 - private Project project;
123.11 + private static final Image ONLINE_ICON = ImageUtilities.loadImage("org/netbeans/modules/plsqlsupport/db/ui/resources/database_online.gif");
123.12 + private static final Image OFFLINE_ICON = ImageUtilities.loadImage("org/netbeans/modules/plsqlsupport/db/ui/resources/database_offline.gif");
123.13 + private static final Image NO_CONNECTION_ICON = ImageUtilities.loadImage("org/netbeans/modules/plsqlsupport/db/ui/resources/database_notconnected.gif");
123.14 + private Project project;
123.15
123.16 - public DatabaseNode(Project project) {
123.17 - super(Children.LEAF, Lookups.fixed(project));
123.18 - this.project = project;
123.19 - setName("Database");
123.20 - DatabaseConnectionManager dbConnectionProvider = project.getLookup().lookup(DatabaseConnectionManager.class);
123.21 - if (dbConnectionProvider != null)
123.22 - dbConnectionProvider.addPropertyChangeListener(new ConnectionChangeListener());
123.23 - }
123.24 + public DatabaseNode(Project project) {
123.25 + super(Children.LEAF, Lookups.fixed(project));
123.26 + this.project = project;
123.27 + setName("Database");
123.28 + DatabaseConnectionManager dbConnectionProvider = project.getLookup().lookup(DatabaseConnectionManager.class);
123.29 + if (dbConnectionProvider != null) {
123.30 + dbConnectionProvider.addPropertyChangeListener(new ConnectionChangeListener());
123.31 + }
123.32 + }
123.33
123.34 - public static NodeFactory createFactory() {
123.35 - return new Factory();
123.36 - }
123.37 + public static NodeFactory createFactory() {
123.38 + return new Factory();
123.39 + }
123.40
123.41 - @Override
123.42 - public Image getIcon(int type) {
123.43 - DatabaseConnectionManager dbConnectionProvider = project.getLookup().lookup(DatabaseConnectionManager.class);
123.44 - if (!dbConnectionProvider.hasConnection())
123.45 - return NO_CONNECTION_ICON;
123.46 - return dbConnectionProvider.isOnline() ? ONLINE_ICON : OFFLINE_ICON;
123.47 - }
123.48 + @Override
123.49 + public Image getIcon(int type) {
123.50 + DatabaseConnectionManager dbConnectionProvider = project.getLookup().lookup(DatabaseConnectionManager.class);
123.51 + if (!dbConnectionProvider.hasConnection()) {
123.52 + return NO_CONNECTION_ICON;
123.53 + }
123.54 + return dbConnectionProvider.isOnline() ? ONLINE_ICON : OFFLINE_ICON;
123.55 + }
123.56
123.57 - @Override
123.58 - public Image getOpenedIcon(int type) {
123.59 - return getIcon(type);
123.60 - }
123.61 + @Override
123.62 + public Image getOpenedIcon(int type) {
123.63 + return getIcon(type);
123.64 + }
123.65
123.66 - @Override
123.67 - public Action[] getActions(boolean context) {
123.68 - List<? extends Action> actions = Utilities.actionsForPath("Databases/Nodes/Oracle");
123.69 - return actions.toArray(new Action[actions.size()]);
123.70 - }
123.71 + @Override
123.72 + public Action[] getActions(boolean context) {
123.73 + List<? extends Action> actions = Utilities.actionsForPath("Databases/Nodes/Oracle");
123.74 + return actions.toArray(new Action[actions.size()]);
123.75 + }
123.76
123.77 - @Override
123.78 - public String getHtmlDisplayName() {
123.79 - return getDisplayName(true);
123.80 - }
123.81 + @Override
123.82 + public String getHtmlDisplayName() {
123.83 + return getDisplayName(true);
123.84 + }
123.85
123.86 - @Override
123.87 - public String getDisplayName() {
123.88 - return getDisplayName(false);
123.89 - }
123.90 + @Override
123.91 + public String getDisplayName() {
123.92 + return getDisplayName(false);
123.93 + }
123.94
123.95 - private String getDisplayName(boolean addHTML) {
123.96 - String name = NbBundle.getMessage(getClass(), "LBL_DatabaseNodeName"); // NOI18N
123.97 - DatabaseConnectionManager connectionProvider = project.getLookup().lookup(DatabaseConnectionManager.class);
123.98 - DatabaseConnection[] connections = connectionProvider.getDatabaseConnections();
123.99 - if (connections.length > 0) {
123.100 - String url = connections[0].getDatabaseURL();
123.101 - String alias = connections[0].getDisplayName();
123.102 - if(alias !=null && !alias.equals(connections[0].getName()))
123.103 - name = name + " " + alias;
123.104 - url = connections[0].getUser() + "@" + url.substring(url.lastIndexOf("@") + 1);
123.105 - if (connectionProvider.isOnline())
123.106 - name = name + " [" + url + "]";
123.107 - else if (addHTML)
123.108 - name = name + " [<s>" + url + "</s>]";
123.109 - } else if (addHTML)
123.110 - name = "<font color='AAAAAA'>" + name + "</font>";
123.111 - return name;
123.112 - }
123.113 + private String getDisplayName(boolean addHTML) {
123.114 + String name = NbBundle.getMessage(getClass(), "LBL_DatabaseNodeName"); // NOI18N
123.115 + DatabaseConnectionManager connectionProvider = project.getLookup().lookup(DatabaseConnectionManager.class);
123.116 + List<DatabaseConnection> connections = connectionProvider.getDatabaseConnections();
123.117 + if (!connections.isEmpty()) {
123.118 + String url = connections.get(0).getDatabaseURL();
123.119 + String alias = connections.get(0).getDisplayName();
123.120 + if (alias != null && !alias.equals(connections.get(0).getName())) {
123.121 + name = name + " " + alias;
123.122 + }
123.123 + url = connections.get(0).getUser() + "@" + url.substring(url.lastIndexOf("@") + 1);
123.124 + if (connectionProvider.isOnline()) {
123.125 + name = name + " [" + url + "]";
123.126 + } else if (addHTML) {
123.127 + name = name + " [<s>" + url + "</s>]";
123.128 + }
123.129 + } else if (addHTML) {
123.130 + name = "<font color='AAAAAA'>" + name + "</font>";
123.131 + }
123.132 + return name;
123.133 + }
123.134
123.135 - private void updateCache() {
123.136 - DatabaseConnectionManager connectionProvider = project.getLookup().lookup(DatabaseConnectionManager.class);
123.137 - DatabaseConnection[] connections = connectionProvider.getDatabaseConnections();
123.138 - if (connections.length > 0) {
123.139 - DatabaseContentManager dbCache = DatabaseContentManager.getInstance(connections[0]);
123.140 - if(dbCache!=null)
123.141 - dbCache.updateCache(connectionProvider);
123.142 - }
123.143 - }
123.144 - private static class Factory implements NodeFactory {
123.145 + private void updateCache() {
123.146 + DatabaseConnectionManager connectionProvider = project.getLookup().lookup(DatabaseConnectionManager.class);
123.147 + List<DatabaseConnection> connections = connectionProvider.getDatabaseConnections();
123.148 + if (!connections.isEmpty()) {
123.149 + DatabaseContentManager dbCache = DatabaseContentManager.getInstance(connections.get(0));
123.150 + if (dbCache != null) {
123.151 + dbCache.updateCache(connectionProvider);
123.152 + }
123.153 + }
123.154 + }
123.155
123.156 - public Factory() {}
123.157 + private static class Factory implements NodeFactory {
123.158
123.159 - public NodeList createNodes(Project project) {
123.160 - return NodeFactorySupport.fixedNodeList(new DatabaseNode(project));
123.161 - }
123.162 - }
123.163 + @Override
123.164 + public NodeList createNodes(Project project) {
123.165 + return NodeFactorySupport.fixedNodeList(new DatabaseNode(project));
123.166 + }
123.167 + }
123.168
123.169 - private class ConnectionChangeListener implements PropertyChangeListener {
123.170 + private class ConnectionChangeListener implements PropertyChangeListener {
123.171
123.172 - public ConnectionChangeListener() {}
123.173 + @Override
123.174 + public void propertyChange(PropertyChangeEvent event) {
123.175 + SwingUtilities.invokeLater(new Runnable() {
123.176
123.177 - public void propertyChange(PropertyChangeEvent event) {
123.178 - SwingUtilities.invokeLater(new Runnable() {
123.179 - public void run() {
123.180 - fireIconChange();
123.181 - setDisplayName(getHtmlDisplayName());
123.182 - updateCache();
123.183 - }
123.184 - });
123.185 - }
123.186 - }
123.187 + @Override
123.188 + public void run() {
123.189 + fireIconChange();
123.190 + setDisplayName(getHtmlDisplayName());
123.191 + updateCache();
123.192 + }
123.193 + });
123.194 + }
123.195 + }
123.196 }
124.1 --- a/Utilities/Oracle/src/org/netbeans/modules/plsqlsupport/db/ui/SQLCommandWindow.java Tue Feb 14 17:36:37 2012 +0100
124.2 +++ b/Utilities/Oracle/src/org/netbeans/modules/plsqlsupport/db/ui/SQLCommandWindow.java Wed Aug 15 20:45:01 2012 +0200
124.3 @@ -111,15 +111,6 @@
124.4 if ((panes != null) && (panes.length != 0)) {
124.5 JEditorPane component = panes[0];
124.6 if (component != null) {
124.7 - //Ugly workaround for a bug in code templates.
124.8 - //This bug makes it impossible to insert code templates at the first position in a file.
124.9 - //By adding a comment line at the start of the file we avoid this problem for our test blocks...
124.10 - Document doc = component.getDocument();
124.11 - try {
124.12 - doc.insertString(0, "-- Enter values for your parameters. Use enter to move to the next parameter\n", null);
124.13 - } catch (BadLocationException ex) {
124.14 - Exceptions.printStackTrace(ex);
124.15 - }
124.16 CodeTemplate ct = CodeTemplateManager.get(component.getDocument()).createTemporary(codeTemplate);
124.17 ct.insert(component);
124.18 }
125.1 --- a/build.xml Tue Feb 14 17:36:37 2012 +0100
125.2 +++ b/build.xml Wed Aug 15 20:45:01 2012 +0200
125.3 @@ -13,6 +13,10 @@
125.4 <property name="timestamp.file" value=".lastModified"/>
125.5
125.6 <property environment="env"/>
125.7 + <property name="env.BUILD_NUMBER" value="0" description="Set a fake value if not run from Jenkins"/>
125.8 + <property name="env.next_jira_release_version" value="8.72.0" description="Set a fake value if not run from Jenkins"/>
125.9 + <property name="new_version" value="${env.next_jira_release_version}.${env.BUILD_NUMBER}" description="Set a version number based on info from Jenkins"/>
125.10 +
125.11 <condition property="build.id" value="${env.BUILD_ID}" else="dev">
125.12 <isset property="env.BUILD_ID"/>
125.13 </condition>
125.14 @@ -132,10 +136,13 @@
125.15 <echo level="verbose">${modules}</echo>
125.16
125.17 <foreach param="module.path" target="-vcs-log" list="${modules}" delimiter=":"/>
125.18 +<!-- <echoproperties srcfile="build/nbms_update.properties" />-->
125.19 + </target>
125.20 +
125.21 + <target name="-add-kit-module" description="add kit module to update" >
125.22 <propertyfile file="build/nbms_update.properties">
125.23 <entry key="selected.modules" default="" operation="+" value="plsql-support.kit/manifest.mf:"/>
125.24 </propertyfile>
125.25 -<!-- <echoproperties srcfile="build/nbms_update.properties" />-->
125.26 </target>
125.27
125.28 <target name="-vcs-log" description="use mercurial to check if the last commit was a release commit">
125.29 @@ -177,31 +184,14 @@
125.30 <target name="current-version" depends="-read-version" description="show current specification.version">
125.31 </target>
125.32
125.33 - <target name="incr-major" description="increment major version for modules with changes" depends="-find-modules-for-update">
125.34 + <target name="update-version" depends="-find-modules-for-update, -add-kit-module"
125.35 + description="update version for all modules in suite that has changes since last release">
125.36 + <echo level="info">Updating modules to version: ${new_version}</echo>
125.37 <loadproperties srcfile="build/nbms_update.properties" />
125.38 <echo>selected.modules=${selected.modules}</echo>
125.39 - <foreach param="manifest.file" target="-major" >
125.40 + <foreach param="manifest.file" target="-update-meta-files" >
125.41 <path path="${selected.modules}"/>
125.42 </foreach>
125.43 - <delete file="build_info.properties" />
125.44 - </target>
125.45 -
125.46 - <target name="incr-minor" description="increment minor version for modules with changes" depends="-find-modules-for-update">
125.47 - <loadproperties srcfile="build/nbms_update.properties" />
125.48 - <echo>selected.modules=${selected.modules}</echo>
125.49 - <foreach param="manifest.file" target="-minor" >
125.50 - <path path="${selected.modules}"/>
125.51 - </foreach>
125.52 - <delete file="build_info.properties" />
125.53 - </target>
125.54 -
125.55 - <target name="incr-revision" description="increment revision version for modules with changes" depends="-find-modules-for-update">
125.56 - <loadproperties srcfile="build/nbms_update.properties" />
125.57 - <echo>selected.modules=${selected.modules}</echo>
125.58 - <foreach param="manifest.file" target="-revision" >
125.59 - <path path="${selected.modules}"/>
125.60 - </foreach>
125.61 - <delete file="build_info.properties" />
125.62 </target>
125.63
125.64 <target name="-read-version">
125.65 @@ -209,61 +199,15 @@
125.66 <property file="${manifest.file}"></property>
125.67 <property name="specification.version" value="${OpenIDE-Module-Specification-Version}"/>
125.68 <echo>OpenIDE-Module: ${OpenIDE-Module}</echo>
125.69 - <echo>Current build number:${specification.version}</echo>
125.70 - <propertyregex property="major.version" input="${specification.version}" regexp="(\d+)\.(\d+)\.(\d+)$" select="\1" />
125.71 - <echo level="verbose">major: ${major.version}</echo>
125.72 - <propertyregex property="minor.version" input="${specification.version}" regexp="(\d+)\.(\d+)\.(\d+)$" select="\2" />
125.73 - <echo level="verbose">minor: ${minor.version}</echo>
125.74 - <propertyregex property="revision.version" input="${specification.version}" regexp="(\d+)\.(\d+)\.(\d+)$" select="\3" />
125.75 - <echo level="verbose">revision: ${revision.version}</echo>
125.76 - <propertyfile file="build_info.properties">
125.77 - <entry key="build.major.number" type="int" value="${major.version}" />
125.78 - <entry key="build.minor.number" type="int" value="${minor.version}" />
125.79 - <entry key="build.revision.number" type="int" value="${revision.version}" />
125.80 - </propertyfile>
125.81 + <echo>Current build number:${env.BUILD_NUMBER}</echo>
125.82 </target>
125.83
125.84 - <target name="-revision" depends="-read-version">
125.85 - <propertyfile file="build_info.properties">
125.86 - <entry key="build.revision.number" type="int" operation="+" value="1"/>
125.87 - </propertyfile>
125.88 -
125.89 - <loadproperties srcfile="build_info.properties" />
125.90 - <manifest file="${manifest.file}" mode="update">
125.91 - <attribute name="OpenIDE-Module-Specification-Version" value="${build.major.number}.${build.minor.number}.${build.revision.number}" />
125.92 + <target name="-update-meta-files" depends="-read-version">
125.93 + <manifest file="${manifest.file}" mode="update" >
125.94 + <attribute name="OpenIDE-Module-Specification-Version" value="${new_version}" />
125.95 </manifest>
125.96 - <replaceregexp match="(dependency\D*code-name-base\W${OpenIDE-Module}\W/\D*)(\d+\.\d+\.\d+)" byline="false"
125.97 - file="plsql-support.kit/nbproject/project.xml" replace="\1${build.major.number}.${build.minor.number}.${build.revision.number}"/>
125.98 - </target>
125.99 -
125.100 - <target name="-minor" depends="-read-version">
125.101 - <propertyfile file="build_info.properties">
125.102 - <entry key="build.minor.number" type="int" operation="+" value="1" />
125.103 - <entry key="build.revision.number" type="int" value="0" />
125.104 - </propertyfile>
125.105 - <loadproperties srcfile="build_info.properties" />
125.106 -
125.107 - <manifest file="${manifest.file}" mode="update">
125.108 - <attribute name="OpenIDE-Module-Specification-Version" value="${build.major.number}.${build.minor.number}.${build.revision.number}" />
125.109 - </manifest>
125.110 - <replaceregexp match="(dependency\D*code-name-base\W${OpenIDE-Module}\W/\D*)(\d+\.\d+\.\d+)" byline="false"
125.111 - file="plsql-support.kit/nbproject/project.xml" replace="\1${build.major.number}.${build.minor.number}.${build.revision.number}"/>
125.112 - </target>
125.113 -
125.114 - <target name="-major" depends="-read-version">
125.115 - <propertyfile file="build_info.properties">
125.116 - <entry key="build.major.number" type="int" operation="+" value="1" />
125.117 - <entry key="build.minor.number" type="int" value="0" />
125.118 - <entry key="build.revision.number" type="int" value="0" />
125.119 - </propertyfile>
125.120 - <!--<echoproperties srcfile="build_info.properties" />-->
125.121 - <loadproperties srcfile="build_info.properties" />
125.122 -
125.123 - <manifest file="${manifest.file}" mode="update" >
125.124 - <attribute name="OpenIDE-Module-Specification-Version" value="${build.major.number}.${build.minor.number}.${build.revision.number}" />
125.125 - </manifest>
125.126 - <replaceregexp match="(dependency\D*code-name-base\W${OpenIDE-Module}\W/\D*)(\d+\.\d+\.\d+)" byline="false"
125.127 - file="plsql-support.kit/nbproject/project.xml" replace="\1${build.major.number}.${build.minor.number}.${build.revision.number}"/>
125.128 + <replaceregexp match="(dependency\D*code-name-base\W${OpenIDE-Module}\W/\D*)(\d+\.\d+\.\d+\.\d+)" byline="false"
125.129 + file="plsql-support.kit/nbproject/project.xml" replace="\1${new_version}"/>
125.130 </target>
125.131
125.132 <target name="all">
126.1 --- a/nbproject/genfiles.properties Tue Feb 14 17:36:37 2012 +0100
126.2 +++ b/nbproject/genfiles.properties Wed Aug 15 20:45:01 2012 +0200
126.3 @@ -8,4 +8,4 @@
126.4 nbproject/build-impl.xml.stylesheet.CRC32=196c7090
126.5 nbproject/platform.xml.data.CRC32=fd65edd3
126.6 nbproject/platform.xml.script.CRC32=db9e1f43
126.7 -nbproject/platform.xml.stylesheet.CRC32=df8ac4dd@2.47.1
126.8 +nbproject/platform.xml.stylesheet.CRC32=df8ac4dd@2.50.1
127.1 --- a/nbproject/platform.properties Tue Feb 14 17:36:37 2012 +0100
127.2 +++ b/nbproject/platform.properties Wed Aug 15 20:45:01 2012 +0200
127.3 @@ -1,3 +1,5 @@
127.4 +branding.token=plsql_support
127.5 +nbjdk.active=JDK_1.6
127.6 nbplatform.default.netbeans.dest.dir=/hudson/workdir/jobs/plsql-support/workspace/ide/netbeans
127.7 nbplatform.default.harness.dir=${nbplatform.default.netbeans.dest.dir}/harness
127.8 cluster.path=\
127.9 @@ -7,6 +9,7 @@
127.10 ${nbplatform.active.dir}/nb:\
127.11 ${nbplatform.active.dir}/platform:\
127.12 ${nbplatform.active.dir}/profiler:\
127.13 + ${nbplatform.active.dir}/webcommon:\
127.14 ${nbplatform.active.dir}/websvccommon
127.15 disabled.modules=\
127.16 org.netbeans.modules.bugzilla.exceptionreporter,\
128.1 --- a/nbproject/project.properties Tue Feb 14 17:36:37 2012 +0100
128.2 +++ b/nbproject/project.properties Wed Aug 15 20:45:01 2012 +0200
128.3 @@ -1,5 +1,5 @@
128.4 app.icon=branding/core/core.jar/org/netbeans/core/startup/frame48.gif
128.5 -app.name=plsql_support
128.6 +app.name=${branding.token}
128.7 app.title=PL/SQL Support
128.8 auxiliary.org-netbeans-modules-apisupport-installer.license-type=no
128.9 auxiliary.org-netbeans-modules-apisupport-installer.os-linux=true
128.10 @@ -7,7 +7,6 @@
128.11 auxiliary.org-netbeans-modules-apisupport-installer.os-solaris=false
128.12 auxiliary.org-netbeans-modules-apisupport-installer.os-windows=true
128.13 auxiliary.org-netbeans-modules-apisupport-installer.pack200-enabled=false
128.14 -branding.token=${app.name}
128.15 modules=\
128.16 ${project.org.netbeans.modules.plsqlsupport.db}:\
128.17 ${project.org.netbeans.modules.plsql.annotation}:\
129.1 --- a/plsql-support.kit/manifest.mf Tue Feb 14 17:36:37 2012 +0100
129.2 +++ b/plsql-support.kit/manifest.mf Wed Aug 15 20:45:01 2012 +0200
129.3 @@ -4,5 +4,5 @@
129.4 OpenIDE-Module: org.netbeans.modules.plsql.kit
129.5 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/plsql/kit/Bundl
129.6 e.properties
129.7 -OpenIDE-Module-Specification-Version: 1.0.59
129.8 +OpenIDE-Module-Specification-Version: 8.72.0.8
129.9
130.1 --- a/plsql-support.kit/nbproject/genfiles.properties Tue Feb 14 17:36:37 2012 +0100
130.2 +++ b/plsql-support.kit/nbproject/genfiles.properties Wed Aug 15 20:45:01 2012 +0200
130.3 @@ -1,8 +1,8 @@
130.4 -build.xml.data.CRC32=b60269e8
130.5 +build.xml.data.CRC32=45e5f1d3
130.6 build.xml.script.CRC32=8894d7fe
130.7 -build.xml.stylesheet.CRC32=a56c6a5b@1.46.2
130.8 +build.xml.stylesheet.CRC32=a56c6a5b@2.50.1
130.9 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
130.10 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
130.11 -nbproject/build-impl.xml.data.CRC32=b60269e8
130.12 +nbproject/build-impl.xml.data.CRC32=45e5f1d3
130.13 nbproject/build-impl.xml.script.CRC32=4cc852db
130.14 -nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.46.2
130.15 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.50.1
131.1 --- a/plsql-support.kit/nbproject/project.xml Tue Feb 14 17:36:37 2012 +0100
131.2 +++ b/plsql-support.kit/nbproject/project.xml Wed Aug 15 20:45:01 2012 +0200
131.3 @@ -11,7 +11,7 @@
131.4 <build-prerequisite/>
131.5 <compile-dependency/>
131.6 <run-dependency>
131.7 - <specification-version>1.8.12</specification-version>
131.8 + <specification-version>1.8.18</specification-version>
131.9 </run-dependency>
131.10 </dependency>
131.11 <dependency>
131.12 @@ -19,13 +19,13 @@
131.13 <build-prerequisite/>
131.14 <compile-dependency/>
131.15 <run-dependency>
131.16 - <specification-version>1.8.5</specification-version>
131.17 + <specification-version>1.8.8</specification-version>
131.18 </run-dependency>
131.19 </dependency>
131.20 <dependency>
131.21 <code-name-base>org.netbeans.modules.plsql.debug</code-name-base>
131.22 <run-dependency>
131.23 - <specification-version>1.7.19</specification-version>
131.24 + <specification-version>1.7.23</specification-version>
131.25 </run-dependency>
131.26 </dependency>
131.27 <dependency>
131.28 @@ -33,7 +33,7 @@
131.29 <build-prerequisite/>
131.30 <compile-dependency/>
131.31 <run-dependency>
131.32 - <specification-version>1.8.20</specification-version>
131.33 + <specification-version>1.8.33</specification-version>
131.34 </run-dependency>
131.35 </dependency>
131.36 <dependency>
131.37 @@ -41,7 +41,7 @@
131.38 <build-prerequisite/>
131.39 <compile-dependency/>
131.40 <run-dependency>
131.41 - <specification-version>1.8.10</specification-version>
131.42 + <specification-version>1.8.13</specification-version>
131.43 </run-dependency>
131.44 </dependency>
131.45 <dependency>
131.46 @@ -53,13 +53,13 @@
131.47 <dependency>
131.48 <code-name-base>org.netbeans.modules.plsql.format</code-name-base>
131.49 <run-dependency>
131.50 - <specification-version>1.9.15</specification-version>
131.51 + <specification-version>1.9.20</specification-version>
131.52 </run-dependency>
131.53 </dependency>
131.54 <dependency>
131.55 <code-name-base>org.netbeans.modules.plsql.format.options</code-name-base>
131.56 <run-dependency>
131.57 - <specification-version>1.7.7</specification-version>
131.58 + <specification-version>1.7.8</specification-version>
131.59 </run-dependency>
131.60 </dependency>
131.61 <dependency>
131.62 @@ -75,19 +75,19 @@
131.63 <build-prerequisite/>
131.64 <compile-dependency/>
131.65 <run-dependency>
131.66 - <specification-version>1.8.8</specification-version>
131.67 + <specification-version>1.8.10</specification-version>
131.68 </run-dependency>
131.69 </dependency>
131.70 <dependency>
131.71 <code-name-base>org.netbeans.modules.plsql.navigator</code-name-base>
131.72 <run-dependency>
131.73 - <specification-version>1.8.1</specification-version>
131.74 + <specification-version>1.8.4</specification-version>
131.75 </run-dependency>
131.76 </dependency>
131.77 <dependency>
131.78 <code-name-base>org.netbeans.modules.plsql.palette</code-name-base>
131.79 <run-dependency>
131.80 - <specification-version>1.8.9</specification-version>
131.81 + <specification-version>1.8.10</specification-version>
131.82 </run-dependency>
131.83 </dependency>
131.84 <dependency>
131.85 @@ -101,7 +101,7 @@
131.86 <build-prerequisite/>
131.87 <compile-dependency/>
131.88 <run-dependency>
131.89 - <specification-version>1.7.20</specification-version>
131.90 + <specification-version>1.7.25</specification-version>
131.91 </run-dependency>
131.92 </dependency>
131.93 <dependency>
131.94 @@ -109,13 +109,13 @@
131.95 <build-prerequisite/>
131.96 <compile-dependency/>
131.97 <run-dependency>
131.98 - <specification-version>1.8.19</specification-version>
131.99 + <specification-version>1.8.23</specification-version>
131.100 </run-dependency>
131.101 </dependency>
131.102 <dependency>
131.103 <code-name-base>org.netbeans.modules.plsqlsupport.db.project</code-name-base>
131.104 <run-dependency>
131.105 - <specification-version>1.0.1</specification-version>
131.106 + <specification-version>1.0.2</specification-version>
131.107 </run-dependency>
131.108 </dependency>
131.109 </module-dependencies>