You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by ni...@apache.org on 2016/12/17 10:28:48 UTC
[72/81] [abbrv] zest-java git commit: ZEST-195, ZEST-201 ;
Rename of everything else from zest to polygene.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/polygene/ide/plugin/idea/mixins/inspections/MixinsAnnotationDeclaredOnMixinType.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/polygene/ide/plugin/idea/mixins/inspections/MixinsAnnotationDeclaredOnMixinType.java b/tools/qidea/src/main/java/org/apache/polygene/ide/plugin/idea/mixins/inspections/MixinsAnnotationDeclaredOnMixinType.java
new file mode 100644
index 0000000..914823d
--- /dev/null
+++ b/tools/qidea/src/main/java/org/apache/polygene/ide/plugin/idea/mixins/inspections/MixinsAnnotationDeclaredOnMixinType.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.polygene.ide.plugin.idea.mixins.inspections;
+
+import com.intellij.codeInspection.InspectionManager;
+import com.intellij.codeInspection.ProblemDescriptor;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.PsiAnnotation;
+import com.intellij.psi.PsiAnnotationMemberValue;
+import com.intellij.psi.PsiClass;
+import org.jetbrains.annotations.NotNull;
+import org.apache.polygene.ide.plugin.idea.common.inspections.AbstractFix;
+import org.apache.polygene.ide.plugin.idea.common.inspections.AbstractInspection;
+
+import static com.intellij.codeInspection.ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
+import static org.apache.polygene.ide.plugin.idea.common.resource.PolygeneResourceBundle.message;
+import static org.apache.polygene.ide.plugin.idea.mixins.common.PolygeneMixinUtil.getMixinsAnnotation;
+
+/**
+ * @author edward.yakop@gmail.com
+ * @since 0.1
+ */
+public final class MixinsAnnotationDeclaredOnMixinType extends AbstractInspection
+{
+ @NotNull
+ public final String getShortName()
+ {
+ return "MixinsAnnotationDeclaredOnMixinType";
+ }
+
+ @NotNull
+ protected final String resourceBundlePrefixId()
+ {
+ return "mixins.annotation.declared.on.mixin.type";
+ }
+
+ @Override
+ public ProblemDescriptor[] checkClass( @NotNull PsiClass psiClass,
+ @NotNull InspectionManager manager,
+ boolean isOnTheFly )
+ {
+ PsiAnnotation mixinsAnnotation = getMixinsAnnotation( psiClass );
+ if( mixinsAnnotation == null )
+ {
+ return null;
+ }
+
+ if( psiClass.isInterface() )
+ {
+ return null;
+ }
+
+ String message = message( "mixins.annotation.declared.on.mixin.type.error.declared.on.class" );
+ RemoveInvalidMixinClassReferenceFix fix = new RemoveInvalidMixinClassReferenceFix( mixinsAnnotation );
+ ProblemDescriptor problemDescriptor = manager.createProblemDescriptor( mixinsAnnotation, message, fix,
+ GENERIC_ERROR_OR_WARNING );
+ return new ProblemDescriptor[]{ problemDescriptor };
+
+ }
+
+ private static class RemoveInvalidMixinClassReferenceFix extends AbstractFix
+ {
+ private final PsiAnnotationMemberValue mixinsAnnotation;
+
+ public RemoveInvalidMixinClassReferenceFix( @NotNull PsiAnnotationMemberValue mixinsAnnotation )
+ {
+ super( message( "mixins.annotation.declared.on.mixin.type.fix.remove.mixins.annotation" ) );
+ this.mixinsAnnotation = mixinsAnnotation;
+ }
+
+ public final void applyFix( @NotNull Project project, @NotNull ProblemDescriptor descriptor )
+ {
+ mixinsAnnotation.delete();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/polygene/ide/plugin/idea/sideEffects/common/PolygeneSideEffectConstants.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/polygene/ide/plugin/idea/sideEffects/common/PolygeneSideEffectConstants.java b/tools/qidea/src/main/java/org/apache/polygene/ide/plugin/idea/sideEffects/common/PolygeneSideEffectConstants.java
new file mode 100644
index 0000000..d3c269f
--- /dev/null
+++ b/tools/qidea/src/main/java/org/apache/polygene/ide/plugin/idea/sideEffects/common/PolygeneSideEffectConstants.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.polygene.ide.plugin.idea.sideEffects.common;
+
+/**
+ * @author edward.yakop@gmail.com
+ * @since 0.1
+ */
+public final class PolygeneSideEffectConstants
+{
+ public static final String QUALIFIED_NAME_SIDE_EFFECTS = "org.apache.polygene.api.sideeffect.SideEffects";
+
+ public static final String QUALIFIED_NAME_SIDE_EFFECT_OF = "org.apache.polygene.api.sideeffect.SideEffectOf";
+ public static final String QUALIFIED_NAME_GENERIC_SIDE_EFFECT = "org.apache.polygene.api.sideeffect.GenericSideEffect";
+
+ private PolygeneSideEffectConstants()
+ {
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/polygene/ide/plugin/idea/sideEffects/common/PolygeneSideEffectUtil.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/polygene/ide/plugin/idea/sideEffects/common/PolygeneSideEffectUtil.java b/tools/qidea/src/main/java/org/apache/polygene/ide/plugin/idea/sideEffects/common/PolygeneSideEffectUtil.java
new file mode 100644
index 0000000..c1533fc
--- /dev/null
+++ b/tools/qidea/src/main/java/org/apache/polygene/ide/plugin/idea/sideEffects/common/PolygeneSideEffectUtil.java
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.polygene.ide.plugin.idea.sideEffects.common;
+
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.*;
+import com.intellij.psi.search.GlobalSearchScope;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collections;
+import java.util.List;
+
+import static com.intellij.codeInsight.AnnotationUtil.findAnnotation;
+import static java.util.Collections.emptyList;
+import static org.apache.polygene.ide.plugin.idea.common.psi.PsiAnnotationUtil.getAnnotationDefaultParameterValue;
+import static org.apache.polygene.ide.plugin.idea.common.psi.PsiAnnotationUtil.getClassReference;
+import static org.apache.polygene.ide.plugin.idea.common.psi.PsiClassUtil.getPSIClass;
+import static org.apache.polygene.ide.plugin.idea.common.psi.search.GlobalSearchScopeUtil.determineSearchScope;
+import static org.apache.polygene.ide.plugin.idea.sideEffects.common.PolygeneSideEffectConstants.*;
+
+/**
+ * @author edward.yakop@gmail.com
+ * @since 0.1
+ */
+public final class PolygeneSideEffectUtil
+{
+ /**
+ * @param searchContext Search context.
+ * @return {@code GenericSideEffect} class given the search context. {@code null} if not found.
+ * @since 0.1
+ */
+ @Nullable
+ public static PsiClass getGenericSideEffectClass( @NotNull PsiElement searchContext )
+ {
+ Project project = searchContext.getProject();
+ GlobalSearchScope searchScope = determineSearchScope( searchContext );
+ return getGenericSideEffectClass( project, searchScope );
+ }
+
+ /**
+ * @param project project.
+ * @param scope search scope.
+ * @return {@code GenericSideEffect} class given {@code project} and {@code scope} parameters.
+ * Returns {@code null} if not found.
+ * @since 0.1
+ */
+ @Nullable
+ public static PsiClass getGenericSideEffectClass( @NotNull Project project,
+ @Nullable GlobalSearchScope scope )
+ {
+ JavaPsiFacade psiFacade = JavaPsiFacade.getInstance( project );
+ return scope == null ? null : psiFacade.findClass( QUALIFIED_NAME_GENERIC_SIDE_EFFECT, scope );
+ }
+
+ /**
+ * @param searchContext Search context.
+ * @return {@code SideEffectOf} class given the search context. {@code null} if not found.
+ * @since 0.1
+ */
+ @Nullable
+ public static PsiClass getSideEffectOfClass( @NotNull PsiElement searchContext )
+ {
+ Project project = searchContext.getProject();
+ GlobalSearchScope searchScope = determineSearchScope( searchContext );
+ return getSideEffectOfClass( project, searchScope );
+ }
+
+
+ /**
+ * @param project project.
+ * @param scope search scope.
+ * @return {@code SideEffectOf} class given {@code project} and {@code scope} parameters.
+ * Returns {@code null} if not found.
+ * @since 0.1
+ */
+ @Nullable
+ public static PsiClass getSideEffectOfClass( @NotNull Project project,
+ @Nullable GlobalSearchScope scope )
+ {
+ JavaPsiFacade psiFacade = JavaPsiFacade.getInstance( project );
+ return scope == null ? null : psiFacade.findClass( QUALIFIED_NAME_SIDE_EFFECT_OF, scope );
+ }
+
+ /**
+ * @param elementWithinJavaClass element within java class.
+ * @return {@code @SideEffects} annotation declaration of the class that contains the element.
+ * Returns {@code null} if not found, or {@code element} is an invalid context.
+ * @since 0.1
+ */
+ @Nullable
+ public static PsiAnnotation getSideEffectsAnnotation( @NotNull PsiElement elementWithinJavaClass )
+ {
+ PsiClass psiClass = getPSIClass( elementWithinJavaClass );
+ return findAnnotation( psiClass, QUALIFIED_NAME_SIDE_EFFECTS );
+ }
+
+ /**
+ * @param annotation annotation to process.
+ * @return {@code @SideEffects} annotation value. Returns {@link Collections#emptyList()} if {@code annotation} is
+ * {@code null} or annotation is not a {@code @SideEffects} annotation.
+ * @since 0.1
+ */
+ @NotNull
+ public static List<PsiAnnotationMemberValue> getSideEffectsAnnotationValue( @Nullable PsiAnnotation annotation )
+ {
+ if( annotation == null )
+ {
+ return emptyList();
+ }
+
+ String concernsQualifiedName = annotation.getQualifiedName();
+ if( !QUALIFIED_NAME_SIDE_EFFECTS.equals( concernsQualifiedName ) )
+ {
+ return emptyList();
+ }
+
+ return getAnnotationDefaultParameterValue( annotation );
+ }
+
+ /**
+ * @param value annotation member value.
+ * @return Side effect class reference given the {@code value} parameter. Returns {@code null} if it's not a
+ * class reference.
+ * @since 0.1
+ */
+ @Nullable
+ public static PsiJavaCodeReferenceElement getSideEffectClassReference( @NotNull PsiAnnotationMemberValue value )
+ {
+ return getClassReference( value );
+ }
+
+ /**
+ * Returns a {@code boolean} indicator whether the specified {@code psiClass} is a side effect.
+ *
+ * @param psiClass class to check.
+ * @return {@code true} if {@code psiClass} is a side effect, {@code false} otherwise.
+ * @since 0.1
+ */
+ public static boolean isASideEffect( @NotNull PsiClass psiClass )
+ {
+ if( psiClass.isInterface() )
+ {
+ return false;
+ }
+
+ PsiClass sideEffectOfClass = getSideEffectOfClass( psiClass );
+ return sideEffectOfClass != null && psiClass.isInheritor( sideEffectOfClass, true );
+ }
+
+ /**
+ * @param psiClass psi class to check.
+ * @return {@code true} if {@code psiClass} inherits {@code GenericSideEffect} class, {@code false} if
+ * {@code psiClass} does
+ * not inherit {@code GenericSideEffect} or {@code GenericSideEffect} is not found.
+ * @since 0.1
+ */
+ public static boolean isAGenericSideEffect( @NotNull PsiClass psiClass )
+ {
+ if( psiClass.isInterface() )
+ {
+ return false;
+ }
+
+ PsiClass genericSideEffect = getGenericSideEffectClass( psiClass );
+ return genericSideEffect != null && psiClass.isInheritor( genericSideEffect, true );
+ }
+
+ private PolygeneSideEffectUtil()
+ {
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/polygene/ide/plugin/idea/sideEffects/inspections/SideEffectsAnnotationDeclaredCorrectlyInspection.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/polygene/ide/plugin/idea/sideEffects/inspections/SideEffectsAnnotationDeclaredCorrectlyInspection.java b/tools/qidea/src/main/java/org/apache/polygene/ide/plugin/idea/sideEffects/inspections/SideEffectsAnnotationDeclaredCorrectlyInspection.java
new file mode 100644
index 0000000..bf46eb3
--- /dev/null
+++ b/tools/qidea/src/main/java/org/apache/polygene/ide/plugin/idea/sideEffects/inspections/SideEffectsAnnotationDeclaredCorrectlyInspection.java
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.polygene.ide.plugin.idea.sideEffects.inspections;
+
+import com.intellij.codeInspection.InspectionManager;
+import com.intellij.codeInspection.ProblemDescriptor;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.PsiAnnotation;
+import com.intellij.psi.PsiAnnotationMemberValue;
+import com.intellij.psi.PsiClass;
+import com.intellij.psi.PsiJavaCodeReferenceElement;
+import com.intellij.psi.search.GlobalSearchScope;
+import org.jetbrains.annotations.NotNull;
+import org.apache.polygene.ide.plugin.idea.common.inspections.AbstractFix;
+import org.apache.polygene.ide.plugin.idea.common.inspections.AbstractInspection;
+import org.apache.polygene.ide.plugin.idea.common.resource.PolygeneResourceBundle;
+import org.apache.polygene.ide.plugin.idea.sideEffects.common.PolygeneSideEffectUtil;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import static com.intellij.codeInspection.ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
+import static org.apache.polygene.ide.plugin.idea.common.psi.search.GlobalSearchScopeUtil.determineSearchScope;
+import static org.apache.polygene.ide.plugin.idea.common.resource.PolygeneResourceBundle.message;
+import static org.apache.polygene.ide.plugin.idea.sideEffects.common.PolygeneSideEffectUtil.*;
+
+/**
+ * @author edward.yakop@gmail.com
+ * @since 0.1
+ */
+public final class SideEffectsAnnotationDeclaredCorrectlyInspection extends AbstractInspection
+{
+ @NotNull
+ protected final String resourceBundlePrefixId()
+ {
+ return "side.effects.annotation.declared.correctly";
+ }
+
+ @NotNull
+ public final String getShortName()
+ {
+ return "SideEffectsAnnotationDeclaredCorrectlyInspection";
+ }
+
+ @Override
+ public final ProblemDescriptor[] checkClass( @NotNull PsiClass psiClass,
+ @NotNull InspectionManager manager,
+ boolean isOnTheFly )
+ {
+ // If class does not have @SideEffects, ignore
+ PsiAnnotation sideEffectsAnnotation = getSideEffectsAnnotation( psiClass );
+ if( sideEffectsAnnotation == null )
+ {
+ return null;
+ }
+
+ // If @SideEffects declared in class, suggest remove @SideEffects annotation
+ if( !psiClass.isInterface() )
+ {
+ String message = message( "side.effects.annotation.declared.correctly.error.annotation.declared.in.class" );
+ RemoveSideEffectsAnnotationFix fix = new RemoveSideEffectsAnnotationFix( sideEffectsAnnotation );
+ ProblemDescriptor problemDescriptor = manager.createProblemDescriptor( sideEffectsAnnotation, message, fix,
+ GENERIC_ERROR_OR_WARNING );
+ return new ProblemDescriptor[]{ problemDescriptor };
+ }
+
+ // If @SideEffects annotation is empty, ignore
+ List<PsiAnnotationMemberValue> sideEffectsAnnotationValue =
+ getSideEffectsAnnotationValue( sideEffectsAnnotation );
+ if( sideEffectsAnnotationValue.isEmpty() )
+ {
+ return null;
+ }
+
+ // If SideEffectOf is not resolved, ignore
+ Project project = psiClass.getProject();
+ GlobalSearchScope searchScope = determineSearchScope( psiClass );
+ PsiClass sideEffectOfClass = PolygeneSideEffectUtil.getGenericSideEffectClass( project, searchScope );
+ if( sideEffectOfClass == null )
+ {
+ return null;
+ }
+
+ List<ProblemDescriptor> problems = new LinkedList<ProblemDescriptor>();
+ for( PsiAnnotationMemberValue sideEffectClassReferenceWrapper : sideEffectsAnnotationValue )
+ {
+ PsiJavaCodeReferenceElement sideEffectClassReference =
+ getSideEffectClassReference( sideEffectClassReferenceWrapper );
+
+ // If it's not a class reference, ignore
+ if( sideEffectClassReference == null )
+ {
+ continue;
+ }
+
+ // If class reference can't be resolved, ignore
+ PsiClass sideEffectClass = (PsiClass) sideEffectClassReference.resolve();
+ if( sideEffectClass == null )
+ {
+ continue;
+ }
+
+ // If side effect class does not inherit SideEffectOf class, suggest remove that reference.
+ if( !sideEffectClass.isInheritor( sideEffectOfClass, true ) )
+ {
+ String message = PolygeneResourceBundle.message(
+ "side.effects.annotation.declared.correctly.error.side.effect.does.not.extend.side.effect.of",
+ sideEffectClass.getQualifiedName()
+ );
+
+ RemoveAnnotationValueFix fix = new RemoveAnnotationValueFix(
+ sideEffectClassReferenceWrapper, sideEffectClassReference
+ );
+ ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(
+ sideEffectClassReferenceWrapper, message, fix, GENERIC_ERROR_OR_WARNING );
+ problems.add( problemDescriptor );
+ }
+ else
+ {
+ // TODO: Test whether it is a generic side effect
+ // TODO: Test whether it is a specific side effect
+ }
+ }
+
+ return problems.toArray( new ProblemDescriptor[problems.size()] );
+ }
+
+ private static class RemoveSideEffectsAnnotationFix extends AbstractFix
+ {
+ private final PsiAnnotation sideEffectsAnnotation;
+
+ private RemoveSideEffectsAnnotationFix( @NotNull PsiAnnotation sideEffectsAnnotation )
+ {
+ super( message( "side.effects.annotation.declared.correctly.fix.remove.annotation" ) );
+ this.sideEffectsAnnotation = sideEffectsAnnotation;
+ }
+
+ public final void applyFix( @NotNull Project project, @NotNull ProblemDescriptor descriptor )
+ {
+ sideEffectsAnnotation.delete();
+ }
+ }
+
+ private static class RemoveAnnotationValueFix extends AbstractFix
+ {
+ private final PsiAnnotationMemberValue annotationValueToRemove;
+
+ private RemoveAnnotationValueFix( @NotNull PsiAnnotationMemberValue annotationValueToRemove,
+ @NotNull PsiJavaCodeReferenceElement sideEffectClassReference )
+ {
+ super( message( "side.effects.annotation.declared.correctly.fix.remove.class.reference",
+ sideEffectClassReference.getQualifiedName() ) );
+ this.annotationValueToRemove = annotationValueToRemove;
+ }
+
+ public final void applyFix( @NotNull Project project, @NotNull ProblemDescriptor descriptor )
+ {
+ annotationValueToRemove.delete();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/PolygeneApplicationComponent.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/PolygeneApplicationComponent.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/PolygeneApplicationComponent.java
deleted file mode 100644
index 42d1104..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/PolygeneApplicationComponent.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.polygene.ide.plugin.idea;
-
-import com.intellij.codeInspection.InspectionToolProvider;
-import com.intellij.facet.FacetTypeRegistry;
-import com.intellij.ide.fileTemplates.FileTemplateDescriptor;
-import com.intellij.ide.fileTemplates.FileTemplateGroupDescriptor;
-import com.intellij.ide.fileTemplates.FileTemplateGroupDescriptorFactory;
-import com.intellij.openapi.components.ApplicationComponent;
-import com.intellij.openapi.fileTypes.FileTypeManager;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.apache.polygene.ide.plugin.idea.appliesTo.inspections.AppliesToAnnotationDeclaredCorrectlyInspection;
-import org.apache.polygene.ide.plugin.idea.common.facet.PolygeneFacetType;
-import org.apache.polygene.ide.plugin.idea.concerns.inspections.ConcernsAnnotationDeclaredCorrectlyInspection;
-import org.apache.polygene.ide.plugin.idea.injections.invocation.inspections.InvocationAnnotationDeclaredCorrectlyInspection;
-import org.apache.polygene.ide.plugin.idea.injections.service.inspections.ServiceAnnotationDeclaredCorrectlyInspection;
-import org.apache.polygene.ide.plugin.idea.injections.structure.inspections.StructureAnnotationDeclaredCorrectlyInspection;
-import org.apache.polygene.ide.plugin.idea.mixins.inspections.MixinImplementsMixinType;
-import org.apache.polygene.ide.plugin.idea.mixins.inspections.MixinsAnnotationDeclaredOnMixinType;
-import org.apache.polygene.ide.plugin.idea.sideEffects.inspections.SideEffectsAnnotationDeclaredCorrectlyInspection;
-
-import javax.swing.*;
-
-import static org.apache.polygene.ide.plugin.idea.common.resource.PolygeneResourceBundle.message;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public final class PolygeneApplicationComponent
- implements ApplicationComponent, InspectionToolProvider, FileTemplateGroupDescriptorFactory
-{
- @NonNls
- private static String[] FILE_TEMPLATES = {
- "GenericConcernOf.java"
- };
-
- private final PolygeneFacetType polygeneFacetType;
-
- public PolygeneApplicationComponent()
- {
- polygeneFacetType = new PolygeneFacetType();
- }
-
- @NotNull
- public final String getComponentName()
- {
- return "PolygeneApplicationComponent";
- }
-
- public final void initComponent()
- {
- registerFacet();
- registerIntentions();
- }
-
- private void registerFacet()
- {
- FacetTypeRegistry facetTypeRegistry = FacetTypeRegistry.getInstance();
- facetTypeRegistry.registerFacetType( polygeneFacetType );
- }
-
- private void registerIntentions()
- {
-// IntentionManager intentionManager = IntentionManager.getInstance();
-// intentionManager.registerIntentionAndMetaData( new AddConcernOnType(), "intention.category.control.flow" );
- }
-
- public final void disposeComponent()
- {
- unregisterFacet();
- }
-
- private void unregisterFacet()
- {
- FacetTypeRegistry facetTypeRegistry = FacetTypeRegistry.getInstance();
- facetTypeRegistry.unregisterFacetType( polygeneFacetType );
- }
-
- public final Class[] getInspectionClasses()
- {
- return new Class[]{
- // Concerns
- ConcernsAnnotationDeclaredCorrectlyInspection.class,
- // Mixins
- MixinImplementsMixinType.class,
- MixinsAnnotationDeclaredOnMixinType.class,
- // Side effects
- SideEffectsAnnotationDeclaredCorrectlyInspection.class,
- // Injections
- InvocationAnnotationDeclaredCorrectlyInspection.class,
- ServiceAnnotationDeclaredCorrectlyInspection.class,
- StructureAnnotationDeclaredCorrectlyInspection.class,
- // AppliesTo
- AppliesToAnnotationDeclaredCorrectlyInspection.class
- };
- }
-
- public final FileTemplateGroupDescriptor getFileTemplatesDescriptor()
- {
- FileTemplateGroupDescriptor group = new FileTemplateGroupDescriptor(
- message( "polygene.file.template.group.title" ), null
- );
-
- FileTypeManager fileTypeManager = FileTypeManager.getInstance();
- for( @NonNls String template : FILE_TEMPLATES )
- {
- Icon icon = fileTypeManager.getFileTypeByFileName( template ).getIcon();
- group.addTemplate( new FileTemplateDescriptor( template, icon ) );
- }
-
- return group;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/appliesTo/common/PolygeneAppliesToConstants.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/appliesTo/common/PolygeneAppliesToConstants.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/appliesTo/common/PolygeneAppliesToConstants.java
deleted file mode 100644
index e50589d..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/appliesTo/common/PolygeneAppliesToConstants.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.polygene.ide.plugin.idea.appliesTo.common;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public final class PolygeneAppliesToConstants
-{
- public static final String QUALIFIED_NAME_APPLIES_TO = "org.apache.polygene.api.common.AppliesTo";
- public static final String QUALIFIED_NAME_APPLIES_TO_FILTER = "org.apache.polygene.api.common.AppliesToFilter";
-
- private PolygeneAppliesToConstants()
- {
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/appliesTo/common/PolygeneAppliesToUtil.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/appliesTo/common/PolygeneAppliesToUtil.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/appliesTo/common/PolygeneAppliesToUtil.java
deleted file mode 100644
index fd56b6b..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/appliesTo/common/PolygeneAppliesToUtil.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.polygene.ide.plugin.idea.appliesTo.common;
-
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.*;
-import com.intellij.psi.search.GlobalSearchScope;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.Collections;
-import java.util.List;
-
-import static com.intellij.codeInsight.AnnotationUtil.findAnnotation;
-import static java.util.Collections.emptyList;
-import static org.apache.polygene.ide.plugin.idea.appliesTo.common.PolygeneAppliesToConstants.QUALIFIED_NAME_APPLIES_TO;
-import static org.apache.polygene.ide.plugin.idea.appliesTo.common.PolygeneAppliesToConstants.QUALIFIED_NAME_APPLIES_TO_FILTER;
-import static org.apache.polygene.ide.plugin.idea.common.psi.PsiAnnotationUtil.getAnnotationDefaultParameterValue;
-import static org.apache.polygene.ide.plugin.idea.common.psi.PsiAnnotationUtil.getClassReference;
-import static org.apache.polygene.ide.plugin.idea.common.psi.PsiClassUtil.getPSIClass;
-import static org.apache.polygene.ide.plugin.idea.common.psi.search.GlobalSearchScopeUtil.determineSearchScope;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public final class PolygeneAppliesToUtil
-{
- /**
- * @param searchContext Search context.
- * @return {@code AppliesToFilter} class given the search context. {@code null} if not found.
- * @since 0.1
- */
- @Nullable
- public static PsiClass getAppliesToFilterClass( @NotNull PsiElement searchContext )
- {
- Project project = searchContext.getProject();
- GlobalSearchScope searchScope = determineSearchScope( searchContext );
- return getAppliesToFilterClass( project, searchScope );
- }
-
- /**
- * @param project project.
- * @param scope search scope.
- * @return {@code AppliesToFilter} class given {@code project} and {@code scope} parameters.
- * Returns {@code null} if not found.
- * @since 0.1
- */
- @Nullable
- public static PsiClass getAppliesToFilterClass( @NotNull Project project,
- @Nullable GlobalSearchScope scope )
- {
- JavaPsiFacade psiFacade = JavaPsiFacade.getInstance( project );
- return scope == null ? null : psiFacade.findClass( QUALIFIED_NAME_APPLIES_TO_FILTER, scope );
- }
-
- /**
- * @param elementWithinJavaClass element within java class.
- * @return {@code @AppliesTo} annotation declaration of the class that contains the element.
- * Returns {@code null} if not found, or {@code element} is an invalid context.
- * @since 0.1
- */
- @Nullable
- public static PsiAnnotation getAppliesToAnnotation( @NotNull PsiElement elementWithinJavaClass )
- {
- PsiClass psiClass = getPSIClass( elementWithinJavaClass );
- return findAnnotation( psiClass, QUALIFIED_NAME_APPLIES_TO );
- }
-
- /**
- * @param annotation annotation to process.
- * @return {@code @AppliesTo} annotation value. Returns {@link Collections#emptyList()} if {@code annotation} is
- * {@code null} or annotation is not a {@code @AppliesTo} annotation.
- * @since 0.1
- */
- @NotNull
- public static List<PsiAnnotationMemberValue> getAppliesToAnnotationValue( @Nullable PsiAnnotation annotation )
- {
- if( annotation == null )
- {
- return emptyList();
- }
-
- String concernsQualifiedName = annotation.getQualifiedName();
- if( !QUALIFIED_NAME_APPLIES_TO.equals( concernsQualifiedName ) )
- {
- return emptyList();
- }
-
- return getAnnotationDefaultParameterValue( annotation );
- }
-
- /**
- * @param value annotation member value.
- * @return Applies to class reference given the {@code value} parameter. Returns {@code null} if it's not a
- * class reference.
- * @since 0.1
- */
- @Nullable
- public static PsiJavaCodeReferenceElement getAppliesToValueClassReference( @NotNull PsiAnnotationMemberValue value )
- {
- return getClassReference( value );
- }
-
- /**
- * Returns a {@code boolean} indicator whether the specified {@code psiClass} is implements
- * {@code AppliesToFilter} class.
- *
- * @param psiClass class to check.
- * @param appliesToFilterClass {@code AppliesToFilter} class.
- * @return {@code true} if {@code psiClass} implements {@code AppliesToFilter} class, {@code false} otherwise.
- * @since 0.1
- */
- public static boolean isAnAppliesToFilter( @NotNull PsiClass psiClass, @NotNull PsiClass appliesToFilterClass )
- {
- return !psiClass.isInterface() && psiClass.isInheritor( appliesToFilterClass, true );
- }
-
- private PolygeneAppliesToUtil()
- {
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/appliesTo/inspections/AppliesToAnnotationDeclaredCorrectlyInspection.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/appliesTo/inspections/AppliesToAnnotationDeclaredCorrectlyInspection.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/appliesTo/inspections/AppliesToAnnotationDeclaredCorrectlyInspection.java
deleted file mode 100644
index b64d762..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/appliesTo/inspections/AppliesToAnnotationDeclaredCorrectlyInspection.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.polygene.ide.plugin.idea.appliesTo.inspections;
-
-import com.intellij.codeInspection.InspectionManager;
-import com.intellij.codeInspection.ProblemDescriptor;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.*;
-import com.intellij.psi.search.GlobalSearchScope;
-import org.jetbrains.annotations.NotNull;
-import org.apache.polygene.ide.plugin.idea.common.inspections.AbstractFix;
-import org.apache.polygene.ide.plugin.idea.common.inspections.AbstractInspection;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import static com.intellij.codeInspection.ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
-import static org.apache.polygene.ide.plugin.idea.appliesTo.common.PolygeneAppliesToUtil.*;
-import static org.apache.polygene.ide.plugin.idea.common.psi.PsiClassUtil.isImplementsInvocationHandler;
-import static org.apache.polygene.ide.plugin.idea.common.psi.search.GlobalSearchScopeUtil.determineSearchScope;
-import static org.apache.polygene.ide.plugin.idea.common.resource.PolygeneResourceBundle.message;
-import static org.apache.polygene.ide.plugin.idea.concerns.common.PolygeneConcernUtil.isAConcern;
-import static org.apache.polygene.ide.plugin.idea.concerns.common.PolygeneConcernUtil.isAGenericConcern;
-import static org.apache.polygene.ide.plugin.idea.sideEffects.common.PolygeneSideEffectUtil.isAGenericSideEffect;
-import static org.apache.polygene.ide.plugin.idea.sideEffects.common.PolygeneSideEffectUtil.isASideEffect;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public final class AppliesToAnnotationDeclaredCorrectlyInspection extends AbstractInspection
-{
- @NotNull
- protected final String resourceBundlePrefixId()
- {
- return "applies.to.annotation.declared.correctly";
- }
-
- @NotNull
- public final String getShortName()
- {
- return "AppliesToAnnotationDeclaredCorrectlyInspection";
- }
-
- @Override
- public final ProblemDescriptor[] checkClass( @NotNull PsiClass psiClass,
- @NotNull InspectionManager manager,
- boolean isOnTheFly )
- {
- PsiAnnotation appliesToAnnotation = getAppliesToAnnotation( psiClass );
- if( appliesToAnnotation == null )
- {
- // If class does not have @AppliesTo, ignore
- return null;
- }
-
- String classQualifiedName = psiClass.getQualifiedName();
- // @AppliesTo can only be declared on class
- if( psiClass.isInterface() )
- {
- // Suggest remove applies to
- String message = message(
- "applies.to.annotation.declared.correctly.error.annotation.must.be.declared.on.class"
- );
- ProblemDescriptor problemDescriptor = createRemoveAppliesToFilterProblemDescriptor(
- manager, message, appliesToAnnotation );
- return new ProblemDescriptor[]{ problemDescriptor };
- }
-
- // If @AppliesTo annotation is empty, ignore
- List<PsiAnnotationMemberValue> appliesToAnnotationValues = getAppliesToAnnotationValue( appliesToAnnotation );
- if( appliesToAnnotationValues.isEmpty() )
- {
- return null;
- }
-
- // If AppliesToFilter is not resolved, ignore
- Project project = psiClass.getProject();
- GlobalSearchScope searchScope = determineSearchScope( psiClass );
- PsiClass appliesToFilterClass = getAppliesToFilterClass( project, searchScope );
- if( appliesToFilterClass == null )
- {
- return null;
- }
-
- boolean classIsAConcern = isAConcern( psiClass );
- boolean classIsASideEffect = isASideEffect( psiClass );
- boolean classIsAGenericConcern = classIsAConcern && isAGenericConcern( psiClass );
- boolean classIsAGenericSideEffect = classIsASideEffect && isAGenericSideEffect( psiClass );
- boolean classIsAMixin = !classIsAConcern && !classIsASideEffect;
- boolean classIsAGenericMixin = classIsAMixin && isImplementsInvocationHandler( psiClass );
-
- List<ProblemDescriptor> problems = new LinkedList<ProblemDescriptor>();
- for( PsiAnnotationMemberValue appliesToAnnotationValue : appliesToAnnotationValues )
- {
- PsiJavaCodeReferenceElement appliesToValueClassReference =
- getAppliesToValueClassReference( appliesToAnnotationValue );
-
- // If it's not a class reference, ignore
- if( appliesToValueClassReference == null )
- {
- continue;
- }
-
- // If class reference can't be resolved, ignore
- PsiClass appliesToValueClass = (PsiClass) appliesToValueClassReference.resolve();
- if( appliesToValueClass == null )
- {
- continue;
- }
-
- String appliesToValueQualifiedName = appliesToValueClass.getQualifiedName();
- boolean appliesToValueIsAnAnnotation = appliesToValueClass.isAnnotationType();
- boolean appliesToValueIsImplementingAppliesToFilter =
- appliesToValueClass.isInheritor( appliesToFilterClass, true );
-
- String message = null;
- if( appliesToValueIsAnAnnotation && classIsAMixin )
- {
- // If Class is a mixin and appliesToValueClass is an annotation
- message = message(
- "applies.to.annotation.declared.correctly.error.value.is.invalid.for.mixin",
- appliesToValueQualifiedName
- );
- }
- else if( appliesToValueIsAnAnnotation || appliesToValueIsImplementingAppliesToFilter )
- {
- if( classIsAConcern && !classIsAGenericConcern )
- {
- // If psiClass is a concern but not generic concern
- message = message(
- "applies.to.annotation.declared.correctly.error.value.requires.class.to.extends.GenericConcern",
- appliesToValueQualifiedName, classQualifiedName
- );
- }
- else if( classIsASideEffect && !classIsAGenericSideEffect )
- {
- // If psiClass a side effect but not a generic side effect
- message = message(
- "applies.to.annotation.declared.correctly.error.value.requires.class.to.extends.GenericSideEffect",
- appliesToValueQualifiedName, classQualifiedName
- );
- }
- else if( appliesToValueIsImplementingAppliesToFilter && !classIsAGenericMixin )
- {
- message = message(
- "applies.to.annotation.declared.correctly.error.value.requires.class.to.implements.InvocationHandler",
- appliesToValueQualifiedName, classQualifiedName
- );
- }
- }
- else if( appliesToValueClass.isInterface() )
- {
- if( !psiClass.isInheritor( appliesToValueClass, true ) &&
- !( classIsAGenericConcern || classIsAGenericSideEffect ) )
- {
- // If psiClass does not implement that interface and it's not a generic concern or generic side effect
- if( classIsAConcern )
- {
- message = message(
- "applies.to.annotation.declared.correctly.error.value.requires.class.to.implement.interface.or.extends.GenericConcern",
- appliesToValueQualifiedName, classQualifiedName );
- }
- else if( classIsASideEffect )
- {
- message = message(
- "applies.to.annotation.declared.correctly.error.value.requires.class.to.implement.interface.or.extends.GenericSideEffect",
- appliesToValueQualifiedName, classQualifiedName );
- }
- else
- {
- message = message(
- "applies.to.annotation.declared.correctly.error.value.requires.class.to.implement.value.interface.or.implements.InvocationHandler",
- appliesToValueQualifiedName, classQualifiedName );
- }
- }
- }
- else
- {
- if( classIsAMixin )
- {
- message = message(
- "applies.to.annotation.declared.correctly.error.value.is.invalid.for.mixin",
- appliesToValueQualifiedName
- );
- }
- else
- {
- message = message(
- "applies.to.annotation.declared.correctly.error.annotation.value.is.invalid.for.non.mixin",
- appliesToValueQualifiedName
- );
- }
- }
-
- if( message != null )
- {
- ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(
- appliesToAnnotationValue,
- message,
- new RemoveAnnotationValueFix( appliesToAnnotationValue, appliesToValueClassReference ),
- GENERIC_ERROR_OR_WARNING );
- problems.add( problemDescriptor );
- }
- }
-
- return problems.toArray( new ProblemDescriptor[problems.size()] );
- }
-
- @NotNull
- private ProblemDescriptor createRemoveAppliesToFilterProblemDescriptor( @NotNull InspectionManager manager,
- @NotNull String problemMessage,
- @NotNull PsiAnnotation appliesToAnnotation )
- {
- RemoveAppliesToFilterAnnotationFix fix = new RemoveAppliesToFilterAnnotationFix( appliesToAnnotation );
- return manager.createProblemDescriptor( appliesToAnnotation, problemMessage, fix, GENERIC_ERROR_OR_WARNING );
- }
-
- private static class RemoveAppliesToFilterAnnotationFix extends AbstractFix
- {
- private final PsiAnnotation appliesToFilterAnnotation;
-
- private RemoveAppliesToFilterAnnotationFix( @NotNull PsiAnnotation appliesToFilterAnnotation )
- {
- super( message( "applies.to.annotation.declared.correctly.fix.remove.annotation" ) );
- this.appliesToFilterAnnotation = appliesToFilterAnnotation;
- }
-
- public final void applyFix( @NotNull Project project, @NotNull ProblemDescriptor descriptor )
- {
- appliesToFilterAnnotation.delete();
- }
- }
-
- private static class RemoveAnnotationValueFix extends AbstractFix
- {
- private final PsiAnnotationMemberValue annotationValueToRemove;
-
- private RemoveAnnotationValueFix( @NotNull PsiAnnotationMemberValue annotationValueToRemove,
- @NotNull PsiJavaCodeReferenceElement appliesToValueClassReference )
- {
- super( message( "applies.to.annotation.declared.correctly.fix.remove.class.reference",
- appliesToValueClassReference.getQualifiedName() ) );
- this.annotationValueToRemove = annotationValueToRemove;
- }
-
- public final void applyFix( @NotNull Project project, @NotNull ProblemDescriptor descriptor )
- {
- annotationValueToRemove.delete();
- }
- }
-
- private static class ClassImplementInterfaceFix extends AbstractFix
- {
- private final PsiClass psiClass;
- private final PsiClass interfaceToImplement;
-
- private ClassImplementInterfaceFix( @NotNull PsiClass psiClass,
- @NotNull PsiClass interfaceToImplement )
- {
- super( message( "applies.to.annotation.declared.correctly.fix.remove.class.reference",
- interfaceToImplement.getQualifiedName() ) );
- this.psiClass = psiClass;
- this.interfaceToImplement = interfaceToImplement;
- }
-
- public final void applyFix( @NotNull Project project, @NotNull ProblemDescriptor descriptor )
- {
- PsiReferenceList implementList = psiClass.getImplementsList();
- if( implementList != null )
- {
-
- implementList.add( interfaceToImplement );
- }
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/actions/AbstractCreateElementActionBase.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/actions/AbstractCreateElementActionBase.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/actions/AbstractCreateElementActionBase.java
deleted file mode 100644
index b47a045..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/actions/AbstractCreateElementActionBase.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.polygene.ide.plugin.idea.common.actions;
-
-import com.intellij.CommonBundle;
-import com.intellij.ide.actions.CreateElementActionBase;
-import com.intellij.ide.fileTemplates.FileTemplate;
-import com.intellij.ide.fileTemplates.FileTemplateManager;
-import com.intellij.ide.fileTemplates.JavaTemplateUtil;
-import com.intellij.openapi.fileTypes.StdFileTypes;
-import com.intellij.openapi.module.Module;
-import com.intellij.openapi.module.ModuleUtil;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.Messages;
-import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.CodeStyleManager;
-import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.Properties;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public abstract class AbstractCreateElementActionBase extends CreateElementActionBase
-{
- @NonNls
- private static final String NAME_TEMPLATE_PROPERTY = "NAME";
-
- protected AbstractCreateElementActionBase( String text, String description )
- {
- super( text, description, null );
- }
-
- @NotNull
- protected final PsiElement[] invokeDialog( Project project, PsiDirectory directory )
- {
- Module module = ModuleUtil.findModuleForFile( directory.getVirtualFile(), project );
- if( module == null )
- {
- return PsiElement.EMPTY_ARRAY;
- }
-
- MyInputValidator validator = doInvokeDialog( project, directory );
- return validator.getCreatedElements();
- }
-
- protected MyInputValidator doInvokeDialog( Project project, PsiDirectory directory )
- {
- MyInputValidator validator = new MyInputValidator( project, directory );
- Messages.showInputDialog( project, getDialogPrompt(), getDialogTitle(), Messages.getQuestionIcon(), "", validator );
- return validator;
- }
-
- /**
- * @return Dialog prompt.
- */
- protected abstract String getDialogPrompt();
-
- /**
- * @return Dialog title.
- */
- protected abstract String getDialogTitle();
-
- protected String getErrorTitle()
- {
- return CommonBundle.getErrorTitle();
- }
-
- protected final void checkBeforeCreate( String newName, PsiDirectory directory )
- throws IncorrectOperationException
- {
- JavaDirectoryService javaDirectoryService = JavaDirectoryService.getInstance();
- javaDirectoryService.checkCreateClass( directory, newName );
- }
-
- protected static PsiClass createClassFromTemplate( @NotNull PsiDirectory directory,
- @NotNull String className,
- @NotNull String templateName,
- @NonNls String... parameters )
- throws IncorrectOperationException
- {
- String classFileName = className + "." + StdFileTypes.JAVA.getDefaultExtension();
- PsiFile file = createFromTemplateInternal( directory, className, classFileName, templateName, parameters );
- return ( (PsiJavaFile) file ).getClasses()[ 0 ];
- }
-
- protected static PsiFile createFromTemplateInternal( @NotNull PsiDirectory directory,
- @NotNull String name,
- @NotNull String fileName,
- @NotNull String templateName,
- @NonNls String... parameters )
- throws IncorrectOperationException
- {
- // Load template
- FileTemplateManager fileTemplateManager = FileTemplateManager.getInstance();
- FileTemplate template = fileTemplateManager.getJ2eeTemplate( templateName );
-
- // Process template properties
- Properties properties = new Properties( fileTemplateManager.getDefaultProperties() );
- JavaTemplateUtil.setPackageNameAttribute( properties, directory );
- properties.setProperty( NAME_TEMPLATE_PROPERTY, name );
-
- // Add parameters
- for( int i = 0; i < parameters.length; i += 2 )
- {
- properties.setProperty( parameters[ i ], parameters[ i + 1 ] );
- }
-
- // Create text from template with specified properties
- String text;
- try
- {
- text = template.getText( properties );
- }
- catch( Exception e )
- {
- String message = "Unable to load template for " +
- fileTemplateManager.internalTemplateToSubject( templateName );
- throw new RuntimeException( message, e );
- }
-
- // Serialized text to file
- PsiManager psiManager = PsiManager.getInstance( directory.getProject() );
- PsiFileFactory fileFactory = PsiFileFactory.getInstance( directory.getProject() );
- PsiFile file = fileFactory.createFileFromText( fileName, text );
-
- // Reformat the file according to project/default style
- CodeStyleManager codeStyleManager = CodeStyleManager.getInstance( psiManager );
- codeStyleManager.reformat( file );
-
- // Add newly created file to directory
- return (PsiFile) directory.add( file );
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/actions/PolygeneCreateActionGroup.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/actions/PolygeneCreateActionGroup.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/actions/PolygeneCreateActionGroup.java
deleted file mode 100644
index d53e0e1..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/actions/PolygeneCreateActionGroup.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.polygene.ide.plugin.idea.common.actions;
-
-import com.intellij.ide.IdeView;
-import com.intellij.openapi.actionSystem.*;
-import com.intellij.openapi.module.Module;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.roots.ProjectFileIndex;
-import com.intellij.openapi.roots.ProjectRootManager;
-import com.intellij.psi.JavaDirectoryService;
-import com.intellij.psi.PsiDirectory;
-
-import static org.apache.polygene.ide.plugin.idea.common.resource.PolygeneResourceBundle.message;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public final class PolygeneCreateActionGroup extends DefaultActionGroup
-{
- public PolygeneCreateActionGroup()
- {
- super( message( "polygene.action.group.title" ), true );
- getTemplatePresentation().setDescription( message( "polygene.action.group.description" ) );
- }
-
- public void update( AnActionEvent e )
- {
- Presentation presentation = e.getPresentation();
- presentation.setVisible( shouldActionGroupVisible( e ) );
- }
-
- private boolean shouldActionGroupVisible( AnActionEvent e )
- {
- Module module = e.getData( LangDataKeys.MODULE );
- if( module == null )
- {
- return false;
- }
-
- // TODO: Enable this once PolygeneFacet can be automatically added/removed
-// if( PolygeneFacet.getInstance( module ) == null )
-// {
-// return false;
-// }
-
- // Are we on IDE View and under project source folder?
- Project project = e.getData( PlatformDataKeys.PROJECT );
- IdeView view = e.getData( LangDataKeys.IDE_VIEW );
- if( view != null && project != null )
- {
- ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance( project ).getFileIndex();
- PsiDirectory[] dirs = view.getDirectories();
- for( PsiDirectory dir : dirs )
- {
- if( projectFileIndex.isInSourceContent( dir.getVirtualFile() ) && JavaDirectoryService.getInstance().getPackage( dir ) != null )
- {
- return true;
- }
- }
- }
-
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/facet/PolygeneFacet.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/facet/PolygeneFacet.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/facet/PolygeneFacet.java
deleted file mode 100644
index 7342707..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/facet/PolygeneFacet.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.polygene.ide.plugin.idea.common.facet;
-
-import com.intellij.facet.Facet;
-import com.intellij.facet.FacetManager;
-import com.intellij.facet.FacetType;
-import com.intellij.openapi.module.Module;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public final class PolygeneFacet extends Facet<PolygeneFacetConfiguration>
-{
- public PolygeneFacet( @NotNull FacetType facetType,
- @NotNull Module module,
- String name,
- @NotNull PolygeneFacetConfiguration configuration,
- Facet underlyingFacet
- )
- {
- super( facetType, module, name, configuration, underlyingFacet );
- }
-
- @Nullable
- public static PolygeneFacet getInstance( @NotNull Module module )
- {
- return FacetManager.getInstance( module ).getFacetByType( PolygeneFacetType.ID );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/facet/PolygeneFacetConfiguration.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/facet/PolygeneFacetConfiguration.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/facet/PolygeneFacetConfiguration.java
deleted file mode 100644
index 6a6f28e..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/facet/PolygeneFacetConfiguration.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.polygene.ide.plugin.idea.common.facet;
-
-import com.intellij.facet.FacetConfiguration;
-import com.intellij.facet.ui.FacetEditorContext;
-import com.intellij.facet.ui.FacetEditorTab;
-import com.intellij.facet.ui.FacetValidatorsManager;
-import com.intellij.openapi.util.InvalidDataException;
-import com.intellij.openapi.util.WriteExternalException;
-import org.jdom.Element;
-import org.apache.polygene.ide.plugin.idea.common.facet.ui.PolygeneFacetEditorTab;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public final class PolygeneFacetConfiguration
- implements FacetConfiguration
-{
- public FacetEditorTab[] createEditorTabs( FacetEditorContext editorContext,
- FacetValidatorsManager validatorsManager )
- {
- return new FacetEditorTab[]{
- new PolygeneFacetEditorTab( editorContext )
- };
- }
-
- public final void readExternal( Element element )
- throws InvalidDataException
- {
- // Do nothing
- }
-
- public final void writeExternal( Element element )
- throws WriteExternalException
- {
- // Do nothing
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/facet/PolygeneFacetType.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/facet/PolygeneFacetType.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/facet/PolygeneFacetType.java
deleted file mode 100644
index b45de9f..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/facet/PolygeneFacetType.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.polygene.ide.plugin.idea.common.facet;
-
-import com.intellij.facet.Facet;
-import com.intellij.facet.FacetType;
-import com.intellij.facet.FacetTypeId;
-import com.intellij.facet.autodetecting.FacetDetector;
-import com.intellij.facet.autodetecting.FacetDetectorRegistry;
-import com.intellij.openapi.fileTypes.StdFileTypes;
-import com.intellij.openapi.module.JavaModuleType;
-import com.intellij.openapi.module.Module;
-import com.intellij.openapi.module.ModuleType;
-import com.intellij.openapi.util.Condition;
-import com.intellij.openapi.vfs.VirtualFileFilter;
-import com.intellij.psi.JavaElementVisitor;
-import com.intellij.psi.PsiFile;
-import com.intellij.psi.PsiImportStatement;
-import com.intellij.psi.PsiReferenceExpression;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.Collection;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public final class PolygeneFacetType extends FacetType<PolygeneFacet, PolygeneFacetConfiguration>
-{
- public static final FacetTypeId<PolygeneFacet> ID = new FacetTypeId<PolygeneFacet>();
-
- public PolygeneFacetType()
- {
- super( ID, "PolygeneFacet", "Polygene Facet" );
- }
-
- public final PolygeneFacetConfiguration createDefaultConfiguration()
- {
- return new PolygeneFacetConfiguration();
- }
-
- public final PolygeneFacet createFacet( @NotNull Module module,
- String name,
- @NotNull PolygeneFacetConfiguration configuration,
- @Nullable Facet underlyingFacet )
- {
- return new PolygeneFacet( this, module, name, configuration, underlyingFacet );
- }
-
- public final boolean isSuitableModuleType( ModuleType moduleType )
- {
- return moduleType instanceof JavaModuleType;
- }
-
- @Override
- public final void registerDetectors( FacetDetectorRegistry<PolygeneFacetConfiguration> registry )
- {
- registry.registerOnTheFlyDetector(
- StdFileTypes.JAVA, VirtualFileFilter.ALL, new HasPolygeneImportPackageCondition(),
- new FacetDetector<PsiFile, PolygeneFacetConfiguration>( "PolygeneFacetDetector" )
- {
- @Override
- public PolygeneFacetConfiguration detectFacet( PsiFile source,
- Collection<PolygeneFacetConfiguration> existingConfigurations )
- {
- if( !existingConfigurations.isEmpty() )
- {
- return existingConfigurations.iterator().next();
- }
-
- return createDefaultConfiguration();
- }
- }
- );
- }
-
- private static class HasPolygeneImportPackageCondition
- implements Condition<PsiFile>
- {
- public final boolean value( PsiFile psiFile )
- {
- final boolean[] hasPolygeneImportPackage = new boolean[]{ false };
-
- psiFile.accept( new JavaElementVisitor()
- {
- @Override
- public final void visitImportStatement( PsiImportStatement statement )
- {
- String packageName = statement.getQualifiedName();
- if( packageName != null && packageName.startsWith( "org.apache.polygene" ) )
- {
- hasPolygeneImportPackage[ 0 ] = true;
- }
- }
-
- @Override
- public void visitReferenceExpression( PsiReferenceExpression expression )
- {
- // Ignore
- }
- } );
- return hasPolygeneImportPackage[ 0 ];
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/facet/ui/PolygeneFacetEditorTab.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/facet/ui/PolygeneFacetEditorTab.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/facet/ui/PolygeneFacetEditorTab.java
deleted file mode 100644
index dc4b121..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/facet/ui/PolygeneFacetEditorTab.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.polygene.ide.plugin.idea.common.facet.ui;
-
-import com.intellij.facet.ui.FacetEditorContext;
-import com.intellij.facet.ui.FacetEditorTab;
-import com.intellij.openapi.options.ConfigurationException;
-import org.jetbrains.annotations.Nls;
-
-import javax.swing.*;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public final class PolygeneFacetEditorTab extends FacetEditorTab
-{
- private final FacetEditorContext editorContext;
-
- public PolygeneFacetEditorTab( FacetEditorContext aContext )
- {
- editorContext = aContext;
- }
-
- @Nls
- public final String getDisplayName()
- {
- return "Polygene";
- }
-
- public JComponent createComponent()
- {
- return new JPanel();
- }
-
- public final boolean isModified()
- {
- return false;
- }
-
- public final void apply()
- throws ConfigurationException
- {
- // From UI to configuration
- }
-
- public final void reset()
- {
- // From Configuration to UI
- }
-
- public final void disposeUIResources()
- {
- // Do nothing for now
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/inspections/AbstractFix.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/inspections/AbstractFix.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/inspections/AbstractFix.java
deleted file mode 100644
index 1369766..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/inspections/AbstractFix.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.polygene.ide.plugin.idea.common.inspections;
-
-import com.intellij.codeInspection.LocalQuickFix;
-import org.jetbrains.annotations.NotNull;
-
-import static org.apache.polygene.ide.plugin.idea.common.resource.PolygeneResourceBundle.message;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public abstract class AbstractFix
- implements LocalQuickFix
-{
- private String fixName;
-
- protected AbstractFix( @NotNull String name )
- {
- fixName = name;
- }
-
- @NotNull
- public final String getName()
- {
- return fixName;
- }
-
- @NotNull
- public final String getFamilyName()
- {
- return message( "polygene.quick.fixes.family.name" );
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/inspections/AbstractInspection.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/inspections/AbstractInspection.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/inspections/AbstractInspection.java
deleted file mode 100644
index a6d0a38..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/inspections/AbstractInspection.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.polygene.ide.plugin.idea.common.inspections;
-
-import com.intellij.codeHighlighting.HighlightDisplayLevel;
-import com.intellij.codeInspection.BaseJavaLocalInspectionTool;
-import org.jetbrains.annotations.Nls;
-import org.jetbrains.annotations.NotNull;
-import org.apache.polygene.ide.plugin.idea.common.resource.PolygeneResourceBundle;
-
-import static com.intellij.codeHighlighting.HighlightDisplayLevel.ERROR;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public abstract class AbstractInspection extends BaseJavaLocalInspectionTool
-{
- private static final String POLYGENE_IDEA_INSPECTIONS_NAME = "polygene.inspections.name";
-
- @Nls @NotNull public String getGroupDisplayName()
- {
- return PolygeneResourceBundle.message( POLYGENE_IDEA_INSPECTIONS_NAME );
- }
-
- @NotNull
- protected abstract String resourceBundlePrefixId();
-
- @Nls @NotNull
- public final String getDisplayName()
- {
- return PolygeneResourceBundle.message( resourceBundlePrefixId() + ".name.display" );
- }
-
- @NotNull @Override
- public HighlightDisplayLevel getDefaultLevel()
- {
- return ERROR;
- }
-
- @Override
- public boolean isEnabledByDefault()
- {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/intentions/AbstractIntention.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/intentions/AbstractIntention.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/intentions/AbstractIntention.java
deleted file mode 100644
index d50693f..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/intentions/AbstractIntention.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.polygene.ide.plugin.idea.common.intentions;
-
-import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction;
-import com.intellij.openapi.editor.CaretModel;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.vfs.ReadonlyStatusHandler;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiFile;
-import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import static org.apache.polygene.ide.plugin.idea.common.resource.PolygeneResourceBundle.message;
-
-/**
- * This class is based from {@code com.siyeh.ipp.base.Intention}
- *
- * @author edward.yakop@gmail.com
- */
-public abstract class AbstractIntention extends PsiElementBaseIntentionAction
-{
- protected abstract boolean isIntentionValidFor( PsiElement element );
-
- protected abstract String resourceBundlePrefixId();
-
- /**
- * Implement this method to process intention.
- *
- * @param project The project in which the availability is checked.
- * @param editor The editor in which the intention will be invoked.
- * @param element The element under caret.
- */
- protected abstract void processIntention( @NotNull Project project,
- @NotNull Editor editor,
- @NotNull PsiElement element );
-
- public void invoke( @NotNull Project project, Editor editor, PsiFile file )
- throws IncorrectOperationException
- {
- if( isFileReadOnly( project, file ) )
- {
- return;
- }
-
- final PsiElement element = findMatchingElement( file, editor );
- if( element == null )
- {
- return;
- }
-
- processIntention( project, editor, element );
- }
-
- protected static boolean isFileReadOnly( @NotNull Project project, @NotNull PsiFile file )
- {
- VirtualFile virtualFile = file.getVirtualFile();
- ReadonlyStatusHandler readonlyStatusHandler = ReadonlyStatusHandler.getInstance( project );
- ReadonlyStatusHandler.OperationStatus operationStatus =
- readonlyStatusHandler.ensureFilesWritable( virtualFile );
- return operationStatus.hasReadonlyFiles();
- }
-
- @Nullable
- private PsiElement findMatchingElement( @NotNull PsiFile file, @NotNull Editor editor )
- {
- CaretModel caretModel = editor.getCaretModel();
- int position = caretModel.getOffset();
- PsiElement element = file.findElementAt( position );
- return findMatchingElement( element );
- }
-
- @Nullable
- private PsiElement findMatchingElement( @Nullable PsiElement element )
- {
- while( element != null )
- {
- if( isIntentionValidFor( element ) )
- {
- return element;
- }
- else
- {
- element = element.getParent();
- if( element instanceof PsiFile )
- {
- break;
- }
- }
- }
-
- return null;
- }
-
- @Override
- public boolean isAvailable( @NotNull Project project, Editor editor, @Nullable PsiElement element )
- {
- return isIntentionValidFor( element );
- }
-
- @NotNull
- public final String getFamilyName()
- {
- return message( resourceBundlePrefixId() + ".family.name" );
- }
-
- @NotNull
- @Override
- public final String getText()
- {
- return message( resourceBundlePrefixId() + ".name" );
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/psi/PsiAnnotationUtil.java
----------------------------------------------------------------------
diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/psi/PsiAnnotationUtil.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/psi/PsiAnnotationUtil.java
deleted file mode 100644
index 4840a04..0000000
--- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/common/psi/PsiAnnotationUtil.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.polygene.ide.plugin.idea.common.psi;
-
-import com.intellij.psi.*;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import static java.util.Collections.emptyList;
-
-/**
- * @author edward.yakop@gmail.com
- * @since 0.1
- */
-public class PsiAnnotationUtil
-{
- @NotNull
- public static List<PsiAnnotationMemberValue> getAnnotationDefaultParameterValue( @Nullable PsiAnnotation annotation )
- {
- if( annotation == null )
- {
- return emptyList();
- }
-
- List<PsiAnnotationMemberValue> defaultParameterValues = new LinkedList<PsiAnnotationMemberValue>();
-
- PsiAnnotationParameterList list = annotation.getParameterList();
- PsiNameValuePair[] attributes = list.getAttributes();
- for( PsiNameValuePair valuePair : attributes )
- {
- String parameterName = valuePair.getName();
- if( parameterName == null || PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME.equals( parameterName ) )
- {
- PsiAnnotationMemberValue value = valuePair.getValue();
- if( value == null )
- {
- continue;
- }
-
- if( value instanceof PsiArrayInitializerMemberValue )
- {
- // If It's an array
- PsiArrayInitializerMemberValue valueWrapper = (PsiArrayInitializerMemberValue) value;
- PsiAnnotationMemberValue[] values = valueWrapper.getInitializers();
- for( PsiAnnotationMemberValue psiAnnotationMemberValue : values )
- {
- if( psiAnnotationMemberValue != null )
- {
- defaultParameterValues.add( psiAnnotationMemberValue );
- }
- }
- }
- else
- {
- // If there's only one value
- defaultParameterValues.add( value );
- }
-
- break;
- }
- }
-
- return defaultParameterValues;
- }
-
- @Nullable
- public static PsiJavaCodeReferenceElement getClassReference( @NotNull PsiAnnotationMemberValue value )
- {
- if( value instanceof PsiClassObjectAccessExpression )
- {
- PsiClassObjectAccessExpression objectAccessExpression = (PsiClassObjectAccessExpression) value;
- PsiTypeElement typeElement = objectAccessExpression.getOperand();
- return typeElement.getInnermostComponentReferenceElement();
- }
-
- return null;
- }
-}