Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 5A44A200C09 for ; Sat, 17 Dec 2016 11:27:48 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 58880160B33; Sat, 17 Dec 2016 10:27:48 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 08C65160B58 for ; Sat, 17 Dec 2016 11:27:43 +0100 (CET) Received: (qmail 24461 invoked by uid 500); 17 Dec 2016 10:27:43 -0000 Mailing-List: contact commits-help@zest.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zest.apache.org Delivered-To: mailing list commits@zest.apache.org Received: (qmail 22608 invoked by uid 99); 17 Dec 2016 10:27:39 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 17 Dec 2016 10:27:39 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id BA86EDFBAA; Sat, 17 Dec 2016 10:27:39 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: niclas@apache.org To: commits@zest.apache.org Date: Sat, 17 Dec 2016 10:28:46 -0000 Message-Id: <5efc7ff3a96744d2a6fcf64ea5f9ba01@git.apache.org> In-Reply-To: <2bda02e69e814fefafe6dd5d8de262bd@git.apache.org> References: <2bda02e69e814fefafe6dd5d8de262bd@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [70/81] [abbrv] zest-java git commit: ZEST-195, ZEST-201 ; Rename of everything else from zest to polygene. archived-at: Sat, 17 Dec 2016 10:27:48 -0000 http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/structure/common/PolygeneStructureAnnotationUtil.java ---------------------------------------------------------------------- diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/structure/common/PolygeneStructureAnnotationUtil.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/structure/common/PolygeneStructureAnnotationUtil.java deleted file mode 100644 index c334276..0000000 --- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/structure/common/PolygeneStructureAnnotationUtil.java +++ /dev/null @@ -1,124 +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.injections.structure.common; - -import com.intellij.openapi.project.Project; -import com.intellij.psi.*; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import static com.intellij.codeInsight.AnnotationUtil.findAnnotation; -import static com.intellij.psi.PsiModifier.STATIC; -import static org.apache.polygene.ide.plugin.idea.injections.structure.common.PolygeneStructureAnnotationConstants.QUALIFIED_NAME_STRUCTURE_ANNOTATION; -import static org.apache.polygene.ide.plugin.idea.injections.structure.common.PolygeneStructureAnnotationConstants.VALID_STRUCTURE_INJECTION_TYPE; -import static org.apache.polygene.ide.plugin.idea.injections.structure.common.PolygeneStructureAnnotationUtil.StructureAnnotationDeclarationValidationResult.*; - -/** - * @author edward.yakop@gmail.com - * @since 0.1 - */ -public final class PolygeneStructureAnnotationUtil -{ - /** - * Returns {@code Structure} annotation if exists. - * - * @param modifierListOwner Modifier list owner. - * @return @Structure annotation if exists, {@code null} otherwise. - * @since 0.1 - */ - @Nullable - public static PsiAnnotation getStructureAnnotation( @NotNull PsiModifierListOwner modifierListOwner ) - { - return findAnnotation( modifierListOwner, QUALIFIED_NAME_STRUCTURE_ANNOTATION ); - } - - /** - * Create structure annotation. - * - * @param project project to create structure annotation. - * @param context the context to create structure annotation. - * @return @Structure annotation. - */ - @NotNull - public static PsiAnnotation createStructureAnnotation( @NotNull Project project, - @NotNull PsiElement context ) - { - JavaPsiFacade psiFacade = JavaPsiFacade.getInstance( project ); - PsiElementFactory factory = psiFacade.getElementFactory(); - return factory.createAnnotationFromText( "@" + QUALIFIED_NAME_STRUCTURE_ANNOTATION, context ); - } - - /** - * @param variable variable to check. - * @return Look at {@link StructureAnnotationDeclarationValidationResult}. - * @since 0.1 - */ - @NotNull - public static StructureAnnotationDeclarationValidationResult validateStructureAnnotationDeclaration( - @NotNull PsiVariable variable ) - { - PsiAnnotation structureAnnotation = getStructureAnnotation( variable ); - if( structureAnnotation == null ) - { - return invalidStructureAnnotationNotDeclared; - } - - PsiModifierList modifierList = variable.getModifierList(); - if( modifierList != null ) - { - if( modifierList.hasModifierProperty( STATIC ) ) - { - return invalidDeclaredOnStaticVariable; - } - } - - if( !isInjecteableByStructureAnnotation( variable ) ) - { - return invalidInjectionType; - } - - return valid; - } - - /** - * Returns a {@code boolean} indicator whether variable type is injectable by @Structure annotation. - * - * @param variable variable to check. - * @return {@code true} if variable type is injecteable by @Structure annotation. - * @since 0.1 - */ - public static boolean isInjecteableByStructureAnnotation( @NotNull PsiVariable variable ) - { - PsiType type = variable.getType(); - String fieldClassQualifiedName = type.getCanonicalText(); - return binarySearch( VALID_STRUCTURE_INJECTION_TYPE, fieldClassQualifiedName ) > -1; - } - - private PolygeneStructureAnnotationUtil() - { - } - - public enum StructureAnnotationDeclarationValidationResult - { - invalidStructureAnnotationNotDeclared, - invalidDeclaredOnStaticVariable, - invalidInjectionType, - valid, - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/structure/common/ReplaceWithStructureAnnotation.java ---------------------------------------------------------------------- diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/structure/common/ReplaceWithStructureAnnotation.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/structure/common/ReplaceWithStructureAnnotation.java deleted file mode 100644 index 3659db3..0000000 --- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/structure/common/ReplaceWithStructureAnnotation.java +++ /dev/null @@ -1,49 +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.injections.structure.common; - -import com.intellij.codeInspection.ProblemDescriptor; -import com.intellij.openapi.project.Project; -import com.intellij.psi.PsiAnnotation; -import org.jetbrains.annotations.NotNull; -import org.apache.polygene.ide.plugin.idea.common.inspections.AbstractFix; - -import static org.apache.polygene.ide.plugin.idea.injections.structure.common.PolygeneStructureAnnotationUtil.createStructureAnnotation; - -/** - * @author edward.yakop@gmail.com - * @since 0.1 - */ -public final class ReplaceWithStructureAnnotation extends AbstractFix -{ - private final PsiAnnotation annotation; - - public ReplaceWithStructureAnnotation( @NotNull String fixMessage, - @NotNull PsiAnnotation annotationToReplace ) - { - super( fixMessage ); - this.annotation = annotationToReplace; - } - - public final void applyFix( @NotNull Project project, @NotNull ProblemDescriptor descriptor ) - { - PsiAnnotation structureAnnotation = createStructureAnnotation( project, annotation ); - annotation.replace( structureAnnotation ); - } -} \ 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/injections/structure/inspections/StructureAnnotationDeclaredCorrectlyInspection.java ---------------------------------------------------------------------- diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/structure/inspections/StructureAnnotationDeclaredCorrectlyInspection.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/structure/inspections/StructureAnnotationDeclaredCorrectlyInspection.java deleted file mode 100644 index a972acd..0000000 --- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/injections/structure/inspections/StructureAnnotationDeclaredCorrectlyInspection.java +++ /dev/null @@ -1,92 +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.injections.structure.inspections; - -import com.intellij.codeInspection.InspectionManager; -import com.intellij.codeInspection.ProblemDescriptor; -import com.intellij.psi.PsiAnnotation; -import com.intellij.psi.PsiVariable; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.apache.polygene.ide.plugin.idea.common.inspections.AbstractFix; -import org.apache.polygene.ide.plugin.idea.injections.common.inspections.AbstractInjectionAnnotationDeclarationOnFieldAndConstructorInspection; - -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.injections.structure.common.PolygeneStructureAnnotationConstants.QUALIFIED_NAME_STRUCTURE_ANNOTATION; -import static org.apache.polygene.ide.plugin.idea.injections.structure.common.PolygeneStructureAnnotationUtil.StructureAnnotationDeclarationValidationResult; -import static org.apache.polygene.ide.plugin.idea.injections.structure.common.PolygeneStructureAnnotationUtil.validateStructureAnnotationDeclaration; - -/** - * {@code StructureAnnotationUsedCorrectly} validates {@code @Structure} injection annotation declaration. - * - * @author edward.yakop@gmail.com - * @since 0.1 - */ -public class StructureAnnotationDeclaredCorrectlyInspection - extends AbstractInjectionAnnotationDeclarationOnFieldAndConstructorInspection -{ - @NotNull - protected final String resourceBundlePrefixId() - { - return "injections.structure.annotation.declared.correctly"; - } - - @NotNull - public final String getShortName() - { - return "StructureAnnotationDeclaredCorrectlyInspection"; - } - - @NotNull - protected final String getRemoveAnnotationMessageFix() - { - return message( "injections.structure.annotation.declared.correctly.fix.remove.annotation" ); - } - - @NotNull - protected final String getAnnotationToCheckQualifiedName() - { - return QUALIFIED_NAME_STRUCTURE_ANNOTATION; - } - - @Nullable - protected final ProblemDescriptor[] verifyAnnotationDeclaredCorrectly( @NotNull PsiVariable psiVariable, - @NotNull PsiAnnotation structureAnnotation, - @NotNull InspectionManager manager ) - { - StructureAnnotationDeclarationValidationResult annotationCheck = - validateStructureAnnotationDeclaration( psiVariable ); - switch( annotationCheck ) - { - case invalidInjectionType: - String message = message( - "injections.structure.annotation.declared.correctly.error.invalid.injection.type", - psiVariable.getType().getCanonicalText() - ); - AbstractFix removeStructureAnnotationFix = createRemoveAnnotationFix( structureAnnotation ); - ProblemDescriptor problemDescriptor = manager.createProblemDescriptor( - structureAnnotation, message, removeStructureAnnotationFix, GENERIC_ERROR_OR_WARNING - ); - return new ProblemDescriptor[]{ problemDescriptor }; - } - - return null; - } -} \ 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/mixins/common/PolygeneMixinConstants.java ---------------------------------------------------------------------- diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/mixins/common/PolygeneMixinConstants.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/mixins/common/PolygeneMixinConstants.java deleted file mode 100644 index c871b3d..0000000 --- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/mixins/common/PolygeneMixinConstants.java +++ /dev/null @@ -1,32 +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.mixins.common; - -/** - * @author edward.yakop@gmail.com - * @since 0.1 - */ -public final class PolygeneMixinConstants -{ - public static final String QUALIFIED_NAME_MIXINS = "org.apache.polygene.api.mixin.Mixins"; - - private PolygeneMixinConstants() - { - } -} \ 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/mixins/common/PolygeneMixinUtil.java ---------------------------------------------------------------------- diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/mixins/common/PolygeneMixinUtil.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/mixins/common/PolygeneMixinUtil.java deleted file mode 100644 index 729ff58..0000000 --- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/mixins/common/PolygeneMixinUtil.java +++ /dev/null @@ -1,196 +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.mixins.common; - -import com.intellij.openapi.project.Project; -import com.intellij.psi.*; -import com.intellij.psi.codeStyle.JavaCodeStyleManager; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.List; -import java.util.Set; - -import static com.intellij.codeInsight.AnnotationUtil.findAnnotation; -import static java.util.Collections.emptyList; -import static java.util.Collections.emptySet; -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.getExtendsDeep; -import static org.apache.polygene.ide.plugin.idea.common.psi.PsiClassUtil.getPSIClass; -import static org.apache.polygene.ide.plugin.idea.concerns.common.PolygeneConcernUtil.isAConcern; -import static org.apache.polygene.ide.plugin.idea.mixins.common.PolygeneMixinConstants.QUALIFIED_NAME_MIXINS; -import static org.apache.polygene.ide.plugin.idea.sideEffects.common.PolygeneSideEffectUtil.isASideEffect; - -/** - * @author edward.yakop@gmail.com - * @since 0.1 - */ -public final class PolygeneMixinUtil -{ - /** - * Get all valid mixin types of given the {@code psiClass} argument. - * - * @param psiClass The psi class to check. - * @return all vlaid mixin types of the given {@code psiClass} argument. - * @since 0.1 - */ - @NotNull - public static Set getAllValidMixinTypes( @NotNull PsiClass psiClass ) - { - PsiAnnotation mixinsAnnotation = getMixinsAnnotation( psiClass ); - if( mixinsAnnotation == null ) - { - return emptySet(); - } - - Set validMixinsType = getExtendsDeep( psiClass ); - validMixinsType.add( psiClass ); - return validMixinsType; - } - - @NotNull - public static List getMixinsAnnotationValue( @NotNull PsiClass psiClass ) - { - return getMixinsAnnotationValue( getMixinsAnnotation( psiClass ) ); - } - - @NotNull - public static List getMixinsAnnotationValue( @Nullable PsiAnnotation mixinsAnnotation ) - { - if( mixinsAnnotation == null ) - { - return emptyList(); - } - - String mixinsQualifiedName = mixinsAnnotation.getQualifiedName(); - if( !QUALIFIED_NAME_MIXINS.equals( mixinsQualifiedName ) ) - { - return emptyList(); - } - - return getAnnotationDefaultParameterValue( mixinsAnnotation ); - } - - @Nullable - public static PsiAnnotation getMixinsAnnotation( PsiElement element ) - { - PsiClass psiClass = getPSIClass( element ); - if( psiClass == null ) - { - return null; - } - - return findAnnotation( psiClass, QUALIFIED_NAME_MIXINS ); - } - - @NotNull - public static PsiAnnotation addOrReplaceMixinAnnotation( @NotNull PsiModifierListOwner modifierListOwner, - @NotNull PsiClass mixinClassToAdd ) - { - Project project = modifierListOwner.getProject(); - JavaPsiFacade psiFacade = JavaPsiFacade.getInstance( project ); - PsiElementFactory factory = psiFacade.getElementFactory(); - PsiAnnotation existingMixinsAnnotation = findAnnotation( modifierListOwner, QUALIFIED_NAME_MIXINS ); - - boolean isReplace = false; - PsiAnnotation newMixinsAnnotation; - if( existingMixinsAnnotation != null ) - { - // Check duplicate - List mixinsValues = getMixinsAnnotationValue( existingMixinsAnnotation ); - for( PsiAnnotationMemberValue mixinValue : mixinsValues ) - { - PsiJavaCodeReferenceElement mixinClassReference = getMixinClassReference( mixinValue ); - if( mixinClassReference == null ) - { - continue; - } - - PsiElement mixinClass = mixinClassReference.resolve(); - if( mixinClassToAdd.equals( mixinClass ) ) - { - return existingMixinsAnnotation; - } - } - - isReplace = true; - } - - String mixinsAnnotationText = createMixinsAnnotationText( existingMixinsAnnotation, mixinClassToAdd ); - newMixinsAnnotation = factory.createAnnotationFromText( mixinsAnnotationText, modifierListOwner ); - - if( isReplace ) - { - // Replace @Mixins instead - existingMixinsAnnotation.replace( newMixinsAnnotation ); - } - else - { - // @Mixins doesn't exists, add it as first child - PsiModifierList modifierList = modifierListOwner.getModifierList(); - modifierList.addBefore( newMixinsAnnotation, modifierList.getFirstChild() ); - } - - // Shorten all class references if possible - JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance( project ); - codeStyleManager.shortenClassReferences( newMixinsAnnotation ); - - return newMixinsAnnotation; - } - - @NotNull - private static String createMixinsAnnotationText( @Nullable PsiAnnotation mixinsAnnotationBase, - @NotNull PsiClass mixinClassToAdd ) - { - StringBuilder annotationTextBuilder = new StringBuilder(); - annotationTextBuilder.append( "@" ).append( QUALIFIED_NAME_MIXINS ).append( "( {" ); - List mixinsValues = getMixinsAnnotationValue( mixinsAnnotationBase ); - for( PsiAnnotationMemberValue mixinValue : mixinsValues ) - { - annotationTextBuilder.append( mixinValue.getText() ).append( ", " ); - } - annotationTextBuilder.append( mixinClassToAdd.getQualifiedName() ).append( ".class" ); - annotationTextBuilder.append( "} )" ); - - return annotationTextBuilder.toString(); - } - - - @Nullable - public static PsiJavaCodeReferenceElement getMixinClassReference( @NotNull PsiAnnotationMemberValue value ) - { - return getClassReference( value ); - } - - /** - * Validate whether psiClass is a mixin. - * - * @param psiClass psi class to check. - * @return {@code true} if psiClass is a mixin, {@code false} otherwise. - */ - public static boolean isAMixin( @NotNull PsiClass psiClass ) - { - return !( psiClass.isInterface() || isAConcern( psiClass ) || isASideEffect( psiClass ) ); - } - - private PolygeneMixinUtil() - { - } -} \ 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/mixins/inspections/MixinImplementsMixinType.java ---------------------------------------------------------------------- diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/mixins/inspections/MixinImplementsMixinType.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/mixins/inspections/MixinImplementsMixinType.java deleted file mode 100644 index c74725b..0000000 --- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/mixins/inspections/MixinImplementsMixinType.java +++ /dev/null @@ -1,190 +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.mixins.inspections; - -import com.intellij.codeInspection.InspectionManager; -import com.intellij.codeInspection.ProblemDescriptor; -import com.intellij.openapi.project.Project; -import com.intellij.psi.PsiAnnotationMemberValue; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiJavaCodeReferenceElement; -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 java.util.Set; - -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.concerns.common.PolygeneConcernUtil.isAConcern; -import static org.apache.polygene.ide.plugin.idea.mixins.common.PolygeneMixinUtil.*; -import static org.apache.polygene.ide.plugin.idea.sideEffects.common.PolygeneSideEffectUtil.isASideEffect; - -/** - * @author edward.yakop@gmail.com - * @since 0.1 - */ -public final class MixinImplementsMixinType extends AbstractInspection -{ - @NotNull - protected final String resourceBundlePrefixId() - { - return "mixin.implements.mixin.type"; - } - - @NotNull - public final String getShortName() - { - return "MixinImplementsMixinType"; - } - - @Override - public final ProblemDescriptor[] checkClass( @NotNull PsiClass psiClass, - @NotNull InspectionManager manager, - boolean isOnTheFly ) - { - // If psiClass is not an interface, ignore - if( !psiClass.isInterface() ) - { - return null; - } - - // If @Mixins annotation is empty, ignore - List mixinAnnotationValues = getMixinsAnnotationValue( psiClass ); - if( mixinAnnotationValues.isEmpty() ) - { - return null; - } - - // Get all valid mixin type - Set validMixinsType = getAllValidMixinTypes( psiClass ); - if( validMixinsType.isEmpty() ) - { - return null; - } - - // For each mixin - List problems = new LinkedList(); - for( PsiAnnotationMemberValue mixinAnnotationValue : mixinAnnotationValues ) - { - PsiJavaCodeReferenceElement mixinClassReference = getMixinClassReference( mixinAnnotationValue ); - - // If it's not a class reference, ignore - if( mixinClassReference == null ) - { - continue; - } - - // If class reference can't be resolved, ignore - PsiClass mixinClass = (PsiClass) mixinClassReference.resolve(); - if( mixinClass == null ) - { - continue; - } - - String mixinQualifiedName = mixinClass.getQualifiedName(); - - boolean isMixinsDeclarationValid = false; - String message = ""; - if( mixinClass.isInterface() ) - { - // Mixin can't be an interface - message = message( "mixin.implements.mixin.type.error.mixin.is.an.interface", mixinQualifiedName ); - } - else if( isAConcern( mixinClass ) ) - { - // Mixin can't be a concern - message = message( "mixin.implements.mixin.type.error.mixin.is.a.concern", mixinQualifiedName ); - } - else if( isASideEffect( mixinClass ) ) - { - // Mixin can't be a side effect - message = message( "mixin.implements.mixin.type.error.mixin.is.a.side.effect", mixinQualifiedName ); - } - else - { - // If doesn't implement any mixin type, it's a problem - if( !isImplementValidMixinType( mixinClass, validMixinsType ) ) - { - message = message( - "mixin.implements.mixin.type.error.does.not.implement.any.mixin.type", - mixinQualifiedName, - psiClass.getQualifiedName() - ); - } - else - { - isMixinsDeclarationValid = true; - } - } - - if( !isMixinsDeclarationValid ) - { - ProblemDescriptor problemDescriptor = createProblemDescriptor( - manager, mixinAnnotationValue, mixinClassReference, message ); - problems.add( problemDescriptor ); - } - } - - return problems.toArray( new ProblemDescriptor[problems.size()] ); - } - - private boolean isImplementValidMixinType( PsiClass mixinClass, Set validMixinsType ) - { - for( PsiClass validMixinTypeClass : validMixinsType ) - { - if( mixinClass.isInheritor( validMixinTypeClass, true ) ) - { - return true; - } - } - - return false; - } - - private ProblemDescriptor createProblemDescriptor( @NotNull InspectionManager manager, - @NotNull PsiAnnotationMemberValue mixinAnnotationValue, - @NotNull PsiJavaCodeReferenceElement mixinClassReference, - @NotNull String message ) - { - RemoveInvalidMixinClassReferenceFix fix = new RemoveInvalidMixinClassReferenceFix( - mixinAnnotationValue, mixinClassReference - ); - return manager.createProblemDescriptor( mixinAnnotationValue, message, fix, GENERIC_ERROR_OR_WARNING ); - } - - private static class RemoveInvalidMixinClassReferenceFix extends AbstractFix - { - private final PsiAnnotationMemberValue mixinClassAnnotationValue; - - public RemoveInvalidMixinClassReferenceFix( @NotNull PsiAnnotationMemberValue mixinClassAnnotationValue, - @NotNull PsiJavaCodeReferenceElement mixinClassReference ) - { - super( message( "mixin.implements.mixin.type.fix.remove.class.reference", mixinClassReference.getQualifiedName() ) ); - this.mixinClassAnnotationValue = mixinClassAnnotationValue; - } - - public final void applyFix( @NotNull Project project, @NotNull ProblemDescriptor descriptor ) - { - mixinClassAnnotationValue.delete(); - } - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/mixins/inspections/MixinsAnnotationDeclaredOnMixinType.java ---------------------------------------------------------------------- diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/mixins/inspections/MixinsAnnotationDeclaredOnMixinType.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/mixins/inspections/MixinsAnnotationDeclaredOnMixinType.java deleted file mode 100644 index 914823d..0000000 --- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/mixins/inspections/MixinsAnnotationDeclaredOnMixinType.java +++ /dev/null @@ -1,92 +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.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/zest/ide/plugin/idea/sideEffects/common/PolygeneSideEffectConstants.java ---------------------------------------------------------------------- diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/sideEffects/common/PolygeneSideEffectConstants.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/sideEffects/common/PolygeneSideEffectConstants.java deleted file mode 100644 index d3c269f..0000000 --- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/sideEffects/common/PolygeneSideEffectConstants.java +++ /dev/null @@ -1,35 +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.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/zest/ide/plugin/idea/sideEffects/common/PolygeneSideEffectUtil.java ---------------------------------------------------------------------- diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/sideEffects/common/PolygeneSideEffectUtil.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/sideEffects/common/PolygeneSideEffectUtil.java deleted file mode 100644 index c1533fc..0000000 --- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/sideEffects/common/PolygeneSideEffectUtil.java +++ /dev/null @@ -1,188 +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.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 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/zest/ide/plugin/idea/sideEffects/inspections/SideEffectsAnnotationDeclaredCorrectlyInspection.java ---------------------------------------------------------------------- diff --git a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/sideEffects/inspections/SideEffectsAnnotationDeclaredCorrectlyInspection.java b/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/sideEffects/inspections/SideEffectsAnnotationDeclaredCorrectlyInspection.java deleted file mode 100644 index bf46eb3..0000000 --- a/tools/qidea/src/main/java/org/apache/zest/ide/plugin/idea/sideEffects/inspections/SideEffectsAnnotationDeclaredCorrectlyInspection.java +++ /dev/null @@ -1,177 +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.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 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 problems = new LinkedList(); - 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/resources/org/apache/polygene/ide/plugin/idea/common/resource/PolygeneResourceBundle.properties ---------------------------------------------------------------------- diff --git a/tools/qidea/src/main/resources/org/apache/polygene/ide/plugin/idea/common/resource/PolygeneResourceBundle.properties b/tools/qidea/src/main/resources/org/apache/polygene/ide/plugin/idea/common/resource/PolygeneResourceBundle.properties new file mode 100644 index 0000000..8c5f29b --- /dev/null +++ b/tools/qidea/src/main/resources/org/apache/polygene/ide/plugin/idea/common/resource/PolygeneResourceBundle.properties @@ -0,0 +1,164 @@ +# +# 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. +# +# +# + +# ***************************************************************************** +# Common +# ***************************************************************************** +polygene.quick.fixes.family.name=Polygene +polygene.action.group.title=Polygene +polygene.action.group.description=Polygene +polygene.inspections.name=Polygene issues +polygene.file.template.group.title=Polygene + +# ***************************************************************************** +# Concern +# ***************************************************************************** + +# ========= +# Intention +# ========= +add.concern.family.name=Add Polygene Concern +add.concern.name=Add Polygene Concern + +# ========== +# Inspection +# ========== +concerns.annotation.declared.correctly.name.display=Concern class extends ConcernOf abstract class +concerns.annotation.declared.correctly.error.concern.class.does.not.extend.ConcernOf=Concern class ''{0}'' does not inherit ''org.apache.polygene.composite.ConcernOf'' class. +concerns.annotation.declared.correctly.fix.remove.concern.class.reference=Remove ''{0}'' concern class reference. +concerns.annotation.declared.correctly.error.annotation.declared.in.class=@Concerns annotation can only be declared at interface +concerns.annotation.declared.correctly.fix.remove.annotation=Remove @Concerns annotation + +# ======= +# Actions +# ======= + +# ------------------------- +# Create concern in package +# ------------------------- +createConcernOfInPackage.menu.action.text=Polygene Concern Of +createConcernOfInPackage.menu.action.description=Creates new Polygene ConcernOf +createConcernOfInPackage.dlg.title=New Polygene ConcernOf +createConcernOfInPackage.dlg.prompt=Enter name for new ConcernOf +createConcernOfInPackage.command.name=Create ConcernOf +createConcernOfInPackage.progress.text=Creating ConcernOf ''{0}'' class +createConcernOfInPackage.error.title=Create concern fail + +# ***************************************************************************** +# Mixin +# ***************************************************************************** + +# ========== +# Inspection +# ========== + +# ---------------------------- +# Mixins implements mixin type +# ---------------------------- +mixin.implements.mixin.type.name.display=Mixin class implements Mixin type class +mixin.implements.mixin.type.fix.remove.class.reference=Remove ''{0}'' mixin class reference. +mixin.implements.mixin.type.error.does.not.implement.any.mixin.type=Mixin class ''{0}'' does not inherit any mixin type of ''{1}'' +mixin.implements.mixin.type.error.mixin.is.an.interface=Mixin class ''{0}'' is an interface +mixin.implements.mixin.type.error.mixin.is.a.concern=''{0}'' class is a concern +mixin.implements.mixin.type.error.mixin.is.a.side.effect=''{0}'' class is a side effect + +# ------------------------------------------ +# Mixins declared on mixin type or composite +# ------------------------------------------ +mixins.annotation.declared.on.mixin.type.name.display=@Mixins must be declared on interface +mixins.annotation.declared.on.mixin.type.error.declared.on.class=@Mixins can only be declared on interface +mixins.annotation.declared.on.mixin.type.fix.remove.mixins.annotation=Remove @Mixins annotation + +# ***************************************************************************** +# Side Effect +# ***************************************************************************** + +# ========== +# Inspection +# ========== +side.effects.annotation.declared.correctly.name.display=@SideEffects annotation declared correctly +side.effects.annotation.declared.correctly.error.side.effect.does.not.extend.side.effect.of=Side Effect class ''{0}'' does not inherit ''org.apache.polygene.composite.SideEffectOf'' class. +side.effects.annotation.declared.correctly.fix.remove.class.reference=Remove ''{0}'' class reference +side.effects.annotation.declared.correctly.error.annotation.declared.in.class=@SideEffects annotation can only be declared at interface +side.effects.annotation.declared.correctly.fix.remove.annotation=Remove @SideEffects annotation + +# ***************************************************************************** +# Injections +# ***************************************************************************** + +# ----------------- +# Common Inspection +# ----------------- +abstract.injection.annotation.declaration.inspection.error.annotation.not.declared.correctly=''{0}'' can only be declared in constructor parameters or non static class field. + +# ------------------- +# @Structure injection +# ------------------- + +# ========== +# Inspection +# ========== +injections.structure.annotation.declared.correctly.name.display=@Structure Injection +injections.structure.annotation.declared.correctly.error.invalid.injection.type=@Structure does not inject ''{0}'' type. +injections.structure.annotation.declared.correctly.fix.remove.annotation=Remove @Structure annotation + +# ----------------- +# @Service injection +# ----------------- + +# ========== +# Inspection +# ========== +injections.service.annotation.declared.correctly.name.display=@Service Injection +injections.service.annotation.declared.correctly.error.type.is.injected.by.structure=''{0}'' type is injected by @Structure +injections.service.annotation.declared.correctly.fix.remove.annotation=Remove @Service annotation +injections.service.annotation.declared.correctly.fix.replace.with.structure.annotation=Replace @Service with @Structure annotation + +# ----------------- +# @Invocation injection +# ----------------- + +# ========== +# Inspection +# ========== +injections.invocation.annotation.declared.correctly.name.display=@Invocation Injection +injections.invocation.annotation.declared.correctly.error.type.is.injected.by.structure=''{0}'' type is injected by @Structure +injections.invocation.annotation.declared.correctly.error.type.is.not.injectable=''{0}'' type is not injectable by @Invocation +injections.invocation.annotation.declared.correctly.fix.remove.annotation=Remove @Invocation annotation +injections.invocation.annotation.declared.correctly.fix.replace.with.structure.annotation=Replace @Invocation with @Structure annotation + +# ***************************************************************************** +# Applies To +# ***************************************************************************** + +# ========== +# Inspection +# ========== +applies.to.annotation.declared.correctly.error.annotation.must.be.declared.on.class=@AppliesTo must be declared on class +applies.to.annotation.declared.correctly.error.value.is.invalid.for.mixin=''{0}'' is neither an interface or implements ''AppliesToFilter'' +applies.to.annotation.declared.correctly.error.value.requires.class.to.extends.GenericConcern=''{0}'' requires ''{1}'' to extends GenericConcern +applies.to.annotation.declared.correctly.error.value.requires.class.to.extends.GenericSideEffect=''{0}'' requires ''{1}'' to extends GenericSideEffect +applies.to.annotation.declared.correctly.error.value.requires.class.to.implements.InvocationHandler=''{0}'' requires ''{1}'' to implements InvocationHandler +applies.to.annotation.declared.correctly.error.value.requires.class.to.implement.interface.or.extends.GenericConcern=''{0}'' requires ''{1}'' to implement ''{0}'' interface or to extends ''GenericConcern'' +applies.to.annotation.declared.correctly.error.value.requires.class.to.implement.interface.or.extends.GenericSideEffect=''{0}'' requires ''{1}'' to implement ''{0}'' interface or to extends ''GenericSideEffect'' +applies.to.annotation.declared.correctly.error.value.requires.class.to.implement.value.interface.or.implements.InvocationHandler=''{0}'' requires ''{1}'' to implement ''{0}'' or ''InvocationHandler'' interface +applies.to.annotation.declared.correctly.error.annotation.value.is.invalid.for.non.mixin=''{0}'' is not an annotation or ''AppliesToFilter'' or an interface +applies.to.annotation.declared.correctly.fix.remove.annotation=Remove ''@AppliesTo'' annotation +applies.to.annotation.declared.correctly.fix.remove.class.reference=Remove ''{0}'' class reference http://git-wip-us.apache.org/repos/asf/zest-java/blob/e0e1d7d4/tools/qidea/src/main/resources/org/apache/zest/ide/plugin/idea/common/resource/PolygeneResourceBundle.properties ---------------------------------------------------------------------- diff --git a/tools/qidea/src/main/resources/org/apache/zest/ide/plugin/idea/common/resource/PolygeneResourceBundle.properties b/tools/qidea/src/main/resources/org/apache/zest/ide/plugin/idea/common/resource/PolygeneResourceBundle.properties deleted file mode 100644 index 8c5f29b..0000000 --- a/tools/qidea/src/main/resources/org/apache/zest/ide/plugin/idea/common/resource/PolygeneResourceBundle.properties +++ /dev/null @@ -1,164 +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. -# -# -# - -# ***************************************************************************** -# Common -# ***************************************************************************** -polygene.quick.fixes.family.name=Polygene -polygene.action.group.title=Polygene -polygene.action.group.description=Polygene -polygene.inspections.name=Polygene issues -polygene.file.template.group.title=Polygene - -# ***************************************************************************** -# Concern -# ***************************************************************************** - -# ========= -# Intention -# ========= -add.concern.family.name=Add Polygene Concern -add.concern.name=Add Polygene Concern - -# ========== -# Inspection -# ========== -concerns.annotation.declared.correctly.name.display=Concern class extends ConcernOf abstract class -concerns.annotation.declared.correctly.error.concern.class.does.not.extend.ConcernOf=Concern class ''{0}'' does not inherit ''org.apache.polygene.composite.ConcernOf'' class. -concerns.annotation.declared.correctly.fix.remove.concern.class.reference=Remove ''{0}'' concern class reference. -concerns.annotation.declared.correctly.error.annotation.declared.in.class=@Concerns annotation can only be declared at interface -concerns.annotation.declared.correctly.fix.remove.annotation=Remove @Concerns annotation - -# ======= -# Actions -# ======= - -# ------------------------- -# Create concern in package -# ------------------------- -createConcernOfInPackage.menu.action.text=Polygene Concern Of -createConcernOfInPackage.menu.action.description=Creates new Polygene ConcernOf -createConcernOfInPackage.dlg.title=New Polygene ConcernOf -createConcernOfInPackage.dlg.prompt=Enter name for new ConcernOf -createConcernOfInPackage.command.name=Create ConcernOf -createConcernOfInPackage.progress.text=Creating ConcernOf ''{0}'' class -createConcernOfInPackage.error.title=Create concern fail - -# ***************************************************************************** -# Mixin -# ***************************************************************************** - -# ========== -# Inspection -# ========== - -# ---------------------------- -# Mixins implements mixin type -# ---------------------------- -mixin.implements.mixin.type.name.display=Mixin class implements Mixin type class -mixin.implements.mixin.type.fix.remove.class.reference=Remove ''{0}'' mixin class reference. -mixin.implements.mixin.type.error.does.not.implement.any.mixin.type=Mixin class ''{0}'' does not inherit any mixin type of ''{1}'' -mixin.implements.mixin.type.error.mixin.is.an.interface=Mixin class ''{0}'' is an interface -mixin.implements.mixin.type.error.mixin.is.a.concern=''{0}'' class is a concern -mixin.implements.mixin.type.error.mixin.is.a.side.effect=''{0}'' class is a side effect - -# ------------------------------------------ -# Mixins declared on mixin type or composite -# ------------------------------------------ -mixins.annotation.declared.on.mixin.type.name.display=@Mixins must be declared on interface -mixins.annotation.declared.on.mixin.type.error.declared.on.class=@Mixins can only be declared on interface -mixins.annotation.declared.on.mixin.type.fix.remove.mixins.annotation=Remove @Mixins annotation - -# ***************************************************************************** -# Side Effect -# ***************************************************************************** - -# ========== -# Inspection -# ========== -side.effects.annotation.declared.correctly.name.display=@SideEffects annotation declared correctly -side.effects.annotation.declared.correctly.error.side.effect.does.not.extend.side.effect.of=Side Effect class ''{0}'' does not inherit ''org.apache.polygene.composite.SideEffectOf'' class. -side.effects.annotation.declared.correctly.fix.remove.class.reference=Remove ''{0}'' class reference -side.effects.annotation.declared.correctly.error.annotation.declared.in.class=@SideEffects annotation can only be declared at interface -side.effects.annotation.declared.correctly.fix.remove.annotation=Remove @SideEffects annotation - -# ***************************************************************************** -# Injections -# ***************************************************************************** - -# ----------------- -# Common Inspection -# ----------------- -abstract.injection.annotation.declaration.inspection.error.annotation.not.declared.correctly=''{0}'' can only be declared in constructor parameters or non static class field. - -# ------------------- -# @Structure injection -# ------------------- - -# ========== -# Inspection -# ========== -injections.structure.annotation.declared.correctly.name.display=@Structure Injection -injections.structure.annotation.declared.correctly.error.invalid.injection.type=@Structure does not inject ''{0}'' type. -injections.structure.annotation.declared.correctly.fix.remove.annotation=Remove @Structure annotation - -# ----------------- -# @Service injection -# ----------------- - -# ========== -# Inspection -# ========== -injections.service.annotation.declared.correctly.name.display=@Service Injection -injections.service.annotation.declared.correctly.error.type.is.injected.by.structure=''{0}'' type is injected by @Structure -injections.service.annotation.declared.correctly.fix.remove.annotation=Remove @Service annotation -injections.service.annotation.declared.correctly.fix.replace.with.structure.annotation=Replace @Service with @Structure annotation - -# ----------------- -# @Invocation injection -# ----------------- - -# ========== -# Inspection -# ========== -injections.invocation.annotation.declared.correctly.name.display=@Invocation Injection -injections.invocation.annotation.declared.correctly.error.type.is.injected.by.structure=''{0}'' type is injected by @Structure -injections.invocation.annotation.declared.correctly.error.type.is.not.injectable=''{0}'' type is not injectable by @Invocation -injections.invocation.annotation.declared.correctly.fix.remove.annotation=Remove @Invocation annotation -injections.invocation.annotation.declared.correctly.fix.replace.with.structure.annotation=Replace @Invocation with @Structure annotation - -# ***************************************************************************** -# Applies To -# ***************************************************************************** - -# ========== -# Inspection -# ========== -applies.to.annotation.declared.correctly.error.annotation.must.be.declared.on.class=@AppliesTo must be declared on class -applies.to.annotation.declared.correctly.error.value.is.invalid.for.mixin=''{0}'' is neither an interface or implements ''AppliesToFilter'' -applies.to.annotation.declared.correctly.error.value.requires.class.to.extends.GenericConcern=''{0}'' requires ''{1}'' to extends GenericConcern -applies.to.annotation.declared.correctly.error.value.requires.class.to.extends.GenericSideEffect=''{0}'' requires ''{1}'' to extends GenericSideEffect -applies.to.annotation.declared.correctly.error.value.requires.class.to.implements.InvocationHandler=''{0}'' requires ''{1}'' to implements InvocationHandler -applies.to.annotation.declared.correctly.error.value.requires.class.to.implement.interface.or.extends.GenericConcern=''{0}'' requires ''{1}'' to implement ''{0}'' interface or to extends ''GenericConcern'' -applies.to.annotation.declared.correctly.error.value.requires.class.to.implement.interface.or.extends.GenericSideEffect=''{0}'' requires ''{1}'' to implement ''{0}'' interface or to extends ''GenericSideEffect'' -applies.to.annotation.declared.correctly.error.value.requires.class.to.implement.value.interface.or.implements.InvocationHandler=''{0}'' requires ''{1}'' to implement ''{0}'' or ''InvocationHandler'' interface -applies.to.annotation.declared.correctly.error.annotation.value.is.invalid.for.non.mixin=''{0}'' is not an annotation or ''AppliesToFilter'' or an interface -applies.to.annotation.declared.correctly.fix.remove.annotation=Remove ''@AppliesTo'' annotation -applies.to.annotation.declared.correctly.fix.remove.class.reference=Remove ''{0}'' class reference